Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.39 KB | None | 0 0
  1. <?php
  2. include('includes/tlca_world.php');
  3. $check = $tlca_do->load('class_check');
  4. $index = $tlca_do->load('class_index');
  5. $tlca_skin=$tlca_do->load('class_skin');
  6. $tlca_member=$tlca_do->load('class_member');
  7. $action=addslashes($_REQUEST['action']);
  8. $user_id=$class_member->check_login();
  9. $user_info=$class_member->user_info($user_id);
  10. if($action=='register'){
  11. $email=addslashes($_REQUEST['email']);
  12. $username=addslashes($_REQUEST['username']);
  13. $password=addslashes($_REQUEST['password']);
  14. $repassword=addslashes($_REQUEST['repassword']);
  15. $phong=addslashes($_REQUEST['phone']);
  16. if($check->check_username($username)==false){
  17. $info=array(
  18. 'thongbao'=>'Thất bại! Tài khoản phải viết liền không dấu,không chứa ký tự đặc biệt...',
  19. 'ok'=>0,
  20. 'link'=>'./register.html'
  21. );
  22. }elseif($check->check_email($email)==false){
  23. $info=array(
  24. 'thongbao'=>'Thất bại! Email không đúng định dạng...',
  25. 'ok'=>0,
  26. 'link'=>'./register.html'
  27. );
  28. }elseif(strlen($password)<6){
  29. $info=array(
  30. 'thongbao'=>'Thất bại! Mật khẩu phải dài từ 6 ký tự...',
  31. 'ok'=>0,
  32. );
  33. }elseif($password!==$repassword){
  34. $info=array(
  35. 'thongbao'=>'Thất bại! Xác nhận mật khẩu không khớp...',
  36. 'ok'=>0,
  37. 'link'=>'./register.html'
  38. );
  39. }else{
  40. $thongtin=mysql_query("SELECT * FROM user_info WHERE username='$username'");
  41. $total_user=mysql_num_rows($thongtin);
  42. if($total_user>0){
  43. $info=array(
  44. 'thongbao'=>'Thất bại! Tài khoản bạn nhập đã có trên hệ thống...',
  45. 'ok'=>0,
  46. 'link'=>'./register.html'
  47. );
  48. }else{
  49. $pass=md5($password);
  50. $date_reg=time();
  51. $thongtin_taikhoan=mysql_query("SELECT * FROM user_info WHERE email='$email'");
  52. $total_taikhoan=mysql_num_rows($thongtin_taikhoan);
  53. if($total_taikhoan==0){
  54. mysql_query("INSERT INTO user_info (username,password,email,kich_hoat,date_reg)VALUES('$username','$pass','$email','1','$date_reg')");
  55. $info=array(
  56. 'thongbao'=>'Đăng ký tài khoản thành công. Đang chuyển hướng...',
  57. 'ok'=>1,
  58. 'link'=>'./dang-nhap.html'
  59. );
  60. }else{
  61. $info=array(
  62. 'thongbao'=>'Thất bại. Email đã có trên hệ thống...',
  63. 'ok'=>0,
  64. 'link'=>'./register.html'
  65. );
  66. }
  67. }
  68. }
  69. echo '<!DOCTYPE html>
  70. <html lang="en">
  71. <head>
  72. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  73. <meta http-equiv="refresh" content="3;url='.$info['link'].'">
  74. <link href="./skin/css/style.css" rel="stylesheet"/>
  75. <title>Thông báo hệ thống</title>
  76. </head>
  77. <body class="loading">
  78. <center>'.$info['thongbao'].'</center>
  79. </body>
  80. </html>';
  81. }
  82. ////////////////////////////////////
  83. elseif($action=='myaccount'){
  84. $ho_ten=addslashes($_REQUEST['ho_ten']);
  85. $dien_thoai=addslashes($_REQUEST['dien_thoai']);
  86. $dia_chi=addslashes($_REQUEST['dia_chi']);
  87. if(strlen($ho_ten)<2){
  88. $info=array(
  89. 'thongbao'=>'Thất bại! Vui lòng nhập họ và tên của bạn...',
  90. 'ok'=>0,
  91. );
  92. }else{
  93. mysql_query("UPDATE user_info SET ho_ten='$ho_ten',dien_thoai='$dien_thoai',dia_chi='$dia_chi' WHERE user_id='$user_id'");
  94. $info=array(
  95. 'thongbao'=>'Lưu thay đổi thông tin thành công...',
  96. 'ok'=>1,
  97. );
  98. }
  99. echo '<!DOCTYPE html>
  100. <html lang="en">
  101. <head>
  102. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  103. <meta http-equiv="refresh" content="3;url=./my-account.html">
  104. <link href="./skin/css/style.css" rel="stylesheet"/>
  105. <title>Thông báo hệ thống</title>
  106. </head>
  107. <body class="loading">
  108. <center>'.$info['thongbao'].'</center>
  109. </body>
  110. </html>';
  111. }
  112. ////////////////////////////////////
  113. elseif($action=='del_chat'){
  114. $id=intval($_REQUEST['id']);
  115. $thongtin=mysql_query("SELECT * FROM chat WHERE id='$id'");
  116. $total=mysql_num_rows($thongtin);
  117. if($total==0){
  118. echo 0;
  119. }else{
  120. if($user_info['user_group']==1){
  121. echo 1;
  122. mysql_query("DELETE FROM chat WHERE id='$id'");
  123. }else{
  124. echo 0;
  125. }
  126. }
  127. }
  128. ////////////////////////////////////
  129. elseif($action=='cam_chat'){
  130. $id=intval($_REQUEST['id']);
  131. $thongtin=mysql_query("SELECT * FROM chat WHERE id='$id'");
  132. $total=mysql_num_rows($thongtin);
  133. if($total==0){
  134. echo 0;
  135. }else{
  136. $r_tt=mysql_fetch_assoc($thongtin);
  137. if($user_info['user_group']==1){
  138. echo 1;
  139. $list_ip=file_get_contents('./data/camchat.txt');
  140. if($list_ip==''){
  141. $list_ip=$r_tt['ip_address'];
  142.  
  143. }else{
  144. $list_ip=$list_ip.','.$r_tt['ip_address'];
  145. }
  146. $myfile = fopen('./data/camchat.txt', "w");
  147. fwrite($myfile, $list_ip);
  148. fclose($myfile);
  149. mysql_query("DELETE FROM chat WHERE id='$id'");
  150. }else{
  151. echo 0;
  152. }
  153. }
  154. }
  155. ////////////////////////////////////
  156. elseif($action=='lienhe'){
  157. $ho_ten=addslashes($_REQUEST['ho_ten']);
  158. $email=addslashes($_REQUEST['email']);
  159. $tieu_de=addslashes($_REQUEST['tieu_de']);
  160. $dien_thoai=addslashes($_REQUEST['dien_thoai']);
  161. $noi_dung=addslashes($_REQUEST['noi_dung']);
  162. $captcha=addslashes($_REQUEST['captcha']);
  163. if(strlen($ho_ten)<2){
  164. $info=array(
  165. 'thongbao'=>'Thất bại! Vui lòng nhập họ và tên của bạn...',
  166. 'ok'=>0,
  167. );
  168. }elseif(strlen($dien_thoai)<8){
  169. $info=array(
  170. 'thongbao'=>'Thất bại! Vui lòng nhập số điện thoại liên hệ...',
  171. 'ok'=>0,
  172. );
  173. }elseif(strlen($tieu_de)<8){
  174. $info=array(
  175. 'thongbao'=>'Thất bại! Tiêu đề liên hệ không rõ ràng...',
  176. 'ok'=>0,
  177. );
  178. }elseif(strlen($noi_dung)<8){
  179. $info=array(
  180. 'thongbao'=>'Thất bại! Nội dung liên hệ quá ngắn...',
  181. 'ok'=>0,
  182. );
  183. }elseif($captcha!==$_SESSION['captcha']){
  184. $info=array(
  185. 'thongbao'=>'Thất bại! Nhập mã xác nhận không chính xác...',
  186. 'ok'=>0,
  187. );
  188. }else{
  189. mysql_query("INSERT INTO contact (ho_ten,dien_thoai,email,tieu_de,noi_dung,date_post)VALUES('$ho_ten','$dien_thoai','$email','$tieu_de','$noi_dung',".time().")");
  190. $info=array(
  191. 'thongbao'=>'Liên hệ đã được gửi thành công! Cảm ơn bạn đã liên hệ với chúng tôi...',
  192. 'ok'=>1,
  193. );
  194. }
  195. echo json_encode($info);
  196. }
  197. ////////////////////////////////////
  198. elseif($action=='avatar'){
  199. $duoi_file=$check->duoi_file($_FILES['avatar']['name']);
  200. $dungluong=$_FILES['avatar']['size'];
  201. if($dungluong>1024*1024){
  202. $info=array(
  203. 'thongbao'=>'Thất bại! Ảnh có dung lượng vượt quá 1MB...',
  204. 'ok'=>0,
  205. );
  206. }elseif(in_array($duoi_file, array('jpg','png','jpeg'))==false){
  207. $info=array(
  208. 'thongbao'=>'Thất bại! Vui lòng chọn ảnh có đuôi jpg,png hoặc jpeg...',
  209. 'ok'=>0,
  210. );
  211. }else{
  212. $folder_username='./data/'.$user_info['username'];
  213. if(is_dir($folder_username)=="1"){
  214. }else{
  215. mkdir($folder_username);
  216. }
  217. $avatar=$folder_username.'/'.$user_info['username'].'.'.$duoi_file;
  218. @unlink($user_info['avatar']);
  219. move_uploaded_file($_FILES["avatar"]["tmp_name"],$avatar);
  220. mysql_query("UPDATE user_info SET avatar='$avatar' WHERE username='{$user_info['username']}'");
  221. $info=array(
  222. 'thongbao'=>'Thành công! Hình đại diện của bạn đã được cập nhật...',
  223. 'ok'=>1,
  224. );
  225. }
  226. echo json_encode($info);
  227. }
  228. ////////////////////////////////////
  229. elseif($action=='xoso'){
  230. $so=addslashes($_REQUEST['so']);
  231. $diem=intval($_REQUEST['diem']);
  232. $ngay=date('d-m-Y',time());
  233. $hientai=time();
  234. $ngay_danh=date('d',time());
  235. $thang_danh=date('m',time());
  236. $nam_danh=date('Y',time());
  237. $gioihan=mktime(18,15,00,$thang_danh,$ngay_danh,$nam_danh);
  238. if($diem=='1'){
  239. $tru=24000;
  240. $diem=1;
  241. }else{
  242. $tru=12000;
  243. $diem=0.5;
  244. }
  245. if($tru>$user_info['user_money']){
  246. $info=array(
  247. 'thongbao'=>'Thất bại! Số tiền hiện tại của bạn không đủ...',
  248. 'ok'=>0,
  249. );
  250.  
  251. }elseif($hientai>$gioihan){
  252. $info=array(
  253. 'thongbao'=>'Thất bại! Vui lòng ghi trước 18h15 phút...',
  254. 'ok'=>0,
  255. );
  256.  
  257. }else{
  258. $conlai=$user_info['user_money']-$tru;
  259. mysql_query("UPDATE user_info SET user_money='$conlai' WHERE user_id='$user_id'");
  260. mysql_query("INSERT INTO xoso(username,so,diem,thanhtien,ngay,date_post)VALUES('{$user_info['username']}','$so','$diem','$tru','$ngay',".time().")");
  261. $info=array(
  262. 'thongbao'=>'Bạn đã ghi số '.$so.': '.$diem.' điểm thành công...',
  263. 'ok'=>1,
  264. );
  265. }
  266.  
  267. echo json_encode($info);
  268. }
  269. ////////////////////////////////////////
  270. elseif($action=='doi_matkhau'){
  271. $password=addslashes($_REQUEST['password']);
  272. $passnew=addslashes($_REQUEST['passnew']);
  273. $re_passnew=addslashes($_REQUEST['repassnew']);
  274. if(strlen($passnew)<6){
  275. $info=array(
  276. 'thongbao'=>'Thất bại! Vui lòng nhập mật khẩu mới dài từ 6 ký tự...',
  277. 'ok'=>0,
  278. 'link'=>'./doi-matkhau.html'
  279. );
  280. }elseif($passnew!==$re_passnew){
  281. $info=array(
  282. 'thongbao'=>'Thất bại! Nhập lại mật khẩu mới không khớp...',
  283. 'ok'=>0,
  284. 'link'=>'./doi-matkhau.html'
  285. );
  286. }else{
  287. if(md5($password)!==$user_info['password']){
  288. $info=array(
  289. 'thongbao'=>'Thất bại! Mật khẩu hiện tại không chính xác...',
  290. 'ok'=>0,
  291. 'link'=>'./doi-matkhau.html'
  292. );
  293. }else{
  294. $pass=md5($passnew);
  295. mysql_query("UPDATE user_info SET password='$pass' WHERE username='{$user_info['username']}'");
  296. $class_member->logout($user_id);
  297. $info=array(
  298. 'thongbao'=>'Đổi mật khẩu thành công! Vui lòng đăng nhập lại...',
  299. 'ok'=>1,
  300. 'link'=>'./dang-nhap.html'
  301. );
  302. }
  303.  
  304. }
  305. echo '<!DOCTYPE html>
  306. <html lang="en">
  307. <head>
  308. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  309. <meta http-equiv="refresh" content="3;url='.$info['link'].'">
  310. <link href="./skin/css/style.css" rel="stylesheet"/>
  311. <title>Thông báo hệ thống</title>
  312. </head>
  313. <body class="loading">
  314. <center>'.$info['thongbao'].'</center>
  315. </body>
  316. </html>';
  317. }
  318. ///////////////////////////////////////
  319. elseif($action=='naptien'){
  320. define('CORE_API_HTTP_USR', 'sublolcom'); // chưa có
  321. define('CORE_API_HTTP_PWD', '4bH8AUuqXVDCuK6AqSxY'); // chưa có
  322. include('../includes/tlca_world.php');
  323. $check = $tlca_do->load('class_check');
  324. $index = $tlca_do->load('class_index');
  325. $user_id=$class_member->check_login();
  326. $user_info=$class_member->user_info($user_id);
  327. $bk = 'https://www.baokim.vn/the-cao/restFul/send';
  328. $seri = isset($_POST['txtseri']) ? $_POST['txtseri'] : '';
  329. $sopin = isset($_POST['txtpin']) ? $_POST['txtpin'] : '';
  330. //Loai the cao (VINA, MOBI, VIETEL, VTC, GATE)
  331. $mang = isset($_POST['chonmang']) ? $_POST['chonmang'] : '';
  332. $user = $_POST['txtuser'];
  333.  
  334. if($mang=='MOBI'){
  335. $ten = "Mobifone";
  336. }
  337. else if($mang=='VIETEL'){
  338. $ten = "Viettel";
  339. }
  340. else if($mang=='GATE'){
  341. $ten = "Gate";
  342. }
  343. else if($mang=='VTC'){
  344. $ten = "VTC";
  345. }
  346. else if($mang=='VNM'){
  347. $ten = "VNM";
  348. }
  349. else $ten ="Vinaphone";
  350.  
  351. //Mã MerchantID dang kí trên Bảo Kim
  352. $merchant_id = '23765';
  353. //Api username
  354. $api_username = 'sublolcom';
  355. //Api Pwd d
  356. $api_password = '4bH8AUuqXVDCuK6AqSxY';
  357. //Mã TransactionId
  358. $transaction_id = time();
  359. //mat khau di kem ma website dang kí trên B?o Kim
  360. $secure_code = '4586f8e37597fa10';
  361.  
  362. $arrayPost = array(
  363. 'merchant_id'=>$merchant_id,
  364. 'api_username'=>$api_username,
  365. 'api_password'=>$api_password,
  366. 'transaction_id'=>$transaction_id,
  367. 'card_id'=>$mang,
  368. 'pin_field'=>$sopin,
  369. 'seri_field'=>$seri,
  370. 'algo_mode'=>'hmac'
  371. );
  372.  
  373. ksort($arrayPost);
  374.  
  375. $data_sign = hash_hmac('SHA1',implode('',$arrayPost),$secure_code);
  376.  
  377. $arrayPost['data_sign'] = $data_sign;
  378.  
  379. $curl = curl_init($bk);
  380.  
  381. curl_setopt_array($curl, array(
  382. CURLOPT_POST=>true,
  383. CURLOPT_HEADER=>false,
  384. CURLINFO_HEADER_OUT=>true,
  385. CURLOPT_TIMEOUT=>30,
  386. CURLOPT_RETURNTRANSFER=>true,
  387. CURLOPT_SSL_VERIFYPEER => false,
  388. CURLOPT_HTTPAUTH=>CURLAUTH_DIGEST|CURLAUTH_BASIC,
  389. CURLOPT_USERPWD=>CORE_API_HTTP_USR.':'.CORE_API_HTTP_PWD,
  390. CURLOPT_POSTFIELDS=>http_build_query($arrayPost)
  391. ));
  392.  
  393. $data = curl_exec($curl);
  394.  
  395. $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  396.  
  397. $result = json_decode($data,true);
  398. //var_dump($data);die;
  399. date_default_timezone_set('Asia/Ho_Chi_Minh');
  400. $time=@date('H:i:s d/m/Y',time());
  401. //$time = time();roi
  402. if($status==200){
  403. $amount = $result['amount'];
  404. switch($amount) {
  405. case 10000 :$xu = 10000;break;
  406. case 20000 :$xu = 20000;break;
  407. case 30000 :$xu = 30000;break;
  408. case 50000 :$xu = 50000;break;
  409. case 100000 :$xu = 100000;break;
  410. case 200000 :$xu = 200000;break;
  411. case 300000 :$xu = 300000;break;
  412. case 500000 :$xu = 500000;break;
  413. }
  414. $dau=$user_info['user_money'];
  415. $money=$user_info['user_money']+ $xu;
  416. $cuoi=$dau+$xu;
  417.  
  418.  
  419.  
  420.  
  421.  
  422. $noi_dung="Nạp tiền vào tài khoản bằng thẻ cào ".$ten." mệnh giá ".$amount.', bạn nhận được '.$xu.' vào tài khoản chính';
  423. mysql_query("UPDATE user_info SET user_money ='$money' WHERE user_id='$user_id'");
  424. mysql_query("INSERT INTO giaodich_xu(user_id,xu,xu_truoc,phuongthuc,xu_sau,noi_dung,loai,ngay)VALUES('$user_id','$xu','$dau','$mang','$cuoi','$noi_dung','1','$time')");
  425. $file = "./napthe/carddung.log";
  426. $fh = fopen($file,'a');
  427. fwrite($fh,"Tai khoan: ".$user_info['username'].", Loai the: ".$ten.",Số seri ".$seri.",Mã thẻ: ".$sopin.", Menh gia: ".$amount.", Thoi gian: ".$time);
  428. fwrite($fh,"\r\n");
  429. fclose($fh);
  430.  
  431. echo '<!DOCTYPE html>
  432. <html lang="en">
  433. <head>
  434. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  435. <meta http-equiv="refresh" content="3;url=./thue-sub.html">
  436. <link href="./skin/css/style.css" rel="stylesheet"/>
  437. <title>Thông báo hệ thống</title>
  438. </head>
  439. <body class="loading">
  440. <center>'.$noi_dung.'</center>
  441. </body>
  442. </html>';
  443.  
  444. }
  445.  
  446.  
  447. else{
  448.  
  449. $error = $result['errorMessage'];
  450.  
  451. $file = "./napthe/cardsai.log";
  452. $fh = fopen($file,'a');
  453. fwrite($fh,"Tai khoan: ".$user_info['username'].", Ma the: ".$sopin.", Seri: ".$seri.", Loai The: ".$ten.", Noi dung loi: ".$error.", Thoi gian: ".$time);
  454. fwrite($fh,"\r\n");
  455. fclose($fh);
  456. echo '<!DOCTYPE html>
  457. <html lang="en">
  458. <head>
  459. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  460. <meta http-equiv="refresh" content="3;url=./nap-the.html">
  461. <link href="./skin/css/style.css" rel="stylesheet"/>
  462. <title>Thông báo hệ thống</title>
  463. </head>
  464. <body class="loading">
  465. <center>'.$error.'</center>
  466.  
  467. </body>
  468. </html>';
  469. }
  470.  
  471. }
  472. //////////////////////////////////////////
  473. elseif($action=='kichhoat_matkhau'){
  474. $email=addslashes($_REQUEST['email']);
  475. $token=addslashes($_REQUEST['token']);
  476. $gioi_han=time()-48*3600;
  477. $thongtin=mysql_query("SELECT * FROM quen_pass WHERE email='$email' AND code='$token' AND date_post>'$gioi_han'");
  478. $total=mysql_num_rows($thongtin);
  479. if($total==0){
  480. echo '<!DOCTYPE html>
  481. <html lang="en">
  482. <head>
  483. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  484. <meta http-equiv="refresh" content="3;url=./index.html">
  485. <link href="./skin/css/style.css" rel="stylesheet"/>
  486. <title>Thông báo hệ thống</title>
  487. </head>
  488. <body class="loading">
  489. <center>Kích hoạt thất bại!<br>Link đã hết hạn hoặc đã được sử dụng.</center>
  490. </body>
  491. </html>';
  492. }else{
  493. $r_tt=mysql_fetch_assoc($thongtin);
  494. $pass=md5($r_tt['password']);
  495. mysql_query("UPDATE user_info SET password='$pass' WHERE email='$email'");
  496. mysql_query("DELETE FROM quen_pass WHERE date_post<'$gioi_han'");
  497. echo '<!DOCTYPE html>
  498. <html lang="en">
  499. <head>
  500. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  501. <meta http-equiv="refresh" content="3;url=./dang-nhap.html">
  502. <link href="./skin/css/style.css" rel="stylesheet"/>
  503. <title>Thông báo hệ thống</title>
  504. </head>
  505. <body class="loading">
  506. <center>Kích hoạt thành cộng...</center>
  507. </body>
  508. </html>';
  509.  
  510. }
  511. }
  512. ////////////////////////////////////////
  513. elseif($action=='login'){
  514. $username=addslashes($_REQUEST['username']);
  515. $password=addslashes($_REQUEST['password']);
  516. if($check->check_username($username)==false){
  517. $info=array(
  518. 'thongbao'=>'Thất bại! Tài khoản không đúng định dạng ...',
  519. 'ok'=>0,
  520. 'link'=>'./dang-nhap.html'
  521. );
  522. }elseif(strlen($password)<6){
  523. $info=array(
  524. 'thongbao'=>'Thất bại! Mật khẩu phải dài từ 6 ký tự...',
  525. 'ok'=>0,
  526. 'link'=>'./dang-nhap.html'
  527. );
  528. }else{
  529. $kq=$class_member->login($username,$password);
  530. if($kq==0){
  531. $info=array(
  532. 'thongbao'=>'Thất bại! Tài khoản không tồn tại trên hệ thống...',
  533. 'ok'=>0,
  534. 'link'=>'./dang-nhap.html'
  535. );
  536. }else if($kq==2){
  537. $info=array(
  538. 'thongbao'=>'Thất bại! Mật khẩu bạn nhập không chính xác...',
  539. 'ok'=>0,
  540. 'link'=>'./dang-nhap.html'
  541. );
  542. }else if($kq==3){
  543. $info=array(
  544. 'thongbao'=>'Thất bại! Tài khoản của bạn chưa được kích hoạt...',
  545. 'ok'=>0,
  546. 'link'=>'./dang-nhap.html'
  547. );
  548. }else if($kq==1){
  549. $info=array(
  550. 'thongbao'=>'Đăng nhập thành công! Bạn đang được chuyển tới tài khoản...',
  551. 'ok'=>1,
  552. 'link'=>'./my-account.html'
  553. );
  554. }else{
  555. $info=array(
  556. 'thongbao'=>'Đăng nhập thất bại! Gặp lỗi không xác định...',
  557. 'ok'=>0,
  558. 'link'=>'./dang-nhap.html'
  559. );
  560. }
  561.  
  562. }
  563. echo '<!DOCTYPE html>
  564. <html lang="en">
  565. <head>
  566. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  567. <meta http-equiv="refresh" content="3;url='.$info['link'].'">
  568. <link href="./skin/css/style.css" rel="stylesheet"/>
  569. <title>Thông báo hệ thống</title>
  570. </head>
  571. <body class="loading">
  572. <center>'.$info['thongbao'].'</center>
  573. </body>
  574. </html>';
  575. }
  576. ////////////////////////////////////////
  577. elseif($action=='giahan'){
  578. $id=intval($_REQUEST['id']);
  579. $goi=intval($_REQUEST['goi']);
  580. $thongtin=mysql_query("SELECT * FROM don_hang WHERE id='$id'");
  581. $total=mysql_num_rows($thongtin);
  582. $thongtin_goi=mysql_query("SELECT * FROM goi_sanpham WHERE id='$goi'");
  583. $total_goi=mysql_num_rows($thongtin_goi);
  584. if($user_id==0){
  585. $info=array(
  586. 'thongbao'=>'Thất bại! Bạn chưa đăng nhập tài khoản ...',
  587. 'ok'=>0,
  588. 'chuyenhuong'=>'./dang-nhap.html'
  589. );
  590. }elseif($total==0){
  591. $info=array(
  592. 'thongbao'=>'Thất bại! Đơn hàng này không tồn tại...',
  593. 'ok'=>0,
  594. 'chuyenhuong'=>'./da-thue.html'
  595. );
  596. }elseif($total_goi==0){
  597. $info=array(
  598. 'thongbao'=>'Thất bại! Gói sản phẩm bạn chọn không tồn tại...',
  599. 'ok'=>0,
  600. 'chuyenhuong'=>'./da-thue.html'
  601. );
  602. }else{
  603. $r_tt=mysql_fetch_assoc($thongtin);
  604. $r_g=mysql_fetch_assoc($thongtin_goi);
  605. if($r_tt['date_end']<time()){
  606. $info=array(
  607. 'thongbao'=>'Thất bại! Bạn đã hết gian thuê tài khoản này...',
  608. 'ok'=>0,
  609. 'chuyenhuong'=>'./da-thue.html'
  610. );
  611. }else{
  612. $thongtin_damua=mysql_query("SELECT * FROM don_hang WHERE sanpham='{$r_tt['sanpham']}' AND tinh_trang='2'");
  613. $total_damua=mysql_num_rows($thongtin_damua);
  614. if($total_damua>0){
  615. $info=array(
  616. 'thongbao'=>'Thất bại! Tài khoản này đã có người đặt trước...',
  617. 'ok'=>0,
  618. 'chuyenhuong'=>'./da-thue.html'
  619. );
  620. }else{
  621. $ok_end=$r_tt['date_end']+3600*$r_g['start'];
  622. $tru=$r_g['gia'];
  623. if($tru>$user_info['user_money']){
  624. $info=array(
  625. 'thongbao'=>'Thất bại! Tiền trong tài khoản của bạn không đủ...',
  626. 'ok'=>0,
  627. 'chuyenhuong'=>'./nap-the.html'
  628. );
  629. }else{
  630. $conlai=$user_info['user_money']-$tru;
  631. $gia_moi=$r_tt['gia']+$tru;
  632. mysql_query("UPDATE user_info SET user_money='$conlai' WHERE user_id='$user_id'");
  633. mysql_query("UPDATE don_hang SET date_end='$ok_end',gia='$gia_moi' WHERE id='$id'");
  634. $info=array(
  635. 'thongbao'=>'Thành công! Đang chuyển hướng tới trang xem thông tin...',
  636. 'ok'=>0,
  637. 'chuyenhuong'=>'./da-thue.html'
  638. );
  639. }
  640.  
  641. }
  642. }
  643.  
  644. }
  645. echo '<!DOCTYPE html>
  646. <html lang="en">
  647. <head>
  648. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  649. <meta http-equiv="refresh" content="3;url='.$info['chuyenhuong'].'">
  650. <link href="./skin/css/style.css" rel="stylesheet"/>
  651. <title>Thông báo hệ thống</title>
  652. </head>
  653. <body class="loading">
  654. <center>'.$info['thongbao'].'</center>
  655. </body>
  656. </html>';
  657. }
  658. ////////////////////////////////////////
  659. elseif($action=='thue'){
  660. $id=intval($_REQUEST['id']);
  661. $goi=intval($_REQUEST['goi']);
  662. $thongtin=mysql_query("SELECT * FROM sanpham WHERE id='$id'");
  663. $total=mysql_num_rows($thongtin);
  664. $thongtin_goi=mysql_query("SELECT * FROM goi_sanpham WHERE id='$goi'");
  665. $total_goi=mysql_num_rows($thongtin_goi);
  666. if($user_id==0){
  667. $info=array(
  668. 'thongbao'=>'Thất bại! Bạn chưa đăng nhập tài khoản ...',
  669. 'ok'=>0,
  670. 'chuyenhuong'=>'./dang-nhap.html'
  671. );
  672. }elseif($total==0){
  673. $info=array(
  674. 'thongbao'=>'Thất bại! Sản phẩm không tồn tại...',
  675. 'ok'=>0,
  676. 'chuyenhuong'=>'./thue-sub.html'
  677. );
  678. }elseif($total_goi==0){
  679. $info=array(
  680. 'thongbao'=>'Thất bại! Gói sản phẩm bạn chọn không tồn tại...',
  681. 'ok'=>0,
  682. 'chuyenhuong'=>'./thue-sub.html'
  683. );
  684. }else{
  685. $r_tt=mysql_fetch_assoc($thongtin);
  686. $r_g=mysql_fetch_assoc($thongtin_goi);
  687. $ok_start=time();
  688. $ok_end=$ok_start+3600*$r_g['start'];
  689. $tru=$r_g['gia'];
  690. $thongtin_damua=mysql_query("SELECT * FROM don_hang WHERE sanpham='$id' AND date_end>'$ok_start' AND tinh_trang='1'");
  691. $total_damua=mysql_num_rows($thongtin_damua);
  692. if($tru>$user_info['user_money']){
  693. $info=array(
  694. 'thongbao'=>'Thất bại! Tiền trong tài khoản của bạn không đủ...',
  695. 'ok'=>0,
  696. 'chuyenhuong'=>'./nap-the.html'
  697. );
  698. }else if($total_damua>0){
  699. $info=array(
  700. 'thongbao'=>'Thất bại! Tài khoản này đang có người sử dụng...',
  701. 'ok'=>0,
  702. 'chuyenhuong'=>'./thue-sub.html'
  703. );
  704. }else{
  705. $ma_donhang=substr(md5($r_tt['tieu_de'].''.time()),0,8);
  706. $conlai=$user_info['user_money']-$tru;
  707. mysql_query("UPDATE user_info SET user_money='$conlai' WHERE user_id='$user_id'");
  708. mysql_query("INSERT INTO don_hang(ma_don,username,khung,tieu_de,account,sanpham,gia,tinh_trang,date_post,date_start,date_end)VALUES('$ma_donhang','{$user_info['username']}','$goi','{$r_tt['tieu_de']}','{$r_tt['account']}','$id','{$r_g['gia']}','1',".time().",'$ok_start','$ok_end')");
  709. $_SESSION['hoanthanh']=$id.'|'.$ma_donhang;
  710. $info=array(
  711. 'thongbao'=>'Thành công! Đang chuyển hướng tới trang xem thông tin...',
  712. 'ok'=>0,
  713. 'chuyenhuong'=>'./hoan-thanh.html'
  714. );
  715. }
  716.  
  717. }
  718. echo '<!DOCTYPE html>
  719. <html lang="en">
  720. <head>
  721. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  722. <meta http-equiv="refresh" content="3;url='.$info['chuyenhuong'].'">
  723. <link href="./skin/css/style.css" rel="stylesheet"/>
  724. <title>Thông báo hệ thống</title>
  725. </head>
  726. <body class="loading">
  727. <center>'.$info['thongbao'].'</center>
  728. </body>
  729. </html>';
  730. }
  731. ////////////////////////////////////////
  732. elseif($action=='dattruoc'){
  733. $id=intval($_REQUEST['id']);
  734. $goi=intval($_REQUEST['goi']);
  735. $thongtin=mysql_query("SELECT * FROM sanpham WHERE id='$id'");
  736. $total=mysql_num_rows($thongtin);
  737. $thongtin_goi=mysql_query("SELECT * FROM goi_sanpham WHERE id='$goi'");
  738. $total_goi=mysql_num_rows($thongtin_goi);
  739. if($user_id==0){
  740. $info=array(
  741. 'thongbao'=>'Thất bại! Bạn chưa đăng nhập tài khoản ...',
  742. 'ok'=>0,
  743. 'chuyenhuong'=>'./dang-nhap.html'
  744. );
  745. }elseif($total==0){
  746. $info=array(
  747. 'thongbao'=>'Thất bại! Sản phẩm không tồn tại...',
  748. 'ok'=>0,
  749. 'chuyenhuong'=>'./thue-sub.html'
  750. );
  751. }elseif($total_goi==0){
  752. $info=array(
  753. 'thongbao'=>'Thất bại! Gói sản phẩm bạn chọn không tồn tại...',
  754. 'ok'=>0,
  755. 'chuyenhuong'=>'./thue-sub.html'
  756. );
  757. }else{
  758. $r_tt=mysql_fetch_assoc($thongtin);
  759. $r_g=mysql_fetch_assoc($thongtin_goi);
  760. $thongtin_dangdung=mysql_query("SELECT * FROM don_hang WHERE sanpham='$id' AND tinh_trang='1' ORDER BY date_end DESC LIMIT 1");
  761. $total_dangdung=mysql_num_rows($thongtin_dangdung);
  762. if($total_dangdung==0){
  763. $ok_start=time();
  764. $ok_end=$ok_start+3600*$r_g['start'];
  765. $tru=$r_g['gia'];
  766. if($tru>$user_info['user_money']){
  767. $info=array(
  768. 'thongbao'=>'Thất bại! Tiền trong tài khoản của bạn không đủ...',
  769. 'ok'=>0,
  770. 'chuyenhuong'=>'./nap-the.html'
  771. );
  772. }else{
  773. $ma_donhang=substr(md5($r_tt['tieu_de'].''.time()),0,8);
  774. $conlai=$user_info['user_money']-$tru;
  775. mysql_query("UPDATE user_info SET user_money='$conlai' WHERE user_id='$user_id'");
  776. mysql_query("INSERT INTO don_hang(ma_don,username,khung,tieu_de,account,sanpham,gia,tinh_trang,date_post,date_start,date_end)VALUES('$ma_donhang','{$user_info['username']}','$goi','{$r_tt['tieu_de']}','{$r_tt['account']}','$id','{$r_g['gia']}','1',".time().",'$ok_start','$ok_end')");
  777. $_SESSION['hoanthanh']=$id.'|'.$ma_donhang;
  778. $info=array(
  779. 'thongbao'=>'Thuê tài khoản thành công! Đang chuyển hướng tới xem thông tin...',
  780. 'ok'=>1,
  781. 'chuyenhuong'=>'./hoan-thanh.html'
  782. );
  783. }
  784. }else{
  785. $r_sd=mysql_fetch_assoc($thongtin_dangdung);
  786. $hientai=time();
  787. if($r_sd['date_end']>$hientai){
  788. $ok_start=$r_sd['date_end'];
  789. }else{
  790. $ok_start=$hientai;
  791. }
  792. $ok_end=$ok_start+3600*$r_g['start'];
  793. $tru=$r_g['gia'];
  794. $thongtin_damua=mysql_query("SELECT * FROM don_hang WHERE sanpham='$id' AND date_end>'$ok_start' AND tinh_trang='2'");
  795. $total_damua=mysql_num_rows($thongtin_damua);
  796. if($tru>$user_info['user_money']){
  797. $info=array(
  798. 'thongbao'=>'Thất bại! Tiền trong tài khoản của bạn không đủ...',
  799. 'ok'=>0,
  800. 'chuyenhuong'=>'./nap-the.html'
  801. );
  802. }else if($total_damua>0){
  803. $info=array(
  804. 'thongbao'=>'Thất bại! Đã có 1 người đặt trước tài khoản này...',
  805. 'ok'=>0,
  806. 'chuyenhuong'=>'./thue-sub.html'
  807. );
  808. }else{
  809. $ma_donhang=substr(md5($r_tt['tieu_de'].''.time()),0,8);
  810. $conlai=$user_info['user_money']-$tru;
  811. mysql_query("UPDATE user_info SET user_money='$conlai' WHERE user_id='$user_id'");
  812. mysql_query("INSERT INTO don_hang(ma_don,username,khung,tieu_de,account,sanpham,gia,tinh_trang,date_post,date_start,date_end)VALUES('$ma_donhang','{$user_info['username']}','$goi','{$r_tt['tieu_de']}','{$r_tt['account']}','$id','{$r_g['gia']}','2',".time().",'$ok_start','$ok_end')");
  813. $_SESSION['hoanthanh']=$id.'|'.$ma_donhang;
  814. $info=array(
  815. 'thongbao'=>'Đặt trước thành công! Đang chuyển hướng tới trang đã thuê ...',
  816. 'ok'=>1,
  817. 'chuyenhuong'=>'./da-thue.html'
  818. );
  819. }
  820.  
  821. }
  822.  
  823. }
  824. echo '<!DOCTYPE html>
  825. <html lang="en">
  826. <head>
  827. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  828. <meta http-equiv="refresh" content="3;url='.$info['chuyenhuong'].'">
  829. <link href="./skin/css/style.css" rel="stylesheet"/>
  830. <title>Thông báo hệ thống</title>
  831. </head>
  832. <body class="loading">
  833. <center>'.$info['thongbao'].'</center>
  834. </body>
  835. </html>';
  836. }
  837. ////////////////////////////////////////
  838. elseif($action=='logout'){
  839. if($user_id==0){
  840. $info=array(
  841. 'thongbao'=>'Thao tác không thành công! Bạn chưa đăng nhập...',
  842. 'ok'=>0,
  843. );
  844. }else{
  845. $class_member->logout($user_id);
  846. $info=array(
  847. 'thongbao'=>'Đăng xuất thành công! Hệ thống đang chuyển hướng...',
  848. 'ok'=>1,
  849. );
  850. }
  851. echo '<!DOCTYPE html>
  852. <html lang="en">
  853. <head>
  854. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  855. <meta http-equiv="refresh" content="3;url=./index.html">
  856. <link href="./skin/css/style.css" rel="stylesheet"/>
  857. <title>Thông báo hệ thống</title>
  858. </head>
  859. <body class="loading">
  860. <center>'.$info['thongbao'].'</center>
  861. </body>
  862. </html>';
  863. }
  864. ///////////////////////////////////
  865. elseif($action=='lost_password'){
  866. $email=addslashes($_REQUEST['email']);
  867. include_once("./class.phpmailer.php");
  868. $port=$check->index_setting('port');
  869. $pass_mail=$check->index_setting('pass_mail');
  870. $smtp=$check->index_setting('smtp');
  871. $mail_noreply=$check->index_setting('mail_noreply');
  872. if($check->check_email($email)==true){
  873. $thongtin_email=mysql_query("SELECT * FROM user_info WHERE email='$email'");
  874. $total_email=mysql_num_rows($thongtin_email);
  875. if($total_email==0){
  876. $info=array(
  877. 'thongbao'=>'Thất bại! Email bạn nhập không tồn tài trên hệ thống...',
  878. 'ok'=>0,
  879. );
  880. }else{
  881. $r_tt=mysql_fetch_assoc($thongtin_email);
  882. $token=md5(time());
  883. $hientai=time();
  884. $password=rand(123456,999999);
  885. $r_email['password']=$password;
  886. $r_email['username']=$r_tt['username'];
  887. $r_email['link_domain']=$check->index_setting('link_domain');
  888. $r_email['link_xacnhan']=$check->index_setting('link_domain').'process.php?action=kichhoat_matkhau&email='.$email.'&token='.$token;
  889. $noidung=$tlca_skin->skin_replace('noidung_email',$r_email);
  890. $mailer = new PHPMailer(); // khởi tạo đối tượng
  891. $mailer->IsSMTP(); // gọi class smtp để đăng nhập
  892. $mailer->CharSet="utf-8"; // bảng mã unicode
  893. $mailer->SMTPAuth = true; // gửi thông tin đăng nhập
  894. // Đăng nhập SMTP
  895. if($smtp=='smtp.gmail.com'){
  896. $mailer->SMTPSecure = "ssl"; // Giao thức SSL
  897. $mailer->Host = "smtp.gmail.com"; // SMTP của GMAIL
  898. $mailer->Port = 465; // cổng SMTP
  899. $mailer->Username = $mail_noreply; // GMAIL username
  900. $mailer->Password = $pass_mail; // GMAIL password
  901. }else{
  902. $mailer->Host =$smtp; // địa chỉ server smtp
  903. $mailer->Port = $port; // cổng SMTP
  904. $mailer->Username = $mail_noreply; // tên đăng nhập
  905. $mailer->Password = $pass_mail; // mật khẩu
  906. }
  907. $mailer->FromName = 'Admin '.$_SERVER['HTTP_HOST']; // tên người gửi
  908. $mailer->From = $mail_noreply; // mail người gửi
  909. $mailer->AddAddress($email,$r_tt['ho_ten']); //thêm mail người nhận
  910. $mailer->Subject = 'Lấy lại mật khẩu trên '.$_SERVER['HTTP_HOST'];
  911. $mailer->IsHTML(true); //Bật HTML không thích thì false
  912. $mailer->Body = $noidung;
  913. if($mailer->Send()){
  914. mysql_query("INSERT INTO quen_pass(email,password,code,date_post)VALUES('$email','$password','$token','$hientai')");
  915. $info=array(
  916. 'thongbao'=>'Thành công! Vui lòng truy cập email '.$email.' để kích hoạt mật khẩu...',
  917. 'ok'=>1,
  918. 'link'=>'./quen-matkhau.html'
  919. );
  920. }else{
  921. $info=array(
  922. 'thongbao'=>'Thất bại! Gặp lỗi trong quá trình gửi email...',
  923. 'ok'=>0,
  924. 'link'=>'./quen-matkhau.html'
  925. );
  926. }
  927.  
  928. }
  929. }else{
  930. $info=array(
  931. 'thongbao'=>'Thất bại! Email bạn nhập không đúng định dạng...',
  932. 'ok'=>0,
  933. 'link'=>'./quen-matkhau.html'
  934. );
  935.  
  936. }
  937. echo '<!DOCTYPE html>
  938. <html lang="en">
  939. <head>
  940. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  941. <meta http-equiv="refresh" content="3;url='.$info['link'].'">
  942. <link href="./skin/css/style.css" rel="stylesheet"/>
  943. <title>Thông báo hệ thống</title>
  944. </head>
  945. <body class="loading">
  946. <center>'.$info['thongbao'].'</center>
  947. </body>
  948. </html>';
  949. }
  950. ///////////////////////////////////////
  951. else{
  952. echo 'No Action';
  953. }
  954. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement