Advertisement
sanych_dv

Untitled

Dec 28th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1.    static public function generatePromocodes($data)
  2.     {
  3.         $pool = array();
  4.  
  5.  
  6.         for ($i = 0; $i < $data["amount"]; $i++) {
  7.  
  8.             $promocode = Lib_Utils::generatePassword(7, false, "ld");
  9.  
  10.             $updateArr = array(
  11.                 "region" => $data["region"],
  12.                 "company" => $data["company"],
  13.                 "promocode" => $promocode,
  14.                 "quality" => $data["quality"],
  15.                 "time_generated" => time(),
  16.                 "user_id" => $data["user"],
  17.                 "status" => 0,
  18.  
  19.             );
  20.  
  21.             $query = Lib_MysqlManage::insertRequestFromArray($updateArr, "promocodes");
  22.  
  23.             $result = Lib_MysqlManage::makeQuery($query);
  24.  
  25.             if ($result != "1") {
  26.                 $i--;
  27.             } else {
  28.                 array_push($pool, $promocode);
  29.             }
  30.  
  31.  
  32.         }
  33.  
  34.         return implode("\r\n", $pool);
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement