function sql_error_connect() { perihelion_die("SQL Error", "The SQL server seems to be offline. Please try again..."); }
function input_check() { $numargs = func_num_args(); $arg_list = func_get_args(); if (!validate_request_checksum()) { perihelion_die("Refresh Error", "You can only submit this form once."); } if (!isset($_REQUEST['cmd'])) { perihelion_die("", "No command requested."); return ""; } // Command is needed. If not present... whooops. $cmd = decrypt_get_vars($_REQUEST['cmd']); // Browse through all numargs, check the command, if it is ours, decrypt all vars EXCEPT // the ne_* vars $i = 0; for (;;) { $tmp_cmd = $arg_list[$i]; $i++; if ($tmp_cmd != $cmd) { while ($arg_list[$i] != "0") { $i++; } } else { while ($arg_list[$i] != "0") { $tmp_var = $arg_list[$i]; $GLOBALS[$tmp_var] = ""; // Error if we can't find a mandatory var if (substr($tmp_var, 0, 1) == "!") { $tmp_var = substr($tmp_var, 1, 255); if (!isset($_REQUEST[$tmp_var])) { perihelion_die("Internal Error", "Mandatory var not found: " . $tmp_var); } } if (isset($_REQUEST[$tmp_var])) { // Check if we need decrypting or not if (substr($tmp_var, 0, 3) == "ne_") { $GLOBALS[$tmp_var] = $_REQUEST[$tmp_var]; } else { $GLOBALS[$tmp_var] = decrypt_get_vars($_REQUEST[$tmp_var]); } } $i++; } return $tmp_cmd; } $i++; if ($i >= $numargs) { break; } } // No command found :( if (user_is_admin(user_ourself())) { $str = "Illegal or no command requested.<br>Command issued: '{$cmd}'"; } else { $str = "Illegal or no command requested."; } perihelion_die("Internal Error", $str); }
function comm_recv_from_server() { global $COMM_SOCK; if ($COMM_SOCK == 0) { perihelion_die("Communication Error", "recv_from_server: socket not inialized!"); } // Read until we find a dot. $data = array(); do { // Read a whole line $buf = ""; $done = false; do { $char = socket_read($COMM_SOCK, 1, PHP_BINARY_READ); if ($char === false) { print_line("Error while reading from socket: " . socket_strerror(socket_last_error())); // exit; } $buf = $buf . $char; if (ord($char) == 13) { $done = true; } } while (!$done); // Neatify the buffer. Make sure all \r and \n's are gone... $buf = trim($buf); // And exit when we find a dot if ($buf == ".") { continue; } // Split line if (substr('==>', $buf)) { list($buf_name, $buf_data) = split('==>', $buf, 2); $data[$buf_name] = $buf_data; } } while ($buf != "."); // Return array return $data; }