public function image() { $upload_directory = 'public/upload/image/' . date("Y") . '/' . date("m"); $upload_path = $this->config->item('upload_path') . $upload_directory; if (!is_dir($upload_path)) { $oldmask = umask(0); mkdir($upload_path, 0777, TRUE); umask($oldmask); } $file_name = $this->session->user->name . '_' . time() . '.png'; $config['upload_path'] = $upload_path; $config['file_name'] = $file_name; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config); $field_name = "imageInput"; $output['csrf'] = true; if (!$this->upload->do_upload($field_name)) { $output['state'] = false; $output['error'] = array('upload' => $this->upload->display_errors("", ""), 'data' => $this->upload->data()); } else { $output['state'] = true; $avatar = '/' . $upload_directory . '/' . $file_name; $output['success'] = array('url' => $avatar); } json_output($output); }
public function load_chat($idx = 0) { $idx = intval($idx); $this->load->model('main_model', 'main'); $chat = $this->main->load_chat($idx); $this->main->logged_in_update(); $online_users = $this->main->online_users(); json_output([$chat, $online_users]); }
public function join_action() { $member = $this->input->post(NULL); $result = $this->user_model->join_member($member); if ($result === true) { json_output([true]); } else { json_output($result); } }
public function ajaxGetManager() { $data = array('PAGE' => !$this->input->post('page') ? 1 : $this->input->post('page'), 'LIMIT' => !$this->input->post('rows') ? 20 : $this->input->post('rows')); $dataArray = $this->Manager_data->selectManagers($data); $managerRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = $data['PAGE']; $response['total'] = ceil($total_count / $data['LIMIT']); $response['records'] = $total_count; $response['rows'] = $managerRows; json_output($response, true); }
public function logout() { $method = $_SERVER['REQUEST_METHOD']; if ($method != 'POST') { json_output(400, array('status' => 400, 'message' => 'Bad request.')); } else { $check_auth_client = $this->MyModel->check_auth_client(); if ($check_auth_client == true) { $response = $this->MyModel->logout(); json_output($response['status'], $response); } } }
function ajaxGetCharactersOfUserData($user_id) { $data = array('USER_ID' => $user_id, 'PAGE' => !$this->input->post('page') ? 1 : $this->input->post('page'), 'LIMIT' => !$this->input->post('rows') ? 20 : $this->input->post('rows')); $dataArray = $this->Character_data->getCharacterRows($data); $characterRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = $data['PAGE']; $response['total'] = ceil($total_count / $data['LIMIT']); $response['records'] = $total_count; $response['rows'] = $characterRows; json_output($response, true); }
public function login_check($function_array) { $function_name = $this->uri->segment(2, null); if (in_array($function_name, $function_array)) { if (!$this->session->user) { $url = base_url('/user/login'); if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { $output['redirect'] = $url; json_output($output); } else { redirect($url); } } } }
function ajaxGetMessage() { $data = array('PAGE' => !$this->input->post('page') ? 1 : $this->input->post('page'), 'LIMIT' => !$this->input->post('rows') ? 20 : $this->input->post('rows')); $dataArray = $this->Push_data->selectPushMessageRows($data); $pushRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = $data['PAGE']; $response['total'] = ceil($total_count / $data['LIMIT']); $response['records'] = $total_count; foreach ($pushRows as $row) { $response['rows'][] = $row; } json_output($response, true); }
function ajaxGetFindUserData() { $data = array('PAGE' => !$this->input->post('page') ? 1 : $this->input->post('page'), 'LIMIT' => !$this->input->post('rows') ? 20 : $this->input->post('rows')); $dataArray = $this->Find_data->getUserRows($data); $paymentRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = $data['PAGE']; $response['total'] = ceil($total_count / $data['LIMIT']); $response['records'] = $total_count; foreach ($paymentRows as $index => $row) { $response['rows'][$index]['id'] = $row['ITEM_CODE'] . '.' . $row['CREATE_DATE']; $response['rows'][$index]['cell'] = array($is_used == 1 ? $item_name_array[$row['ITEM_CODE']] : $diamond_log_type_array[$row['TYPE']], $row['DIAMOND'], $row['CURRENT_DIAMOND'], $row['CREATE_DATE']); } json_output($response, true); }
function ajaxGetBannerOfUserData($user_id) { $data = array('USER_ID' => $user_id, 'TABLE_MONTH' => $this->input->post('year_month'), 'PAGE' => !$this->input->post('page') ? 1 : $this->input->post('page'), 'LIMIT' => !$this->input->post('rows') ? 20 : $this->input->post('rows')); $dataArray = $this->Log_data->getBannerOfUserRows($data); $paymentRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = $data['PAGE']; $response['total'] = ceil($total_count / $data['LIMIT']); $response['records'] = $total_count; foreach ($paymentRows as $index => $row) { $response['rows'][$index]['id'] = $row['GAME_CODE']; $response['rows'][$index]['cell'] = array('모두의 게임', $row['STATE'] == 0 ? '클릭만' : '보상지급', $row['CLICK_DATE'], $row['PAY_DATE']); } json_output($response, true); }
function ajaxGetReceiveGiftOfUserData($user_id) { $data = array('USER_ID' => $user_id, 'TABLE_MONTH' => $this->input->post('year_month'), 'PAGE' => !$this->input->post('page') ? 1 : $this->input->post('page'), 'LIMIT' => !$this->input->post('rows') ? 20 : $this->input->post('rows')); $dataArray = $this->Log_data->getReceiveGiftOfUserRows($data); $giftRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = $data['PAGE']; $response['total'] = ceil($total_count / $data['LIMIT']); $response['records'] = $total_count; foreach ($giftRows as $index => $row) { $response['rows'][$index]['id'] = $row['NO']; $response['rows'][$index]['cell'] = array($row['NO'], '<a href="' . site_url(array('user', 'view', $row['SEND_ID'])) . '" target="_blank">' . $row['SEND_ID'] . '</a>', $row['SEND_DATE'], $row['RECEIVE_DATE']); } json_output($response, true); }
public function auth() { $users_id = $this->input->get_request_header('User-ID', TRUE); $token = $this->input->get_request_header('Authorization', TRUE); $q = $this->db->select('expired_at')->from('users_authentication')->where('users_id', $users_id)->where('token', $token)->get()->row(); if ($q == "") { return json_output(401, array('status' => 401, 'message' => 'Unauthorized.')); } else { if ($q->expired_at < date('Y-m-d H:i:s')) { return json_output(401, array('status' => 401, 'message' => 'Your session has been expired.')); } else { $updated_at = date('Y-m-d H:i:s'); $expired_at = date("Y-m-d H:i:s", strtotime('+12 hours')); $this->db->where('users_id', $users_id)->where('token', $token)->update('users_authentication', array('expired_at' => $expired_at, 'updated_at' => $updated_at)); return array('status' => 200, 'message' => 'Authorized.'); } } }
function ajaxGetDiamondOfUserData($user_id, $is_used = 0) { $this->load->config('solipop'); $item_name_array = $this->config->item('item_name'); $diamond_log_type_array = $this->config->item('diamond_log_type'); $data = array('USER_ID' => $user_id, 'TABLE_MONTH' => $this->input->post('year_month'), 'IS_USED' => $is_used, 'PAGE' => !$this->input->post('page') ? 1 : $this->input->post('page'), 'LIMIT' => !$this->input->post('rows') ? 20 : $this->input->post('rows')); $dataArray = $this->Log_data->getDiamondOfUserRows($data); $paymentRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = $data['PAGE']; $response['total'] = ceil($total_count / $data['LIMIT']); $response['records'] = $total_count; foreach ($paymentRows as $index => $row) { $response['rows'][$index]['id'] = $row['ITEM_CODE'] . '.' . $row['CREATE_DATE']; $response['rows'][$index]['cell'] = array($is_used == 1 ? $item_name_array[$row['ITEM_CODE']] : $diamond_log_type_array[$row['TYPE']], $row['DIAMOND'], $row['CURRENT_DIAMOND'], $row['CREATE_DATE']); } json_output($response, true); }
public function createPost() { $this->load->model('Category_model'); $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Name', 'required'); $output = array('state' => false); if ($this->form_validation->run() == FALSE) { $output['error'] = form_error_array(); $output['csrf'] = true; } else { $output['state'] = true; $name = $this->input->post('name', TRUE); $category = array('name' => $name, 'count' => 0); $id = $this->Category_model->insert($category); $url = base_url('/category/create'); $output['redirect'] = $url; } json_output($output); }
function save_customerwork() { //cmd/save_customerwork.html $customerdata = get_session('customerdata'); //customer data if (!$customerdata) { //not login json_output('requireLogin'); return ''; } //history preg_match('#[^-]+$#', $_POST['history'], $r); //final result $history = array('customer_id' => $customerdata->id, 'company' => $_POST['company'], 'salary' => $_POST['sal'], 'save_history' => $_POST['history'], 'result' => $r[0], 'post_date' => date("Y-m-d"), 'post_time' => date('H:i:s a'), 'loan' => preg_replace('#\\.#', '', $_POST['loan']), 'note' => 'Mục đích sử dụng:' . PHP_EOL . $_POST['usedfor'] . PHP_EOL . ',Thời gian chúng tôi liên hệ:' . $_POST['contacttime']); if (isset($_POST['modify'])) { //update history do_update($history, array('id' => $_POST['modify']), 'vcn_histories'); $hid = $_POST['modify']; } else { do_insert($history, 'vcn_histories'); $hid = mysql_insert_id(); //history id } //update histories1 that save answer text $history_text = array(); //multi rows $historyt = json_decode($_POST['historyt']); //decode answers_text foreach ($historyt as $answer_id => $text) { $history_t = array('answer_id' => $answer_id, 'answer_text' => $text, 'hid' => $hid); $history_text[] = $history_t; if (isset($_POST['modify'])) { //update single answer text do_update($history_t, array('hid' => $_POST['modify']), 'vcn_histories1'); } } if (!isset($_POST['modify'])) { do_insert($history_text, 'vcn_histories1'); } json_output($hid); //return new history }
function ajaxGetFriendCountOfClassTypeData() { $data = array('STAT_TYPE' => 6, 'START_DATE' => $this->input->post('start_date'), 'END_DATE' => $this->input->post('end_date')); $dataArray = $this->Log_data->getStatsDailyDepthRows($data); $statRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = 1; $response['total'] = 1; $response['records'] = $total_count; foreach ($statRows as $date => $rows) { $data = array('STAT_DATE' => $date, 'TOTAL_COUNT' => 0); ksort($rows); foreach ($rows as $class_type => $user_count) { if (!isset($data['FRIEND_COUNT_' . $class_type])) { $data['FRIEND_COUNT_' . $class_type] = 0; } $data['FRIEND_COUNT_' . $class_type] += $user_count; $data['TOTAL_COUNT'] += $user_count; } $response['rows'][] = $data; } json_output($response, true); }
function op_addclient() { $arr['domain'] = $_POST['adddomain']; $pattern = "/([\\w]+\\.[\\w]+)/i"; if (!preg_match($pattern, $arr['domain'])) { $msg = array('s' => 400, 'm' => lang('invaliddomain'), 'd' => ''); exit(json_output($msg)); } include_once "ClientModel.class.php"; $clientModel = new ClientModel(); if ($row = $clientModel->getClientByName($arr['domain'])) { $msg = array('s' => 400, 'm' => lang('domainexist'), 'd' => ''); exit(json_output($msg)); } $arr['key'] = $clientModel->generateKey(); $r = $clientModel->addNewClient($arr); if ($r) { $msg = array('s' => 200, 'm' => lang('success'), 'd' => $GLOBALS['gSiteInfo']['www_site_url'] . "/admin.php/client/defaults"); exit(json_output($msg)); } else { $msg = array('s' => 400, 'm' => lang('failed'), 'd' => ''); exit(json_output($msg)); } }
} } else { $api_status_code = 403; $api_status_txt = $api_upload->error; } } else { $api_status_code = 403; $api_status_txt = $error; } $REST_API = array('status_code' => $api_status_code, 'status_txt' => $api_status_txt, 'data' => $api_data_array); $OUTPUT_REST_API = array_filter($REST_API); switch ($format) { default: case 'json': default: json_output($OUTPUT_REST_API, $callback); break; case 'xml': xml_output($OUTPUT_REST_API); break; case 'txt': echo $api_txt_output; break; case 'redirect': if ($OUTPUT_REST_API['status_code'] == 200) { $redirect_url = __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . $api_upload->image_info['image_id_public']; header("Location: {$redirect_url}"); } else { die($OUTPUT_REST_API['status_txt']); } break;
/** * json_prepare * Hide the display errors and blocks the non XMLHttpRequest */ function json_prepare() { error_reporting(0); @ini_set('display_errors', false); $http_referer = isset($_SERVER['HTTP_REFERER']) ? parse_url($_SERVER['HTTP_REFERER']) : NULL; if ($_SERVER['HTTP_X_REQUESTED_WITH'] !== 'XMLHttpRequest' && !preg_match('/' . HTTP_HOST . '/', $http_referer['host']) && !preg_match('/127\\.0\\.0\\.1/', $_SERVER['SERVER_ADDR'])) { die(json_output(array('status_code' => 400, 'status_txt' => 'bad request'))); } }
operation_fail("登陆失败"); } $weixinAPI = new WeixinAPI(); $json = $weixinAPI->getOpenid($code); session_start(); // 记录用户信息 $_SESSION['openid'] = $json['openid']; $_SESSION['access_token'] = $json; $openid = $json['openid']; $home_url = '../index.php'; $account = Account::getAccount($json['openid']); if ($account != null) { $_SESSION['account'] = $account; $extra = AccountExtra::getInfo($json['openid']); if ($extra != null) { $_SESSION['account_extra'] = $extra; } } else { $weixinAPI = new WeixinAPI(); $userInfo = $weixinAPI->getUserInfo($json['access_token'], $openid); Account::createAccount($openid, $userInfo['nickname']); $account = Account::getAccount($json['openid']); $_SESSION['account'] = $account; } //$home_url = '../h5/publish_task_page.php'; header('Location: ' . $home_url); json_put("session", $_SESSION['access_token']); json_output(); ?>
public function get_bread_crumbs($id) { $this->load->model('playermodel'); $data = $this->playermodel->getBreadCrumbs($id); echo json_output($data); }
$data['msg'] = '颜色参数不正确'; $data['code'] = 5; json_output($data); } C::t('server_member')->update_collect_by_serverid_and_uid($serverid, $uid, $backgroundcolor, $value); } else { C::t('server_member')->update_action_by_serverid_and_uid($serverid, $uid, $filed, $value); } } else { if ($do == 'collect' && $value == 1) { $backgroundcolor = $_GET['backgroundcolor']; if (strlen($backgroundcolor) != 7) { $data = array(); $data['msg'] = '颜色参数不正确'; $data['code'] = 4; json_output($data); } C::t('server_member')->insert(array("server_id" => $serverid, "uid" => $uid, "backgroundcolor" => $backgroundcolor, "iscollect" => 1, "acttime" => date("Y-m-d H:i:s"))); } else { C::t('server_member')->insert(array("server_id" => $serverid, "uid" => $uid, $filed => $value, 'acttime' => date("Y-m-d H:i:s"))); } } $data = array(); $data['msg'] = '操作成功'; $data['code'] = 0; json_output($data); function json_output($data) { echo json_encode($data); exit; }
/** * @desc 删除一个下载任务,通常是已经被完成的下载任务 */ public function remove() { $file_key = get_post('file_key'); $down_status = $this->get_down_status(); if (empty($down_status) || !isset($down_status[$file_key])) { return json_output('101', '参数错误'); } if (!isset($down_status[$file_key]['progress'])) { return json_output('102', '系统错误'); } if (is_file($down_status[$file_key]['pregress'])) { unlink($down_status[$file_key]['pregress']); } if ($down_status[$file_key]['pid']) { $this->baidu_pcs->kill($down_status[$file_key]['pid']); } unset($down_status[$file_key]); return json_output(0, 'success'); }
/** * proccess_request * Process the request for the public area */ private function proccess_request() { global $lang; $this->template = 404; // Default template $this->pages = $this->get_pages(); // get theme pages // Prepare te request array to use the legacy request (?v=file.ext) if (check_value($_GET['v']) && preg_match("/^\\w*\\.jpg|png|gif\$/", $_GET['v'])) { $this->base_request = '?' . $this->request_array[1]; unset($this->request_array[1]); } @session_start(); if (count($_SESSION['ImagesUp']) > 0) { $_SESSION['ImagesUp'] = array_values($_SESSION['ImagesUp']); self::$uploaded = true; } if (chevereto_config('maintenance')) { $this->base_request = 'maintenance'; } // Switch according the request switch ($this->base_request) { case '': case 'index.php': @session_start(); $_SESSION['last_upload_request'] = time(); $this->template = 'index'; break; case 'json': json_prepare(); // Do a special trick for the json action=login if ($_REQUEST['action'] == 'login') { // Check for user match... $login_user = login_user($_REQUEST['password'], $_REQUEST['keep']); if ($login_user !== false) { $json_array = array('status_code' => 200, 'status_txt' => 'logged in'); } else { $json_array = array('status_code' => 403, 'status_txt' => 'invalid login'); } } elseif ($_REQUEST['action'] == 'logout') { do_logout(); $json_array = array('status_code' => 200, 'status_txt' => 'logged out'); } $json_array = check_value($json_array) ? $json_array : array('status' => 403, 'status_txt' => 'unauthorized'); session_write_close(); die(json_output($json_array)); break; case __CHV_VIRTUALFOLDER_IMAGE__: // View request $id_public = $this->request_array[1]; $this->template = !is_upload_result() ? 'view' : 'uploaded'; self::$is_viewer = true; break; case __CHV_VIRTUALFOLDER_UPLOADED__: @session_start(); if (count($_SESSION['ImagesUp']) > 0) { $this->template = 'uploaded'; self::$doctitle = $lang['doctitle_upload_complete']; } else { $this->redirect(__CHV_BASE_URL__, 400); } break; case 'error-javascript': chevereto_die(array(get_lang_txt('critical_js_step_1'), get_lang_txt('critical_js_step_2')), 'JavaScript', array(get_lang_txt('critical_js'))); break; case '?chevereto': $this->template = 'bool'; break; // Legacy viewer // Legacy viewer case '?v=' . $_GET['v']: // View request $id_public = $_GET['v']; $this->legacy_redirect = true; break; case 'delete': case 'delete-confirm': //$delete_what = $this->request_array[1]; $id_public = $this->request_array[2]; $deleteHash = $this->request_array[3]; $this->template = $this->base_request; self::$is_viewer = true; break; case 'maintenance': $this->template = 'maintenance'; self::$doctitle = chevereto_config('doctitle'); break; default: // Pages request require_once $this->path_theme . 'pages/pages_config.php'; // We load the special pages config if (in_array($this->base_request . '.php', $this->pages) and $this->request_array[1] == '' and $pages_config[$this->base_request]['live']) { $this->template = 'pages/' . $this->base_request; self::$doctitle = $pages_config[$this->base_request]['title']; } else { $this->template = 'shorturl'; $id_public = $this->base_request; self::$is_viewer = true; } break; } // Ask for the login on index and pages if ($this->template == 'index' || $this->template == 'pages/' . $this->base_request) { if (conditional_config('private_mode')) { if (!is_logged_user()) { $doctitle = get_lang_txt('txt_enter_password') . ' - ' . chevereto_config('doctitle'); include __CHV_PATH_SYSTEM__ . 'login.php'; die; } } } if ($this->template == 'uploaded') { self::$doctitle = get_lang_txt('doctitle_upload_complete'); self::$image_info = $_SESSION['ImagesUp'][0]; self::$uploaded_images = $_SESSION['ImagesUp']; $_SESSION['ImagesUp'] = NULL; unset($_SESSION['ImagesUp']); } if (preg_match('/view|shorturl|delete/', $this->template) || $this->legacy_redirect) { // Test connection if ($this->dB->dead) { self::$doctitle = 'dB connection error'; $this->template = 404; } else { // get image info $imageID = $this->legacy_redirect ? $id_public : decodeID($id_public); self::$image_info = $this->dB->image_info($imageID); self::$id_public = $id_public; if (!is_array(self::$image_info)) { // Record? if ($this->template == 'delete-confirm') { json_output(array('status_code' => 403, 'status_txt' => 'target image doesn\'t exists')); } else { $this->template = 404; } } else { if ($this->legacy_redirect) { $this->redirect(__CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . encodeID(self::$image_info['image_id']), 301); } $target = get_image_target(self::$image_info); self::$image_target = $target['image_path']; self::$image_thumb_target = $target['image_thumb_path']; self::$image_url = absolute_to_url($target['image_path']); self::$image_thumb_url = absolute_to_url($target['image_thumb_path']); self::$image_filename = self::$image_info['image_filename']; self::$image_viewer = __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . $id_public; self::$delete_image_url = __CHV_BASE_URL__ . 'delete/image/' . self::$id_public . '/' . self::$image_info['image_delete_hash']; $image_delete_proceed = !empty(self::$image_info['image_delete_hash']) && $deleteHash === self::$image_info['image_delete_hash'] ? true : false; switch ($this->template) { case 'delete': if (!$image_delete_proceed) { $this->redirect(__CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . self::$id_public, 301); } self::$delete_image_confirm_url = __CHV_BASE_URL__ . 'delete-confirm/image/' . self::$id_public . '/' . self::$image_info['image_delete_hash']; self::$doctitle = get_lang_txt('doctitle_delete_confirm') . ' ' . self::$image_info['image_filename']; break; case 'delete-confirm': if (!$image_delete_proceed) { json_output(array('status_code' => 403, 'status_txt' => 'invalid delete hash')); } else { require_once __CHV_PATH_ADMIN_CLASSES__ . 'class.manage.php'; $manage = new Manage(array('id' => self::$image_info['image_id'], 'action' => 'delete')); if ($manage->dead) { $json_array = array('status_code' => 403, 'status_txt' => $manage->error); } else { $json_array = $manage->process(); } } // Make the status_txt more readable... switch ($json_array['status_code']) { case 200: $json_array['status_txt'] = get_lang_txt('txt_image_deleted'); break; default: case 403: $json_array['status_txt'] = get_lang_txt('txt_error_deleting_image'); break; } json_output($json_array); break; default: self::$doctitle = get_lang_txt('doctitle_viewing_image') . ' ' . self::$image_info['image_filename']; break; } } } } if ($this->template == 404) { status_header(404); self::$doctitle = check_value(self::$doctitle) ? self::$doctitle : get_lang_txt('txt_404_title'); } else { status_header(200); } // We load the template if ($this->template == 'bool') { exit(json_encode(true)); } else { $this->load_template(); } }
public function view_getuser() { $ticket = $_GET['ticket']; $sign = $_GET['sign']; $domain = $_GET['domain']; $data = ''; if ($this->_verifySign($domain, md5($ticket . $domain), $sign)) { if ($this->_verifyTicket($_GET['ticket'])) { require_once 'PassportModel.class.php'; $ticket = PassportModel::unpackTicket($_GET['ticket']); $pass = new PassportModel(); $data = $pass->getDataByTicket($ticket); } if ($data) { $msg['s'] = 200; $msg['m'] = "success!"; $msg['d'] = $this->_encryptToken($data); } else { $msg['s'] = 300; $msg['m'] = "Please Relogin!"; $msg['d'] = $GLOBALS["gSiteInfo"]['www_site_url'] . "/index.php?action=passport&view=login"; } } else { $msg['s'] = 400; $msg['m'] = "Signature Invalid!" . $ticket; $msg['d'] = ''; } json_output($msg); }
function output() { json_output(); }
function ajaxGetUserPlayTimeOfOSData() { $data = array('STAT_TYPE' => 14, 'STAT_DEPTH2' => 1, 'START_DATE' => $this->input->post('start_date'), 'END_DATE' => $this->input->post('end_date')); $dataArray = $this->Log_data->getStatsDailyDepthRows($data); $totalPlayTimeRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $data = array('STAT_TYPE' => 14, 'STAT_DEPTH2' => 2, 'START_DATE' => $this->input->post('start_date'), 'END_DATE' => $this->input->post('end_date')); $dataArray = $this->Log_data->getStatsDailyDepthRows($data); $statRows = $dataArray['DATA']; $total_count = $dataArray['TOTAL_COUNT']; $response = array(); $response['page'] = 1; $response['total'] = 1; $response['records'] = $total_count; foreach ($statRows as $date => $rows) { $data = array('STAT_DATE' => $date, 'TOTAL_COUNT' => 0); ksort($rows); $total_play_time_total = 0; $total_play_time_average = 0; foreach ($rows as $os => $user_count) { $total_play_time = $totalPlayTimeRows[$date][$os]; $data['USER_COUNT_' . $os] = number_format($user_count / 60, 2) . 'm (' . number_format($total_play_time / 60) . 'm)'; $total_play_time_total += $total_play_time; $total_play_time_average += $user_count; } $data['TOTAL_COUNT'] = number_format($total_play_time_average / 60, 2) . 'm (' . number_format($total_play_time_total / 60) . 'm)'; $response['rows'][] = $data; } json_output($response, true); }
/** * Method: GET * Verb: analisa/rbm */ $app->options('/analisa/rbm', function () use($app) { $app->status(204); $app->stop(); }); $app->get('/analisa/rbm', function () use($app, $ctr) { $ctr->load('model', 'main'); is_logged($app, $ctr); $ctr->load('model', 'analisa'); $r = $ctr->AnalisaModel->get_analisa_rbm(); json_output($app, $r); }); // ---------------------------------------------------------------- /** * Method: GET * Verb: analisa/tarif */ $app->options('/analisa/tarif', function () use($app) { $app->status(204); $app->stop(); }); $app->get('/analisa/tarif', function () use($app, $ctr) { $ctr->load('model', 'main'); is_logged($app, $ctr); $ctr->load('model', 'analisa'); $r = $ctr->AnalisaModel->get_analisa_tarif(); json_output($app, $r); });
public function createPost() { $this->load->library('form_validation'); $this->form_validation->set_rules('title', 'Title', 'required|max_length[30]', array('required' => 'You have not provided %s.')); $this->form_validation->set_rules('category_id', 'Category', 'required'); $this->form_validation->set_rules('markdown', 'Content', 'required'); $output = array('state' => false); if ($this->form_validation->run() == FALSE) { $output['error'] = form_error_array(); $output['csrf'] = true; } else { $output['state'] = true; $post_id = $this->input->post('post_id', TRUE); $title = $this->input->post('title', TRUE); $category_id = $this->input->post('category_id', TRUE); $markdown = $this->input->post('markdown', TRUE); $this->load->model('Post_model'); $this->load->model('Category_model'); $this->load->library('Markdown'); $content = $this->markdown->markdown_to_html($markdown); $post = array('title' => $title, 'markdown' => $markdown, 'content' => $content, 'category_id' => $category_id, 'user_id' => $this->session->user->id); if ($post_id) { $_post = $this->Post_model->select($post_id); if ($this->session->user->id == $_post->user_id) { $post['update_at'] = date("Y-m-d H:i:s"); $this->Post_model->update($post_id, $post); } } else { $id = $this->Post_model->insert($post); } $category = $this->Category_model->select($category_id); $update = array('count' => $category->count + 1, 'update_at' => date("Y-m-d H:i:s")); $this->Category_model->update($category_id, $update); $url = base_url('/post'); $output['redirect'] = $url; } json_output($output); }
} break; //SearchNotes //SearchNotes case "searchnotes": //make sure we were given a note subject and body if (!isset($_POST['Search_String'])) { json_output(array('Function' => 'SearchNotes', 'Status' => '706', 'Description' => $EC->error(706))); } $result = $INP->Search_Notes($_POST['Search_String'], 2); if (empty($result) || is_null($result)) { json_output(array('Function' => 'SearchNotes', 'Status' => '702', 'Description' => $EC->error(702))); } json_output(array('Function' => 'SearchNotes', 'Status' => '200', 'Result' => $result)); break; //SearchNotesCaseSensitive //SearchNotesCaseSensitive case "searchnotescasesensitive": //make sure we were given a note subject and body if (!isset($_POST['Search_String'])) { json_output(array('Function' => 'SearchNotesCaseSensitive', 'Status' => '706', 'Description' => $EC->error(706))); } $result = $INP->Search_Notes($_POST['Search_String'], 1); if (empty($result) || is_null($result)) { json_output(array('Function' => 'SearchNotesCaseSensitive', 'Status' => '702', 'Description' => $EC->error(702))); } json_output(array('Function' => 'SearchNotesCaseSensitive', 'Status' => '200', 'Result' => $result)); break; default: json_output(array('Function' => $_GET['f'], 'Status' => '699', 'Description' => $EC->error(699))); }