function errorCheck() { //check for error global $return, $data_contact, $url_curl, $userpwd, $content, $to_error, $headers, $modify, $url_contacts, $entityID; $status = 'default'; $status = get_string_between($return, 'status":"', '"'); $errorMessage = get_string_between($return, 'message":"', '"'); if ($status !== "ok") { if (begins_with($errorMessage, "A duplicate record has been found")) { $modify = 'True'; //if contacts table if ($url_curl == $url_contacts) { $entityID = filter_var($errorMessage, FILTER_SANITIZE_NUMBER_INT); } $url_curl = $url_curl . '/' . $entityID; sendData(); } else { //set email variables $subject = 'Error: Hobson Radius Form'; $message = 'There has been an error on the Hobson Radious Form Submission Status: ' . $status . ' ***Modify: ' . $modify . ' ***Error: ' . $errorMessage . ' ***url:' . $url_curl . ' ***entityID:' . $entityID . ' ***error return:' . $return . ' data send:' . print_r($data_contact, true); //send email mail($to_error, $subject, $message, $headers); } } }
function sendIdAndData($data) { if ($GLOBALS['is_sse']) { $id = $data['rows'][0]['id']; echo "id:" . json_encode($id) . "\n"; } sendData($data); }
/** * Write a message to channel/user */ function sendMessage($socket, $channel, $msg) { if (strlen($msg) > 2) { //Avoid sending empty lines to server, since all data should contain a line break, 2 chars is minimum $msg = prettify($msg); sendData($socket, "PRIVMSG {$channel} :{$msg}"); } }
function onData($data) { if ($this->autoOpConfig['mode']) { if (strpos($data, 'JOIN :') !== false) { $bits = explode(" ", $data); $nick = getNick(@$bits[0]); $channel = trim(str_replace(":", '', @$bits[2])); if ($this->autoOpConfig['mode'] == 1) { if (in_array($nick, $this->autoOpConfig['channel'][$channel])) { sendData($this->socket, "MODE {$channel} +o {$nick}"); } } elseif ($this->autoOpConfig['mode'] == 2) { sendData($this->socket, "MODE {$channel} +o {$nick}"); } } } }
function onMessage($from, $channel, $msg) { if (stringStartsWith($msg, "{$this->config['trigger']}op")) { $bits = explode(" ", $msg); $pass = @$bits[3]; $who = @$bits[1]; $where = @$bits[2]; if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) { sendMessage($this->socket, $channel, "{$from}: Wrong password"); } else { if (strlen($who) == 0 || strlen($where) == 0) { sendMessage($this->socket, $channel, "{$from}: Syntax: {$this->config['trigger']}op nick #channel [adminPassword]"); } else { sendData($this->socket, "MODE {$where} +o {$who}"); sendMessage($this->socket, $channel, "{$from}: OP has been attempted given, note that i must be OP myself to do it."); } } } }
public function onMessage($from, $channel, $msg) { if (stringStartsWith($msg, "{$this->config['trigger']}upgrade")) { $bits = explode(" ", $msg); $pass = $bits[1]; if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) { sendMessage($this->socket, $channel, "{$from}: Wrong password"); } else { $restartRequired = false; sendMessage($this->socket, $channel, "{$from}: Starting upgrade of bot and its plugins..."); $response = trim(shell_exec("git pull")); if (empty($response)) { sendMessage($this->socket, $channel, "{$from}: Error upgrading core. Check permissions!"); } elseif ($response != 'Already up-to-date.') { $restartRequired = true; sendMessage($this->socket, $channel, "{$from}: Upgrading core: {$response}"); } $coreDir = getcwd(); $pluginsRecDirIterator = new RecursiveDirectoryIterator('./'); foreach (new RecursiveIteratorIterator($pluginsRecDirIterator) as $gitDir) { if (stringEndsWith($gitDir, ".git/..")) { chdir($gitDir); $response = trim(shell_exec("git pull")); if (empty($response)) { sendMessage($this->socket, $channel, "{$from}: Error upgrading sub git. Check permissions!"); } elseif ($response != 'Already up-to-date.') { $restartRequired = true; sendMessage($this->socket, $channel, "{$from}: Upgrading sub git: {$response}"); } chdir($coreDir); } } if ($restartRequired) { sendMessage($this->socket, $channel, "{$from}: Restarting..."); sendData($this->socket, 'QUIT :Restarting due to upgrade'); die(exec('sh start.sh > /dev/null &')); } else { sendMessage($this->socket, $channel, "{$from}: Everything up to date, not restarting."); } } } }
function onMessage($from, $channel, $msg) { if (stringStartsWith($msg, "{$this->config['trigger']}upgrade")) { $bits = explode(" ", $msg); $pass = $bits[1]; if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) { sendMessage($this->socket, $channel, "{$from}: Wrong password"); } else { sendMessage($this->socket, $channel, "{$from}: Starting upgrade..."); $response = trim(shell_exec("git pull")); if ($response == 'Already up-to-date.') { sendMessage($this->socket, $channel, "{$from}: The bot is already up to date, not restarting."); } else { sendMessage($this->socket, $channel, "{$from}: {$response}"); sendMessage($this->socket, $channel, "{$from}: Restarting..."); sendData($this->socket, 'QUIT :Restarting due to upgrade'); die(exec('sh start.sh > /dev/null &')); } } } }
function errorCheck() { /*check for error Hobson returns a string after form submission. We need to parse the string to determine the error. */ global $return, $data_contact, $url_curl, $userpwd, $content, $to_error, $headers, $modify, $url_contacts, $entityID; $status = 'default'; $status = get_string_between($return, 'status":"', '"'); $errorMessage = get_string_between($return, 'message":"', '"'); //if we are ok, then there is not error and we can move on. if ($status !== "ok") { if (begins_with($errorMessage, "A duplicate record has been found")) { //The record already exists in the database, prepare to resubmit using the Modify/Put Method. $modify = 'True'; //if contacts table if ($url_curl == $url_contacts) { $entityID = filter_var($errorMessage, FILTER_SANITIZE_NUMBER_INT); } $url_curl = $url_curl . '/' . $entityID; sendData(); } else { //prepare variables for email $subject = 'Error: Hobson Radius Form'; $message = 'There has been an error on the Hobson Radious Form Submission Status: ' . $status . ' ***Modify: ' . $modify . ' ***Error: ' . $errorMessage . ' ***url:' . $url_curl . ' ***entityID:' . $entityID . ' ***error return:' . $return . ' data send:' . print_r($data_contact, true); //send email mail($to_error, $subject, $message, $headers); } } //send email mail($to_error, $subject, $message, $headers); }
include_once "fxpair.structured.php"; header("Content-Type: text/event-stream"); $symbols = array(new FXPair('EUR/USD', 1.303, 0.0001, 5, 360, 47), new FXPair('EUR/USD', 1.303, 0.0001, 5, 360, 47), new FXPair('USD/JPY', 95.09999999999999, 0.01, 3, 341, 55), new FXPair('AUD/GBP', 1.455, 0.0002, 5, 319, 39)); function sendData($data) { echo "data:"; echo json_encode($data) . "\n"; echo "\n"; @flush(); @ob_flush(); } $clock = microtime(true); if (isset($argc) && $argc >= 2) { $t = $argv[1]; } elseif (array_key_exists('seed', $_REQUEST)) { $t = $_REQUEST['seed']; } else { $t = $clock; sendData(array('seed' => $t)); } mt_srand($t * 1000); while (true) { $sleepSecs = mt_rand(250, 500) / 1000.0; $now = microtime(true); $adjustment = $now - $clock; usleep(($sleepSecs - $adjustment) * 1000000); $t += $sleepSecs; $clock += $sleepSecs; $ix = mt_rand(0, count($symbols) - 1); sendData($symbols[$ix]->generate($t)); }
} break; default: $contactOwnerID = $coleenCoxID; break; } } elseif ($countryLength >= 1) { $contactOwnerID = $sophieMettlerGroveID; } else { $contactOwnerID = $coleenCoxID; } $fields["Contact Owner"] = $contactOwnerID; /* 4. Create createFields array per web service requirement */ $data_contact = array("createFields" => $fields, "returnFields" => array("Entity ID", "Description")); //define variables for specic curl event $content = json_encode($data_contact); $url_curl = $url_contacts; //5. send data to Hobson sendData(); if ($_POST['userRole'] !== 'Other') { $modify = 'False'; //reset to default //get entity id from return string $entityID = get_string_between($return, 'Entity ID":', '}'); $data_lifecycle = array("createFields" => array("Contact" => $entityID, "Lifecycle Role" => 'Inquirer', "Lifecycle Stage" => 'Open', "Primary Role" => 'True')); //define variables for specic curl event $content = json_encode($data_lifecycle); $url_curl = $url_lifecycles; //send data to Hobson sendData(); }
function signalHandler($signal) { sendData($this->socket, "QUIT :Caught signal {$signal}, shutting down"); logMsg("Caught {$signal}, shutting down\n"); exit; }
<?php include_once "fx_server.auth.inc1.php"; sendHeaders(); if (!@$_SERVER['REMOTE_USER']) { sendData(array('action' => "auth", 'msg' => "System problem. Exiting.")); exit; } include_once "fx_server.auth.inc2.php";
if ($servers[$x]['id'] != 0) { if ($numadd == 0) { if ($servers[$x]['path'] == 'true') { $dusbody .= "URL=" . $servers[$x]['url'] . $line['URL'] . "\n"; } else { $dusbody .= "URL=" . $servers[$x]['url'] . $line['fileDL'] . "\n"; } } else { if ($servers[$x]['path'] == 'true') { $dusbody .= "URL{$numadd}=" . $servers[$x]['url'] . $line['URL'] . "\n"; } else { $dusbody .= "URL{$numadd}=" . $servers[$x]['url'] . $line['fileDL'] . "\n"; } } $numadd++; } } $dusbody .= "Size=" . $line['size'] . "\nFile=" . $line['file'] . "\nFileDL=" . $line['fileDL'] . "\nDate=" . $line['date'] . "\nRealSize=" . $line['realsize'] . "\nHash=" . $line['hash'] . "\n\n"; } } $queryresult->close(); $dusheader .= "Result=OK\n"; $dusheader .= trim($dusupdates) . "\n"; $dusheader .= trim($dusupdatesuntable) . "\n"; $dusheader .= trim($dustranslations) . "\n"; $dusheader .= trim($dusservers) . "\n\n"; $dusbody = $dusheader . $dusbody; // Closing MYSQL connection $mysqli->close(); sendData($dusbody);
$url .= "&XDEBUG_SESSION_START=phpstorm"; } $result = sendData($urlPostXML, $_POST["body"]); echo "<pre>"; if (strpos($result, "<style") === false && strpos($result, "<hr>") === false) { echo htmlentities($result); } else { echo $result; } echo "</pre>"; echo "<hr />"; break; case "session": $urlSession = $_POST['urlSession'] . "&username="******"&password="******"<br />"; $result = sendData($urlSession, ""); print_r($result); echo "Test"; break; default: break; } } else { $urlPostXML = $default_urlPostXML; $_POST["body"] = ""; } $debug_checked = isset($_POST["debug"]) ? " checked=\"checked\" " : ""; ?> <form action="<?php echo $_SERVER['PHP_SELF'];
function rmsViewHistory($id, $pp, $lenght = 10, $offset = 0) { global $sock; $result = array(); $cmd = "HISTORY " . $id . "." . $pp . " " . $lenght . " " . $offset . "\r\n"; sendData($cmd); $packet = socket_read($sock, 1024, PHP_NORMAL_READ); if (substr($packet, 0, 3) >= 400) { return false; } // kses input filtering $allowed = array('b' => array(), 'i' => array(), 'a' => array('href' => 1, 'title' => 1), 'p' => array('align' => 1), 'br' => array(), 'font' => array('size' => 1, 'color' => 1, 'face' => 1) ); while (!preg_match("/^231 /", $packet)) { $msg = ""; preg_match("/from (.*)/", $packet, $header); $from = $header[1]; $packet = socket_read($sock, 1024, PHP_NORMAL_READ); $snttime = substr($packet, 12); $packet = socket_read($sock, 1024, PHP_NORMAL_READ); $packet = socket_read($sock, 1024, PHP_NORMAL_READ); while (!preg_match("/^223 /", $packet)) { $msg .= (($msg!="")?"<br/>":"").$packet; $packet = socket_read($sock, 1024, PHP_NORMAL_READ); } if (get_magic_quotes_gpc()) $msg = stripslashes($msg); $result[] = array('msg' => kses($msg, $allowed), 'time' => trim($snttime), 'from' => trim($from)); $packet = socket_read($sock, 1024, PHP_NORMAL_READ); } return $result; }
/** * Write a notice to channel/user * * @param string $socket * @param string $channel * @param string $msg */ function sendNotice($socket, $channel, $msg) { if (strlen($msg) > 2) { //Avoid sending empty lines to server, since all data should contain a line break, 2 chars is minimum sendData($socket, "NOTICE {$channel} :{$msg}"); } }
$type = $properties[6]; $machine = $properties[7]; $priority = $properties[5]; $tempestID = $properties[1]; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if (!$socket) { $err_message = 'socket%20create%20failed'; } else { $result = @socket_connect($socket, $machine, $port); if (!$result) { $err_message = 'socket%20connect%20failed'; } else { $data = "SEND," . $name . "," . $path . "," . $params . "," . $tempestID . "," . $priority . "," . $type; sendData($socket, $data); $ret = receiveData($socket); sendData($socket, "END"); $ret = receiveData($socket); } } } } } if ($err_message == "") { header('Location: index.php'); } else { header("Location: error.php?err={$err_message}"); } function sendData($socket, $d) { socket_write($socket, $d . "\n", strlen($d) + 1); }
} mt_srand($t * 1000); $nextKeepalive = time() + 15; while (true) { $sleepSecs = mt_rand(250, 500) / 1000.0; $now = microtime(true); $adjustment = $now - $clock; usleep(($sleepSecs - $adjustment) * 1000000); $t += $sleepSecs; $clock += $sleepSecs; $s = @file_get_contents("shutdown.txt"); if ($s) { $when = strtotime($s); $untilSecs = $when - time(); if ($when > 0 && $untilSecs > 0) { $until = date("Y-m-d H:i:s T", $when); sendData(array('action' => 'scheduled_shutdown', 'until' => $until, 'until_secs' => $untilSecs)); break; } //else ignore: either a bad timestamp or time has already passed } if (time() > $nextKeepalive) { sendData(array('action' => 'keep-alive', 'timestamp' => gmdate("Y-m-d H:i:s"))); $nextKeepalive = time() + 15; } $ix = mt_rand(0, count($symbols) - 1); sendIdAndData($symbols[$ix]->generate($t)); if ($GLOBALS['is_longpoll']) { break; } }
$data["projectID"] = $path[1]; } $results = addPicture($data); break; case "DELETE": if (isset($path[1]) && trim($path[1]) !== "") { $data["projectID"] = $path[1]; } $results = deletePicture($data); break; default: $results["meta"] = methodNotAllowed($method, $path); } break; case "countProjects": switch ($method) { case "GET": $results = countProjects($data); break; default: $results["meta"] = methodNotAllowed($method, $path); } break; default: $results["meta"]["ok"] = false; $results["meta"]["status"] = 404; $results["meta"]["feedback"] = "Unrecognised URI."; $results["meta"]["message"] = "Not Found"; } sendData($results, $data, $method, $path);
<?php include_once "fx_server.auth.inc1.php"; sendHeaders(); if (array_key_exists("login", $_COOKIE)) { $d = $_COOKIE["login"]; } elseif (array_key_exists("login", $_POST)) { $d = $_POST["login"]; } else { sendData(array("action" => "auth", "msg" => "The login data is missing. Exiting.")); exit; } if (strpos($d, ",") === false) { sendData(array("action" => "auth", "msg" => "The login data is invalid. Exiting.")); exit; } list($user, $pw) = explode(",", $d); $fromDB = '$2a$10$4LLeBta770Y0Z7795j.8' . 'He/ZCQonnvImXIX0egalzE1MuWiEa6PQa'; if (!password_verify($pw, $fromDB)) { sendData(array("action" => "auth", "msg" => "The login is bad. Exiting.")); exit; } include_once "fx_server.auth.inc2.php";
function sendIdAndData($data) { $id = $data['rows'][0]['id']; echo "id:" . json_encode($id) . "\n"; sendData($data); }
<?php header("Content-Type: text/event-stream"); function sendData($data) { echo "data:"; echo json_encode($data) . "\n"; echo "\n"; //Extra blank line @flush(); @ob_flush(); } //-------------------------------------- while (true) { switch (rand(1, 10)) { case 1: sendData(array("comeBackIn10s" => true)); exit; case 2: sendData(array("msg" => "About to sleep 10s")); sleep(10); //Force a keep-alive timeout break; default: sendData(array("t" => date("Y-m-d H:i:s"))); sleep(1); break; } }
} $resp->redirect('call_handler.php'); } else { if ($config['step2_ticket_mode'] == 'text') { $say = convertText($config['step2_ticket_text'], 'ticket', $tid); $resp->say($say); } else { $resp->play('get_audio.php?f=step2_ticket_file'); } foreach ($numbers as $key => $number) { $resp->dial($number['number'], array('timeout' => $number['timeout'])); } // Send data to node.js to pass along to WHMCS admins $ticket = mysql_fetch_assoc($d); $data = array('type' => 'ticket', 'ticketid' => $ticket['id']); sendData($data, $config['server_port']); // Just in case no one answers, forward to VM $resp->redirect('http://twimlets.com/voicemail?Email=' . $config['voicemail_email']); } } else { if ($config['invalid_request_mode'] == 'text') { $resp->say($config['invalid_request_text']); } else { $resp->play('get_audio.php?f=invalid_request_file'); } $resp->redirect('call_handler.php'); } } print $resp; function sendData($dataArr, $port) {
$AddNodeName->name = "Name"; $AddNodeName->value = $val; $AddNode->addChild($AddNodeName); $resultNode->addChild($AddNode); } } if (!empty($query)) { $resData = db_res($query); if (mysql_affected_rows() == 0 and $dataType == "ReloadClassifiedsAndCustomsFields") { $iIDClassified = process_db_input($_GET["IDClassified"]); $query = "\r\nSELECT `CustomFieldName1` , `CustomFieldName2` , `CustomAction1` , `CustomAction2`, `Unit`\r\nFROM `Classifieds` \r\nWHERE `ID` = '{$iIDClassified}'\r\n"; $resData = db_res($query); } fillXmlNodeWithDBData($resultNode, $resData, $dataType); } sendData($resultNode); /** * Output XML data * * @param XmlNode $xmlNode */ function sendData($xmlNode) { header("Content-type: application/xml"); send_headers_page_changed(); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"; echo $xmlNode->getXMLText(); } function fillXmlNodeWithDBData(&$xmlNode, $dbResource, $objectName) { if (!$dbResource) {
function prepareShutdown($msg) { if (strlen($msg) == 0) { $msg = "VikingBot - https://github.com/Ueland/VikingBot"; } sendData($this->socket, "QUIT :{$msg}"); }
function uploadRecordFile() { // get and decode JSON request body $app = Slim::getInstance(); $request = $app->request(); $record_id = $request->post('record_id'); //check if entry already exists in database try { $db = getConnection(); $stmt = $db->prepare("SELECT * FROM " . DB_TABLE_RECORDS . " WHERE id = :id"); $stmt->execute(array('id' => $record_id)); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $db = null; if (sizeof($result) < 1) { _sendData("Record entry for upload file does not exist, id: " . $record_id, 404); } } catch (Exception $e) { _sendData($e->getMessage(), 500); } // check if any file got submitted if (!isset($_FILES['file'])) { sendData("No file submitted", 404); } $file = $_FILES['file']; //move file to records directory $upload_dir = DIR_RECORD_FILES . '/' . $record_id; if (is_uploaded_file($file['tmp_name'])) { //_sendData($file['tmp_name']." uploaded successfully.",500); move_uploaded_file($file['tmp_name'], $upload_dir . '/' . $file['name']); _sendData($file['name'] . " uploaded successfully."); } else { _sendData("File got not uploaded.", 404); } }
function getJson($domains) { return sendData(getDomainCheckUrl(getDomainConsist($domains))); }