function proxypass($url, $method, $parameters, $header_timeout_ms, $body_timeout_ms) { global $user_agent, $chunk_size_kb; $opts = array(); $opts['http'] = array(); $opts['http']['method'] = $method; if ($user_agent == "") { // setting the user agent according to the user choise $opts['http']['user_agent'] = $_SERVER['HTTP_USER_AGENT']; } else { $opts['http']['user_agent'] = $user_agent; } if ($method == "POST" || $method == "PUT" || $method == "DELETE") { $opts['http']['content'] = http_build_query($parameters); } $context = stream_context_create($opts); $handle = @fopen($url, "rb", false, $context); if (!$handle) { @fclose($handle); generate_http_error("HTTP/1.1 500 Backend Server Error"); echo ": caused by: "; echo $http_response_header[0]; // echo " opening url: $url\n"; // security issue here because the password is printed in the output echo " opening url: " . parse_url($url, PHP_URL_SCHEME) . "://_hidden_server_" . parse_url($url, PHP_URL_PATH); ob_end_flush(); flush(); exit; } if ($header_timeout_ms > 0) { @stream_set_timeout($handle, 0, $header_timeout_ms * 1000); } $info = parse_headers($handle); if ($body_timeout_ms > 0) { @stream_set_timeout($handle, 0, $body_timeout_ms * 1000); } while (!feof($handle)) { $res = @fread($handle, $chunk_size_kb); // read a chunk of data from the backend server if ($res === FALSE) { //generate_http_error("HTTP/1.1 500 Backend Server Error"); ob_end_flush(); flush(); exit; } $i = check_timeout($handle); // check if there was a timeout error if (!$i) { // good! The server's response chunk was in time with our need print $res; // send it to the client ob_flush(); // be sure to send it to the client flush(); // be extra sure to send it to the client :-) } else { // mhhh... :-( there was a timeout reading data handle_response_timeout(1); break; } } @fclose($handle); ob_end_flush(); }
/** * print table with system checking results * * @param integer &$errCounter reference to error counter * @author Martin Havlat **/ function reportCheckingWeb(&$errCounter) { echo '<h2>Web and PHP configuration</h2><table class="common" style="width: 100%;">'; echo check_timeout($errCounter); echo check_php_settings($errCounter); echo checkPhpExtensions($errCounter); echo '</table>'; }
if (move_uploaded_file($downloaded_file, $target_file_path)) { // error_log("uploadvideo exten ". $exten); $onlyname = $randomstr; $thumbnail = $pictureaddress . $onlyname . '.jpg'; // destine.jpg $encode_query = $ffmpegaddress . 'ffmpeg.exe -itsoffset -4 -i ' . '"' . $ffmpegaddress . $file_name . '" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 100x100 "' . $thumbnail . '"' . ' && exit'; // error_log($encode_query); $username = ""; $message = $thumbnail; sendMail($username, $message); $timeline = time() + MAX_EXECUTION_TIME; //PsExecute($encode_query,60,2); session_write_close(); exec($encode_query); session_start(); check_timeout(); echo 'Success'; error_log("finishing Thumbnail uploadvideo.php randomstr " . $randomstr . " filename " . $file_name); ob_flush(); flush(); exit; } else { $Message = 'Error'; showmessage(); } } function showmessage() { global $Message; //echo "<rsp>"; //echo "<message>$Message</message>";
require 'mongofactory.php'; $url = 'mongodb://114.113.155.22:27017'; $db_name = 'shizqdb'; $db = mongofactory::getInstance($url, $db_name); $request_type = $_GET['type']; $appid = 'wx40c3a549a1f9df06'; $secret = '2b844fcf66c0e6bdfd608381f8f4c779'; if ($request_type === 'token') { $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $secret; $req = 'token'; } else { $url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=' . $_GET['token'] . '&type=jsapi'; $req = 'ticket'; } if (check_timeout($req)) { echo get_from_server($url, $req); } else { echo get_from_cache($req); } function check_timeout($req) { global $db; $time = time(); $res = $db->wechat->find(array('tag' => $req)); if ($res->hasNext()) { $res_info = $res->next(); $spend = $time - $res_info['save_time']; if ($spend > 7000) { // 过期 return true;