public function get($url, $params = []) { $params["auth_token"] = $this->auth_token; $params['apikey'] = $this->apikey; $params['version'] = self::VERSTION; $path = self::BASE_URL . $url . "?" . http_build_query($params); $process = curl_init($path); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); $page = curl_exec($process); $this->error = curl_error($process); log_msg("ridewithgps " . $path); log_msg($page); if ($this->error) { log_msg("ERROR: " . $this->error); } log_msg("Total time: " . curl_getinfo($process)["total_time"]); curl_close($process); if ($page) { return $page; } else { return $this->error; } }
function array_matches($have, $should, $name = 'array') { $ret = true; if (is_array($have)) { foreach ($should as $key => $value) { if (!array_key_exists($key, $have)) { log_msg('Missing: ' . $key); $ret = false; } else { if (is_array($value) && is_array($have[$key])) { $ret &= array_matches($have[$key], $value); } else { if (is_array($value) || is_array($have[$key])) { log_msg('Type mismatch: ' . $key); $ret = false; } else { if (!fnmatch($value, $have[$key])) { log_msg("Failed comparison: {$key}={$have[$key]} (expected {$value})"); $ret = false; } } } } } } else { log_msg('Not an array: ' . $name); $ret = false; } return $ret; }
public function get($url, $params = []) { if (!$this->apikey) { $this->error = "No Google maps api key set"; return false; } $this->error = ""; $retries = 3; $params['key'] = $this->apikey; $url = self::BASE_URL . $url . "?" . http_build_query($params); $process = curl_init($url); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); $page = false; // make IDE happy for ($i = 0; $i < $retries; $i++) { $page = curl_exec($process); $error = curl_error($process); if ($error) { $this->error .= "{$error}\n"; } if ($page) { break; } } log_msg("google " . $url); log_msg($page); if ($error) { log_msg("ERROR: " . $error); } log_msg("Total time: " . curl_getinfo($process)["total_time"]); curl_close($process); return $page; }
/** * @param $key * @param $secret * @return BTCeAPI */ static function api($key, $secret) { try { $api = new BTCeAPI($key, $secret); return $api; } catch (BtceLibException $e) { log_msg('Connection failed: ' . $e->getMessage(), true); } }
public static function init($dbtype, $config) { if (!in_array($dbtype, self::$valid_drivers)) { log_msg('无效的数据库驱动!', __CLASS__); //此处引用了公共函数 } $dbtype = 'DB_' . $dbtype; require_once SYS_PATH . 'database/drivers/' . $dbtype . '.php'; //引入相关数据库驱动文件 $db = new $dbtype(); $db->connect($config); return $db; }
function __construct($path) { log_msg("Storage::construct >> inited"); $this->_src = $path; if (file_exists($this->_src)) { $_file = file_get_contents($this->_src); $_dataArr = json_decode($_file, true); log_msg("Storage::construct >> load from " . $this->_src); } else { throw new StorageException(StorageException::$messages[StorageException::DATA_FILE_NOT_FOUND], StorageException::DATA_FILE_NOT_FOUND); } $this->data = new StorageData($_dataArr); }
/** * 进行json字符串标准化,并解析json后返回对象 * @param string $filepath 配置文件路径 * @return boolean|object 解析是失败返回NULL并有错误记录,配置文件为空则返回FALSE,正确解析返回Obj */ static final function readjsonstring($filepath) { $jsonstring = file_get_contents($filepath); if (empty($jsonstring)) { return FALSE; } $pattern = array('~#.*\\n~', '~(\\s*)(\\S+)(\\s*)(\\S+)(\\s*)~', '~\\,\\}~', '~\\,\\]~'); $replacement = array('', '$2$4', '}', ']'); $jsonstring = preg_replace($pattern, $replacement, $jsonstring); $json = json_decode($jsonstring); empty($json) && log_msg($filepath . PHP_EOL . $jsonstring, '配置文件解析失败,请检查文件内容'); return $json; }
/** * logs error into database using functions defined in log.php */ function log_error($level, $code, $msg, $mysql_msg = "NONE") { $er_code = $this->er_code_prefix + $code; //call to a predefined function $log_id = log_msg($level, $er_code, $msg, $mysql_msg); //if log id is false return 0; if (!$log_id) { return 0; } //display this code to user $this->error = "{$er_code}-{$log_id}"; return $log_id; }
function log_new_file() { global $_log_file; global $_state; global $debug; global $_log; $_log = fopen($_log_file, "w"); log_msg(); log_msg('=========='); log_msg('Request: ' . date("Y-m-d") . ' ' . date("H:i:s")); log_msg('File: ' . $_SERVER['PHP_SELF']); log_msg(); log_msg($_state); $debug = true; }
function delete_workorder($woinfo) { global $username; $loc = rmabs(__FILE__ . ".delete_workorder"); $wid = $woinfo["WID"]; $sql = "DELETE FROM Assignments WHERE WID=" . intval($wid); SqlQuery($loc, $sql); $sql = "DELETE FROM AppendedData WHERE WID=" . intval($wid); SqlQuery($loc, $sql); $sql = "DELETE FROM WorkOrders WHERE WID=" . intval($wid); SqlQuery($loc, $sql); $widstr = WIDStr($wid, $woinfo["Revision"], $woinfo["IsApproved"]); $msg = "Work Order " . $widstr . " deleted by " . $username . "."; log_msg($loc, $msg); return $msg; }
public function getPage($url) { $process = curl_init(self::REST_SERVER_BASE_URL . $url); $headers = array('Authorization: Basic ' . $this->auth); curl_setopt($process, CURLOPT_HTTPHEADER, $headers); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); $page = curl_exec($process); log_msg("MCL get URL " . $url); log_msg($page); $error = curl_error($process); if ($error) { log_msg("ERROR: " . $error); } log_msg("Total time: " . curl_getinfo($process)["total_time"]); curl_close($process); return $page; }
function main($server_cfg) { $eu_conf = parse_ini_file($server_cfg['eu_conf_file'], true); $db_host = $eu_conf['DB']['host']; $db_user = $eu_conf['DB']['user']; $db_pwd = $eu_conf['DB']['password']; $log_file = sprintf($server_cfg['log_file'], "add_correct_p_tag"); log_msg("Starting [partition_dynamics]", $log_file); log_msg("db_host: {$db_host}", $log_file); $con = mysql_connect($db_host, $db_user, $db_pwd); $con or die("mysql_connect failed: " . mysql_error()); $query = "select table_schema from information_schema.tables where\n table_name = 'xhprof_blob_30min'"; $res_a = mysql_query_p($query, $con, $log_file); $db_array = array(); while ($row_a = mysql_fetch_assoc($res_a)) { $db_array[] = $row_a['table_schema']; } add_correct_p_tag($db_array, $con, $log_file); mysql_close($con); }
public function post($url, $params = [], $body = "") { //this functionality is part of addtrack for endomondo, and not working yet. if (!$this->auth) { return null; } if (!$params) { $params = []; } $params["authToken"] = $this->auth; $path = self::BASE_URL . $url . "?" . http_build_query($params); $process = curl_init($path); // $process = curl_init("http://localhost/~jem/EddingtonAndMore/j.php". "?" . http_build_query($params)); curl_setopt($process, CURLOPT_HEADER, 0); vd("about to curl"); vd($body); curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type' => 'application/octet-stream')); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($process, CURLOPT_POST, 1); curl_setopt($process, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($process, CURLOPT_POSTFIELDS, $body); $page = curl_exec($process); $this->error = curl_error($process); log_msg("endomondo post " . $path); log_msg($params); log_msg($page); if ($this->error) { log_msg("ERROR: " . $this->error); } log_msg("Total time: " . curl_getinfo($process)["total_time"]); curl_close($process); if ($page) { return $page; } else { return $this->error; } }
function MakeGif($data) { global $config; $loc = 'badgeli.php->MakeGif'; if (isset($data["UserID"])) { $userid = intval($data["UserID"]); } else { $msg = 'UserID not given.'; log_error($loc, $msg); return $msg; } if (!isset($data["BadgeID"])) { $msg = 'BadgeID not given for UserID = ' . $userid; log_error($loc, $msg); return $msg; } if (!isset($data["PicID"])) { $msg = 'PicID not given for UserID = ' . $userid; log_error($loc, $msg); return $msg; } $badgeid = $data["BadgeID"]; $picid = intval($data["PicID"]); if (!VerifyBadgeFormat($badgeid)) { $msg = 'Bad Badge Format. Must be in form of "A000".'; log_error($loc, $msg); return $msg; } if ($picid <= 0) { $msg = 'User ' . $userid . ' does not have a picture.'; log_error($loc, $msg); return $msg; } CheckBadgeDir(); // We have a image to put on the badge! $picfile = PicPathName($picid, 'standard'); // Standard should have more than enough resolution. $imginfo = @getimagesize($picfile); if ($imginfo === false) { $msg = 'Getimagesize() failed on our image: ' . $picfile; log_error($loc, $msg); return $msg; } $picwidth = $imginfo[0]; $picheight = $imginfo[1]; $picimg = @imagecreatefromjpeg($picfile); if ($picimg === false) { $msg = 'imagecreatefromjpeg() failed on our image: ' . $picfile; log_error($loc, $msg); return $msg; } $scale = 260 / $picheight; $xsize = intval($picwidth * $scale); $ysize = intval($picheight * $scale); $img = imagecreatetruecolor($xsize, $ysize); $result = @imagecopyresampled($img, $picimg, 0, 0, 0, 0, $xsize, $ysize, $picwidth, $picheight); if ($result === false) { $msg = 'imagecopyresized() failed for PidId=' . $picid; log_error($loc, $msg); return $msg; } $outfile = $config["UploadDir"] . 'gifs/' . $badgeid . '.gif'; $result = imagegif($img, $outfile); if ($result === false) { $msg = 'imagegif() failed for PicID=' . $picid; log_error($loc, $msg); return $msg; } log_msg($loc, 'Image Successfully made for BadgeID= ' . $badgeid . '.'); return true; }
public function write_user_data() { file_put_contents($this->_users_file, $this->_jsonify_users()); log_msg(USER_LOG, "User inventory data written to file \"{$this->_users_file}\""); }
<?php //------------------------------------------------------------------------------ // Author: Denise // Date : november/2003 //------------------------------------------------------------------------------ // Globals include "globals.php"; include_once "request.class.php"; import_request_variables("gpc"); log_msg("Calling request dispatcher for id {$reqId}"); // Globals $dbcat = $GLOBALS["dbcatalog"]; $dbman = $GLOBALS["dbmanager"]; echo "Request- Dispatcher = Man " . $GLOBALS["dbmanager"] . " Cat = " . $GLOBALS["dbcatalog"] . "\n"; log_msg("Request- Dispatcher = Man " . $GLOBALS["dbmanager"] . " Cat = " . $GLOBALS["dbcatalog"] . "\n"); // Openning log file $logFile = $GLOBALS["systemLog"] . "requestDispatcher.log"; echo "Log = " . $logFile; if (!($lf = fopen($logFile, "a"))) { die('N<E3>o foi possivel criar o arquivo de log'); } $message = Date("d/m/Y H:m:s") . " - <Despachando para execução o pedido n. " . $reqId; if (!$itemId) { $message .= ">\r\n"; } else { $message .= " - item n. " . $itemId . ">\r\n"; } fwrite($lf, $message); // Processsing the RequestItem or the entire Request $nReq = searchReqByNumber($dbcat, $matReq, 1, 'B', "", $reqId);
public function write_project_state_data() { file_put_contents($this->_project_state_file, $this->_jsonify_project_data()); log_msg(PROJECT_LOG, "Project state data written to file \"{$this->_project_state_file}\""); }
/** * 获取JS票据 * @return string */ public function jsapi_ticket() { // 从没有获取过access_token或者已经过期 if (empty($_SESSION['jsapi_ticket']) || $_SESSION['jsapi_ticket_expire'] - time() <= 0) { $url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi'; $json = json_decode(curl_file_get_contents(sprintf($url, $this->access_token))); if ($json->errcode) { log_msg($json, '获取jsapi_ticket失败'); die('get jsapi_ticket fail!'); } $_SESSION['jsapi_ticket'] = $json->ticket; $_SESSION['jsapi_ticket_expire'] = time() + $json->expires_in; // 过期的时间 } return $_SESSION['jsapi_ticket']; }
//引入鉴权类 use Qiniu\Storage\UploadManager; //引用上传类 $accessKey = QINIU_AK; $secretKey = QINIU_SK; $zone = QINIU_ZONE; //生成七牛认证对象 $auth = new Auth($accessKey, $secretKey); //生成上传的token $token = $auth->uploadToken($zone); //要上传的文件路径 $filePath = '../../public/imgs/baidu.jpg'; //上传到七牛后保存的文件名 $destFileName = 'test.jpg'; // 初始化 UploadManager 对象并进行文件的上传。 $uploadMgr = new UploadManager(); $result = $uploadMgr->putFile($token, $destFileName, $filePath); list($ret, $err) = $result; $logContent = "========= Get token ========\r\n"; $logContent .= "token : {$token}\r\n"; $logContent .= "========= Upload file ========\r\n"; $logContent .= "response : " . json_encode($result) . " \r\n"; $logContent .= "result : " . json_encode($ret) . "\r\n"; $logContent .= "error : " . json_encode($err) . "\r\n\r\n"; log_msg($logContent, QINIU_LOG, 2); if (!$err) { echo "<img src='http://" . QINIU_DOMAIN . "/{$destFileName}'/>"; } /* * 还有很多图片处理功能,视频功能等 */
<?php /** * Created by JetBrains PhpStorm. * User: Effus * Date: 01.12.13 * Time: 22:47 * To change this template use File | Settings | File Templates. */ include_once 'exceptions.php'; include_once 'lib.php'; include_once 'storage.php'; include_once 'coins.php'; include_once 'funds.php'; include_once 'pairs.php'; include_once 'helpers.php'; include_once 'logic.php'; if (count($argv) < 2) { log_msg('Usage: php command.php <config-file.json>', true); } try { $logic = new Logic(); $startParams = array('baseCoin' => new Coin('btc'), 'min_fund_amount' => 0.012, 'expire_fund' => 60 * 10, 'expire_pairs' => 60, 'expire_pairs_life' => 60 * 2, 'diffs_sell' => array('btc_rur' => 15, 'btc_usd' => 1, 'btc_eur' => 2, 'ltc_btc' => 0.002), 'diffs_buy' => array('btc_rur' => 60, 'btc_usd' => 2, 'btc_eur' => 2, 'ltc_btc' => 0.002), 'capture_count' => array('sell' => 2, 'buy' => 6)); $logic->init($startParams); $logic->run(); } catch (Exception $e) { log_msg('Connection failed: ' . $e->getMessage(), true); }
function user($data) { $data = unserialize($data); if (!is_object($data) || !isset($data->user)) { return false; } $cmd = "/usr/sbin/"; $result = false; $USER = $data->user; $PASS = $data->pass; $CGI_SYS = ZH_DATA . "/cgi-system"; if (!is_dir($CGI_SYS)) { mkdir($CGI_SYS, 0700, true); } switch ($data->action) { case 'add': log_msg("Adding user account..."); $pass_crypted = crypt($PASS); $cmd0 = "/usr/sbin/useradd -m -s /bin/bash -p '{$pass_crypted}' {$USER}"; log_msg($cmd0); $result = shell_exec($cmd0); // ADD USER //if(!$result) return; /*echo "Setting password...\n"; $cmd0 = "echo '$USER:$PASS' | chpasswd"; echo "$cmd0\n\n"; $result = shell_exec($cmd0); // SET PASSWORD //if(!$result) return;*/ log_msg("Copying template files..."); $cmd0 = "cp -r {$CGI_SYS}/TEMPLATE {$CGI_SYS}/{$USER}"; log_msg($cmd0); $result = shell_exec($cmd0); // MAKE FASTCGI WRAPPERS //if(!$result) return; log_msg("Updating template files..."); $cmd0 = "sed -i 's/TEMPLATE/{$USER}/g' {$CGI_SYS}/{$USER}/*"; log_msg($cmd0); $result = shell_exec($cmd0); // DO UPDATE //if(!$result) return; log_msg("Fixing ownership..."); $cmd0 = "chown -R {$USER}.{$USER} {$CGI_SYS}/{$USER}"; log_msg($cmd0); $result = shell_exec($cmd0); // FIX PERMISSIONS //if(!$result) return; log_msg("Fixing permissions..."); $cmd0 = "chmod -R 755 {$CGI_SYS}/{$USER}"; log_msg($cmd0); $result = shell_exec($cmd0); // FIX PERMISSIONS //if(!$result) return; log_msg("Fixing ownership..."); $cmd0 = "chmod 711 /home/{$USER}"; log_msg($cmd0); $result = shell_exec($cmd0); // FIX PERMISSIONS //if(!$result) return; $passwd = file_get_contents('/etc/passwd'); preg_match("#\n{$USER}:x:(\\d+):(\\d+)#", $str, $out); $uid = $out[1]; $gid = $out[2]; global $pdo; $pdo->update('user', array('uid' => $uid, 'gid' => $gid), "user='******'"); syncFtpUsers(false); global $zhd; $zhd->proftpd('restart'); break; case 'mod': $pass_crypted = getcrypted($PASS); $cmd .= "/usr/sbin/usermod -p '{$pass_crypted}' {$USER}"; $result = shell_exec($cmd); syncFtpUsers(false); global $zhd; $zhd->proftpd('restart'); break; case 'del': // DANGEROUS log_msg('Backup user\'s files...'); $cmd0 = "mv -f /home/{$USER} /home/backup/"; log_msg($cmd0); $result = shell_exec($cmd0); // DO A BACKUP FIRST log_msg("Deleting user account..."); $cmd0 = "/usr/sbin/userdel -rf {$USER}"; log_msg($cmd0); $result = shell_exec($cmd0); log_msg("Deleting user's fcgid wrappers..."); $cmd0 = "rm -rf {$CGI_SYS}/{$USER}"; log_msg($cmd0); $result = shell_exec($cmd0); break; case 'jail': $service .= $cmd; break; case 'unjail': $service .= $cmd; break; default: return false; } return $result; }
if (isset($orderid)) { log_msg(" orderid = {$orderid}"); $procPagRetorno->setOrderId($orderid); } // Na documentacao eh dito que o valor pago eh retornado na variavel 'P_Amount', // entretanto, um dump da pagina mostra que essa variavel nao existe e que o // valor pago estah na variavel 'price'. if (isset($price)) { log_msg(" retPrice = {$price}"); $procPagRetorno->setRetPrice($price); } if (isset($lr)) { log_msg(" lr = {$lr}"); $procPagRetorno->setLR($lr); } if (isset($ars)) { log_msg(" ars = {$ars}"); $procPagRetorno->setRetMsg($ars); } if (isset($arp)) { log_msg(" arp = {$arp}"); $procPagRetorno->setAuthCode($arp); } // Descobre o tipo de pagina que deve ser gerado $procPagRetorno->processa(); echo "<html>\n"; // Gera cabecalho da pagina $procPagRetorno->generateHeader(); // Gera corpo da pagina $procPagRetorno->generateBody(); echo "</html>\n";
function iframe_save_state($args) { $elem = $args['elem']; $obj = $args['obj']; if (array_shift(elem_classes($elem)) != 'iframe') { return false; } // make sure the type is set $obj['type'] = 'iframe'; $obj['module'] = 'iframe'; // hook invoke_hook('alter_save', array('obj' => &$obj, 'elem' => $elem)); load_modules('glue'); $ret = save_object($obj); if ($ret['#error']) { log_msg('error', 'iframe_save_state: save_object returned ' . quot($ret['#data'])); return false; } else { return true; } }
function StoreUserPic($tempfile, $userid) { $loc = "piclib.php->StoreUserPic"; $id = StorePicture($tempfile); if ($id === false) { return false; } // Delete old pic, if any... $sql = 'DELETE FROM UserPics WHERE UserID=' . intval($userid); SqlQuery($loc, $sql); $sql = 'INSERT INTO UserPics (PicId, UserID) VALUES ('; $sql .= ' ' . intval($id); // PicID $sql .= ', ' . intval($userid); // UserID $sql .= ')'; $result = SqlQuery($loc, $sql); log_msg($loc, 'User Picture Successfully Stored. PicID= ' . $id . ', UserID = ' . $userid); return $id; }
if (!method_exists($instrument, "score")) { fwrite(STDERR, "Error, the instrument ({$test_name}) does not have a scoring feature \n"); return false; } // print out candidate/session info fwrite(STDERR, "Candidate: " . $record['CandID'] . "/" . $record['Visit_label'] . "/" . $record['SessionID'] . ":: ({$record['PSCID']})\n"); //fwrite(STDERR, "Candidate: ".$instrument->_dob."/"."Test_name:".$test_name."/". $instrument->_pls3Age."/".$instrument->getDateOfAdministration().":: \n"); // call the score function $db->selectRow("SELECT * FROM {$test_name} WHERE CommentID='{$record['CommentID']}'", $oldRecord); $success = $instrument->score(); $db->selectRow("SELECT * FROM {$test_name} WHERE CommentID='{$record['CommentID']}'", $newRecord); unset($oldRecord['Testdate']); unset($newRecord['Testdate']); $diff = array_diff_assoc($oldRecord, $newRecord); if ($diff != array()) { log_msg("Updated {$record['CommentID']}:"); foreach ($diff as $key => $val) { $old = $oldRecord[$key] == null ? 'null' : $oldRecord[$key]; $new = $newRecord[$key] == null ? 'null' : $newRecord[$key]; log_msg("\t{$key}: {$old} => {$new}"); } } else { log_msg("No changes made to {$record['CommentID']}"); } fwrite(STDERR, "-- OK! \n"); // unset unset($instrument); } } fclose($logfp); fwrite(STDERR, "End \n");
/** * try to turn a mixture of html code an plain text into valid html * * @param string $html input * @return string encoded output */ function html_encode_str_smart($html) { // TODO (later): remove debug code log_msg('debug', 'html_encode_str_smart: string is ' . quot(var_dump_inl($html))); // encode ampersand characters where needed $cur = 0; while ($cur < strlen($html)) { // check & if (substr($html, $cur, 1) == '&') { $replace = true; // DEBUG $reason = false; // check &#?? if ($cur + 3 < strlen($html) && substr($html, $cur + 1, 1) == '#') { // check $#x or not if (strtolower(substr($html, $cur + 2, 1)) == 'x') { // check for hexadecimal characters before ; $ahead = $cur + 3; while ($ahead < strlen($html)) { $char = strtolower(substr($html, $ahead, 1)); if (48 <= ord($char) && ord($char) <= 57 || 97 <= ord($char) && ord($char) <= 102) { // valid hexadecimal character $ahead++; } elseif ($char == ';') { if ($cur + 3 < $ahead) { // valid entitiy $replace = false; break; } else { // invalid entity // DEBUG $reason = 1; break; } } else { // invalid entity // DEBUG $reason = 2; break; } } if ($ahead == strlen($html)) { // DEBUG $reason = 3; } } elseif (is_numeric(substr($html, $cur + 2, 1))) { // check for for decimal characters before ; $ahead = $cur + 3; while ($ahead < strlen($html)) { $char = substr($html, $ahead, 1); if (48 <= ord($char) && ord($char) <= 57) { // valid decimal character $ahead++; } elseif ($char == ';') { // valid entity $replace = false; break; } else { // invalid entity $reason = 4; break; } } if ($ahead == strlen($html)) { // DEBUG $reason = 5; } } else { // DEBUG $reason = 6; } } else { // assume a named entity // it turns out we can't use get_html_translation_table() // for this as the HTML_ENTITIES table is not complete $ahead = $cur + 1; while ($ahead < strlen($html)) { $char = strtolower(substr($html, $ahead, 1)); if (48 <= ord($char) && ord($char) <= 57 || 97 <= ord($char) && ord($char) <= 122) { // valid alphanumeric character $ahead++; } elseif ($char == ';') { if ($cur + 1 < $ahead) { // (supposedly) valid entity $replace = false; break; } else { // invalid entity // DEBUG $reason = 7; break; } } else { // invalid entity // DEBUG $reason = 8; break; } } if ($ahead == strlen($html)) { $reason = 9; break; } } if ($replace) { log_msg('debug', 'html_encode_str_smart: replacing ampersand at ' . $cur . ' because of ' . $reason); $html = substr($html, 0, $cur) . '&' . substr($html, $cur + 1); log_msg('debug', 'html_encode_str_smart: new string is ' . quot(var_dump_inl($html))); $cur += 5; } else { log_msg('debug', 'html_encode_str_smart: not replacing ampersand at ' . $cur); $cur++; } } else { $cur++; } } // encode < and > where needed $cur = 0; while ($cur < strlen($html)) { $char = substr($html, $cur, 1); $replace = true; if ($char == '<') { // a possible tag // search for a closing bracket $ahead = $cur + 1; while ($ahead < strlen($html)) { $c = strtolower(substr($html, $ahead, 1)); if ($c == '<') { // found another opening bracket // the first one can't be legit // DEBUG $reason = 1; break; } elseif ($c == '>') { if ($cur + 1 < $ahead) { // can be a valid tag $replace = false; // forward till after the closing bracket $cur = $ahead; break; } else { // invalid (empty) tag // DEBUG $reason = 2; break; } } elseif ($ahead == $cur + 1) { if (48 <= ord($c) && ord($c) <= 57 || 97 <= ord($c) && ord($c) <= 122 || $c == '/') { // starts with an alphanumeric character or a slash, can be valid } else { // DEBUG $reason = 3; break; } } $ahead++; } if ($ahead == strlen($html)) { // DEBUG $reason = 4; } } else { if ($char == '>') { // we should be getting all valid tags through the code above // DEBUG $reason = 5; } } if ($replace && $char == '<') { log_msg('debug', 'html_encode_str_smart: replacing opening bracket at ' . $cur . ' because of ' . $reason); $html = substr($html, 0, $cur) . '<' . substr($html, $cur + 1); log_msg('debug', 'html_encode_str_smart: new string is ' . quot(var_dump_inl($html))); $cur += 4; } elseif ($replace && $char == '>') { log_msg('debug', 'html_encode_str_smart: replacing closing bracket at ' . $cur . ' because of ' . $reason); $html = substr($html, 0, $cur) . '>' . substr($html, $cur + 1); log_msg('debug', 'html_encode_str_smart: new string is ' . quot(var_dump_inl($html))); $cur += 4; } else { $cur++; } } return $html; }
/** * disable caching of output * * can be used for modules that need the php to be executed every time. * @param string $reason (e.g. your module) */ function html_disable_caching($reason = '') { global $html; if ($html['cache']) { log_msg('info', 'html: disabled caching for this request because of ' . quot($reason)); $html['cache'] = false; } }
public function run() { try { $this->getFunds(); $this->getPairs(); $this->calcTrand(); } catch (Exception $e) { log_msg('run >> exception: (' . $e->getCode() . ') ' . $e->getMessage()); } }
function display_second_chance(&$cmt_object, $unlock_key) { log_msg(__("Default Second Chance function (empty) called for plugin: ", 'sk2') . $this->name, 7, $comment_ID); echo __("This is an empty placeholder...", 'sk2'); }
function AddPictureToUser($username, $source) { $loc = "members_bulkpics.php->AddPIctureToUser"; $userid = GetUserIDFromName($username); $userinfo = GetUserInfo($userid); if ($userinfo === false) { DieWithMsg($loc, 'User with ID=' . $userid . ' not found, but should be there.'); } // Copy the file into our website. $target = GetTempDir() . "temppic.jpg"; $result = @copy($source, $target); if ($result == false) { log_msg($loc, array('Picture not added. Unable to copy file.', 'External File=' . $source, 'Internal Target=' . $target)); return false; } $id = StoreUserPic($target, $userid); return true; }