Advertisement
Guest User

1

a guest
Nov 19th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.85 KB | None | 0 0
  1. class Test extends CI_Controller {
  2.     public $user_session;
  3.     public function __construct()
  4.     {
  5.         parent::__construct();
  6.         $this->load->model('Admin_Model');
  7.     }
  8.  
  9.     //////////////////////////////////////ACCOUNT NAVBAR//////////////////////////////////////
  10.     public function account_nav($username = "")
  11.     {
  12.         if(is_logged_in() && $username != ""){
  13.             $acc_nav = $this->Admin_Model->account($username);
  14.             return $acc_nav;
  15.         }
  16.         else
  17.         {
  18.             header("Location:".base_url()."admin/login");
  19.         }
  20.     }
  21.     //////////////////////////////////////ACCOUNT NAVBAR//////////////////////////////////////
  22.     public function index()
  23.     {
  24.         if(is_logged_in()){
  25.             $push_notification = $this->Admin_Model->push_notification();
  26.             $get_number_user = $this->Admin_Model->get_number_user();
  27.             $get_number_deal = $this->Admin_Model->get_number_deal();
  28.             $get_number_card = $this->Admin_Model->get_number_card();
  29.             $get_total_cash = $this->Admin_Model->get_total_cash();
  30.  
  31.             $data = array(
  32.                 "acc_nav"=>$this->account_nav($_SESSION["admin_login"]),
  33.                 "get_number_user"=>$get_number_user,
  34.                 "get_number_deal"=>$get_number_deal,
  35.                 'get_number_card'=>$get_number_card,
  36.                 'get_total_cash'=>$get_total_cash,
  37.                 'push_notification'=>$push_notification,
  38.  
  39.             );
  40.             $this->load->view('admin/index',$data);
  41.         }
  42.         else
  43.         {
  44.             header("Location:".base_url()."admin/login");
  45.         }
  46.     }
  47.     //////////////////////////////////////UPLOAD//////////////////////////////////////
  48.     public function upload()
  49.     {
  50.         $this->load->view('upload_f', array('error' => ' ' ));
  51.     }
  52.  
  53.     public function do_upload($files_input)
  54.     {
  55.         // $config['upload_path']          = './uploads/';
  56.         // $config['allowed_types']        = 'gif|jpg|png';
  57.         // $config['max_size']             = 1024*20;
  58.         // $config['max_width']            = 1024;
  59.         // $config['max_height']           = 768;
  60.         // $config['encrypt_name']          = TRUE;
  61.  
  62.         // $this->load->library('upload', $config);
  63.  
  64.         // if ( ! $this->upload->do_upload('userfile'))
  65.         // {
  66.         //         $error = array('error' => $this->upload->display_errors());
  67.         //         $this->load->view('upload_f', $error);
  68.         // }
  69.         // else
  70.         // {
  71.         //         $data = array('upload_data' => $this->upload->data());
  72.         //         $this->load->view('upload_s', $data);
  73.         // }
  74.         if(!empty($_FILES[$files_input]['name'])){
  75.             $filesCount = count($_FILES[$files_input]['name']);
  76.             for($i = 0; $i < $filesCount; $i++){
  77.                 $_FILES[$files_input."s"]['name']     = $_FILES[$files_input]['name'][$i];
  78.                 $_FILES[$files_input."s"]['type']     = $_FILES[$files_input]['type'][$i];
  79.                 $_FILES[$files_input."s"]['tmp_name'] = $_FILES[$files_input]['tmp_name'][$i];
  80.                 $_FILES[$files_input."s"]['error']     = $_FILES[$files_input]['error'][$i];
  81.                 $_FILES[$files_input."s"]['size']     = $_FILES[$files_input]['size'][$i];
  82.                
  83.                 // File upload configuration
  84.                 $uploadPath = './uploads/';
  85.                 $config['upload_path'] = $uploadPath;
  86.                 $config['allowed_types'] = 'jpg|jpeg|png|gif';
  87.                 $config['max_size']             = 1024*30;
  88.                 // $config['max_width']            = 1024;
  89.                 // $config['max_height']           = 768;
  90.                 $config['encrypt_name']         = TRUE;
  91.  
  92.                 // Load and initialize upload library
  93.                 $this->load->library('upload', $config);
  94.                 $this->upload->initialize($config);
  95.                
  96.                 // Upload file to server
  97.                 if($this->upload->do_upload($files_input."s")){
  98.                     // Uploaded file data
  99.                     $fileData = $this->upload->data();
  100.                     $uploadData[$i]['file_name'] = $fileData['file_name'];
  101.                 }
  102.             }
  103.             $data_out = array();
  104.             $data_final = array();
  105.             if(isset($uploadData)){
  106.                 for($i = 0; $i < $filesCount; $i++){
  107.                     if(isset($uploadData[$i])){
  108.                         array_push($data_out, $uploadData[$i]['file_name']);
  109.                     }
  110.                 }
  111.             }
  112.             if($data_out != NULL){
  113.                 $data_final[$files_input] = json_encode($data_out);
  114.             }
  115.             else
  116.             {
  117.                 $data_final[$files_input] = "";
  118.             }
  119.             // $uploadData[$i]["file_name"];
  120.             return $data_final[$files_input];
  121.         }
  122.         else
  123.         {
  124.             return "";
  125.         }
  126.  
  127.     }
  128.  
  129.     //////////////////////////////////////UPLOAD//////////////////////////////////////
  130.  
  131.     /////////////////////////////////////LOGIN SIGNUP////////////////////////////////
  132.  
  133.     public function register()
  134.     {
  135.         $csrf = array(
  136.             'name' => $this->security->get_csrf_token_name(),
  137.             'hash' => $this->security->get_csrf_hash()
  138.         );
  139.         $data = array(
  140.             "csrf"=>$csrf
  141.         );
  142.         if(is_logged_in()){
  143.             $this->load->view('admin/register',$data);
  144.         }
  145.         else
  146.         {
  147.             header("Location:".base_url()."admin");
  148.         }
  149.     }
  150.  
  151.     public function register_process()
  152.     {
  153.         if(is_logged_in()){
  154.             $email = $this->input->post('email');
  155.             $username = $this->input->post('username');
  156.             $password = md5($this->input->post('password'));
  157.             if($this->Admin_Model->register($email,$username,$password) != 200){
  158.                 $array = array(
  159.                     'register_new_admin' => $username
  160.                 );
  161.                 $this->session->set_userdata( $array );
  162.                 header("Location:".base_url()."admin/register");
  163.             }
  164.             else
  165.             {
  166.                 echo "Error: User or Email has been exist !";
  167.             }
  168.         }
  169.         else
  170.         {
  171.             header("Location:".base_url()."admin");
  172.         }
  173.     }
  174.  
  175.     public function login()
  176.     {
  177.         $csrf = array(
  178.             'name' => $this->security->get_csrf_token_name(),
  179.             'hash' => $this->security->get_csrf_hash()
  180.         );
  181.         $data = array(
  182.             "csrf"=>$csrf
  183.         );
  184.         if(!is_logged_in()){
  185.             $this->load->view('admin/login',$data);
  186.         }
  187.         else
  188.         {
  189.             header("Location:".base_url()."admin");
  190.         }
  191.        
  192.     }
  193.     public function login_process(){
  194.         if(!is_logged_in()){
  195.            
  196.             $emailuser_get = $this->input->post('emailorusername');
  197.             $password_get = md5($this->input->post('password'));
  198.             $data = $this->Admin_Model->login($emailuser_get,$password_get);
  199.             if($data == NULL){
  200.                 echo "Failed";
  201.                 $_SESSION["admin_login"] = "";
  202.                 $_SESSION["admin_login_ok"] = 0;
  203.             }
  204.             else
  205.             {
  206.                 $_SESSION["admin_login"] = $data[0]['usrname'];
  207.                 $_SESSION["admin_login_ok"] = 1;
  208.                 header("Location:".base_url()."admin");
  209.             }
  210.            
  211.  
  212.             // if(($emailuser_get == $data[0]["usrname"] || $emailuser_get == $data[0]["email"]) && md5($password_get) == $data[0]["passwd"]){
  213.             //  $_SESSION["admin_login"] = $data[0]['usrname'];
  214.             //  $_SESSION["admin_login_ok"] = 1;
  215.             //  header("Location:".base_url()."admin");
  216.             // }
  217.             // else
  218.             // {
  219.             //  echo "Failed";
  220.             //  $_SESSION["admin_login"] = "";
  221.             //  $_SESSION["admin_login_ok"] = 0;
  222.             // }
  223.         }
  224.         else
  225.         {
  226.             header("Location:".base_url()."admin/login");
  227.         }
  228.        
  229.     }
  230.     public function logout()
  231.     {
  232.         $_SESSION["admin_login"] = "";
  233.         $_SESSION["admin_login_ok"] = 0;
  234.         header("Location:".base_url()."admin");
  235.     }
  236. ////////////////////////////////SHOP////////////////////////////////
  237.     public function shop($game_type = "")
  238.     {
  239.         if(is_logged_in() && is_admin()){
  240.             $data = $this->Admin_Model->shop($game_type);
  241.             $data = array(
  242.                 "data"=>$data,
  243.                 "acc_nav"=>$this->account_nav($_SESSION["admin_login"]),
  244.             );
  245.             $this->load->view('admin/shop/index', $data, FALSE);
  246.         }
  247.         else
  248.         {
  249.             header("Location:".base_url()."admin/login");
  250.         }
  251.     }
  252.  
  253.     public function add_shop()
  254.     {
  255.         if(is_logged_in() && is_admin()){
  256.             $csrf = array(
  257.                 'name' => $this->security->get_csrf_token_name(),
  258.                 'hash' => $this->security->get_csrf_hash()
  259.             );
  260.             $data = $this->Admin_Model->game();
  261.             $data = array(
  262.                 "data"=>$data,
  263.                 "acc_nav"=>$this->account_nav($_SESSION["admin_login"]),
  264.                 'csrf'=>$csrf
  265.             );
  266.             $this->load->view('admin/shop/add_shop',$data);
  267.         }
  268.         else
  269.         {
  270.             header("Location:".base_url()."admin/login");
  271.         }
  272.        
  273.     }
  274.  
  275.     public function add_shop_process()
  276.     {
  277.         if(is_logged_in() && is_admin()){
  278.             $game_type = $this->input->post('game_type');
  279.             $user_acc = $this->input->post('username');
  280.             $id_acc = substr(md5($user_acc), 0,10).rand(1000,9999);
  281.             $pass_acc = $this->input->post('password');
  282.             $more_info_acc = $this->input->post('more_info_acc');
  283.             if($game_type == "lienquan"){
  284.                 $sotuong = $this->input->post('sotuong');
  285.                 $trangphuc = $this->input->post('trangphuc');
  286.                 $bangngoc = $this->input->post('bangngoc');
  287.                 $bacngoc = $this->input->post('bacngoc');
  288.                 $rank = $this->input->post('rank');
  289.                 $vang = $this->input->post('vang');
  290.                 $ruby = $this->input->post('ruby');
  291.                 $quanhuy = $this->input->post('quanhuy');
  292.                 $noibat = $this->input->post('noibat');
  293.  
  294.                 $info_acc = array(
  295.                     "sotuong"=>$sotuong,
  296.                     "trangphuc"=>$trangphuc,
  297.                     "bangngoc"=>$bangngoc,
  298.                     "bacngoc"=>$bacngoc,
  299.                     "rank"=>$rank,
  300.                     "vang"=>$vang,
  301.                     "ruby"=>$ruby,
  302.                     "quanhuy"=>$quanhuy,
  303.                     "noibat"=>$noibat,
  304.                 );
  305.                 $info_acc = json_encode($info_acc);
  306.             }
  307.             else if($game_type == "lienminh"){
  308.                 $sotuong = $this->input->post('sotuong');
  309.                 $trangphuc = $this->input->post('trangphuc');
  310.                 $bangngoc = $this->input->post('bangngoc');
  311.                 $bacngoc = $this->input->post('bacngoc');
  312.                 $ip = $this->input->post('ip');
  313.                 $rank = $this->input->post('rank');
  314.                 $khung = $this->input->post('khung');
  315.                 $noibat = $this->input->post('noibat');
  316.                 $info_acc = array(
  317.                     "sotuong"=>$sotuong,
  318.                     "trangphuc"=>$trangphuc,
  319.                     "bangngoc"=>$bangngoc,
  320.                     "bacngoc"=>$bacngoc,
  321.                     "ip"=>$ip,
  322.                     "rank"=>$rank,
  323.                     "khung"=>$khung,
  324.                     "noibat"=>$noibat,
  325.                 );
  326.                 $info_acc = json_encode($info_acc);
  327.             }
  328.             else if($game_type == "ngocrong"){
  329.                 $hanhtinh = $this->input->post('hanhtinh');
  330.                 $server = $this->input->post('server');
  331.                 $dangki = $this->input->post('dangki');
  332.                 $bongtai = $this->input->post('bongtai');
  333.                 $noibat = $this->input->post('noibat');
  334.                 $info_acc = array(
  335.                     "hanhtinh"=>$hanhtinh,
  336.                     "server"=>$server,
  337.                     "dangki"=>$dangki,
  338.                     "bongtai"=>$bongtai,
  339.                     "noibat"=>$noibat,
  340.                 );
  341.                 $info_acc = json_encode($info_acc);
  342.             }
  343.             else if($game_type == "ninja"){
  344.                 $capdo = $this->input->post('capdo');
  345.                 $server = $this->input->post('server');
  346.                 $class = $this->input->post('class');
  347.                 $ttgt = $this->input->post('ttgt');
  348.                 $noibat = $this->input->post('noibat');
  349.                 $info_acc = array(
  350.                     "capdo"=>$capdo,
  351.                     "server"=>$server,
  352.                     "class"=>$class,
  353.                     "ttgt"=>$ttgt,
  354.                     "noibat"=>$noibat,
  355.                 );
  356.                 $info_acc = json_encode($info_acc);
  357.             }
  358.  
  359.             // $image_acc = $this->input->post('image_acc');
  360.             // if($image_acc != NULL){
  361.             //  $image_acc = explode("\n", $image_acc);
  362.             //  $image_array = array();
  363.             //  foreach ($image_acc as $key => $value) {
  364.             //      array_push($image_array, $value);
  365.             //  }
  366.             //  $image_array = json_encode($image_array);
  367.             // }
  368.             $tuong = 'tuong';
  369.             $trangphuc = 'trangphuc';
  370.             $bangngoc = 'bangngoc';
  371.             $anhchung ='anhchung';
  372.             // $image_tuong = ""; $image_trangphuc = ""; $image_ngoc = ""; $image_anhchung = "";
  373.             $image_tuong = $this->do_upload($tuong);
  374.             $image_trangphuc = $this->do_upload($trangphuc);
  375.             $image_ngoc = $this->do_upload($bangngoc);
  376.             $image_anhchung = $this->do_upload($anhchung);
  377.            
  378.  
  379.             $cost_acc = $this->input->post('cost_acc');
  380.             $status = 0;
  381.  
  382.             if($game_type != NULL && $user_acc != NULL && $id_acc != NULL && $pass_acc != NULL && $info_acc != NULL && $cost_acc != NULL){
  383.                 $this->Admin_Model->add_shop($id_acc,$game_type,$user_acc,$pass_acc,$more_info_acc,$info_acc,$image_tuong,$image_trangphuc,$image_ngoc,$image_anhchung,$cost_acc,$status);
  384.                 $_SESSION["them_thanh_cong_vao_shop"] = 1;
  385.                 header("Location:".base_url()."admin/add_shop");
  386.             }
  387.             else
  388.                 echo "Chua nhap du thong tin";
  389.         }
  390.         else
  391.         {
  392.             header("Location:".base_url()."admin/login");
  393.         }
  394.        
  395.     }
  396.  
  397.     public function shop_detail($id_acc = ""){
  398.         if(is_logged_in() && is_admin()){
  399.             $csrf = array(
  400.                 'name' => $this->security->get_csrf_token_name(),
  401.                 'hash' => $this->security->get_csrf_hash()
  402.             );
  403.             $data = $this->Admin_Model->shop_detail($id_acc);
  404.             $data = array(
  405.                 "data"=>$data,
  406.                 "acc_nav"=>$this->account_nav($_SESSION["admin_login"]),
  407.                 "csrf"=>$csrf,
  408.             );
  409.             $this->load->view('admin/shop/detail', $data, FALSE);
  410.         }
  411.         else
  412.         {
  413.             header("Location:".base_url()."admin/login");
  414.         }
  415.     }
  416.  
  417.     public function shop_detail_process(){
  418.         if(is_logged_in() && is_admin()){
  419.             $game_type = $this->input->post('game_type');
  420.             $user_acc = $this->input->post('username');
  421.             $id_acc = $this->input->post('id_acc');
  422.             $pass_acc = $this->input->post('password');
  423.             $more_info_acc = $this->input->post('more_info_acc');
  424.             if($game_type == "lienquan"){
  425.                 $sotuong = $this->input->post('sotuong');
  426.                 $trangphuc = $this->input->post('trangphuc');
  427.                 $bangngoc = $this->input->post('bangngoc');
  428.                 $bacngoc = $this->input->post('bacngoc');
  429.                 $rank = $this->input->post('rank');
  430.                 $vang = $this->input->post('vang');
  431.                 $ruby = $this->input->post('ruby');
  432.                 $quanhuy = $this->input->post('quanhuy');
  433.                 $noibat = $this->input->post('noibat');
  434.  
  435.                 $info_acc = array(
  436.                     "sotuong"=>$sotuong,
  437.                     "trangphuc"=>$trangphuc,
  438.                     "bangngoc"=>$bangngoc,
  439.                     "bacngoc"=>$bacngoc,
  440.                     "rank"=>$rank,
  441.                     "vang"=>$vang,
  442.                     "ruby"=>$ruby,
  443.                     "quanhuy"=>$quanhuy,
  444.                     "noibat"=>$noibat,
  445.                 );
  446.                 $info_acc = json_encode($info_acc);
  447.             }
  448.             else if($game_type == "lienminh"){
  449.                 $sotuong = $this->input->post('sotuong');
  450.                 $trangphuc = $this->input->post('trangphuc');
  451.                 $bangngoc = $this->input->post('bangngoc');
  452.                 $bacngoc = $this->input->post('bacngoc');
  453.                 $ip = $this->input->post('ip');
  454.                 $rank = $this->input->post('rank');
  455.                 $khung = $this->input->post('khung');
  456.                 $noibat = $this->input->post('noibat');
  457.                 $info_acc = array(
  458.                     "sotuong"=>$sotuong,
  459.                     "trangphuc"=>$trangphuc,
  460.                     "bangngoc"=>$bangngoc,
  461.                     "bacngoc"=>$bacngoc,
  462.                     "ip"=>$ip,
  463.                     "rank"=>$rank,
  464.                     "khung"=>$khung,
  465.                     "noibat"=>$noibat,
  466.                 );
  467.                 $info_acc = json_encode($info_acc);
  468.             }
  469.             else if($game_type == "ngocrong"){
  470.                 $hanhtinh = $this->input->post('hanhtinh');
  471.                 $server = $this->input->post('server');
  472.                 $dangki = $this->input->post('dangki');
  473.                 $bongtai = $this->input->post('bongtai');
  474.                 $noibat = $this->input->post('noibat');
  475.                 $info_acc = array(
  476.                     "hanhtinh"=>$hanhtinh,
  477.                     "server"=>$server,
  478.                     "dangki"=>$dangki,
  479.                     "bongtai"=>$bongtai,
  480.                     "noibat"=>$noibat,
  481.                 );
  482.                 $info_acc = json_encode($info_acc);
  483.             }
  484.             else if($game_type == "ninja"){
  485.                 $capdo = $this->input->post('capdo');
  486.                 $server = $this->input->post('server');
  487.                 $class = $this->input->post('class');
  488.                 $ttgt = $this->input->post('ttgt');
  489.                 $noibat = $this->input->post('noibat');
  490.                 $info_acc = array(
  491.                     "capdo"=>$capdo,
  492.                     "server"=>$server,
  493.                     "class"=>$class,
  494.                     "ttgt"=>$ttgt,
  495.                     "noibat"=>$noibat,
  496.                 );
  497.                 $info_acc = json_encode($info_acc);
  498.             }
  499.  
  500.             $tuong = 'tuong';
  501.             $trangphuc = 'trangphuc';
  502.             $bangngoc = 'bangngoc';
  503.             $anhchung ='anhchung';
  504.  
  505.             $image_tuong = $this->do_upload($tuong);
  506.             $image_trangphuc = $this->do_upload($trangphuc);
  507.             $image_ngoc = $this->do_upload($bangngoc);
  508.             $image_anhchung = $this->do_upload($anhchung);
  509.  
  510.             if($image_tuong != NULL){
  511.                 $image_tuong = json_decode($this->do_upload($tuong));
  512.             }
  513.             if($image_trangphuc != NULL){
  514.                 $image_trangphuc = json_decode($this->do_upload($trangphuc));
  515.             }
  516.             if($image_ngoc != NULL){
  517.                 $image_ngoc = json_decode($this->do_upload($bangngoc));
  518.             }
  519.             if($image_anhchung != NULL){
  520.                 $image_anhchung = json_decode($this->do_upload($anhchung));
  521.             }
  522.  
  523.             $db_img = $this->Admin_Model->shop_detail($id_acc);
  524.             if($db_img[0]['image_tuong']){
  525.                 $db_img_tuong = json_decode($db_img[0]['image_tuong']);
  526.             }
  527.             else
  528.             {
  529.                 $db_img_tuong = array();
  530.             }
  531.             if($db_img[0]['image_trangphuc']){
  532.                 $db_img_trangphuc = json_decode($db_img[0]['image_trangphuc']);
  533.             }
  534.             else
  535.             {
  536.                 $db_img_trangphuc = array();
  537.             }
  538.             if($db_img[0]['image_ngochotro']){
  539.                 $db_img_ngoc = json_decode($db_img[0]['image_ngochotro']);
  540.             }
  541.             else
  542.             {
  543.                 $db_img_ngoc = array();
  544.             }
  545.             if($db_img[0]['image_chung']){
  546.                 $db_img_anhchung = json_decode($db_img[0]['image_chung']);
  547.             }
  548.             else
  549.             {
  550.                 $db_img_anhchung = array();
  551.             }
  552.  
  553.            
  554.             if($image_tuong != NULL){
  555.                 for($i=0;$i<count($image_tuong);$i++){
  556.                     array_push($db_img_tuong, $image_tuong[$i]);
  557.                 }
  558.                 $image_tuong = json_encode($db_img_tuong);
  559.             }
  560.             else
  561.             {
  562.                 $image_tuong = $db_img[0]['image_tuong'];
  563.             }
  564.             if($image_trangphuc != NULL){
  565.                 for($i=0;$i<count($image_trangphuc);$i++){
  566.                     array_push($db_img_trangphuc, $image_trangphuc[$i]);
  567.                 }
  568.                 $image_trangphuc = json_encode($db_img_trangphuc);
  569.             }
  570.             else
  571.             {
  572.                 $image_trangphuc = $db_img[0]['image_trangphuc'];
  573.             }
  574.             if($image_ngoc != NULL){
  575.                 for($i=0;$i<count($image_ngoc);$i++){
  576.                     array_push($db_img_ngoc, $image_ngoc[$i]);
  577.                 }
  578.                 $image_ngoc = json_encode($db_img_ngoc);
  579.             }
  580.             else
  581.             {
  582.                 $image_ngoc = $db_img[0]['image_ngochotro'];
  583.             }
  584.             if($image_anhchung != NULL){
  585.                 for($i=0;$i<count($image_anhchung);$i++){
  586.                     array_push($db_img_anhchung, $image_anhchung[$i]);
  587.                 }
  588.                 $image_anhchung = json_encode($db_img_anhchung);
  589.             }
  590.             else
  591.             {
  592.                 $image_anhchung = $db_img[0]['image_chung'];
  593.             }
  594.  
  595.  
  596.             $cost_acc = $this->input->post('cost_acc');
  597.             $status = $this->input->post('status');
  598.  
  599.             if($game_type != NULL && $user_acc != NULL && $id_acc != NULL && $pass_acc != NULL && $info_acc != NULL && $cost_acc != NULL){
  600.                 $this->Admin_Model->shop_detail_process($id_acc,$game_type,$user_acc,$pass_acc,$more_info_acc,$info_acc,$image_tuong,$image_trangphuc,$image_ngoc,$image_anhchung,$cost_acc,$status);
  601.                 $_SESSION["sua_thanh_cong_vao_shop"] = 1;
  602.                 header("Location:".base_url()."admin/shop_detail/".$id_acc);
  603.             }
  604.             else
  605.                 echo "Chua nhap du thong tin";
  606.         }
  607.         else
  608.         {
  609.             header("Location:".base_url()."admin/login");
  610.         }
  611.     }
  612.  
  613.     public function shop_delete(){
  614.         if(is_logged_in() && is_admin()){
  615.             $id_acc = $_POST['id_acc'];
  616.             if($id_acc != NULL){
  617.                 $dat = $this->Admin_Model->get_image_to_delete($id_acc);
  618.                 $image_tuong = json_decode($dat[0]['image_tuong'],true);
  619.                 $image_trangphuc = json_decode($dat[0]['image_trangphuc'],true);
  620.                 $image_ngochotro = json_decode($dat[0]['image_ngochotro'],true);
  621.                 $image_chung = json_decode($dat[0]['image_chung'],true);
  622.                 print_r($image_tuong);
  623.                 if($image_tuong != NULL){
  624.                     for($i=0;$i<count($image_tuong);$i++){
  625.                         unlink("/var/www/html/uploads/".$image_tuong[$i]);
  626.                     }
  627.                 }
  628.                 if($image_trangphuc != NULL){
  629.                     for($i=0;$i<count($image_trangphuc);$i++){
  630.                         unlink("/var/www/html/uploads/".$image_trangphuc[$i]);
  631.                     }
  632.                 }
  633.                 if($image_ngochotro != NULL){
  634.                     for($i=0;$i<count($image_ngochotro);$i++){
  635.                         unlink("/var/www/html/uploads/".$image_ngochotro[$i]);
  636.                     }
  637.                 }
  638.                 if($image_chung != NULL){
  639.                     for($i=0;$i<count($image_chung);$i++){
  640.                         unlink("/var/www/html/uploads/".$image_chung[$i]);
  641.                     }
  642.                 }
  643.                 $this->Admin_Model->delete_shop($id_acc);
  644.             }
  645.         }
  646.         else
  647.         {
  648.             header("Location:".base_url()."admin/login");
  649.         }
  650.     }
  651.  
  652.     public function game($game)
  653.     {
  654.         if(is_logged_in() && is_admin()){
  655.             $this->load->view('admin/shop/game/'.$game);
  656.         }
  657.         else
  658.         {
  659.             header("Location:".base_url()."admin/login");
  660.         }
  661.     }
  662.     ///////////Danh sach the nap///////////
  663.     public function card_list()
  664.     {
  665.         if(is_logged_in() && is_admin()){
  666.             $csrf = array(
  667.                 'name' => $this->security->get_csrf_token_name(),
  668.                 'hash' => $this->security->get_csrf_hash()
  669.             );
  670.             $data = $this->Admin_Model->card_list();
  671.             $data = array(
  672.                 "acc_nav"=>$this->account_nav($_SESSION["admin_login"]),
  673.                 "data"=>$data,
  674.                 "csrf"=>$csrf,
  675.             );
  676.             $this->load->view('admin/mobilecard/index', $data, FALSE);
  677.         }
  678.         else
  679.         {
  680.             header("Location:".base_url()."admin/login");
  681.         }
  682.     }
  683.    
  684.     public function card_list_process_confirm()
  685.     {
  686.         $username = $_POST['username'];
  687.         $nhamang = $_POST['nhamang'];
  688.         $masothe = $_POST['mathe'];
  689.         $soserial = $_POST['serial'];
  690.         $menhgia = $_POST['menhgia'];
  691.         $trangthai = array();
  692.         if(is_logged_in() && is_admin()){
  693.             for($i=0;$i<count($username);$i++){
  694.                 array_push($trangthai,$this->Admin_Model->card_list_status($username[$i],$masothe[$i],$soserial[$i],$menhgia[$i]));
  695.             }
  696.             for($i=0;$i<count($username);$i++){
  697.                 if($trangthai[$i][0]['trangthai'] == 0){
  698.                     if($username[$i] != NULL && $masothe[$i] != NULL && $soserial[$i] != NULL && $menhgia[$i] != NULL){
  699.                         $this->Admin_Model->card_list_process($username[$i],$masothe[$i],$soserial[$i],$menhgia[$i]);
  700.                         $_SESSION["xacnhanthanhcong"] = true;
  701.                     }
  702.                 }
  703.                 else if($trangthai[$i][0]['trangthai'] == 1){
  704.                     $_SESSION["loixacnhanlai"] = true;
  705.                 }
  706.             }
  707.            
  708.         }
  709.         else
  710.         {
  711.             header("Location:".base_url()."admin/login");
  712.         }
  713.  
  714.     }
  715.     public function card_list_process_cancel_confirm()
  716.     {
  717.         $username = $_POST['username'];
  718.         $nhamang = $_POST['nhamang'];
  719.         $masothe = $_POST['mathe'];
  720.         $soserial = $_POST['serial'];
  721.         $menhgia = $_POST['menhgia'];
  722.         $trangthai = array();
  723.         if(is_logged_in() && is_admin()){
  724.             for($i=0;$i<count($username);$i++){
  725.                 array_push($trangthai,$this->Admin_Model->card_list_status($username[$i],$masothe[$i],$soserial[$i],$menhgia[$i]));
  726.             }
  727.             for($i=0;$i<count($username);$i++){
  728.                 if($trangthai[$i][0]['trangthai'] == 1){
  729.                     if($username[$i] != NULL && $masothe[$i] != NULL && $soserial[$i] != NULL && $menhgia[$i] != NULL){
  730.                         $this->Admin_Model->card_list_process_detroy($username[$i],$masothe[$i],$soserial[$i],$menhgia[$i]);
  731.                         $_SESSION["huyxacnhanthanhcong"] = true;
  732.                     }
  733.                 }
  734.                 else if($trangthai[$i][0]['trangthai'] == 0){
  735.                     $_SESSION["loihuyxacnhanlai"] = true;
  736.                 }
  737.             }
  738.            
  739.         }
  740.         else
  741.         {
  742.             header("Location:".base_url()."admin/login");
  743.         }
  744.  
  745.     }
  746.     ///////////Danh sach the nap///////////
  747.  
  748.  
  749.  
  750.     // public function card_list_process()
  751.     // {
  752.     //  $login = $this->Admin_Model->login();
  753.        
  754.     //  $username = $this->input->post('username');
  755.     //  $masothe = $this->input->post('masothe');
  756.     //  $soserial = $this->input->post('soserial');
  757.     //  $menhgia = $this->input->post('menhgia');
  758.     //  $trangthai = $this->Admin_Model->card_list_status($username,$masothe,$soserial,$menhgia);
  759.        
  760.     //  if(is_logged_in() && is_admin() == $login[0]['usrname']){
  761.     //      $xacnhan = $this->input->post('xacnhan');
  762.     //      $huyxacnhan = $this->input->post('huyxacnhan');
  763.     //      if(isset($xacnhan) && $xacnhan == "Xác nhận" && $trangthai[0]['trangthai'] == 0){
  764.     //          if($username != NULL && $masothe != NULL && $soserial != NULL && $menhgia != NULL){
  765.     //              $this->Admin_Model->card_list_process($username,$masothe,$soserial,$menhgia);
  766.     //              $_SESSION["xacnhanthanhcong"] = true;
  767.     //              header("Location:".base_url()."admin/card_list");
  768.     //          }
  769.     //      }
  770.     //      else if(isset($huyxacnhan) && $huyxacnhan == "Hủy" && $trangthai[0]['trangthai'] == 1){
  771.     //          if($username != NULL && $masothe != NULL && $soserial != NULL && $menhgia != NULL){
  772.     //              $this->Admin_Model->card_list_process_detroy($username,$masothe,$soserial,$menhgia);
  773.     //              $_SESSION["huyxacnhanthanhcong"] = true;
  774.     //              header("Location:".base_url()."admin/card_list");
  775.     //          }
  776.     //      }
  777.     //      else if(isset($xacnhan) && $xacnhan == "Xác nhận" && $trangthai[0]['trangthai'] == 1){
  778.     //          $_SESSION["loixacnhanlai"] = true;
  779.     //          header("Location:".base_url()."admin/card_list");
  780.     //      }
  781.     //      else if(isset($huyxacnhan) && $huyxacnhan == "Hủy" && $trangthai[0]['trangthai'] == 0){
  782.     //          $_SESSION["loihuyxacnhanlai"] = true;
  783.     //          header("Location:".base_url()."admin/card_list");
  784.     //      }
  785.     //  }
  786.     //  else
  787.     //  {
  788.     //      header("Location:".base_url()."admin/login");
  789.     //  }
  790.     // }
  791.    
  792.     ///////////Danh Sach Mua Hang//////////////
  793.  
  794.     public function deal_history()
  795.     {
  796.         if(is_logged_in() && is_admin()){
  797.             $csrf = array(
  798.                 'name' => $this->security->get_csrf_token_name(),
  799.                 'hash' => $this->security->get_csrf_hash()
  800.             );
  801.             $data = $this->Admin_Model->deal_history();
  802.             $data = array(
  803.                 "acc_nav"=>$this->account_nav($_SESSION["admin_login"]),
  804.                 "data"=>$data,
  805.                 "csrf"=>$csrf,
  806.             );
  807.             $this->load->view('admin/deal/index', $data, FALSE);
  808.         }
  809.         else
  810.         {
  811.             header("Location:".base_url()."admin/login");
  812.         }
  813.     }
  814.  
  815.     ///////////Danh Sach Mua Hang//////////////
  816.     public function settings()
  817.     {
  818.         if(is_logged_in() && is_admin()){
  819.             $info = $this->Admin_Model->account($_SESSION['admin_login']);
  820.             $csrf = array(
  821.                 'name'=>$this->security->get_csrf_token_name(),
  822.                 'hash'=>$this->security->get_csrf_hash()
  823.             );
  824.             $data = array(
  825.                 'csrf'=>$csrf,
  826.                 'info'=>$info,
  827.             );
  828.             $this->load->view('admin/settings', $data, FALSE);
  829.         }
  830.         else
  831.         {
  832.             header("Location:".base_url()."admin/login");
  833.         }
  834.     }
  835.  
  836.     public function settings_process()
  837.     {
  838.         if(is_logged_in() && is_admin()){
  839.             $info = $this->Admin_Model->account($_SESSION['admin_login']);
  840.             $username = $this->input->post('username');
  841.             $email = $this->input->post('email');
  842.             if($this->input->post('password') != ""){
  843.                 $password = md5($this->input->post('password'));
  844.             }
  845.             else
  846.             {
  847.                 $password = $info[0]['passwd'];
  848.             }
  849.             $this->Admin_Model->settings_change($username,$email,$password);
  850.             redirect('/admin/settings');
  851.         }
  852.         else
  853.         {
  854.             header("Location:".base_url()."admin/login");
  855.         }
  856.     }
  857.  
  858. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement