コード例 #1
0
ファイル: home.php プロジェクト: ngothanhduoc/wap_tao
 public function download()
 {
     $params = $this->input->get(NULL, TRUE);
     $db = $this->m_wap->jqxGetId('game_app', array('id_game_app' => $params['id'], 'status' => 'active'), 'id_game_app, download_url, count_download, count_install');
     $url = json_decode($db[0]['download_url'], TRUE);
     $link = base_url($url[$params['platform']]);
     if (link_copy($url[$params['platform']]) === FALSE) {
         $link = $url[$params['platform']];
     }
     $data_update = array('count_download' => $db[0]['count_download'] + 1, 'count_install' => $db[0]['count_install'] + 1);
     $this->m_wap->jqxUpdate('game_app', 'id_game_app', $params['id'], $data_update);
     header('Location: ' . $link);
     die;
 }
コード例 #2
0
ファイル: admin_ajax.php プロジェクト: ngothanhduoc/wap_tao
 public function addgame()
 {
     $this->load->library('form_validation');
     $response['code'] = -1;
     $response['redirect'] = '/backend/game/index';
     $response['message']['type'] = '';
     $response['message']['name'] = '';
     $response['message']['code_game'] = '';
     $response['message']['platform'] = '';
     $response['message']['system'] = '';
     $response['message']['id_game'] = 0;
     $response['message']['order'] = '';
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $arrParam = $this->input->post();
         $Id = $arrParam['id'];
         //            die(json_encode($arrParam));
         //get publisher
         $this->m_backend->datatables_config = array("table" => 'publisher', "order_by" => "ORDER BY id_publisher DESC");
         $this->form_validation->set_rules('code_game', 'code_game', 'callback_xss_check|trim|required');
         $this->form_validation->set_rules('name', 'name', 'callback_xss_check|trim|required');
         $this->form_validation->set_rules('platform', 'platform', 'callback_xss_check|trim|required');
         $this->form_validation->set_rules('type', 'type', 'callback_xss_check|trim|required');
         $this->form_validation->set_rules('description', 'description', 'callback_xss_check');
         $this->form_validation->set_rules('order', 'order', 'callback_num_check|trim');
         $this->form_validation->set_rules('cate', 'cate', 'callback_num_check|trim');
         $this->form_validation->set_message('required', 'Không được rỗng');
         if ($this->form_validation->run() == TRUE) {
             $Params = array();
             if (isset($arrParam['set_new'])) {
                 $Params['set_new'] = $arrParam['set_new'];
             } else {
                 $Params['set_new'] = 'block';
             }
             if (isset($arrParam['favorite'])) {
                 $Params['favorite'] = $arrParam['favorite'];
             } else {
                 $Params['favorite'] = 'block';
             }
             $Params['name'] = $this->security->xss_clean($arrParam['name']);
             $Params['code_game'] = $this->security->xss_clean($arrParam['code_game']);
             $Params['platform'] = json_encode(explode(',', $this->security->xss_clean($arrParam['platform'])));
             $Params['download_url'] = $this->security->xss_clean($arrParam['url_download']);
             $Params['package_name'] = json_encode($this->security->xss_clean($arrParam['package_name']));
             $Params['size'] = $this->security->xss_clean($arrParam['size']);
             $Params['cate'] = $this->security->xss_clean($arrParam['cate']);
             $Params['description'] = $this->security->xss_clean($arrParam['description']);
             $Params['type'] = $this->security->xss_clean($arrParam['type']);
             $Params['icon'] = $this->security->xss_clean($arrParam['icon']);
             $Params['slide_image'] = json_encode($this->security->xss_clean($arrParam['slide']));
             $Params['count_download'] = $arrParam['count_download'];
             $Params['order'] = $arrParam['order'];
             $user_info = $this->session->userdata("user_info");
             $Params['content'] = $arrParam['content'];
             //image
             $subject = $Params['content'];
             $pattern = '#.*<img.*src="(.*)".*>#imsU';
             preg_match_all($pattern, $subject, $matches);
             $data['arrImg'] = $matches[1];
             if (empty($matches[1]) === FALSE) {
                 foreach ($matches[1] as $k => $v) {
                     if (strpos($v, 'http') !== false) {
                         continue;
                     } else {
                         $badchars = '"' . $v . '"';
                         $rep = '"' . 'http://' . $_SERVER['HTTP_HOST'] . $v . '"';
                         $subject = str_replace($badchars, $rep, $subject);
                     }
                 }
             }
             $Params['content'] = $subject;
             //Xu Ly file Plist
             $link_copy = link_copy($Params['download_url']['ios']);
             if (!empty($Params['download_url']['ios']) and $link_copy !== FALSE) {
                 $paramsInfo = array('client' => 'https://' . $_SERVER['HTTP_HOST'] . $Params['download_url']['ios'], 'image' => 'https://' . $_SERVER['HTTP_HOST'] . $Params['icon'], 'bundle' => @$arrParam['package_name']['ios'], 'version' => '1.1.0', 'subtitle' => $Params['name'], 'title' => $Params['name'], 'link_copy' => $link_copy);
                 $Params['download_url']['plist'] = $this->replaceInfo($paramsInfo);
             } else {
                 unset($Params['download_url']['plist']);
             }
             $Params['download_url'] = json_encode($Params['download_url']);
             if (empty($Id) === TRUE) {
                 $Params['status'] = 'active';
                 $Params['create_time'] = date('Y-m-d H:i:s');
                 $Params['create_user'] = $this->session->userdata['user_info']['username'];
                 $id_game = $this->m_backend->jqxInsertId('game_app', $Params);
                 $id_forkey = $id_game;
                 $response['code'] = 0;
                 $response['message']['id_game'] = $id_game;
             } else {
                 $id_forkey = $Id;
                 $Params['update_time'] = date('Y-m-d H:i:s');
                 $id_game = $this->m_backend->jqxUpdate('game_app', 'id_game_app', $Id, $Params);
                 $response['code'] = 0;
                 $response['message']['id_game'] = $Id;
             }
         } else {
             $badchars = array('<p>', '</p>');
             $response['message']['code_game'] = trim(str_replace($badchars, '', form_error('code_game')));
             $response['message']['name'] = trim(str_replace($badchars, '', form_error('name')));
             $response['message']['type'] = trim(str_replace($badchars, '', form_error('type')));
             $response['message']['platform'] = trim(str_replace($badchars, '', form_error('platform')));
             $response['message']['description'] = trim(str_replace($badchars, '', form_error('description')));
             $response['message']['icoin_download'] = trim(str_replace($badchars, '', form_error('icoin_download')));
             $response['message']['icoin_share'] = trim(str_replace($badchars, '', form_error('icoin_share')));
             $response['message']['order'] = trim(str_replace($badchars, '', form_error('order')));
             $response['code'] = 1;
         }
     }
     end:
     echo json_encode($response);
     exit;
 }