function verifyNotify($alipay_safepid, $md5) { if (empty($_POST)) { //判断POST来的数组是否为空 return false; } else { //生成签名结果 $isSign = getSignVeryfy($_POST, $_POST["sign"], $md5); //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息) $responseTxt = 'true'; if (!empty($_POST["notify_id"])) { $responseTxt = getResponse($_POST["notify_id"], $alipay_safepid); } //写日志记录 //if ($isSign) { // $isSignStr = 'true'; //} //else { // $isSignStr = 'false'; //} //$log_text = "responseTxt=".$responseTxt."\n notify_url_log:isSign=".$isSignStr.","; //$log_text = $log_text.createLinkString($_POST); //logResult($log_text); //验证 //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关 //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关 if (preg_match("/true\$/i", $responseTxt) && $isSign) { return true; } else { return false; } } }
function get($method, $params) { setDefaultKey($params, 'v', '5.5'); setDefaultKey($params, 'need_all', '1'); setDefaultKey($params, 'count', '0'); setDefaultKey($params, 'offset', '0'); $methodUrl = "http://api.vk.com/method/database.{$method}?" . http_build_query($params); $resp = getResponse($methodUrl); return $resp; }
function makeRequest($item_id, $m_floor) { $data_set = []; // 単品動画 $request = builtingRequestURL($item_id, 'digital', 'videoa'); $result = getResponse($request); // 月額動画 foreach ($m_floor as $key) { $request_m = builtingRequestURL($item_id, 'monthly', $key); $result_m = getResponse($request_m); if ($result_m) { break; } } // 無料動画 $result_f = getFreeMovieInfo($item_id); $data_set = ['single' => $result, 'monthly' => $result_m, 'free' => $result_f]; return $data_set; }
function getChallenge() { $challenge = array(); if ($categories = getCategories()) { // Shuffle the categories. shuffle($categories); // retrieve the top four. $categories = array_slice($categories, 0, 4); // grab the images from the first. shuffle($categories[0]['images']); // use the first image. $challenge['image'] = $categories[0]['images'][0]; // Build the answer. $challenge['answer'] = array('id' => md5($challenge['image']['id'] . $categories[0]['id']), 'role' => $categories[0]['role'], 'title' => $categories[0]['title'], 'source' => $challenge['image']['source'], 'correct' => getResponse('correct'), 'incorrect' => getResponse('incorrect')); // Build the options. shuffle($categories); foreach ($categories as $category) { $challenge['options'][] = array('id' => $category['id'], 'title' => $category['title']['name'] . ($category['year'] ? ' (' . $category['year'] . ')' : '')); } } return (object) $challenge; }
$http_line = substr($accpet_msg, 0, $num); $accpet_remain = substr($accpet_msg, $num + 2, $msg_len); //$num+2:回车、换行 //分离:请求头-请求数据 list($http_header, $http_data) = explode("\r\n\r\n", $accpet_remain); } else { //错误请求,返回error 400 $http_line = ''; $http_header = ''; $http_data = ''; $response = returnError($code = 400, 'Bad Request : server cannot resolute the request correctly.'); socket_write($accpet, $response); socket_close($accpet); } //处理请求,返回数据:response $response = getResponse($http_line, $http_header, $http_data); // $session= '__ci_last_regenerate|i:1441529979;adminid|s:1:"1";'; //-----------处理http协议-------------- //接送返回的消息 socket_write($accpet, $response); //关闭连接 socket_close($accpet); } //关闭连接 socket_close($socket); } catch (Exception $exception) { echo $exception->getMessage(); //反应在client端,应该就是一个 5xx错误 } /** * server-response 拼接响应报文,返回对应的url资源
<?php require_once 'lib/2leggedOAuthRequestGenerator.php'; $api_url = 'http://r-weblife.sakura.ne.jp/SignedRequest/example.php'; $opensocial_appurl = 'http://r-weblife.sakura.ne.jp/SignedRequest/SignedRequest.xml'; $consumerkey = 'r-weblife.sakura.ne.jp'; $consumersecret = 'r-weblife.sakura.ne.jp.secret'; $params = array("opensocial_app_url" => $opensocial_appurl, "opensocial_param_a" => "testValueA", "opensocial_param_b" => "testValueB"); $ur = ""; $response = ""; $generator = new twoLeggedOAuthRequestGenerator($api_url, $consumerkey, $consumersecret, 'HMAC-SHA1', 'GET', $params); if ($generator) { $url = $generator->getUrl(); $response = getResponse($url); } else { print "sorry..."; exit; } function getResponse($url, $post_data = null) { $ch = curl_init(); if (defined("CURL_CA_BUNDLE_PATH")) { curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH); } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); if (isset($post_data)) { curl_setopt($ch, CURLOPT_POST, 1);
<?php /*gets details on a specific job*/ include 'PlatsbankenApiRequest.php'; try { //jobid from frontend if (isset($_GET['jobid'])) { $jobId = $_GET['jobid']; //sends urlextension to PlatsbankenApiRequsest.php $jobDetails = getResponse("platsannonser/{$jobId}"); //send response to frontend header('Content-Type: application/json'); echo $jobDetails; } } catch (Exception $e) { echo http_response_code(500); }
function post_to_trx($confirmation, $form, $lead, $ajax) { if ($lead["8"] == 'Credit') { // need to do conditional for transaction type //membership - amount = lead["5"]; // donation - amount = lead["17"]; // party - amount = 25 if ($lead["14"] == 'Membership') { $amount = $lead["5"]; } elseif ($lead["14"] == 'Donation') { $amount = $lead["17"] . ".00"; } else { // it's a party $amount = '25.00'; } require_once trailingslashit(get_template_directory()) . '/trx/config.php'; $data = '<Detail>'; $data .= '<TranType>Credit</TranType>'; $data .= '<TranAction>Sale</TranAction>'; $data .= '<Amount>' . $amount . '</Amount>'; $data .= '<CurrencyCode>840</CurrencyCode>'; $data .= '</Detail>'; $data .= '<Account>'; if (!empty($lead["1.3"])) { $data .= '<FirstName>' . $lead["1.3"] . '</FirstName>'; } if (!empty($lead["1.6"])) { $data .= '<LastName>' . $lead["1.6"] . '</LastName>'; } $data .= '<Email>' . $lead["2"] . '</Email>'; $data .= '<Pan>' . str_replace("-", "", $lead["9"]) . '</Pan>'; $data .= '<Expiration>' . $lead["10"] . $lead["11"] . '</Expiration>'; if (!empty($lead["13"])) { $data .= '<Cvv>' . $lead["13"] . '</Cvv>'; } if (!empty($lead["12.5"])) { $data .= '<Postal>' . $lead["12.5"] . '</Postal>'; } if (!empty($lead["12.1"])) { $data .= '<Address>' . $lead["12.1"] . '</Address>'; } $data .= '</Account>'; $data .= '<IndustryData>'; $data .= '<Industry>CardNotPresent</Industry>'; $data .= '<Eci>7</Eci>'; $data .= '</IndustryData>'; //echo $data; $response = getResponse($data); if (strpos(strip_tags($response), 'RESPONSECODE = 00')) { return "Thank you. Your payment has been received. You will receive an email confirmation shortly."; } else { return "We're sorry, your payment was not approved. Please <a href=\"#\" onclick=\"window.history.go(-1); return false;\"> go back and try again</a>."; } } else { return "Thank you for your submission. You will receive an email confirmation."; } }
} // CHECK PERMISSIONS checkPermissions(); // READ CONFIG $user = getConfigValue("user"); // CHECK FOR VALID SETUP if ($_POST && isset($_POST["action"])) { // ACTION HANDLE switch ($_POST["action"]) { case "save": $result = authorizeAction(); if ($result == "success") { $result = onActionSaveRoutine(); } // HANDLE RESULT $response = getResponse($result); echo "<?xml version='1.0' encoding='ISO-8859-1'?>"; die($response); break; default: $result = false; } } else { // CONFIG HANDLE onConfigViewRoutine(); } die; function authorizeAction() { // CHECK FILENAME if (!getPost("file")) {
//查询kec实例信息 $param = array('Filter.1.Name' => 'instance-id', 'Filter.1.Value.1' => $kecInstanceId); while (true) { $response = Kec::getInstance()->request('DescribeInstances', array('query' => $param)); $kecInstanceInfo = getResponse($response); $networkInterfaceId = $kecInstanceInfo['InstancesSet'][0]['NetworkInterfaceSet'][0]['NetworkInterfaceId']; if (is_null($networkInterfaceId)) { echo "sleeping...\n"; sleep(5); continue; } else { var_dump("networkInterfaceId is " . $networkInterfaceId); break; } } //获取用户可选链路信息 $response = Eip::getInstance()->request('GetLines'); $lineInfo = getResponse($response); $lineId = $lineInfo['LineSet'][0]['LineId']; var_dump("lineId is " . $lineId); //创建eip $param = array('LineId' => $lineId, 'BandWidth' => 1, 'ChargeType' => 'Daily'); $response = Eip::getInstance()->request('AllocateAddress', array('query' => $param)); $eipInfo = getResponse($response); $allocationId = $eipInfo['AllocationId']; var_dump("allocationId is " . $allocationId); //绑定eip $param = array('AllocationId' => $allocationId, 'InstanceType' => 'Ipfwd', 'InstanceId' => $kecInstanceId, 'NetworkInterfaceId' => $networkInterfaceId); $response = Eip::getInstance()->request('AssociateAddress', array('query' => $param)); $associateInfo = getResponse($response); var_dump($associateInfo);
echo countParticipants($db); ?> </p> <a class="btn pull-right" href="flush.php">Logout</a> </header> <main class="clear"> <?php if (isset($_GET['response'])) { $currentResponse = $_GET['response']; ?> <a href="admin.php" class="home-link"><i class="fa fa-home"></i></a> <div class="response-chart-container"> <input type="hidden" id="chart-data" value='<?php echo json_encode(getResponse($db, $currentResponse)); ?> '> <div id="response-chart"></div> </div> <div class="response-navigation clear"> <?php if ($currentResponse >= 2) { ?> <a class="prev" href="admin.php?response=<?php echo $currentResponse - 1; ?> "><i class="fa fa-arrow-left"></i> Response <?php echo $currentResponse - 1; ?> </a>
$deps = explode(";", $_GET['deployments']); } if (@$_GET['awards'] && @$_GET['awards'] != '') { $awards = explode(";", $_GET['awards']); } if (@$_GET['parameters'] && @$_GET['parameters'] != '') { $params = explode(";", $_GET['parameters']); } if (@$_GET['instcats'] && @$_GET['instcats'] != '') { $instcats = explode(";", $_GET['instcats']); } if (@$_GET['paramcats'] && @$_GET['paramcats'] != '') { $paramcats = explode(";", $_GET['paramcats']); } if (@$_GET['platforms'] && @$_GET['platforms'] != '') { $platforms = explode(";", $_GET['platforms']); } if (@$_GET['limit'] && @$_GET['limit'] != '') { $limit = $_GET['limit']; } if (@$_GET['offset'] && @$_GET['offset'] != '') { $offset = $_GET['offset']; } if (@$_GET['sort'] && @$_GET['sort'] != '') { $sort = $_GET['sort']; } if (@$_GET['request'] && @$_GET['request'] != '') { $type = $_GET['request']; } getResponse(@$box, @$begin, @$end, @$insts, @$instcats, @$ppl, @$prjs, @$progs, @$deps, @$awards, @$params, @$paramcats, @$platforms, @$type, @$limit, @$offset, @$sort);
<?php include_once 'config.php'; include_once 'http-response.php'; $name = isset($_POST['name']) ? $_POST['name'] : null; $email = isset($_POST['email']) ? $_POST['email'] : null; $subject = isset($_POST['subject']) ? $_POST['subject'] : 'Formulario de contacto'; $phone = isset($_POST['phone']) ? $_POST['phone'] : 'N'; $message = isset($_POST['message']) ? $_POST['message'] : null; $method = isset($_POST['method']) ? $_POST['method'] : null; $document = isset($_POST['document']) ? $_POST['document'] : null; if ($name != null && $email != null && $message != null && $method != null) { $response = getResponse(array('method' => $method, 'name' => $name, 'email' => $email, 'subject' => $subject, 'phone' => $phone, 'message' => $message)); $json = json_decode($response); $error = $json[0]->error; $wsmessage = $json[0]->message; if ($document != null) { $get = '?error=' . $error . '&message=' . $wsmessage; $url = $_SERVER['HTTP_HOST'] . '/' . $document . $get; header('Location: http://' . $url); } } else { if ($document != null) { $get = '?error=true&message=Hay campos requeridos que se encuentran vacíos, no se pudo continuar.'; $url = $_SERVER['HTTP_HOST'] . '/' . $document . $get; header('Location: http://' . $url); } }
function getIp($src, $dst, $timeout) { $port = 25; $localHostname = "whatsmyip.test"; $result = null; // Create a new socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("\r\n\r\nFatal error - Could not create socket.\r\n"); // Configure a timeout for read socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, $timeout); // Bind to local IP address socket_bind($sock, $src) or die("\r\n\r\nFatal error - Could not bind to socket.\r\nCheck IP address " . $src . " is configured on this computer.\r\n"); // Connect to destination IP address if (socket_connect($sock, $dst, $port)) { // Listen to server's HELO $call1 = getResponse($sock); // If return status is 220. if (substr($call1, 0, 3) == "220") { // Write client HELO if (writeRequest($sock, "EHLO " . $localHostname . " \r\n")) { // Listen to server's answer $call2 = getResponse($sock); if (substr($call2, 0, 3) == "250") { // Get the IP, but only the last one (Hotmail provides 2 IPs) $result = end(find_ip($call2)); } else { $result = "Server response (status 250) to client EHLO was expected from " . $dst . ":" . $port . ", didn't arrive."; } // Write disconnection writeRequest($sock, "QUIT" . "\r\n"); } else { $result = "Could not write EHLO on socket."; } } else { $result = "Server HELO (status 220) was expected from " . $dst . ":" . $port . ", didn't arrive."; } } else { $result = "Could not open connection to " . $dst . ":" . $port . " with this IP."; } // Close socket socket_close($sock); return $result; }
<?php ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); //gets all jobs within users county //based on user current position include 'GoogleMapsApi.php'; try { $data = json_decode(file_get_contents("php://input")); $lat = $data->lat; $lng = $data->lng; if (is_numeric($lat) && is_numeric($lng)) { //sends extension url to GoogleMapsApi.php $positionDetails = getResponse($lat, $lng); //send response to frontend header('Content-Type: application/json'); echo $positionDetails; } else { echo http_response_code(400); } } catch (Exception $e) { echo http_response_code(500); }
default: break; } } //Main ------------------------------------------------------------------------- do { $isoSRV->openStream(); $isoMsg->addISO($isoSRV->inputStream()); if ($isoMsg->validateISO()) { echo "<<<<<<<<<< Incoming.................................................\n"; echo $isoMsg->getISO() . "\n"; echo "+++++++++++++++++++++++++++ Parsed ISO +++++++++++++++++++++++++++++++\n"; var_dump($isoMsg->getData()); echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"; echo "Start processing message: " . date("ymdHis") . "\n"; $isoProc = getResponse($isoMsg->getMTI(), $isoMsg->getData()); $isoRsp->addMTI($isoProc["mti"]); $isoRsp->addISO($isoProc["iso"]); $isoSRV->outputStream($isoRsp->getISO()); echo "Finish processing message: " . date("ymdHis") . "\n"; echo ">>>>>>>>>>> Outgoing................................................\n"; echo $isoRsp->getISO() . "\n"; echo "++++++++++++++++++++++++++++ Parsed ISO ++++++++++++++++++++++++++++++\n"; var_dump($isoRsp->getData()); echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"; echo "\n\n\n"; } else { echo "ERROR!!!! - Invalid ISO Message.\n\n\n\n"; } } while (true); $isoMsg->addMTI('0200');
/** * Tests one sync session. * * Returns true on successful test and false on no (more) test data available * for this $startnumber. Exits if test fails. */ function testSession($name, $startnumber, &$anchor) { global $debuglevel; $uids = $refuids = array(); $number = $startnumber; while ($ref = getServer($name, $number)) { if ($debuglevel >= 2) { } testPre($name, $number); $number++; } $number = $startnumber; while ($ref = getServer($name, $number)) { if ($debuglevel >= 2) { echo "handling packet {$number}\n"; } $c = str_replace($refuids, $uids, getClient($name, $number)); $resp = getResponse($c); /* Set anchor from prev sync as last anchor: */ /* @TODO: this assumes startnumber in first packet */ if ($number == $startnumber) { $anchor = convertAnchors($ref, $resp, $anchor); } $resp = sortChanges($resp); $ref = sortChanges($ref); $tuids = getUIDs($resp); $trefuids = getUIDs($ref); $uids = array_merge($uids, $tuids); $refuids = array_merge($refuids, $trefuids); $ref = str_replace($refuids, $uids, $ref); parse_map($c); check($name, $resp, $ref, $number); $number++; } if ($number == $startnumber) { // No packet found at all, end of test. return false; } return true; }
} getResponse($client); echo "Start transport. file={$file}, size={$size}\n"; $fp = fopen($file, 'r'); if (!$fp) { die("Error: open {$file} failed.\n"); } $i = 0; while (!feof($fp)) { $read = fread($fp, 8000); if (!$client->send($read)) { echo "send failed. ErrCode=" . $client->errCode . "\n"; break; } } getResponse($client); echo "Success. send_size = {$size}\n"; function getResponse(swoole_client $client) { $recv = $client->recv(); if (!$recv) { die("Error: recv header failed.\n"); } $respCode = json_decode($recv, true); if (!$respCode) { die("Error: header json_decode failed.\n"); } if ($respCode['code'] != 0) { die("Server: message={$respCode['msg']}.\n"); } else { echo "[FromServer]\t{$respCode['msg']}\n";
<?php /** * Rest client services. * @author KikApp PHP Generator * @version 1.0 */ define('_BLOB_PATH', "http://www.devxtend.com/nicolas/DynamicComboBoxExample/services/"); define('_FOLDER', "PublicStorage/"); $fileName = getName() . "." . getExtension(getHeader("Content-Type")); fwrite_stream(_FOLDER . $fileName, file_get_contents('php://input')); echo json_encode(getResponse($fileName)); function getResponse($fileName) { header('Content-Type: application/json; charset=utf-8'); header('HTTP/ 201 '); header('GeneXus-Object-Id: gxupload:' . _FOLDER . $fileName); $data = array('object_id' => _FOLDER . $fileName); return $data; } function getHeader($header) { foreach (getallheaders() as $name => $value) { if ($name == $header) { return $value; } } } function fwrite_stream($path, $string) { $fp = fopen($path, 'w');
break; case Step::group_unique: throw new Exception("TODO"); //TODO: implement //TODO: implement case Step::group_none: default: return TRUE; break; } } function startStep() { global $RESPONSE, $SESSION; $SESSION->startStep(); $basset_variables = new BassetVariables($SESSION); // TODO: rather than constructing it anew, get the one created by callback (?) // initialize Smarty template engine $smarty = new Smarty(); // $smarty->registerObject('basset', $basset_variables); $smarty->assign('basset', $basset_variables); $RESPONSE = array('action' => 'replace', 'html' => $smarty->fetch($SESSION->current_step->getHTMLFilename()), 'controls' => json_encode($SESSION->current_step->getControls())); } /******************************************************************************/ getResponse(); if (is_array($RESPONSE)) { header("Content-type: application/json"); echo json_encode($RESPONSE); } else { echo $RESPONSE; }
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php error_reporting(1); ini_set('error_reporting', E_ALL ^ E_NOTICE ^ E_WARNING); #include_once(dirname(__FILE__).'/bootstrap.php'); $lang = array(); include dirname(__FILE__) . "/language/english/index.php"; $arrEngLang = $lang; $lang = array(); include dirname(__FILE__) . "/language/chines/index.php"; $arrChinLang = $lang; $str = ''; foreach ($arrEngLang as $key => $value) { if (trim($arrChinLang[$key]) == '') { $value = getResponse($value); if (strlen($value) < 100) { $arrTranslated[] = '$lang["' . $key . '"] = "' . $value . '"'; } } else { $arrTranslated[] = '$lang["' . $key . '"] = "' . $arrChinLang[$key] . '"'; } } $fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/aiclub/language/chines/index1.txt'); if ($fp) { foreach ($arrTranslated as $value) { fwrite($fp, $value . "\n"); } } fclose($fp); echo "<pre>";
<?php //gets all jobs within users county //based on user current position include 'PlatsbankenApiRequest.php'; try { //gets county id from frontend if (isset($_GET['county'])) { //check to se that it is a number if (is_numeric($_GET['county'])) { $countyId = $_GET['county']; $jobCategory = "3"; //sends extension url to PlatsbankenApiRequest.php $availableJobs = getResponse("platsannonser/matchning?lanid={$countyId}&yrkesomradeid={$jobCategory}"); //send response to frontend header('Content-Type: application/json'); echo $availableJobs; } else { echo http_response_code(400); } } } catch (Exception $e) { echo http_response_code(500); }