/** Connects to a database, we don't need a link for our purposes */ function connect() { mysql_connect(DB_SERVER, DB_USER, DB_PASS) or err("failure connecting to database..."); if (!@mysql_select_db(DB)) { err("failure selecting the database <strong>" . DB . "</strong>..."); } }
public static function get($require, $what = null) { // $routes_array = []; if ($require == 1) { require "site_routes/site_routes_common.php"; } elseif ($require == 2) { require "site_routes/site_routes_pages.php"; } elseif ($require == 3) { require "site_routes/site_routes_projects.php"; } elseif ($require == 4) { require "site_routes/site_routes_hidden.php"; } elseif ($require == 5) { require "site_routes/site_routes_siteTests.php"; } elseif ($require == 6) { require "site_routes/site_routes_api.php"; } elseif ($require == 7) { require "site_routes/site_routes_spidro.php"; } elseif ($require == 8) { require "site_routes/site_routes_sellingManager.php"; } elseif ($require == 9) { require "site_routes/site_routes_games.php"; } else { err("not a defined site route"); } // err($require."--".$what); // err($routes_array[$what]); if ($what == null) { $ans = $routes_array; } else { $ans = $routes_array[$what]; } return $ans; }
function urandom_bytes($num) { if ($num < 0) { err("NUM must be nonnegative in urandom_bytes"); } if ($this->use_urandom && !$this->urandom_filehandle) { $file = @fopen("/dev/urandom", "r"); if (!$file) { $this->use_urandom = false; } else { $this->urandom_filehandle = $file; } } $res = ''; if ($this->use_urandom) { while (strlen($res) < $num) { $res .= fread($this->urandom_filehandle, $num - strlen($res)); } } else { for ($i = 0; $i < $num; $i++) { $res .= chr(mt_rand(0, 255)); } } return $res; }
function query($sql) { if (!($res = @mysql_query($sql, $this->link))) { err('操作数据库失败' . mysql_error() . "<br>sql:{$sql}", "javascript:history.go(-1);"); } return $res; }
function survey_do_command($command, $user_code, $auth_signature) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_USERAGENT, 'PHP survey client, version $Id: survey.php,v 1.3 2008-06-24 16:41:21 francis Exp $'); curl_setopt($ch, CURLOPT_URL, OPTION_SURVEY_URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "{$command}&user_code=" . urlencode($user_code) . "&auth_signature=" . urlencode($auth_signature)); $r = curl_exec($ch); if ($r === FALSE) { err(curl_error($ch) . " curling " . OPTION_SURVEY_URL); } $errcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($errcode != 200) { err("Error {$errcode} curling " . OPTION_SURVEY_URL); } curl_close($ch); $r = trim($r); if ($r == "1") { return true; } elseif ($r == "0") { return false; } else { err("Error returned from survey service: " . $r); } }
function pgerr( $err ) { $e = pg_last_error(); if( $e == '' ) $e = $err; if( $e == '' ) $e = 'unknown pgsql error'; pg_free_result( pg_query( 'ROLLBACK' ) ); err( $e ); }
function fun_refused_nocomments($comment_data) { $pattern = '/[一-龥]/u'; if (!preg_match($pattern, $comment_data['comment_content'])) { err('评论必须含中文!'); } return $comment_data; }
function dbconn() { global $TBDEV; if (!@mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass'])) { err('Please call back later'); } mysql_select_db($TBDEV['mysql_db']) or err('Please call back later'); }
function dbconn() { global $mysql_host, $mysql_user, $mysql_pass, $mysql_db; if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass)) { err('Please call back later'); } mysql_select_db($mysql_db) or err('Please call back later!'); }
public function __construct() { // Connect to DB server $this->dbConn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or err("Could not connect to database " . mysql_errno()); // Set charset mysql_set_charset("utf8") or err("Could not set character set " . $this->getLastErrNo()); // Select DB mysql_select_db(DB_NAME) or err("Could not select database \"" . DB_NAME . "\" error code" . $this->getLastErrNo()); }
function eyecandyConsole($consoleObject) { if (method_exists($consoleObject, "getBuffer")) { $consoleObject->getBuffer(); } else { err("System console object invalid", "EyecandyConsole() got an invalid system console object.\nThis is unlikely to happen without *ANY* reason, please contact the administrator!", $CONFIG['DebugLevel'] + 1); } $this->buffer .= '<div class="eyecandyConsole">' . $consoleObject->getBuffer() . '</div>'; }
function ResetPass() { global $msql, $SiteUrl; global $strLostpassNtc1, $strLostpassNtc2, $strLostpassNtc3, $strLostpassNtc4, $strLostpassNtc5; global $strLostpassNtc6, $strLostpassNtc7, $strLostpassNtc8, $strLostpassNtc9; $coltitle = $GLOBALS["PLUSVARS"]["coltitle"]; $tempname = $GLOBALS["PLUSVARS"]["tempname"]; $Temp = LoadTemp($tempname); $step = $_REQUEST["step"]; if ($step == "checkmail") { $codestr = $_GET["codestr"]; $username = $_GET["username"]; $tm = $_GET["tm"]; if (!isset($_COOKIE["NEWPASSWD"]) || $_COOKIE["NEWPASSWD"] == "") { $PageMain = err($strLostpassNtc7, "lostpass.php", ""); return $PageMain; } $md5 = md5($username . "Z(o)C~LoSbZ8Tj7MvBAs(8)!nn^Lp^12345^Pm" . $_COOKIE["NEWPASSWD"] . $tm); if ($md5 == $codestr) { $mdpass = md5($_COOKIE["NEWPASSWD"]); $msql->query("update {P}_member set password='******' where user='******'"); $PageMain = SayOk($strLostpassNtc8, "login.php", ""); return $PageMain; } else { $PageMain = err($strLostpassNtc9, "lostpass.php", ""); return $PageMain; } } elseif ($step == "2") { $username = $_POST["username"]; $newpass = $_POST["newpass"]; if (!isset($username) || $username == "" || $newpass == "") { $str = err($strLostpassNtc1, "", ""); return $str; } else { $msql->query("select email from {P}_member where user='******'"); if ($msql->next_record()) { $email = $msql->f('email'); $tm = time(); setCookie("NEWPASSWD", $newpass, time() + 7200); $md5 = md5($username . "Z(o)C~LoSbZ8Tj7MvBAs(8)!nn^Lp^12345^Pm" . $newpass . $tm); $link = $SiteUrl . "lostpass.php?step=checkmail&username="******"&codestr=" . $md5 . "&tm=" . $tm; $message = $username . $strLostpassNtc2 . "\r\n \r\n" . $strLostpassNtc3 . "\r\n \r\n" . $link . "\r\n \r\n" . $GLOBALS["CONF"]["SiteName"] . "\r\n" . $GLOBALS["CONF"]["SiteHttp"]; include ROOTPATH . "includes/ebmail.inc.php"; ebmail($email, $GLOBALS["CONF"]["SiteEmail"], $strLostpassNtc4, $message); $str = SayOk($strLostpassNtc5 . "<br><br>" . $email, "", ""); return $str; } else { $str = err($strLostpassNtc6, "", ""); return $str; } } } else { $var = array('coltitle' => $coltitle); $str = ShowTplTemp($Temp, $var); return $str; } }
public function doAdd($user_id) { if (!me()->hasPermissionTo('add', 'Recommendation')) { err('You don\'t have permission to leave a recommendation for that user.'); return Redirect::to(URL::previous()); } $recommendation = new Recommendation(); return $recommendation->validateAndUpdateFromArray(Input::all()); }
function ratty_test($scope, $vals) { if (!isset($scope)) { err("SCOPE must be supplied"); } debug("RATTY", "Rate limiting", $vals); $res = ratty_do_call('test', array($scope, $vals)); debug("RATTYRESULT", "Result is:", $res); return $res; }
function getRec($s) { global $reci; $reci = isset($reci) ? $reci + 1 : 1; $rec = $s[$reci - 1]; if (substr($rec, 500, 8) != $reci) { err("bad seq num at {$reci}"); } return $rec; }
public function pornstars_pop() { ini_set('max_execution_time', 3600); $pornstars = lists::common("pornstars"); $obj = new pornstars_model(); foreach ($pornstars as $pornstar) { $obj->create($pornstar); } err($pornstars); }
/** * Prints all questions stored in the Mysql database */ function printQuestions() { $link = connect(); $q = "SELECT * FROM " . QUESTIONS_TABLE; $result = mysql_query($q) or err("No database configured yet, please use the admin interface!"); while ($row = mysql_fetch_array($result)) { printQuestion($row); } disconnect(); }
function v7v3_comment_post($incoming_comment) { $pattern = '/[一-龥]/u'; $jpattern = '/[ぁ-ん]+|[ァ-ヴ]+/u'; if (!preg_match($pattern, $incoming_comment['comment_content'])) { err("Please write some Chinese words!"); } if (preg_match($jpattern, $incoming_comment['comment_content'])) { err("Japanese please say Chinese!"); } return $incoming_comment; }
function template_string($template_name, $values = null) { global $template_style_dir; if (!isset($template_style_dir)) { err("no template style directory set"); } ob_start(); template_draw($template_name, $values); $ret = ob_get_contents(); ob_end_clean(); return $ret; }
function buildLink($wvActionId, $options, $caption) { $lttemp = false; if (isset($_POST["login"])) { if ($_POST["login"] == "1") { $lttemp = true; } } if ($lttemp == true) { //Check that the user is properly logged in $wvuserpasswdmd5ln = qry('user', 'user_password_md5', 'user_name', fv('wvUserName')); if (md5($_SESSION['wvUserPassword']) == $wvuserpasswdmd5ln) { $loginverifiedln = 1; $loginln = 1; } else { $loginverifiedln = 0; err(5); $loginbl = 0; } if ($loginverifiedln == 1) { } else { err(289); $loginln = 0; } } else { $loginln = 0; } $localeid = fv('locale'); if ($loginln == 0) { if ($options == '') { $separator = ''; $options = $options . '&locale=' . $localeid; $options = str_replace('&&', '&', $options); } else { $separator = '&'; $options = $options . 'locale=' . $localeid; $options = str_replace('&&', '&', $options); } $linkGenerated = itr(38) . $wvActionId . $separator . $options . itr(39) . $caption . itr(40); } else { if ($options == '') { $separator = ''; $options = $options . '&wvSession=' . session_id() . '&' . itr(63) . $localeid; $options = str_replace('&&', '&', $options . '&wvSession=' . session_id()); } else { $separator = itr(41); $options = $options . '&' . itr(62) . $localeid; $options = str_replace('&&', '&', $options); } $linkGenerated = str_replace('&&', '&', itr(42) . $wvActionId . str_replace(itr(54), itr(43), str_replace('=', itr(44), $options)) . itr(1083) . $caption . itr(1084)); } return $linkGenerated; }
public function setRegion($regionId) { debug(__METHOD__ . "({$regionId})"); if (!array_key_exists($regionId, $this->_regions)) { err(__METHOD__ . ': Region does not exist'); return false; } $this->_currentRegion = $this->_regions[$regionId]; if (!setcookie('region', $regionId, time() + TWO_WEEKS, getConfiguration('public.path') . '/')) { warn(__METHOD__ . ': Could not set cookie for user! Output already exists.'); return false; } return true; }
function canonicalise_partial_postcode($pc) { $pc = str_replace(' ', '', $pc); $pc = trim($pc); $pc = strtoupper($pc); if (validate_postcode($pc)) { $pc = preg_replace('#(\\d[A-Z]{2})#', '', $pc); } elseif (validate_partial_postcode($pc)) { # OK } else { err('Unexpected not full or partial postcode'); } return $pc; }
function jw_filter_comment_post($incoming_comment) { $pattern = '/[一-龥]/u'; if (!preg_match($pattern, $incoming_comment['comment_content'])) { err("是国人请说汉语!"); } $foreach = array("女装", "蘑菇街", "返佣", "网赚", "返利", "gmail", "*****@*****.**", "sitemap"); foreach ($foreach as $temp) { if (stripos($incoming_comment['comment_content'], $temp)) { unset($temp); err('已拦截垃圾评论敏感词!'); } } return $incoming_comment; }
function urandom_bytes($num) { global $urandom_bytes_filehandle; if ($num < 0) { err("NUM must be nonnegative in urandom_bytes"); } if (!isset($urandom_bytes_filehandle) && !($urandom_bytes_filehandle = fopen("/dev/urandom", "r"))) { err("Unable to open /dev/urandom"); } $res = ''; while (strlen($res) < $num) { $res .= fread($urandom_bytes_filehandle, $num - strlen($res)); } return $res; }
function list_stations() { $stations = file_get_contents("./data/stations.txt"); if ($stations === false) { err("stations file unreadable or does not exist", 1201); } if (!trim($stations)) { err("stations file is empty", 1202); } $stations = explode("\n", trim($stations)); $ret = array(); foreach ($stations as $s) { $ret[] = get_station($s); } return $ret; }
function NewUploadImage1($jpg, $jpg_type, $jpg_size, $path) { global $strUploadNotice1, $strUploadNotice2, $strUploadNotice3; if ($jpg_size == 0) { return false; } if ($jpg_size > 1024000) { err($strUploadNotice2, "", ""); } if ($jpg_type != "image/pjpeg" && $jpg_type != "image/jpeg" && $jpg_type != "image/gif" && $jpg_type != "image/x-png" && $jpg_type != "application/x-shockwave-flash") { err($strUploadNotice3, "", ""); } switch ($jpg_type) { case "image/pjpeg": $extention = ".jpg"; $UploadImage[2] = "gif"; break; case "image/gif": $extention = ".gif"; $UploadImage[2] = "gif"; break; case "image/x-png": $extention = ".png"; $UploadImage[2] = "gif"; break; case "application/x-shockwave-flash": $extention = ".swf"; $UploadImage[2] = "swf"; break; } $fname = time(); $fname = $fname . "_s" . $extention; $file_path = ROOTPATH . $path . "/" . $fname; $UploadImage[3] = $path . "/" . $fname; copy($jpg, $file_path); chmod($file_path, 0666); $size = GetImageSize($file_path); if ($size[0] > 0 && $size[1] > 0) { $UploadImage[0] = $size[0]; $UploadImage[1] = $size[1]; } else { $UploadImage[0] = 50; $UploadImage[1] = 50; } return $UploadImage; }
public function validateAndUpdateFromArray($array) { $rules = array('contributed_for' => 'required|exists:users,id', 'body' => 'required'); $validator = Validator::make($array, $rules); if ($validator->fails()) { err('Something was wrong with the recommendation you submitted. Check below.'); return Response::json($validator->failed()); return Redirect::to(URL::previous())->withErrors($validator); } $this->contributed_for = $array['contributed_for']; $this->body = $array['body']; $this->contributed_by = me()->id; $this->save(); //Boost the reputation of the person who just received the recommendation $this->contributedFor->doHelpReputation(10); return Redirect::route('userprofile', array('id' => $array['contributed_for'])); }
function auth_token_retrieve($scope, $token) { $data = db_getOne(' select data from token where scope = ? and token = ?', array($scope, $token)); /* Madness. We have to unescape this, because the PEAR DB library isn't * smart enough to spot BYTEA columns and do it for us. */ $data = pg_unescape_bytea($data); $pos = 0; $res = rabx_wire_rd(&$data, &$pos); if (rabx_is_error($res)) { $res = unserialize($data); if (is_null($res)) { err("Data for scope '{$scope}', token '{$token}' are not valid"); } } return $res; }
public function validateAndUpdateFromInput() { if (!me()->hasPermissionTo('add', $this)) { err('You don\'t have permission to add pledges'); return Redirect::to(URL::previous()); } $rules = array('plea_id' => 'required|exists:pleas,id', 'dollars' => 'numeric|required_without:alternatives', 'alternatives' => 'required_without:dollars'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { err('Something was wrong with the pledge you submitted. Check below.'); // return Response::json($validator->failed()); return Redirect::to(URL::previous())->withErrors($validator); } $this->plea_id = Input::get('plea_id'); $this->dollars = Input::get('dollars', ''); $this->alternatives = Input::get('alternatives', ''); $this->user_id = me()->id; $this->save(); return Redirect::to(URL::previous()); }
function do_curl_post_request($url, $proxy, $delivery, $callback) { $curl = curl_init(); if (!is_string($proxy)) { $proxy = json_encode($proxy); } if (!is_string($delivery)) { $delivery = json_encode($delivery); } $postfields = "proxy=" . $proxy . "&delivery=" . $delivery; curl_setopt_array($curl, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_POSTFIELDS => $postfields, CURLOPT_POST => 1)); $response = curl_exec($curl); if (!$response) { //curl error $ce = curl_error($curl); curl_close($curl); err($ce); } curl_close($curl); $callback($response); }