Connection.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <?php
  2. include "_api/appconfig.php";
  3. session_start();
  4. class Connection
  5. {
  6. public $db;
  7. public $hostname;
  8. //public $fromMail = "noreply@cygnusa.com";
  9. public $passchar = "1234567890";
  10. public $groupID = "/topics/cygnusajtech1976";
  11. public $errorMsg = "NULL";
  12. public $pageData = "NULL";
  13. public $langDir = "../language/common.json";
  14. public function __construct()
  15. {
  16. $hostname = $_SERVER['HTTP_HOST'];
  17. //$this->db = $this->getConnection();
  18. }
  19. public function checkDatabase()
  20. {
  21. global $host;
  22. global $user;
  23. global $pass;
  24. global $dbname;
  25. try
  26. {
  27. $database = new PDO("mysql:host=" . HOST . ";dbname=" . DBNAME, DBUSER, DBPASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
  28. //$database->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  29. return true;
  30. } catch (Exception $e) {
  31. return false;
  32. }
  33. }
  34. public function generateToken($length = 256)
  35. {
  36. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  37. $charactersLength = strlen($characters);
  38. $randomString = '';
  39. for ($i = 0; $i < $length; $i++) {
  40. $randomString .= $characters[rand(0, $charactersLength - 1)];
  41. }
  42. return $randomString;
  43. }
  44. public function loadJSON($lang)
  45. {
  46. $pageData = json_decode(file_get_contents($this->langDir));
  47. $data = null;
  48. foreach ($pageData as $key => $value) {
  49. if ($key == $lang) {
  50. $data = $value;
  51. }
  52. }
  53. return $data;
  54. }
  55. public function getMessage($lang, $module, $message)
  56. {
  57. //echo $module.$message;
  58. if (file_exists("../language/" . $lang . "/admin.php")) {
  59. include_once "../language/" . $lang . "/admin.php";
  60. //echo $module." ".$message;
  61. //print_r($string[$module]);
  62. if (!isset($string[$module])) {
  63. echo $this->message(false, 'MODULE LANGUAGE FILE NOT FOUND');
  64. }
  65. if (!isset($string[$module][$message])) {
  66. echo $this->message(false, 'MESSAGE LANGUAGE FILE NOT FOUND');
  67. }
  68. return $string[$module][$message];
  69. } else {
  70. //$parent->response(array('response'=>'failed','message'=>'LANGUAGE FILE NOT FOUND'),500);
  71. echo $this->message(false, 'LANGUAGE FILE NOT FOUND');
  72. }
  73. }
  74. public function getConnection()
  75. {
  76. $this->db = new PDO("mysql:host=" . HOST . ";dbname=" . DBNAME, DBUSER, DBPASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
  77. $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  78. $this->db->exec("SET CHARACTER SET utf8");
  79. return $this->db;
  80. }
  81. public function query($str)
  82. {
  83. try
  84. {
  85. $result = $this->db->query($str);
  86. return $result;
  87. } catch (PDOException $e) {
  88. echo "MYSQL ERROR " . $e->getMessage();exit;
  89. } catch (Exception $e) {
  90. echo "Error " . $e->getMessage();exit;
  91. //$this->response(array('response'=>'failed','message'=>$e->getMessage()),500);
  92. }
  93. }
  94. public function lastinsetid()
  95. {
  96. return $this->db->lastInsertId();
  97. }
  98. public function prepare($str)
  99. {
  100. $result = $this->db->prepare($str);
  101. return $result;
  102. }
  103. public function getUpdateData($str)
  104. {
  105. try
  106. {
  107. $selectquery = $this->query($str);
  108. $selectarr = $selectquery->fetchAll(PDO::FETCH_OBJ);
  109. return $selectarr[0];
  110. } catch (PDOException $e) {
  111. header("HTTP/1.1 500 Internal Server Error");
  112. $this->message(false, "MYSQL ERROR " . $e->getMessage());
  113. } catch (Exception $e) {
  114. //echo "Error ".$e->getMessage(); exit;
  115. header("HTTP/1.1 500 Internal Server Error");
  116. $this->message(false, "PHP ERROR " . $e->getMessage());
  117. //$this->response(array('response'=>'failed','message'=>$e->getMessage()),500);
  118. }
  119. }
  120. public function selectQuery($table_name, $field_name, $condition, $limitations = '')
  121. {
  122. try {
  123. if ($field_name == "") {
  124. $field_name = "*";
  125. }
  126. $select_query_str = "SELECT $field_name FROM $table_name";
  127. if ($condition != "") {
  128. $select_query_str .= " where $condition";
  129. }
  130. if ($limitations != "") {
  131. $select_query_str .= " limit $limitations";
  132. }
  133. //echo $select_query_str;
  134. $query_obj = $this->executeQuery($select_query_str);
  135. $num_rows = $query_obj->rowCount($query_obj);
  136. $result_value = array();
  137. if ($num_rows > 0) {
  138. $result_value = $query_obj->fetchAll(PDO::FETCH_OBJ);
  139. }
  140. return array('nr' => $num_rows, 'result' => $result_value);
  141. } catch (PDOException $e) {
  142. header("HTTP/1.1 500 Internal Server Error");
  143. $this->message(false, "MYSQL ERROR " . $e->getMessage());
  144. } catch (Exception $e) {
  145. header("HTTP/1.1 500 Internal Server Error");
  146. $this->message(false, "PHP ERROR " . $e->getMessage());
  147. }
  148. }
  149. public function message($cont, $mess, $item = null)
  150. {
  151. //header('Set-Cookie: same-site-cookie=foo; SameSite=Lax');
  152. //header('Set-Cookie: cross-site-cookie=bar; SameSite=None; Secure');
  153. header('Access-Control-Allow-Origin: *');
  154. header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
  155. header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');
  156. header("Content-Type:application/json");
  157. $obj = new stdClass();
  158. $obj->mess = $mess;
  159. $obj->cont = $cont;
  160. if ($item != null) {
  161. $obj->item = $item;
  162. } else if (is_array($item)) {
  163. $obj->item = $item;
  164. }
  165. echo json_encode($obj);
  166. exit(0);
  167. return null;
  168. }
  169. public function errormessage($cont, $mess, $item = null)
  170. {
  171. header('Access-Control-Allow-Origin: *');
  172. header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
  173. header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');
  174. header("Content-Type:application/json");
  175. $obj = new stdClass();
  176. $obj->mess = $mess;
  177. $obj->cont = $cont;
  178. if ($item != null) {
  179. $obj->item = $item;
  180. }
  181. echo json_encode($obj);
  182. exit;
  183. }
  184. public function generatPassword($passLen)
  185. {
  186. $passChars = $this->passchar;
  187. $passArray = str_split($passChars);
  188. $newPassArray = array_rand($passArray, $passLen);
  189. $newPass = "";
  190. if ($passLen != 1) {
  191. for ($i = 0; $i < $passLen; $i++) {
  192. $newPass .= $passArray[$newPassArray[$i]];
  193. }
  194. } else {
  195. $newPass = $passArray[$newPassArray];
  196. }
  197. return $newPass;
  198. }
  199. /*
  200. public function sendNotification($conn,$string,$title,$type){
  201. global $prefix;
  202. $selectnotification = $conn->query("SELECT * FROM ".$prefix."notification WHERE id=1");
  203. $notificationrow = $selectnotification->fetchAll(PDO::FETCH_OBJ);
  204. $notificationid = ((int) $notificationrow[0]->notificationid)+1;
  205. $data = array( 'message' => $string,'title' => $title,'type' => $type,'notificationid' => $notificationid);
  206. $updatenotification = $conn->query("UPDATE ".$prefix."notification SET notificationid='$notificationid' WHERE id=1");
  207. $conn->sendGoogleCloudMessage($data,$conn->groupID,"group");
  208. }
  209. */
  210. /* ////////////////////////////////////// GET MYSQL EXECUTEQUERY ///////////////////////////////// */
  211. public function executeQuery($str)
  212. {
  213. try
  214. {
  215. $result = $this->db->query($str);
  216. return $result;
  217. } catch (PDOException $e) {
  218. header("HTTP/1.1 500 Internal Server Error");
  219. $this->message(false, "MYSQL ERROR " . $e->getMessage());
  220. } catch (Exception $e) {
  221. header("HTTP/1.1 500 Internal Server Error");
  222. $this->message(false, "PHP ERROR " . $e->getMessage());
  223. }
  224. }
  225. /* ////////////////////////////////////// GET MYSQL VALUES ///////////////////////////////// */
  226. public function getQueryValue($str)
  227. {
  228. try
  229. {
  230. $result = $this->executeQuery($str);
  231. $result_value = $result->fetchAll(PDO::FETCH_OBJ);
  232. return $result_value;
  233. } catch (PDOException $e) {
  234. header("HTTP/1.1 500 Internal Server Error");
  235. $this->message(false, "MYSQL ERROR " . $e->getMessage());
  236. } catch (Exception $e) {
  237. header("HTTP/1.1 500 Internal Server Error");
  238. $this->message(false, "PHP ERROR " . $e->getMessage());
  239. }
  240. }
  241. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  242. /* /////////////////////////////// VALIDATE FILE ////////////////////////////// */
  243. public function validateFile($obj)
  244. {
  245. try {
  246. if (is_object($obj)) {
  247. (!(isset($obj->filekey) && isset($obj->size) && isset($obj->type) && is_array($obj->type))) ? $this->errormessage(false, 'CODE ERROR') : null;
  248. (!(isset($_FILES[$obj->filekey]) && ($_FILES[$obj->filekey]["error"] == 0))) ? $this->errormessage(false, 'FILE NOT FOUND') : null;
  249. $maxsize = $obj->size * 1024 * 1024;
  250. ($maxsize < $_FILES[$obj->filekey]['size']) ? $this->errormessage(false, 'INVALID FILE SIZE') : null;
  251. $fileParts = pathinfo($_FILES[$obj->filekey]['name']);
  252. $fileext_arr = explode('?', $fileParts['extension']);
  253. (!@in_array(strtolower($fileext_arr[0]), $obj->type)) ? $this->errormessage(false, 'You can upload only ' . @implode(', ', $obj->type) . " file type.") : null;
  254. } else {
  255. $this->errormessage(false, 'validateFile fields missing');
  256. }
  257. } catch (Exception $e) {
  258. $this->errormessage(false, $e->getMessage());
  259. }
  260. }
  261. /* ///////////////////////////////////////////////////////////////////////////////////// */
  262. /* ////////////////////////////////////// UPLOAD FILE ///////////////////////////////// */
  263. public function uploadFile($obj)
  264. {
  265. $filekey = $obj->filekey;
  266. $path = $obj->path;
  267. $fileprefix = (isset($obj->fileprefix)) ? $obj->fileprefix : 'file';
  268. if (is_object($obj) && isset($_FILES[$obj->filekey])) {
  269. $tempFile = $_FILES[$obj->filekey]['tmp_name'];
  270. $fileParts = pathinfo($_FILES[$obj->filekey]['name']);
  271. $fileext_arr = explode('?', $fileParts['extension']);
  272. $fileExtension = strtolower($fileext_arr[0]);
  273. $file_prehead = (IS_LIVE_SERVER != '1') ? "_development" : "";
  274. $fileName = (isset($obj->filename)) ? $obj->filename . $file_prehead . '.' . $fileExtension : $fileprefix . '_' . date('YmdHis') . uniqid() . $file_prehead . '.' . $fileExtension;
  275. $targetFile = $path . $fileName;
  276. @move_uploaded_file($tempFile, $targetFile);
  277. //shell_exec("sudo chmod -R 777 ".$targetFile);
  278. chmod($targetFile, 0777);
  279. return $fileName;
  280. } else {
  281. $this->errormessage(false, 'FILE NOT FOUND');
  282. }
  283. }
  284. /* ///////////////////////////////////////////////////////////////////////////////////// */
  285. /* /////////////////////////////// get ip ////////////////////////////// */
  286. public function getIp($data = array())
  287. {
  288. $ip = $_SERVER['REMOTE_ADDR'];
  289. if ($ip) {
  290. if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  291. $ip = $_SERVER['HTTP_CLIENT_IP'];
  292. } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  293. $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  294. }
  295. return $ip;
  296. }
  297. // There might not be any data
  298. return false;
  299. }
  300. /* ///////////////////////////////////////////////////////////////////////////////////// */
  301. /* /////////////////////////////// get ip ////////////////////////////// */
  302. public function insertUserLog($conn, $activity)
  303. {
  304. if (isset($_SESSION["userid"])) {
  305. $client_ip = self::getIp($parent);
  306. $conn->executeQuery("INSERT INTO " . TABLE_USER_LOG . "( `userid`,`device_type`, `module`, `ip`, `created_on`) VALUES ('" . $_SESSION["userid"] . "','admin','" . $activity . "','" . $client_ip . "','" . NOW . "')");
  307. }
  308. }
  309. /* ///////////////////////////////////////////////////////////////////////////////////// */
  310. /* /////////////////////////////// GET MONTH DATES ////////////////////////////// */
  311. public function getMonthDates($month, $year)
  312. {
  313. $month_str = date('Y-m', strtotime($year . "-" . $month . "-01"));
  314. $month_start = $month_str . "-01";
  315. $month_days = date('t', strtotime($month_start));
  316. $month_date = array();
  317. $day_arr = array();
  318. for ($i = 1; $i <= $month_days; $i++) {
  319. $date_str = date('Y-m-d', strtotime($year . "-" . $month . "-" . $i));
  320. $day_arr[] = ($i < 10) ? "0" . $i : (string) $i;
  321. $month_date[] = $date_str;
  322. }
  323. $month_last = $date_str;
  324. $data_arr = array('start' => $month_start, 'month' => $month_date, 'last' => $month_last, 'date' => $day_arr);
  325. return $data_arr;
  326. }
  327. /* ///////////////////////////////////////////////////////////////////////////////////// */
  328. /* ////////////////////////////////////// ANDRIOD GCM FUNCTION ///////////////////////////////// */
  329. private function sendGoogleCloudMessage($messagearr, $reg_id)
  330. {
  331. // print_r($reg_id);
  332. $title = $messagearr['title'];
  333. $message = $messagearr['message'];
  334. $messagearr['body'] = $messagearr['message'];
  335. $fields = array(
  336. 'registration_ids' => $reg_id,
  337. 'priority' => "high",
  338. 'notification' => array("title" => $title, "body" => $message, "sound" => "default"),
  339. 'data' => $messagearr,
  340. );
  341. $headers = array(
  342. GOOGLE_FCM_URL,
  343. 'Content-Type: application/json',
  344. 'Authorization: key=' . GOOGLE_API_KEY,
  345. );
  346. //echo "<br>";
  347. // $ch = curl_init();
  348. // curl_setopt($ch, CURLOPT_URL, GOOGLE_FCM_URL);
  349. // curl_setopt($ch, CURLOPT_POST, true);
  350. // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  351. // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  352. // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  353. // curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
  354. // $result = curl_exec($ch);
  355. // echo $result;
  356. // curl_close($ch);
  357. echo $result="";
  358. }
  359. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  360. /* ////////////////////////////////////// IOS CLOUD MESSAGE FUNCTION ///////////////////////////////// */
  361. private function sendFCMIOSCloudMessage($messagearr, $reg_id)
  362. {
  363. // print_r($reg_id);
  364. $title = $messagearr['title'];
  365. $message = $messagearr['message'];
  366. $fields = array(
  367. //'to'=> $reg_id,
  368. "content_available" => true,
  369. 'registration_ids' => $reg_id,
  370. 'priority' => "high",
  371. 'aps' => array("content-available" => 1),
  372. 'notification' => $messagearr,
  373. // 'notification' => $messagearr,
  374. 'data' => array('published' => NOW),
  375. 'notId' => rand(1000, 9999),
  376. );
  377. $headers = array(
  378. GOOGLE_FCM_URL,
  379. 'Content-Type: application/json',
  380. 'Authorization: key=' . GOOGLE_API_KEY,
  381. );
  382. //echo "<br>";
  383. // $ch = curl_init();
  384. // curl_setopt($ch, CURLOPT_URL, GOOGLE_FCM_URL);
  385. // curl_setopt($ch, CURLOPT_POST, true);
  386. // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  387. // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  388. // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  389. // curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
  390. // $result = curl_exec($ch);
  391. // echo $result;
  392. // curl_close($ch);
  393. echo $result="";
  394. }
  395. /* ////////////////////////////////////// SEND NOTIFICATION ///////////////////////////////// */
  396. public function sendUserNotification($message, $usertokenarr)
  397. {
  398. // print_r($message);
  399. // print_r($usertokenarr);
  400. //STRUCTURE $usertokenarr =array('android'=>$arr,'ios'=>$arr);
  401. // $android_ids = (isset($usertokenarr['android'])) ? $usertokenarr['android'] : array();
  402. // $ios_ids = (isset($usertokenarr['ios'])) ? $usertokenarr['ios'] : array();
  403. // if (count($android_ids) > 0) {
  404. // $ids_arr = array_chunk($android_ids, 1000);
  405. // if (count($ids_arr) > 0) {
  406. // foreach ($ids_arr as $groupids) {
  407. // $this->sendGoogleCloudMessage($message, $groupids);
  408. // }
  409. // }
  410. // }
  411. // if (count($ios_ids) > 0) {
  412. // //echo "asdasd";
  413. // $ids_arr = array_chunk($ios_ids, 1000);
  414. // if (count($ids_arr) > 0) {
  415. // foreach ($ids_arr as $groupids) {
  416. // $this->sendFCMIOSCloudMessage($message, $groupids);
  417. // //$this->sendIoCloudMessage($message,$groupids);
  418. // }
  419. // }
  420. // }
  421. }
  422. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  423. /* ////////////////////////////////////// USER ADD WALLET ///////////////////////////////// */
  424. public function userAddWallet($conn, $obj, $userid)
  425. {
  426. $user_str = "SELECT * FROM " . TABLE_USER . " WHERE userid='" . $userid . "' AND is_deleted=0 LIMIT 1";
  427. $user_arr = $conn->getQueryValue($user_str);
  428. if (count($user_arr) > 0) {
  429. $smpin = $user_arr[0]->smpin;
  430. } else {
  431. echo $this->message(false, 'REQUIRED USER NOT FOUND');
  432. }
  433. if (!isset($obj->type)) {
  434. $this->message(false, 'REQUIRED REQUIRED obj->type');
  435. }
  436. if (!isset($obj->type_id)) {
  437. $this->message(false, 'REQUIRED REQUIRED obj->type_id');
  438. }
  439. if (!isset($obj->amount)) {
  440. $this->message(false, 'REQUIRED REQUIRED obj->amount');
  441. }
  442. $obj->description = (isset($obj->description)) ? $obj->description : "";
  443. //NEED TO CHECK AMOUNT ALREADY ADDED
  444. $amount_str = "SELECT * FROM " . TABLE_USER_WALLET_HISTORY . " WHERE smpin='" . $smpin . "' AND type='" . $obj->type . "' AND type_id='" . $obj->type_id . "' AND transaction_type='C'";
  445. $amount_arr = $conn->getQueryValue($amount_str);
  446. if (count($amount_arr) > 0) {
  447. //AMOUNT ALREADY ADDED
  448. } else {
  449. $lvl_points = (isset($obj->lvl_points)) ? $obj->lvl_points : 0;
  450. $conn->executeQuery("INSERT INTO " . TABLE_USER_WALLET_HISTORY . "( `smpin`, `type`, `type_id`, `description`, `lvl_points`, `amount`, `transaction_type`, `created_on`, `modified_on`) VALUES ('" . $smpin . "','" . $obj->type . "','" . $obj->type_id . "','" . $obj->description . "','" . $lvl_points . "','" . $obj->amount . "' ,'C','" . NOW . "','" . NOW . "')");
  451. //UPDATE POINT IN USER
  452. $conn->executeQuery("UPDATE " . TABLE_USER_WALLET . " SET amount=amount+" . $obj->amount . " WHERE smpin='" . $smpin . "' ");
  453. }
  454. }
  455. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  456. /* /////////////////////////////// USER ADD POINTS //////////////////////////////////////////////// */
  457. public function userAddPoints($obj, $userid = 0)
  458. {
  459. $user_str = "SELECT * FROM " . TABLE_USER . " WHERE userid='" . $userid . "' AND is_deleted=0 LIMIT 1";
  460. $user_arr = $this->getQueryValue($user_str);
  461. if (count($user_arr) > 0) {
  462. $smpin = $user_arr[0]->smpin;
  463. } else {
  464. echo "userAddPoints USER NOT FOUND";exit;
  465. }
  466. if (!isset($obj->type)) {echo "userAddPoints obj->type MISSING";exit;}
  467. if (!isset($obj->type_id)) {echo "userAddPoints obj->type_id MISSING";exit;}
  468. if (!isset($obj->points)) {echo "userAddPoints obj->points MISSING";exit;}
  469. $obj->description = (isset($obj->description)) ? $obj->description : "";
  470. //NEED TO CHECK POINTS ALREADY ADDED
  471. $points_str = "SELECT * FROM " . TABLE_USER_EPOINTS_HISTORY . " WHERE smpin='" . $smpin . "' AND type='" . $obj->type . "' AND type_id='" . $obj->type_id . "' AND transaction_type='C'";
  472. $points_arr = $this->getQueryValue($points_str);
  473. if (count($points_arr) > 0) {
  474. //POINTS ALREADY ADDED
  475. } else {
  476. $this->executeQuery("INSERT INTO " . TABLE_USER_EPOINTS_HISTORY . "( `smpin`, `type`, `type_id`, `description`, `points`, `transaction_type`, `created_on`, `modified_on`) VALUES ('" . $smpin . "','" . $obj->type . "','" . $obj->type_id . "','" . $obj->description . "','" . $obj->points . "' ,'C','" . NOW . "','" . NOW . "')");
  477. //UPDATE POINT IN USER
  478. $this->executeQuery("UPDATE " . TABLE_USER_EPOINTS . " SET points=points+" . $obj->points . " WHERE smpin='" . $smpin . "' ");
  479. }
  480. }
  481. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  482. }