function gotDTMF($text) { global $ourcallid; global $partycallid; global $state; Yate::Output("gotDTMF('" . $text . "') state: " . $state); switch ($text) { case "1": setState("record"); break; case "2": setState("play"); break; case "3": setState(""); break; case "#": setState("prompt"); break; } }
return ""; } return file_get_contents($file); } $stateFile = sys_get_temp_dir() . "/tripmine-status"; $command = $_GET['command']; if ($command) { if ($command == "status") { echo getState($stateFile); } exit; } $method = $_SERVER['REQUEST_METHOD']; $contentType = $_SERVER['CONTENT_TYPE']; if ($method == "OPTIONS") { // Don't allow cross-site requests with preflight. exit; } // Only allow simple cross-site requests - since we did not allow preflight, this is all we should ever get. if ($method != "GET" && $method != "HEAD" && $method != "POST") { setState("FAIL. Non-simple method {$method}.", $stateFile); exit; } if (isset($contentType) && !preg_match("/^application\\/x\\-www\\-form\\-urlencoded(;.+)?\$/", $contentType) && !preg_match("/^multipart\\/form\\-data(;.+)?\$/", $contentType) && !preg_match("/^text\\/plain(;.+)?\$/", $contentType)) { setState("FAIL. Non-simple content type: {$contentType}.", $stateFile); exit; } if (isset($_SERVER['HTTP_X_WEBKIT_TEST'])) { setState("FAIL. Custom header sent with a simple request.", $stateFile); exit; }
function endRoute($callto, $ok, $err) { global $partycallid; global $num; global $collect; if ($ok) { Yate::Output("Overlapped got route: '{$callto}' for '{$collect}'"); $m = new Yate("chan.masquerade"); $m->params["message"] = "call.execute"; $m->params["id"] = $partycallid; $m->params["callto"] = $callto; $m->params["caller"] = $num; $m->params["called"] = $collect; $m->Dispatch(); return; } if ($err != "incomplete") { setState("noroute"); } else { Yate::Output("Overlapped still incomplete: '{$collect}'"); } }
<?php require_once '../../resources/portabilityLayer.php'; $stateFile = sys_get_temp_dir() . "/access-control-preflight-headers-status"; function setState($newState, $file) { file_put_contents($file, $newState); } function getState($file) { if (!file_exists($file)) { return ""; } return file_get_contents($file); } header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: X-Custom-Header"); header("Access-Control-Max-Age: 0"); if ($_SERVER["REQUEST_METHOD"] == "OPTIONS") { if (isset($_SERVER["HTTP_X_CUSTOM_HEADER"])) { setState("FAIL", $stateFile); } else { setState("PASS", $stateFile); } } else { if (isset($_SERVER["HTTP_X_CUSTOM_HEADER"])) { echo getState($stateFile); } else { echo "FAIL - no header in actual request"; } }
exit; } setState(false); echo "<br/>*** DATABASE SETUP IS NOW COMPLETE ***<br/><br/>"; setStatus("Generating config.php"); $cfgFile = generateConfig(); echo $cfgFile; $filename = "config.php"; if (!($handle = fopen($filename, 'w'))) { setState(true); echo "<strong>ERROR: Could not open config.php</strong>"; exitConsole(); exit; } if (fwrite($handle, $cfgFile) === FALSE) { setState(true); echo "Cannot write to file ({$filename})"; exitConsole(); exit; } echo "</span></div>"; $connector->closeConnection(); ?> 29o3 has been installed successfully. <a href="index.php?InstallationSuccessful">Please click here to go on.</a> </div> </div> <?php } else { if (!$config_exists) { ?>
<?php $api = "http://10.12.114.181:3000/api"; if ($_GET['user'] and $_GET['setState']) { setState($_GET['user'], $_GET['setState']); header("Location: index.php"); exit; } //get current state from server $cur = file_get_contents($api . "/state/get"); $cur = json_decode($cur, 1); function putrequest($url, $body) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($body))); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $body); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); } function setState($user, $state) { global $api; putrequest($api . "/state/set/" . $user, "{\"state\":\"" . $state . "\"}"); } ?> <html> <head> <title>L0.13 Presence Palm TX</title>
function endRoute($callto, $ok, $err, $params) { global $partycallid; global $collect; global $final; global $queue; global $routeOnly; global $state; if ($ok && $callto != "-" && $callto != "error") { Yate::Output("Overlapped got route: '{$callto}' for '{$collect}'"); $m = new Yate("chan.masquerade"); $m->params = $params; $m->params["message"] = "call.execute"; $m->params["complete_minimal"] = true; $m->params["id"] = $partycallid; $m->params["callto"] = $callto; $m->Dispatch(); if (strlen($queue)) { // Masquerade the remaining digits // TODO: wait for call.execute to be processed to do that? $d = new Yate("chan.masquerade"); $d->params["message"] = "chan.dtmf"; $d->params["id"] = $partycallid; $d->params["tone"] = $queue; $d->Dispatch(); } return; } if ($final) { Yate::Output("Overlapped got final error '{$err}' for '{$collect}'"); Yate::SetLocal("reason", $err); setState(""); } else { if ($err != "incomplete") { Yate::Output("Overlapped got error '{$err}' for '{$collect}'"); Yate::SetLocal("reason", $err); setState(""); $final = true; } else { Yate::Debug("Overlapped still incomplete: '{$collect}'"); if ($routeOnly) { setState("noroute"); } else { // Don't use setState: we don't want to change the prompt $state = "prompt"; } // Check if got some other digits if ($queue != "") { gotDTMF(""); } } } }
function navigate($text) { global $state; global $current; switch ($text) { case "0": listenTo(0); break; case "7": listenTo($current - 1); break; case "8": listenTo($current); break; case "9": listenTo($current + 1); break; case "1": setState("play:record,play:beep,record"); break; case "2": setState("play"); break; case "3": setState(""); break; case "*": setState("prompt"); break; } }
function filterHTML($codeContent) { global $state; // Array holds information about the current state of parsing // e.g. the current tag, the last tag, etc. $state = array(); // Clear the document in case function is called several times on one page clearDoc(); // set up state defaults setState('abort_filtering', false); // used to abort filtering on encountering an unsupported tag setState('current_tag', ""); // the current tag being processed setState('in_list', false); // whether the parser is currently inside a list (<ul> or <ol> etc...) setState('is_ordered_list', false); // whether the current list being parsed is an <ol> (for preservation) setState('last_tag', ""); // the last tag that was processed setState('css', ""); // keeps track of css styles to add to the next p tag (used to grab textformat attributes) setState('empty', true); // keeps track of whether an element is empty setState('depth', 0); // keeps track of the depth of the current node setState('style_depth', 0); // keeps track of the depth of the current styling node (used to remove redundant styles) setState('last_style_depth', 0); // keeps track of the depth of the current styling node (used to remove redundant styles) setState('last_depth', 0); // keeps track of the last depth processed setState('last_font', ""); // keeps track of the last font family (used to avoid redundant styles) setState('last_size', ""); // keeps track of the last font size (used to avoid redundant styles) setState('last_color', ""); // keeps track of the last foreground color (used to avoid redundant styles) // // URL-Decode the incoming content (obedit will url-encode it before sending.) // $codeContent = urldecode($codeContent); // // Initialize the XML parser and set element handler functions // $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); // // Wrap the obedit document in XML to prevent validation errors // from the XML parser (this extra stuff is ignored by the filter and won't show up in the output) // $xml_data = "<?xml version='1.0'?><parserdocument>".$codeContent."</parserdocument>"; // // Do the parsing. See the handler functions above. // $filterResult = @xml_parse($xml_parser, $xml_data, true); // // If the document is invalidly formed or not valid obedit-generated HTML (e.g. hand-coded), // then spit out the originally submitted HTML (but still perform unicode conversion) // if (!$filterResult || filterWasAborted()) { clearDoc(); add2Doc(unicode_to_entities(utf8_to_unicode($codeContent))); } else { // // If we're here, the document is a valid RTE document and was successfully parsed and filtered. // // Now we just have to check if the document ended with a list, and if so, // close the list off with the appropriate </ul> or </ol> to wrap things up. // if (isInsideList()) { if (isOrderedList()) add2Doc("\n</ol>"); else add2Doc("\n</ul>"); setInsideList(false); } } // Free up memory xml_parser_free($xml_parser); // Return the final HTML document return getDoc(); }
function gotNotify($reason) { global $state; debug("gotNotify('{$reason}') state: {$state}"); if ($reason == "replaced") { return; } switch ($state) { case "greeting": setState("prolong_greeting"); break; case "prolong_greeting": setState("call.route"); break; case "goodbye": setState(""); break; } }
header("Access-Control-Max-Age: 1"); } echo "FAIL: This request should not be displayed.\n"; setState("Denied", $tmpFile); } else { fail($state); } } else { if ($state == "Denied") { if ($_SERVER['REQUEST_METHOD'] == "GET" && $_GET['state'] == "complete") { unlink($tmpFile); header("Access-Control-Allow-Origin: http://127.0.0.1:8000"); header("Access-Control-Max-Age: 1"); echo "PASS: Request successfully blocked.\n"; } else { setState("Deny Ignored", $tmpFile); fail($state); } } else { if ($state == "Deny Ignored") { unlink($tmpFile); fail($state); } else { if (file_exists($tmpFile)) { unlink($tmpFile); } fail("Unknown"); } } } }
function gotDTMF($text) { global $state; global $mailbox; global $collect_user; global $collect_pass; debug("gotDTMF('{$text}') state: {$state}"); switch ($state) { case "user": if ($text == "*") { promptUser(); return; } if ($text == "#") { checkUser(); } else { $collect_user .= $text; } return; case "pass": if ($text == "*") { promptPass(); return; } if ($text == "#") { checkPass(); } else { $collect_pass .= $text; } return; case "record": setState("prompt"); return; } if ($mailbox == "") { return; } navigate($text); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. */ public function actionUpdate() { if (!isset($_GET['rem'])) { $back_url = $_POST['back_url'] ? $_POST['back_url'] : rurl(); setState('back_url', $back_url); } $action =& $_GET['action']; $top_leaf_id =& $_GET['top_leaf_id']; $model = $this->loadModel(); if (isset($_POST['Article'])) { $model->attributes = $_POST['Article']; $model->update_time = date("Y-m-d H:i:s"); if ($model->save()) { if (count($_POST['category_article_ids']) > 0) { ManyCategoryArticle::model()->deleteAllByAttributes(array('article_id' => $model->id)); foreach ($_POST['category_article_ids'] as $m_category_id) { $_model = new ManyCategoryArticle(); $_model->article_id = $model->id; $_model->category_id = $m_category_id; $_model->save(); } } $str = Yii::t('cp', 'Data saved success On ') . Time::now(); Yii::app()->user->setFlash('success', $str); $this->redirect(array('update', 'id' => $model->id, 'action' => $action, 'top_leaf_id' => $top_leaf_id, 'rem' => 0)); } } $leaf_tree =& $this->getTree($top_leaf_id); $top_leaf = Category::Model()->findByPk($top_leaf_id); $this->path = Category::model()->getPath($model->category_id, $top_leaf->id); $this->render('update', array('action' => $action, 'model' => $model, 'top_leaf' => $top_leaf, 'leaf_tree' => $leaf_tree)); }
function gotNotify($reason) { global $state; debug("gotNotify('{$reason}') state: {$state}"); if ($reason == "replaced") { return; } switch ($state) { case "goodbye": setState(""); break; case "greeting": setState("beep"); break; case "beep": setState("record"); break; default: setState("goodbye"); break; } }
if ($_SERVER['REQUEST_METHOD'] == "PUT") { header("Access-Control-Allow-Origin: http://127.0.0.1:8000"); header("Access-Control-Allow-Credentials: true"); echo "PASS: First PUT request."; setState("FirstPUTSent", $tmpFile); } else { fail(); } } else { if ($state == "FirstPUTSent") { if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") { header("Access-Control-Allow-Origin: http://127.0.0.1:8000"); header("Access-Control-Allow-Credentials: true"); header("Access-Control-Allow-Methods: PUT"); header("Access-Control-Allow-Headers: x-webkit-test"); setState("SecondOPTIONSSent", $tmpFile); } else { if ($_SERVER['REQUEST_METHOD'] == "PUT") { header("Access-Control-Allow-Origin: http://127.0.0.1:8000"); header("Access-Control-Allow-Credentials: true"); echo "FAIL: Second PUT request sent without preflight"; } } } else { if ($state == "SecondOPTIONSSent") { if ($_SERVER['REQUEST_METHOD'] == "PUT") { header("Access-Control-Allow-Origin: http://127.0.0.1:8000"); header("Access-Control-Allow-Credentials: true"); echo "PASS: Second OPTIONS request was sent."; } else { fail();
function getState($file) { if (!file_exists($file)) { return "Uninitialized"; } return file_get_contents($file); } $command = $_GET['command']; $state = getState($tmpFile); header("Expires: Thu, 01 Dec 2003 16:00:00 GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); if ($command == "reset") { unlink($tmpFile); } else { if ($command == "delete") { setState("Deleted", $tmpFile); } else { if ($state == "Uninitialized") { header("Content-Type: text/cache-manifest"); print "CACHE MANIFEST\n"; print "fail-on-update-2.html\n"; print "NETWORK:\n"; print "fail-on-update-2.php?command=\n"; } else { if ($state == "Deleted") { header('HTTP/1.0 404 Not Found'); } } } }
function handleLogResourceRequest($path) { $resourceLogFile = sys_get_temp_dir() . "/resource-log"; $newData = "\n" . $path; // Documentation says that appends are atomic. file_put_contents($resourceLogFile, $newData, FILE_APPEND); generateResponse($path); } $stateFile = sys_get_temp_dir() . "/network-simulator-state"; $command = $_GET['command']; if ($command) { if ($command == "connect") { setState("Online", $stateFile); } else { if ($command == "disconnect") { setState("Offline", $stateFile); } else { if ($command == "increase-resource-count") { handleIncreaseResourceCountCommand($_GET['path']); } else { if ($command == "reset-resource-count") { handleResetResourceCountCommand(); } else { if ($command == "get-resource-count") { handleGetResourceCountCommand($_GET['path']); } else { if ($command == "start-resource-request-log") { handleStartResourceRequestsLog(); } else { if ($command == "clear-resource-request-log") { handleClearResourceRequestsLog();
} function getState($file) { if (!file_exists($file)) { return "0"; } return file_get_contents($file); } $stateFile = sys_get_temp_dir() . "/remember-bad-password-status"; $command = $_GET['command']; if ($command) { if ($command == "status") { echo getState($stateFile); } else { if ($command == "reset") { echo setState("0", $stateFile); } } exit; } if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_REQUEST['uid']) || $_REQUEST['uid'] != $_SERVER['PHP_AUTH_USER']) { header('WWW-Authenticate: Basic realm="WebKit Test Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authentication canceled'; if (isset($_SERVER['PHP_AUTH_USER'])) { setState(getState($stateFile) + 1, $stateFile); } exit; } else { echo "User: {$_SERVER['PHP_AUTH_USER']}, password: {$_SERVER['PHP_AUTH_PW']}."; }
getRegion($mysqli); } if ($functionname == 'getRegionByID') { $regionID = $_POST["regionID"]; getRegionByID($regionID, $mysqli); } if ($functionname == 'delRegion') { $regionID = $_POST["regionID"]; delRegion($regionID, $mysqli); } /*State*/ if ($functionname == 'setState') { $stateID = $_POST["stateID"]; $stateName = $_POST["stateName"]; $stateCode = $_POST["stateCode"]; setState($stateID, $stateName, $stateCode, $mysqli); } if ($functionname == 'getState') { getState($mysqli); } if ($functionname == 'getStateByID') { $stateID = $_POST["stateID"]; getStateByID($stateID, $mysqli); } if ($functionname == 'delState') { $stateID = $_POST["stateID"]; delState($stateID, $mysqli); } /*City*/ if ($functionname == 'setCity') { $cityID = $_POST["cityID"];