public function _upload_callback() { $reponses = $this->input['return_type'] == 'sync' ? $_GET : $_POST; //接受回调返回的数据 log2file($this->user, 'debug', '上传回调数据', $this->input, $reponses); if ($reponses['code'] != '200') { if ($this->input['return_type']) { switch ($this->input['return_type']) { case 'sync': if ($this->input['return_url']) { $url_info = parse_url(urldecode($this->input['return_url'])); //header('HTTP/1.1 302 Moved Permanently'); header("Location:" . $url_info['scheme'] . '://' . $url_info['host'] . $url_info['path'] . '?' . ($url_info['query'] ? $url_info['query'] . '&' : '') . 'data=' . urlencode(json_encode($reponses))); exit; } elseif ($this->input['data_format'] == 'jsonp') { exit($this->input['func_name'] . '(' . json_encode($reponses) . ')'); } else { exit(json_encode($reponses)); } case 'asyn': default: exit; } } else { log2file($this->user, 'error', '上传失败', $this->input, $reponses); exit; } //file_put_contents(CACHE_DIR . 'callback_error.txt', var_export($_POST, 1), FILE_APPEND); } $reponses['access_token'] = $this->input['access_token']; //视频入库 $ext_param = parseQueryString(rawurldecode($reponses['ext-param'])); $reponses['ext-param'] = $ext_param; $filepath = pathinfo($reponses['url']); $params = array('title' => $ext_param['title'] ? $ext_param['title'] : '精彩视频', 'chain_m3u8' => DEFAULT_M3U8, 'access_token' => $this->input['access_token'], 'status' => 0, 'source_filename' => basename($reponses['url']), 'source_path' => $filepath['dirname'], 'a' => 'create'); $curl = new curl($this->settings['App_livmedia']['host'], $this->settings['App_livmedia']['dir'] . 'admin/'); $curl->initPostData(); $curl->setSubmitType('post'); foreach ($params as $key => $val) { $curl->addRequestData($key, $val); } $result = $curl->request('vod_update.php'); log2file($this->user, 'debug', '视频数据入库', $params, $result); $result = $result[0]; if ($result['error'] == 'repeat') { log2file($this->user, 'error', '重复回调', $params, $reponses); return; } $reponses['video_id'] = $video_id = $result['id']; //更新视频库数据,同时提交转码 $result = $this->transcode($reponses); //file_put_contents(CACHE_DIR . 't.txt', var_export($reponses, 1), FILE_APPEND); if ($result) { foreach ($result as $key => $tid) { $this->cache_task2file($video_id, 'write', $tid, true); } } analytic_statistics('upload', $this->user['user_id']); //上传回调应用 if ($video_id && $reponses['ext-param']['client_id']) { unset($params['a']); $params['id'] = $video_id; //同步返回 if ($this->input['return_type'] == 'sync') { if ($this->input['return_url']) { $url_info = parse_url(urldecode($this->input['return_url'])); //header('HTTP/1.1 302 Moved Permanently'); header("Location:" . $url_info['scheme'] . '://' . $url_info['host'] . $url_info['path'] . '?' . ($url_info['query'] ? $url_info['query'] . '&' : '') . 'data=' . urlencode(json_encode($params))); exit; } elseif ($this->input['data_format'] == 'jsonp') { exit($this->input['func_name'] . '(' . json_encode($params) . ')'); } else { exit(json_encode($params)); } } //异步 if ($this->input['return_type'] == 'asyn') { //先记录到数据库 通过计划任务调用 $data = array('client_id' => $reponses['ext-param']['client_id'], 'data' => json_encode($params), 'update_time' => TIMENOW); $sql = 'INSERT INTO ' . DB_PREFIX . 'app_upload_queue SET '; foreach ($data as $key => $value) { $sql .= $key . '="' . addslashes($value) . '",'; } //file_put_contents(CACHE_DIR . 'debug2.txt', $sql); $this->db->query(trim($sql, ',')); } } }
function cleanUrl($url, $disallowed_params = array('PHPSESSID')) { $parsed = @parse_url($url); $params = array(); if (empty($parsed['query'])) { $parsed['query'] = ''; } # hmm parse_str should take the delimiters as a parameter if (strpos($parsed['query'], '&')) { $pairs = explode('&', $parsed['query']); foreach ($pairs as $pair) { if (strpos($pair, '=') !== false) { list($key, $val) = explode('=', $pair); $params[$key] = $val; } else { $params[$pair] = ''; } } } else { ## parse_str turns . into _ which is wrong # parse_str($parsed['query'],$params); $params = parseQueryString($parsed['query']); } $uri = !empty($parsed['scheme']) ? $parsed['scheme'] . ':' . (strtolower($parsed['scheme']) == 'mailto' ? '' : '//') : ''; $uri .= !empty($parsed['user']) ? $parsed['user'] . (!empty($parsed['pass']) ? ':' . $parsed['pass'] : '') . '@' : ''; $uri .= !empty($parsed['host']) ? $parsed['host'] : ''; $uri .= !empty($parsed['port']) ? ':' . $parsed['port'] : ''; $uri .= !empty($parsed['path']) ? $parsed['path'] : ''; # $uri .= $parsed['query'] ? '?'.$parsed['query'] : ''; $query = ''; foreach ($params as $key => $val) { if (!in_array($key, $disallowed_params)) { //0008980: Link Conversion for Click Tracking. no = will be added if key is empty. $query .= $key . ($val != '' ? '=' . $val . '&' : '&'); } } $query = substr($query, 0, -1); $uri .= $query ? '?' . $query : ''; # if (!empty($params['p'])) { # $uri .= '?p='.$params['p']; # } $uri .= !empty($parsed['fragment']) ? '#' . $parsed['fragment'] : ''; return $uri; }
function buildAreaInfoPage($url) { $area = parseQueryString($url); //getting the area name from the url $area = convertLinkAreaStingToDbAreaFieldSting($area); $areaDetails = '<h2>איזור '; $titleOfTheArea = substr($area, 1, -1); $areaDetails .= $titleOfTheArea; $areaDetails .= '</h2>'; $areaDetails .= '<form action="#" method="post"> <input type="text" name="search" placeholder="הקלד מילים לחיפוש..."/> <input type="submit" value=""> </form> </article> <article id="map"> <section id="areaMapWrapper"> <form id="mapForm" action="#" method="post"> <label class="mapOptions">הראה רופאים פעילים</label><input type="checkbox" name="interests[]" value="showAvailableVisits"> <label class="mapOptions">הראה ביקורים פעילים </label><input type="checkbox" name="interests[]" value="showAvailableDoctors"> <select name="mapresolution"> <option value="noraml" selcted="">תצוגת מפה רגילה</option> <option value="black" >שחור / לבן</option> <option value="gray">אפור</option> </select> </form> <img src="images/jerusalemMap.jpg"> </section> </article> <article id="list-area"> <ul> <li>סה"כ ביקורים באיזור : 2</li> <li>רופאים שסיימו ביקורים : 0</li> <li>רופאים שנמצאים בביקורים : 0</li> <li>רופאים בנסיעה לביקורים : 1</li> <li>ביקורים ממתינים לשליחה : 1</li> <li>מספר רופאים פעילים באיזור :1</li> <li>מספר רופאים כוננים באיזור : 3</li> </ul> </article> <article id="taskArticle">'; $areaDetails .= getOrdersDatailsTableByArea($area); return $areaDetails; }
function initCurlGet() { $cookieValues = parseQueryString(@$_COOKIE['wl_auth']); //Since cookies are user-supplied content, it must be encoded to avoid header injection $encodedAccessToken = rawurlencode(@$cookieValues['access_token']); $ch = curl_init(URL); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $encodedAccessToken)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); return $ch; }
function handleTokenResponse($token, $error = null) { $authCookie = $_COOKIE[AUTHCOOKIE]; $cookieValues = parseQueryString($authCookie); if (!empty($token)) { $cookieValues[ACCESSTOKEN] = $token->{ACCESSTOKEN}; $cookieValues[SCOPE] = $token->{SCOPE}; $cookieValues[EXPIRESIN] = $token->{EXPIRESIN}; if (!empty($token->{REFRESHTOKEN})) { saveRefreshToken($token->{REFRESHTOKEN}); } } if (!empty($error)) { $cookieValues[ERRORCODE] = $error[ERRORCODE]; $cookieValues[ERRORDESC] = $error[ERRORDESC]; } setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER[SERVER_NAME]); }
<meta name="viewport" content="width=device-width,initial-scale=1"> <link rel="stylesheet" href="includes/style.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="includes/script.js"></script> <title>דוקתור - שיגור רופאים</title> </head> <body> <?php require_once 'nav.php'; ?> <main> <article class="breadcrumbs"> <h3><a href="#">ביקורים פעילים</a> > <a href="#">בחירת איזור</a> > <!--Import dynamically area string to breadcrumbs--> <?php $myArea = parseQueryString($actual_link); $myAreaStr = convertLinkAreaStingToDbAreaFieldSting($myArea); //remove the ' carecter $finalAreaString = substr($myAreaStr, 1, -1); $currentAreaStr = '<a href="#">'; $currentAreaStr .= $finalAreaString; $currentAreaStr .= '</a></h3>'; echo $currentAreaStr; //Build wanted page echo buildAreaInfoPage($actual_link); ?> </article> </main> <div class="clear"></div> <script>(function(){
?> <tbody> </table> <table id="querystring" class="datatable"> <thead> <tr> <th colspan=2 class="section"> QUERY STRING </th> </tr> </thead> <tbody> <?php parseQueryString(); ?> <tbody> </table> <table id="postdata" class="datatable"> <thead> <tr> <th colspan=2 class="section"> POST DATA </th> </tr> </thead> <tbody> <?php parcelPost();
function initCurl($type = 'multipart') { $cookieValues = parseQueryString(@$_COOKIE['wl_auth']); //Since cookies are user-supplied content, it must be encoded to avoid header injection $encodedAccessToken = rawurlencode(@$cookieValues['access_token']); $initUrl = $this->getPagesEndpointUrlWithSectionName(); $ch = curl_init($initUrl); curl_setopt($ch, CURLOPT_HEADER, 1); if ($type == 'multipart') { curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data; boundary={$this->boundary}\r\n" . "Authorization: Bearer " . $encodedAccessToken)); } else { //simple single-part request curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:text/html\r\n" . "Authorization: Bearer " . $encodedAccessToken)); } //configures curl_exec() to return the response as a string rather than echoing it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //use HTTP POST method curl_setopt($ch, CURLOPT_POST, true); return $ch; }
if (!$ok) { die('WikWiki cannot access the data directory ./wikdata/. Please create the directory and make it writeable by PHP.'); } } $msg = ''; // Instantiate Texy parser. require dirname(__FILE__) . '/texy.min.php'; $texy = new Texy(); $texy->encoding = 'utf-8'; $texy->headingModule->top = 2; $texy->headingModule->generateID = true; $texy->allowed['image'] = FALSE; $texy->registerLinePattern('parseWikiLinks', '~\\[([^|\\]]+)(?:\\s*\\|\\s*([^\\]]+)\\s*)?\\]~', 'wikilinks'); // init path $page = parseQueryString($_SERVER['QUERY_STRING']); if (empty($_GET)) { $page = titleToId(BASE_PAGE); } // Save content. if (!empty($_POST)) { if (file_exists('captcha_codes.php')) { $resp = recaptcha_check_answer(get_private_recaptcha_key(), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); $accepted = $resp->is_valid; } else { $accepted = 1; } if (!$accepted) { $msg = "Not a correct reCaptcha."; } else { if (!savePageContent($_POST)) {