public function testGetCSRFHiddenForm() { $checker = new RequestChecker(); $factory = new TestSessionFactory(); $checker->setSessionFactory($factory); $getCsrfToken = getMethod('RequestChecker', 'getCsrfToken'); $token = $getCsrfToken->invokeArgs($checker, array()); $this->assertEquals($checker->getCSRFHiddenForm(), '<input type="hidden" name="csrf_token" value="' . $token . '" >'); }
private function getCode() { $url = $this->url . '/oauth2/authorize?client_id=' . $this->client_id . '&client_secret=' . $this->client_secret; $res = json_decode(getMethod($url)); if ($res->code != 1000) { $this->error("获取authorize code时出错:{$res->info}"); } return $res->data; }
public function testGetFieldTags() { $getFieldTags = getMethod('MailForm', 'getFieldTags'); $mailform = new MailForm(); $array = $getFieldTags->invokeArgs($mailform, array('testtesttest')); $this->assertCount(0, $array); $array = $getFieldTags->invokeArgs($mailform, array('{{{aaa}}}')); $this->assertCount(1, $array); $this->assertEquals('aaa', $array[0]); $array = $getFieldTags->invokeArgs($mailform, array('{{{aaa_1}}}runnrun{{{aaa_2}}}testtest')); $this->assertCount(2, $array); $this->assertEquals('aaa_1', $array[0]); $this->assertEquals('aaa_2', $array[1]); }
public function testMakeAddressText() { $makeAddressText = getMethod('SimpleMailer', 'makeAddressText'); $Encoding = getProperty('SimpleMailer', 'Encoding'); $mailer = new SimpleMailer(); $mailer->setFromEncoding("EUC-JP"); $mailer->setCharSet("UTF-8"); $value = $makeAddressText->invokeArgs($mailer, array('*****@*****.**', '')); $this->assertEquals('*****@*****.**', $value); $value = $makeAddressText->invokeArgs($mailer, array('*****@*****.**', 'test')); $this->assertEquals('test <*****@*****.**>', $value); }
public static function getRoute() { $path = getUrl(); $method = getMethod(); return self::match($method, $path); }
/** * @param array &$Request объект запроса * * @return bool является ли запрос - GET */ function isGet(array &$Request) { return getMethod($Request) == 'GET'; }
//write log files or other files to drive. not sussed out yet completely. /* PUT data comes in on the stdin stream */ //$putdata = fopen("php://input", "r"); /* Open a file for writing */ //$fp = fopen($endpoint->global_cfg['config_location'] . $_SERVER['REDIRECT_URL'], "a"); /* Read the data 1 KB at a time and write to the file */ //while ($data = fread($putdata, 1024)) // fwrite($fp, $data); /* Close the streams */ //fclose($fp); //fclose($putdata); header('HTTP/1.1 200 OK', true, 200); die; } if (getMethod() == "GET") { # Workaround for SPAs that don't actually request their type of device # Assume they're 504G's. Faulty in firmware 7.4.3a $filename = basename($_SERVER["REQUEST_URI"]); $web_path = 'http://' . $_SERVER["SERVER_NAME"] . dirname($_SERVER["PHP_SELF"]) . '/'; /* if ($filename == "p.php") { $filename = "spa502G.cfg"; $_SERVER['REQUEST_URI']=$_SERVER['REQUEST_URI']."/spa502G.cfg"; $web_path = $web_path."p.php/"; } */ # Firmware Linksys/SPA504G-7.4.3a is broken and MUST be upgraded. if (preg_match('/7.4.3a/', $_SERVER['HTTP_USER_AGENT'])) { $str = '<flat-profile><Upgrade_Enable group="Provisioning/Firmware_Upgrade">Yes</Upgrade_Enable>'; $str .= '<Upgrade_Rule group="Provisioning/Firmware_Upgrade">http://' . $provis_ip . '/current.bin</Upgrade_Rule></flat-profile>';
<?php $url = $_REQUEST["url"]; if (!$url) { echo "You need to pass in a target URL."; return; } $response = ""; switch (getMethod()) { case 'POST': $response = makePostRequest(getPostData(), $url); break; case 'PUT': $response = makePutRequest(getPutOrDeleteData($url), $url); break; case 'DELETE': $response = makeDeleteRequest($url); break; case 'GET': $response = makeGetRequest($url); break; default: echo "This proxy only supports POST, PUT, DELETE AND GET REQUESTS."; return; } echo $response; function getMethod() { return $_SERVER["REQUEST_METHOD"]; } function getPostData()
try { $db->connect(); $cometrue = 0; $count = 10; $from = ((int) $_GET['page'] - 1) * $count; if ($_GET['come_true'] == 'yes') { $cometrue = 1; } $sql = "select recommend_id,recommendedfood.user_id,recommendedfood.canteen_id,recommendedfood.food_id,username,canteenname,\n\t\t\t\tfoodname,favor,recommendedfood.imageurl from users,canteens,food,recommendedfood\n\t\t\t\twhere users.user_id=recommendedfood.user_id and canteens.canteen_id=recommendedfood.canteen_id \n\t\t\t\tand food.food_id=recommendedfood.food_id\n\t\t\t and recommendedfood.cometrue={$cometrue} and recommendedfood.user_id in \n\t\t\t\t(select user_id from users where school_id={$_POST['school_id']})\n\t\t\t\torder by favor desc limit {$from},{$count};"; $res = $db->query($sql); if ($res !== false) { if (empty($res)) { $res = null; } else { foreach ($res as &$value) { getMethod($db, $value); } } $json = getJsonResponse(0, "success", $res); $cache->set($cachename, $json, 1200); echo $json; } else { echo getJsonResponse(1, $db->error, null); Log::error_log('database error:' . $db->error . ' in ' . basename(__FILE__)); } $db->close(); } catch (Exception $e) { echo getJsonResponse(1, "数据库连接错误", null); Log::error_log("数据库连接错误"); exit; }
include '../php/controller/ChildController.php'; include '../php/controller/MethodController.php'; include '../php/controller/MarkController.php'; include '../php/controller/ResidentController.php'; include '../php/controller/PastPupilController.php'; include '../php/controller/PresentPupilController.php'; include '../php/controller/StaffController.php'; include '../php/model/Resident.php'; include '../php/model/Staff.php'; include '../php/model/PastPupil.php'; include '../php/model/PresentPupil.php'; include '../php/model/Selection.php'; $id = $_POST["calculate_school_id"]; $all_schools = getAllSchools(); foreach ($all_schools as $main_result) { $methods = getMethod($main_result['school_id']); $select = new Selection($main_result['capacity']); foreach ($methods as $result_2) { if (strcmp($result_2['method_name'], "RESIDENT") == 0) { $res_detail = getAllResidenMethodInforChild($result_2['method_id']); foreach ($res_detail as $result_3) { $resi = new \Model\Resident($result_3['resident_id'], $result_2['method_id'], $result_3['num_of_years_spent'], $result_3['ownership'], $result_3['num_of_closes_schools'], $result_3['confirm'], null); if ($resi->getConfirm() == 1) { $resi_marks = $resi->getFullMarks(); $count_sel = $select->getCount("RESIDENT"); insertMarksForChild("RESIDENT", $resi_marks, $result_2['child_id']); } } $resi_select = getResidentSelection($main_result['school_id']); foreach ($resi_select as $selec_resi) { if ($count_sel > 0) {
function getPerson($id) { # implements GET method for person # Example: GET /staffapi/person/13 echo "Getting person: " . $id; } function deletePerson($id) { # implements DELETE method for person # Example: DELETE /staffapi/person/13 echo "Deleting person: " . $id; } # Main # ---- $resource = getResource(); $request_method = getMethod(); $parameters = getParameters(); # Redirect to appropriate handlers. if ($resource[0] == "staffapi") { if ($request_method == "POST" && $resource[1] == "person") { postPerson($parameters); } else { if ($request_method == "GET" && $resource[1] == "persons") { getPersons(); } else { if ($request_method == "GET" && $resource[1] == "person") { getPerson($resource[2]); } else { if ($request_method == "DELETE" && $resource[1] == "person") { deletePerson($resource[2]); } else {