function edit_note($id) { if ((string) (int) $id != $id) { _die("Invalid ID"); } include "lib/tags.php"; $post_data =& $_POST; foreach (array('ID', 'title', 'contents', 'tags', 'time', 'slug') as $key) { $post_data[$key] = pg_escape_string(@$post_data[$key]); } $post_data['tags'] = clean_tags($post_data['tags']); if (trim($post_data['slug']) == '') { $post_data['slug'] = make_slug($post_data['title']); } if (!($time = strtotime(@$post_data['time']))) { $time = date("Y-m-d H:i:s O", time()); } else { $time = date("Y-m-d H:i:s O", $time); } $result = db("UPDATE public.\"notes\" SET \"title\" = '{$post_data['title']}',\n\t\t\t\"contents\" ='{$post_data['contents']}', \"tags\" = '{$post_data['tags']}',\n\t\t\t\"slug\" ='{$post_data['slug']}'\n\t\t\tWHERE \"ID\" = " . pg_escape_string($id)); if ($result) { if (!rebuild_tags()) { _die("There was an error rebuilding the tag cloud data.\n\t\t\t\t<a href=\"" . _l("/edit/{$id}") . "\">Go back →"); } _die("Edit successfull. <a href=\"" . _l("/edit/{$id}") . "\">continue editing →"); } else { _die("There was an unexpected error."); } }
public function start() { $c = Configurator::getInstance(); $l = Logger::getInstance(); if (isset($c->config['logfile'])) $l->setLogfile($c->config['logfile']); if ((!isset($c->config['debugmode'])) || ($c->config['debugmode'] == "false")) $l->debug(FALSE); elseif (is_numeric($c->config['debugmode'])) $l->debug($c->config['debugmode']); elseif ($c->config['debugmode'] == "true") $l->debug(3); else $l->debug(FALSE); if (isset($c->config['die'])) _die("Icarus: read the config file!"); $this->loadClients(); $this->loadServers(); $this->running = TRUE; $SH = SocketHandler::getInstance(); $SH->loop(); }
function find_all_words($name = NULL, $lang = NULL, $spart = NULL) { global $sql_stmts; $stmt = []; $params = [""]; if ($name !== NULL) { $stmt[] = "word_name"; $params[0] .= "s"; $params[] = $name; } if ($lang !== NULL) { $stmt[] = "word_lang"; $params[0] .= "s"; $params[] = $lang; } if ($spart !== NULL) { $stmt[] = "word_spart"; $params[0] .= "s"; $params[] = $spart; } if (!count($stmt)) { _die("bad arguments: need one non-NULL"); } $stmt = $sql_stmts["word_id<-" . implode(",", $stmt)]; $res = NULL; sql_getmany(sql_prepare($stmt), $res, $params); foreach ($res as &$r) { $r = WORD($this, $r); } return $res; }
public function register_place($data, $type = '') { $table = $this->get_table_name($type); if ($this->setTable($table)->setWhereGroup($data)->get_results()) { _die("This data already exists."); } return $this->insertRecord($table, $data); }
function importo_save_node($node) { $node = node_submit($node); if (!$node) { _die("FATAL [" . __FILE__ . " (" . __LINE__ . ")]: node_submit failed"); } node_save($node); return $node; }
public function assign($driver_id, $vehical_id, $data = array()) { if ($this->setTable(TBL_DRIVER_VEHICALS)->setWhereStringArray(array("( driver_id = '{$driver_id}' AND is_current = '1' )", "( vehical_id = '{$vehical_id}' AND is_current = '1' )"), "OR")->execute()->result()) { _die("The driver or vehical may be engage."); } if (!$data) { return false; } return $this->insertRecord(TBL_DRIVER_VEHICALS, $data); }
function add_directory_to_zip(&$z, $dir, $base_dir = NULL) { global $exclude_files, $exclude_dirs; if (empty($z)) { _die('Error in ZIP Parameter'); } if (is_null($base_dir)) { $base_dir = trim($dir, '/'); $base_dir = trim($base_dir, '\\'); } if (!file_exists($dir)) { _log('dir: ' . $dir . ' does not exist'); return; } foreach (scandir($dir) as $file) { if (in_array($file, array('.', '..'))) { continue; } // check the exclude dirs $continue = false; if (!empty($exclude_dirs)) { foreach ($exclude_dirs as $e_dir) { if (preg_match($e_dir, $dir . DIRECTORY_SEPARATOR . $file)) { $continue = true; } } } if ($continue) { continue; } // check the exclude files $continue = false; if (!empty($exclude_files)) { foreach ($exclude_files as $e_file) { if (preg_match($e_file, $dir . DIRECTORY_SEPARATOR . $file)) { $continue = true; } } } if ($continue) { continue; } if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { // add add_directory_to_zip($z, $dir . DIRECTORY_SEPARATOR . $file, $base_dir); } elseif (is_readable($dir . DIRECTORY_SEPARATOR . $file)) { // directory for the ZIP file $zDir = str_replace($base_dir, '', $dir); $zDir = trim($zDir, '/'); $zDir = trim($zDir, '\\'); $zDir .= empty($zDir) ? '' : '/'; $z->addFile($dir . DIRECTORY_SEPARATOR . $file, $zDir . $file); } } }
protected function _create($filename = NULL) { $logger = Logger::getInstance(NULL); if (!is_null($filename)) $this->configfile = $filename; else $this->configfile = $GLOBALS['etcdir'] . 'icarus.conf'; if (!file_exists($this->configfile)) _die("Fatal Error: Configuration file (%s) not found.", $this->configfile); $this->config = $this->parse($this->configfile); }
final public function __construct($name, $config) { $this->config = $config; if ((!isset($config['listen'])) || (!isset($config['port']))) _die("Server %s: Didn't get a listening address or port value!", $name); $SH = SocketHandler::getInstance(); // $this->sid = $SH->createListener(etc. etc. etc.) $this->loadModules(); $this->_create($name, $config); }
final public function __construct($name, $config) { $this->config = $config; if ((!isset($config['server'])) || (!isset($config['port']))) _die("Client %s: Didnt get a server or port value!", $name); $SH = SocketHandler::getInstance(); $this->sid = $SH->createSocket($config['server'], $config['port'], $this); $this->loadModules(); $this->_create($name, $config); }
function delete_note($id) { if ((string) (int) $id != $id) { _die("Invalid ID"); } require_once "lib/tags.php"; $result = db("DELETE FROM public.\"notes\" WHERE \"ID\" = " . pg_escape_string($id)); if ($result) { if (rebuild_tags()) { _die("Note was purged successfully."); } else { _die("There was an error building the tag cloud data. Please run make_tags.php to fix this."); } } else { _die("There was an unexpected error."); } }
function delete_tags($id) { $tags = db("SELECT tags from public.notes WHERE \"ID\"=" . pg_escape_string($id)); if (pg_num_rows($tags) == 0) { _die("Does not exists.", "404"); } $row = pg_fetch_assoc($tags); $tags = trim($row['tags']); $tags = explode(' ', $tags); $tags_data = unserialize(file_get_contents("ser/tags.ser")); foreach ($tags as $tag) { $tags_data['tags'][$tag] -= 1; if ($tags_data['tags'][$tag] == 0) { unset($tags_data['tags'][$tag]); } } $tags_data['max'] = max($tags_data); $tags_data['min'] = min($tags_data); $tags_data['total'] = array_sum($tags_data); file_put_contents("ser/tags.ser", serialize($tags_data)); }
public function cancel_booking($booking_no, $passenger_id) { $booking = $this->get_booking(array('id' => $booking_no, 'passenger_id' => $passenger_id)); if (!$booking) { _die("The booking does not belongs to you."); } if ($booking['booking_status'] == BOOKING_COMPLETED) { _die("Sorry! the order is already completed. You can't cancel."); } $orders = $this->get_booking_orders($booking_no, array('order_status')); if ($orders) { foreach ($orders as $order) { if ($order['order_status'] == ORDER_ARRIVED or $order['order_status'] == ORDER_STARTED) { _die("Sorry! the truck already arrived or started. You can't cancel."); } } } $this->updateRecord(TBL_BOOKING, array('id' => $booking_no), array('booking_status' => BOOKING_CANCELLED)); $this->updateRecord(TBL_ORDERS, array('booking_no' => $booking_no), array('order_status' => ORDER_CANCELLED)); $this->updateRecord(TBL_ORDERS_TRACKING, array('booking_no' => $booking_no), array('tracking_status' => 2)); }
function find_all_words($name = NULL, $lang = NULL, $id = NULL) { if ($id !== NULL) { return [$this->_data[$id]]; } if ($name === NULL) { _die("need name"); } $res = []; foreach ($this->_data as &$word) { if ($lang !== NULL and $word->lang() !== $lang) { continue; } else { if ($name !== NULL and $word->name() !== $name) { continue; } else { $res[] =& $word; } } } return $res; }
/** * Function error_handler */ function myErrorHandler($errno, $errstr, $errfile, $errline) { if (!(error_reporting() & $errno)) { return; } switch ($errno) { case E_USER_ERROR: _die("Error Occured!", sprintf("<p><strong>Fatal Error: </strong>[{$errno}] {$errstr}.</p>" . "<p><strong>Line Number: {$errline}</p>" . "<p><strong>File Name: {$errfile}</p>")); break; case E_USER_WARNING: _die("Warning!", sprintf("<p><strong>Warning: </strong>[{$errno}] {$errstr}.</p>" . "<p><strong>Line Number: {$errline}</p>" . "<p><strong>File Name: {$errfile}</p>"), false); break; case E_USER_NOTICE: echo "<b>My NOTICE</b> [{$errno}] {$errstr}<br />\n"; _die("Notice!", sprintf("<p><strong>Notice: </strong>[{$errno}] {$errstr}.</p>" . "<p><strong>Line Number: {$errline}</p>" . "<p><strong>File Name: {$errfile}</p>"), false); break; default: _die("Error!", sprintf("<p><strong>Error: </strong>[{$errno}] {$errstr}.</p>" . "<p><strong>Line Number: {$errline}</p>" . "<p><strong>File Name: {$errfile}</p>")); break; } /* Don't execute PHP internal error handler */ return false; }
} ++$tries; } if (!$db) { _die("Unable to connect to storage server.\n"); } if (!mysql_select_db(STORAGE_DB, $db)) { _die("Unable to select database " . STORAGE_DB . ".\n"); } $filename = ltrim($_SERVER['SCRIPT_NAME'], "/"); // Issue #015459 // Fetch file metadata. $filePathHash = mysql_real_escape_string($filename); $sql = "SELECT * FROM " . TABLE_METADATA . " WHERE name_hash=MD5('{$filePathHash}')"; if (!($res = mysql_query($sql, $db))) { _die("Failed to retrieve file metadata\n"); } if (!($metaData = mysql_fetch_array($res, MYSQL_ASSOC)) || $metaData['mtime'] < 0) { header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found"); ?> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>404 Not Found</TITLE> </HEAD><BODY> <H1>Not Found</H1> The requested URL <?php echo htmlspecialchars($filename); ?> was not found on this server.<P> </BODY></HTML> <?php
/** * Builds a query into a final query statement. * * @param AnDomainQuery $query Query object * * @return string */ public function build($query) { //clone the query so it won't be modified $query = clone $query; $parts = array(); $this->_query = $query; $this->_store = $query->getRepository()->getStore(); switch ($query->operation['type']) { case AnDomainQuery::QUERY_SELECT_DEFAULT: case AnDomainQuery::QUERY_SELECT: $parts[] = $this->select($query); $parts[] = $this->from($query); $parts[] = '@MYSQL_JOIN_PLACEHOLDER'; $parts[] = $this->where($query); $parts[] = $this->group($query); $parts[] = $this->having($query); $parts[] = $this->order($query); $parts[] = $this->limit($query); break; case AnDomainQuery::QUERY_UPDATE: $parts[] = $this->update($query); $parts[] = $this->where($query); $parts[] = $this->order($query); $parts[] = $this->limit($query); break; case AnDomainQuery::QUERY_DELETE: $parts[] = $this->delete($query); $parts[] = $this->from($query); $parts[] = $this->where($query); break; default: _die(); } $string = implode(' ', $parts); $string = $this->parseMethods($query, $string); $string = str_replace('@MYSQL_JOIN_PLACEHOLDER', $this->join($query), $string); $string = $this->parseMethods($query, $string); if (count($query->binds)) { foreach ($query->binds as $key => $value) { $key = ':' . $key; $value = $this->_store->quoteValue($value); $string = str_replace($key, $value, $string); } } $string = str_replace('@DISTINCT', $query->distinct ? 'DISTINCT' : '', $string); return $string; }
function add_directory_to_zip(&$z, $dir, $base_dir = NULL) { if (empty($z)) { _die('Error in ZIP Parameter'); } if (is_null($base_dir)) { $base_dir = trim($dir, '/'); $base_dir = trim($base_dir, '\\'); } foreach (scandir($dir) as $file) { if (in_array($file, array('.', '..'))) { continue; } if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { add_directory_to_zip($z, $dir . DIRECTORY_SEPARATOR . $file, $base_dir); } elseif (is_readable($dir . DIRECTORY_SEPARATOR . $file)) { // directory for the ZIP file $zDir = str_replace($base_dir, '', $dir); $zDir = trim($zDir, '/'); $zDir = trim($zDir, '\\'); $zDir .= empty($zDir) ? '' : '/'; $z->addFile($dir . DIRECTORY_SEPARATOR . $file, $zDir . $file); _log('Added "' . $dir . DIRECTORY_SEPARATOR . $file . '" to ZIP'); } } }
if (!$error) { $user_pass = salt_user_pass($_POST['user_pass']); $mysql['user_pass'] = $db->real_escape_string($user_pass); $mysql['user_id'] = $db->real_escape_string($user_row['user_id']); $user_sql = "UPDATE \t202_users\n\t\t\t\t\t\t SET\t\tuser_pass='******'user_pass'] . "',\n\t\t\t\t\t\t\t\t\tuser_pass_time='0'\n\t\t\t\t\t\t WHERE\tuser_id='" . $mysql['user_id'] . "'"; $user_result = _mysqli_query($user_sql); $success = true; } } $html['user_name'] = htmlentities($user_row['user_name'], ENT_QUOTES, 'UTF-8'); //if password was changed successfully if ($success == true) { _die("<center><small>Congratulations, your password has been reset.<br/>You can now <a href=\"/202-login.php\">login</a> with your new password.</small></center>"); } if ($error['user_pass_key']) { _die("<center><small>" . $error['user_pass_key'] . "<br/>Please use the <a href=\"/202-lost-pass.php\">password retrieval tool</a> to get a new password reset key.</small></center>"); } //else if none of the above, show the code to reset! ?> <?php info_top(); ?> <div class="row"> <div class="main col-xs-4"> <center><img src="202-img/prosper202.png"></center> <center><span class="infotext">Please create a new password and verify it to proceed.</span></center> <form class="form-signin form-horizontal" role="form" method="post" action=""> <div class="form-group"> <input type="text" class="form-control first" id="user_name" name="user_name" value="<?php echo $html['user_name'];
/** * Issue a new random key to the session. Everything else stays the same. */ public function scramble() { $new_sess_id = static::getNewSessionId(); if (empty($new_sess_id)) { _die('Session error.'); } Database::getInstance()->update('session', array('session_key' => $new_sess_id), array('session_id' => $this->id)); $this->session_key = $new_sess_id; $this->setCookie(); }
<?php //include mysql settings include_once $_SERVER['DOCUMENT_ROOT'] . '/202-config/connect.php'; //check to see if this is already installed, if so dob't do anything if (upgrade_needed() == false) { _die("<h2>Already Upgraded</h2>\n\t\t\t Your Prosper202 version {$version} is already upgraded."); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (UPGRADE::upgrade_databases() == true) { $success = true; } else { $error = true; } } //only show install setup, if it, of course, isn't install already. if ($success != true) { info_top(); ?> <?php if ($error == true) { ?> <h2 style="color: #900;">An error occured</h2> <span style="color: #900;">An unexpected error occured while you were trying to upgrade, please try again or if you keep encountering problems please contact <a href="http://prosper202.com/forum">our support forum</a>.</span> <br/><br/> <?php } ?>
function getBlocks() { if (!$this->isValid()) { _die("Data provider is empty."); } return (int) (($this->_size - 1) / 0x200) - 1; }
public function __construct(hostAssistance &$bot, $bind_port, $hostname, $host_id, $creator, $gamename) { $this->bot = $bot; $this->started_time = time(); if ($bind_port < 1024 || $bind_port > 65535) { _die("Invalid port range", __FILE__, __LINE__, __FUNCTION__); return false; } $this->hostname = $hostname; $this->creator = $creator; $this->game_name = $gamename; $this->room = new Room(12); $this->ping_timer = new timer('ping', 5000); $this->reserver_timer = new timer('reserver', 60000); $this->room_life_timer = new timer('room', 300000); $this->wait_timer = new timer('wait', 1000); $this->created_time = time(); $this->userlist = new index(WORKING_PATH . 'data/vouched.txt', $read_only = true); $this->bind_port = $bind_port; call_method('reserveSlot', $this->room, 1); $tries = 0; $hosted = false; $this->host_id = $host_id; while ($this->failed) { try { call_method('buildSocket', $this); $this->failed = false; } catch (hostException $e) { $this->failed = true; sleep(1); $tries++; if ($tries > 60) { return; } } } $username_length = strlen($hostname); if ($username_length < self::USERNAME_MIN_LEN || $username_length > self::USERNAME_MAX_LEN) { _die("Invalid username", __FILE__, __LINE__, __FUNCTION__); } }
} if ($upgrade_done != true) { ?> <br> <form method="post" action="" class="form-horizontal"> <button class="btn btn-lg btn-p202 btn-block" type="submit">Upgrade Prosper202<span class="fui-check-inverted pull-right"></span></button> <input type="hidden" name="start_upgrade" value="1"/> </form> <br> <span class="infotext"><i>We highly recommended you make a backup of your database, before upgrading.<br> Also make sure PHP has write permissions.</i></span> <?php } else { ?> <h6>Success!</h6> <small>Prosper202 has been upgraded! You can now <a href="/202-login.php">log in</a>.</small> <?php } ?> </div> <?php info_bottom(); } else { _die("<h6>Already Upgraded</h6>\n\t\t\t<small>Your Prosper202 version {$version} is already upgraded.</small>"); } ?>
// Set cache time out to 100 minutes by default $expiry = defined( 'EXPIRY_TIMEOUT' ) ? EXPIRY_TIMEOUT : 6000; if ( file_exists( $dfsFilePath ) ) { // Output HTTP headers. $path = $metaData['name']; $size = $metaData['size']; $mimeType = $metaData['datatype']; $mtime = $metaData['mtime']; $mdate = gmdate( 'D, d M Y H:i:s', $mtime ) . ' GMT'; header( "Content-Length: $size" ); header( "Content-Type: $mimeType" ); header( "Last-Modified: $mdate" ); header( "Expires: " . gmdate('D, d M Y H:i:s', time() + $expiry) . ' GMT' ); header( "Connection: close" ); header( "X-Powered-By: eZ Publish" ); header( "Accept-Ranges: none" ); header( 'Served-by: ' . $_SERVER["SERVER_NAME"] ); // Output image data. $fp = fopen( $dfsFilePath, 'r' ); fpassthru( $fp ); fclose( $fp ); } else { _die( "Server error: DFS File not found." ); } ?>
if (!$error) { $user_pass = salt_user_pass($_POST['user_pass']); $mysql['user_pass'] = mysql_real_escape_string($user_pass); $mysql['user_id'] = mysql_real_escape_string($user_row['user_id']); $user_sql = "UPDATE \t202_users\n\t\t\t\t\t\t SET\t\tuser_pass='******'user_pass'] . "',\n\t\t\t\t\t\t\t\t\tuser_pass_time='0'\n\t\t\t\t\t\t WHERE\tuser_id='" . $mysql['user_id'] . "'"; $user_result = _mysql_query($user_sql); $success = true; } } $html['user_name'] = htmlentities($user_row['user_name'], ENT_QUOTES, 'UTF-8'); //if password was changed succesfully if ($success == true) { _die("<div style='text-align: center'><br/>Congratulations, your password has been reset.<br/>\n\t\t You can now <a href=\"/xtracks-login.php\">login</a> with your new password</div>"); } if ($error['user_pass_key']) { _die("<div style='text-align: center'><br/>" . $error['user_pass_key'] . "<p>Please use the <a href=\"/202-lost-pass\">password retrieval tool</a> to get a new password reset key.</p></div>"); } //else if none of the above, show the code to reset! ?> <?php info_top(); ?> <form method="post" action=""> <input type="hidden" name="token" value=""/> <table class="config" cellspacing="0" cellpadding="5" style="margin: 0px auto;" > <tr><td colspan="2" style="text-align: center;">Please create a new password and verify it to proceed.</td></tr> <tr><td/></tr> <tr> <th>Username:</th> <td><input id="user_name" type="text" name="user_name" value="<?php
<?php //if the 202-config.php doesn't exist, we need to build one if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/202-config.php')) { require_once $_SERVER['DOCUMENT_ROOT'] . '/202-config/functions.php'; _die("There doesn't seem to be a <code>202-config.php</code> file. I need this before we can get started. Need more help? <a href=\"http://prosper202.com/apps/about/contact/\">Contact Us</a>. You can <a href='/202-config/setup-config.php'>create a <code>202-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "202 › Error"); } else { require_once $_SERVER['DOCUMENT_ROOT'] . '/202-config/connect.php'; if (is_installed() == false) { header('location: /202-config/install.php'); } else { if (upgrade_needed() == true) { header('location: /202-config/upgrade.php'); } else { require_once $_SERVER['DOCUMENT_ROOT'] . '/202-config.php'; header('location: /' . LOGIN_URI); } } }
function add_alias($alias, $value, $key = NULL) { if (!array_key_exists($value, $this->value2key)) { _die("bad value '{$value}'"); } if ($key !== NULL) { $this->aliases[$key][$alias] = $value; } else { $this->aliases[$alias] = $value; } }
function &sql_exec($stmt, $params) { $result = NULL; if ($params) { $bind_names[] = $params[0]; for ($i = 1; $i < count($params); $i++) { $bind_name = 'bind' . $i; ${$bind_name} = $params[$i]; $bind_names[] =& ${$bind_name}; } if (!call_user_func_array(array($stmt, "bind_param"), $bind_names)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; return $result; } } if (!$stmt->execute()) { _die("Execute failed (" . __FILE__ . "@" . __LINE__ . "): (" . $stmt->errno . ") " . $stmt->error); return $result; } $stmt->reset(); $result = TRUE; return $result; }
<?php /** * @Author Jonathon byrd * @link http://www.5twentystudios.com * @Package CCprocessing * @Since 1.0.0 * @copyright Copyright (C) 2011 5Twenty Studios * */ defined('ABSPATH') or _die("Cannot access pages directly."); /** * Credit Card Response * */ function CCresponse() { }