public function fenxi() { $othernum = 0; $str = ''; if (IS_POST) { $arr = $this->importtext(); $data = array(); foreach ($arr as $val) { $v = explode(',', $val); $k = to_utf8(preg_replace('/(\\.\\w+)\\/.*/i', '$1', $v[1])); $data[$k] = isset($data[$k]) ? ++$data[$k] : 1; } //去掉小于1的链接 foreach ($data as $key => $val) { if ($val <= 1) { $othernum++; } else { $str .= empty($str) ? "['{$key}({$val})', {$val}]" : ",['{$key}({$val})', {$val}]"; } } //$str.=(",['小于10的外链的站点总共 $othernum 个', $othernum]"); } $this->assign('other', "小于10个外链的站点总共 {$othernum} 个,已过滤不显示。"); $this->assign('data', $str); return $this->fetch('fenxi'); }
function recode_header($header, $basecharset) { if (strpos($header, "=?") === false) { return to_utf8($header, $basecharset); } return preg_replace_callback("/=\\?(.+?)\\?([qb])\\?(.+?)(\\?=|\$)/i", function ($m) { return decode_header($m[1], $m[2], $m[3]); }, $header); }
public function index() { $position = I('position'); $keywords = to_utf8(I('keywords')); if (!empty($position)) { $map['_string'] = "find_in_set('{$position}',position)"; } $map['title'] = array('like', '%' . $keywords . '%'); $list = $this->pages(array('model' => 'Article', 'where' => $map, 'rows' => 6, 'order' => 'create_time desc,article_id desc')); $this->display(); }
function str($str, $amp = false) { global $vbulletin; if ($amp) { $str = str_replace('&', '&', $str); } $charset = vB_Template_Runtime::fetchStyleVar('charset'); if ($charset == '') { $charset = 'ISO-8859-1'; } return to_utf8($str, $charset); }
/** обрабатываем входные параметры скрипта, определяем запрашиваемую страницу * */ public static function initialize($deep = false) { if (!$deep && self::$initialized) { return; } $headers = @apache_request_headers(); if (array_key_exists('X-Forwarded-For', $headers)) { $hostname = $headers['X-Forwarded-For']; } else { $hostname = $_SERVER["REMOTE_ADDR"]; } self::$ip = $hostname; self::$path_history = ''; self::$initialized = true; // принимаем uri $e = explode('?', $_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI'] = $e[0]; if (isset($e[1])) { parse_str($e[1], $d); } else { $d = array(); } $prepared_get = array(); foreach ($d as $name => &$val) { $val = to_utf8($val); $prepared_get[$name] = stripslashes($val); } self::$get_normal = self::$get = $prepared_get; $path_array = explode('/', self::processRuri($_SERVER['REQUEST_URI'])); // убиваем начальный слеш array_shift($path_array); // определяем, что из этого uri является страницей self::$structureFile = self::getPage($path_array, $deep); if (self::$real_path >= 0) { self::$structureFile = 'errors/p404.xml'; } //die(self::$structureFile); // разбираем параметры self::parse_parameters($path_array); if (isset($_POST)) { foreach ($_POST as $f => $v) { if (!is_array($v)) { self::$post[$f] = stripslashes($v); } else { self::$post[$f] = $v; } } } unset($_POST); unset($_GET); self::afterAll(); }
function to_utf8($in) { if (is_array($in)) { foreach ($in as $key => $value) { $out[to_utf8($key)] = to_utf8($value); } } elseif (is_string($in)) { if (mb_detect_encoding($in) != "UTF-8") { return utf8_encode($in); } else { return $in; } } else { return $in; } return $out; }
/** обрабатываем входные параметры скрипта, определяем запрашиваемую страницу * */ public static function initialize($deep = false) { if (!$deep && self::$initialized) return; self::$path_history = ''; self::$initialized = true; // принимаем uri $e = explode('?', $_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI'] = $e[0]; if (isset($e[1])) parse_str($e[1], $d); else $d = array(); $prepared_get = array(); foreach ($d as $name => &$val) { $val = to_utf8($val); $prepared_get[$name] = stripslashes($val); } self::$get_normal = self::$get = $prepared_get; $path_array = explode('/', self::processRuri($_SERVER['REQUEST_URI'])); // убиваем начальный слеш array_shift($path_array); // определяем, что из этого uri является страницей self::$structureFile = self::getPage($path_array, $deep); if (self::$real_path >= 0) { self::$structureFile = 'errors/p404.xml'; } //die(self::$structureFile); // разбираем параметры self::parse_parameters($path_array); if (isset($_POST)) foreach ($_POST as $f => $v) { if (!is_array($v)) self::$post[$f] = stripslashes($v); else self::$post[$f] = $v; } unset($_POST); unset($_GET); }
protected function processregistered(&$value, $charset) { global $VB_API_REQUESTS; if (is_array($value)) { foreach ($value as &$el) { $this->processregistered($el, $charset); } } if (is_string($value)) { $value = to_utf8($value, $charset, true); if ($VB_API_REQUESTS['api_version'] < 4) { $value = unhtmlspecialchars($value, true); } } if ($VB_API_REQUESTS['api_version'] > 1 and is_bool($value)) { if ($value) { $value = 1; } else { $value = 0; } } }
function read_dir_pic($main_dir = "") { global $xoopsDB; $pics = ""; $post_max_size = ini_get('post_max_size'); //$size_limit=intval($post_max_size) * 0.5 * 1024 * 1024; if (substr($main_dir, -1) != '/') { $main_dir = $main_dir . "/"; } if ($dh = opendir($main_dir)) { $total_size = 0; $i = 1; while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) == ".") { continue; } if (is_dir($main_dir . $file)) { $pic = read_dir_pic($main_dir . $file); $pics .= $pic['pics']; $total_size += $pic['total_size']; } else { //讀取exif資訊 $result = exif_read_data($main_dir . $file, 0, true); $creat_date = $result['IFD0']['DateTime']; $dir = (empty($creat_date) or substr($creat_date, 0, 1) != "2") ? date("Y_m_d") : str_replace(":", "_", substr($result['IFD0']['DateTime'], 0, 10)); $exif = mk_exif($result); $size = filesize($main_dir . $file); $total_size += intval($size); $size_txt = sizef($size); $pic = getimagesize($main_dir . $file); $width = $pic[0]; $height = $pic[1]; $subname = strtolower(substr($file, -3)); if ($subname == "jpg" or $subname == "peg") { $type = "image/jpeg"; } elseif ($subname == "png") { $type = "image/png"; } elseif ($subname == "gif") { $type = "image/gif"; } else { $type = $subname; continue; } $sql = "select width,height from " . $xoopsDB->prefix("tad_gallery") . " where filename='{$file}' and size='{$size}'"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); list($db_width, $db_height) = $xoopsDB->fetchRow($result); if ($db_width == $width and $db_height == $height) { $checked = "disabled='disabled'"; $upload = "0"; $status = _MD_TADGAL_IMPORT_EXIST; //}elseif($total_size >= $size_limit){ // $checked="disabled='disabled'"; // $upload="1"; // $status=sprintf(_MD_TADGAL_IMPORT_OVER_SIZE,sizef($total_size),$post_max_size); } else { $checked = "checked='checked'"; $upload = "1"; $status = $type; } if (_CHARSET == "UTF-8") { $file = to_utf8($file); } $pics .= "\n <tr>\n <td style='font-size:11px'>{$i}</td>\n <td style='font-size:11px'>\n <input type='hidden' name='all[{$i}]' value='" . $main_dir . $file . "'>\n <input type='checkbox' name='import[{$i}][upload]' value='1' {$checked}>\n {$file}\n <input type='hidden' name='import[{$i}][filename]' value='{$file}'></td>\n <td style='font-size:11px'>{$dir}<input type='hidden' name='import[{$i}][dir]' value='{$dir}'></td>\n <td style='font-size:11px'>{$width} x {$height}\n <input type='hidden' name='import[{$i}][post_date]' value='{$creat_date}'>\n <input type='hidden' name='import[{$i}][width]' value='{$width}'>\n <input type='hidden' name='import[{$i}][height]' value='{$height}'></td>\n <td style='font-size:11px'>{$size_txt}<input type='hidden' name='import[{$i}][size]' value='{$size}'></td>\n <td style='font-size:11px'>{$status}\n <input type='hidden' name='import[{$i}][exif]' value='{$exif}'>\n <input type='hidden' name='import[{$i}][type]' value='{$type}'></td>\n </tr>"; $i++; } } closedir($dh); } $main['pics'] = $pics; $main['total_size'] = $total_size; return $main; }
/** * Starts the process of sending an email - preps it so it's fully ready to send. * Call send() to actually send it. * * @param string $toemail Destination email address * @param string $subject Email message subject * @param string $message Email message body * @param string $from Optional name/email to use in 'From' header * @param string $uheaders Additional headers * @param string $username Username of person sending the email * * @return boolean True on success, false on failure */ public function start($toemail, $subject, $message, $from = '', $uheaders = '', $username = '') { $toemail = $this->fetchFirstLine($toemail); if (empty($toemail)) { return false; } $delimiter =& $this->delimiter; $vboptions = vB::getDatastore()->getValue('options'); $toemail = vB_String::unHtmlSpecialChars($toemail); $subject = $this->fetchFirstLine($subject); $message = preg_replace("#(\r\n|\r|\n)#s", $delimiter, trim($message)); if ((strtolower(vB_Template_Runtime::fetchStyleVar('charset')) == 'iso-8859-1' or vB_Template_Runtime::fetchStyleVar('charset') == '') and preg_match('/&[a-z0-9#]+;/i', $message)) { $message = utf8_encode($message); $subject = utf8_encode($subject); $username = utf8_encode($username); $encoding = 'UTF-8'; $unicode_decode = true; } else { if ($vboptions['utf8encode']) { $message = to_utf8($message, vB_Template_Runtime::fetchStyleVar('charset')); $subject = to_utf8($subject, vB_Template_Runtime::fetchStyleVar('charset')); $username = to_utf8($username, vB_Template_Runtime::fetchStyleVar('charset')); $encoding = 'UTF-8'; $unicode_decode = true; } else { // we know nothing about the message's encoding in relation to UTF-8, // so we can't modify the message at all; just set the encoding $encoding = vB_Template_Runtime::fetchStyleVar('charset'); $unicode_decode = false; } } // theses lines may need to call convert_int_to_utf8 directly $message = vB_String::unHtmlSpecialChars($message, $unicode_decode); $subject = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($subject, $unicode_decode), $encoding, false, false); $from = $this->fetchFirstLine($from); if (empty($from)) { $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('x_mailer')); if (isset($vbphrase['x_mailer'])) { $mailfromname = sprintf($this->fetchFirstLine($vbphrase['x_mailer']), $vboptions['bbtitle']); } else { $mailfromname = $vboptions['bbtitle']; } if ($unicode_decode == true) { $mailfromname = utf8_encode($mailfromname); } $mailfromname = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($mailfromname, $unicode_decode), $encoding); $headers = "From: {$mailfromname} <" . $vboptions['webmasteremail'] . '>' . $delimiter; $headers .= 'Auto-Submitted: auto-generated' . $delimiter; // Exchange (Oh Microsoft) doesn't respect auto-generated: http://www.vbulletin.com/forum/project.php?issueid=27687 if ($vboptions['usebulkheader']) { $headers .= 'Precedence: bulk' . $delimiter; } } else { if ($username) { $mailfromname = "{$username} @ " . $vboptions['bbtitle']; } else { $mailfromname = $from; } if ($unicode_decode == true) { $mailfromname = utf8_encode($mailfromname); } $mailfromname = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($mailfromname, $unicode_decode), $encoding); $headers = "From: {$mailfromname} <{$from}>" . $delimiter; $headers .= "Sender: " . $vboptions['webmasteremail'] . $delimiter; } $fromemail = empty($vboptions['bounceemail']) ? $vboptions['webmasteremail'] : $vboptions['bounceemail']; $headers .= 'Return-Path: ' . $fromemail . $delimiter; $http_host = vB::getRequest()->getVbHttpHost(); if (!$http_host) { $http_host = substr(md5($message), 12, 18) . '.vb_unknown.unknown'; } $msgid = '<' . gmdate('YmdHis') . '.' . substr(md5($message . microtime()), 0, 12) . '@' . $http_host . '>'; $headers .= 'Message-ID: ' . $msgid . $delimiter; $headers .= preg_replace("#(\r\n|\r|\n)#s", $delimiter, $uheaders); unset($uheaders); $headers .= 'MIME-Version: 1.0' . $delimiter; $headers .= 'Content-Type: text/plain' . iif($encoding, "; charset=\"{$encoding}\"") . $delimiter; $headers .= 'Content-Transfer-Encoding: 8bit' . $delimiter; $headers .= 'X-Priority: 3' . $delimiter; $headers .= 'X-Mailer: vBulletin Mail via PHP' . $delimiter; if (!empty($vboptions['extra_smtp_headers'])) { $headers .= preg_replace("#\r[^\n]|[^r]\n#", $delimiter, $vboptions['extra_smtp_headers']) . $delimiter; } $this->toemail = $toemail; $this->subject = $subject; $this->message = $message; $this->headers = $headers; $this->fromemail = $fromemail; return true; }
} if (empty($ticket)) { //登录失败 echo '{status: "' . $client->status . '", "errorMsg":"' . $pageContents . '"}'; exit; } $buddy_online_ids = ids_array($pageData->buddies); //在线好友列表ids $clientnum = $pageData->clientnum; $rooms_num = $pageData->roominfo; if (is_object($rooms_num)) { foreach ($rooms_num as $key => $value) { $rooms[$key]['count'] = $value; } } $output = array(); $output['buddy_online_ids'] = join(",", $buddy_online_ids); $output['clientnum'] = $clientnum; $output['server_time'] = microtime(true) * 1000; $output['user'] = array('id' => $space['uid'], 'name' => to_utf8($name), 'pic_url' => avatar($space['uid'], 'small', true), 'status' => '', 'presence' => 'online', 'status_time' => '', 'url' => 'space.php?uid=' . $space['uid']); //用户信息 $imserver = 'http://' . $_IMC['imsvr'] . ':' . $_IMC['impoll']; $output['connection'] = array('domain' => $_IMC['domain'], 'ticket' => $ticket, 'server' => $imserver); //服务器连接 $output['new_messages'] = $new_messages; $output['buddies'] = find_buddy($buddy_ids); $output['rooms'] = $rooms; $output['histories'] = find_history($buddy_ids); new_message_to_histroy(); //新消息转到历史记录 echo json_encode($output);
/** * 通用分页列表数据集获取方法 * * 可以通过url参数传递where条件,例如: index.html?name=asdfasdfasdfddds * 可以通过url空值排序字段和方式,例如: index.html?_field=id&_order=asc */ protected function Pages($conf) { $model = @$conf['model']; $whe = isset($conf['where']) ? $conf['where'] : ''; $join = isset($conf['join']) ? $conf['join'] : ''; $field = isset($conf['field']) ? $conf['field'] : ''; $order = isset($conf['order']) ? $conf['order'] : ''; $rows = isset($conf['rows']) ? $conf['rows'] : 15; $url = isset($conf['url']) ? $conf['url'] : ''; $User = preg_match('/[a-zA-Z0-9]+View/', $model) ? D($model) : M($model); $count = 0; if (is_string($whe)) { $whe = str_replace('__DB_PREFIX__', __DB_PREFIX__, $whe); } else { if (is_array($whe)) { $temarr = array(); foreach ($whe as $key => $val) { $temarr[str_replace('__DB_PREFIX__', __DB_PREFIX__, $key)] = $val; } $whe = $temarr; } } $field = str_replace('__DB_PREFIX__', __DB_PREFIX__, $field); $order = str_replace('__DB_PREFIX__', __DB_PREFIX__, $order); if (is_array($join)) { $join[0] = str_replace('__DB_PREFIX__', __DB_PREFIX__, $join[0]); $join[1] = str_replace('__DB_PREFIX__', __DB_PREFIX__, $join[1]); $count = $User->where($whe)->field($field)->order($order)->join($join[0])->join($join[1])->count(); // 查询满足要求的总记录数 } else { $join = str_replace('__DB_PREFIX__', __DB_PREFIX__, $join); $count = $User->where($whe)->field($field)->order($order)->join($join)->count(); // 查询满足要求的总记录数 } $Page = new \Think\Page($count, $rows); // 实例化分页类 传入总记录数和每页显示的记录数(25) if (!empty($url)) { $Page->url = $url; } //$Page->url=$pageurl; $Page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%'); //分页跳转的时候保证查询条件 $mp = array_merge(I('post.'), I('get.')); if (is_array($mp)) { foreach ($mp as $key => $val) { if (!is_array($val)) { $Page->parameter[$key] = to_utf8($val); } } } $show = $Page->show(); // 分页显示输出 // 进行分页数据查询 注意limit方法的参数要使用Page类的属性 if (is_array($join)) { $list = $User->where($whe)->field($field)->order($order)->join($join[0])->join($join[1])->limit($Page->firstRow . ',' . $Page->listRows)->select(); } else { $list = $User->where($whe)->field($field)->join($join)->order($order)->limit($Page->firstRow . ',' . $Page->listRows)->select(); } $this->assign('_total', $count); $this->assign('_page', $show); // 赋值分页输出 $this->assign('_list', $list); return $list; }
function indexscreen($url, $reindex) { global $db_con, $mysql_table_prefix, $real_log, $debug, $conv_puny, $cyrillic, $curl, $include_dir; /* if ($conv_puny && strstr($url, "xn--")) { require_once "$include_dir/idna_converter.php"; // Initialize the converter class $IDN = new idna_convert(array('idn_version' => 2008)); // Decode it to its readable presentation $url = $IDN->decode($url); } */ $url = urldecode($url); // get it readable if ($cyrillic) { $url = to_utf8($url); // because of the bug in PHP function urldecode() we need special processing for CP1252 charset } $compurl = parse_url("" . $url); // we will need all details of the URL // https scheme requires cURL extension if (!$curl && $compurl['scheme'] == "https") { $message = "<p class='msg cntr'><br /><br /><span class='warnadmin'>Sorry, but in order to index URLs containing the https scheme,<br />you need to install the cURL extension on your server.</span><br /><br /><br /></p>"; echo "{$message}"; addsiteform(); exit; } $check = ""; $levelchecked = 'checked="checked"'; $spider_depth = 2; if ($url == "") { $url = "http://"; $url_crypt = ""; } else { // prepare the URL for multiple & and + as part of the URL $url_crypt = str_replace("&", "-_-", $url); // crypt the & character $url_crypt = str_replace("+", "_-_", $url_crypt); // crypt the + character $url_crypt = htmlentities($url_crypt, ENT_QUOTES); $url_ent = htmlentities($url, ENT_QUOTES); $advurl = $url; $sql_query = "SELECT spider_depth, required, disallowed, can_leave_domain, use_prefcharset from " . $mysql_table_prefix . "sites " . "where url='{$url_ent}'"; $result = $db_con->query($sql_query); if ($result->num_rows) { $row = $result->fetch_array(MYSQLI_NUM); $spider_depth = $row[0]; if ($spider_depth == -1) { $fullchecked = 'checked="checked"'; $spider_depth = ""; $levelchecked = ""; } $must = $row[1]; $mustnot = $row[2]; $canleave = $row[3]; $use_pref = $row[4]; } } echo "<br />\n "; if ($must != "" || $mustnot != "" || $canleave == 1 || $use_pref) { $_SESSION['index_advanced'] = 1; } if ($_SESSION['index_advanced'] == 1) { echo "<form class='cntr sml' action='admin.php' method='post'>\n <input type='hidden' name='f' value='index' />\n <input type='hidden' name='adv' value='0' />\n <input type='hidden' name='url' value='{$url_crypt}' />\n <input class='cntr sbmt' type='submit' id='submit' value=' Hide advanced options ' title='Click to hide the advanced options in this menue' />\n </form>\n "; } else { echo "<form class='cntr sml' action='admin.php' method='post'>\n <input type='hidden' name='f' value='index' />\n <input type='hidden' name='adv' value='1' />\n <input type='hidden' name='url' value='{$url_crypt}' />\n <input class='cntr sbmt' type='submit' id='submit' value=' Show advanced options ' title='Click to show all the advanced options in this menue' />\n </form>\n "; } echo "<br />\n <div class='panel w75'>\n <form class='txt' action='spider.php' method='post'>\n <fieldset><legend>[ Basic Indexing Options ]</legend>\n <label class='em' for='url'>Address:</label>\n <input type='text' name='url' id='url' size='68' maxlength='1024' title='Enter new URL' value='{$url_crypt}' />\n <label class='em' for='soption'>Spidering options:</label>\n <input type='radio' name='soption' id='soption' title='Check box for Full indexing' value='full' {$fullchecked} /> Full<br />\n <input type='radio' name='soption' value='level' title='Check box to limit indexing depth' {$levelchecked} />\n Index depth:\n <input type='text' name='maxlevel' size='2' title='Enter indexing depth level' value='{$spider_depth}' />\n "; if ($reindex == 1) { $check = 'checked="checked"'; } echo "<label class='em' for='reindex'>Re-index</label>\n <input type='checkbox' name='reindex' id='reindex' title='Check box to Re-index' value='1' {$check} /> Check to Re-index\n </fieldset>\n "; if ($_SESSION['index_advanced'] == 1) { if ($canleave == 1) { $checkcan = 'checked="checked"'; } if ($use_pref == 1) { $use_pref = 'checked="checked"'; } echo "<fieldset><legend>[ Advanced Indexing Options ]</legend>\n <label class='em' for='can_leave'>Spider can leave domain?</label>\n <input type='checkbox' name='can_leave' id='can_leave' value='1' title='Check box if Sphider can leave above domain' {$checkcan} /> Check for Yes\n <label class='em' for='use_pref'>Use preferred charset for indexing?</label>\n <input type='checkbox' name='use_pref' id=use_pref'' value='1' title='Check box if Sphider should use the preferred charset as defined in \"Settings\"' {$use_pref} /> Check for Yes\n <label class='em' for='reindex'>robots.txt</label>\n <input type='hidden' name='not_use_robot' value='0' />\n <input type='checkbox' name='not_use_robot' value='1' {$not_use_robot} /> Temporary ignore 'robots.txt'\n <label class='em' for='nofollow'>'nofollow' tags</label>\n <input type='hidden' name='not_use_nofollow' value='0' />\n <input type='checkbox' name='not_use_nofollow' value='1' {$not_use_nofollow} /> Temporary ignore 'nofollow' directive\n </fieldset>\n <fieldset><legend>[ Include/Exclude Options ]</legend>\n <label class='em' for='in'>URL Must include:</label>\n <textarea name='in' id='in' cols='35' rows='5' title='Enter URLs that Must be included, one per line'>{$must}</textarea>\n <label class='em' for='out'>URL must Not include:</label>\n <textarea name='out' id='out' cols='35' rows='5' title='Enter URLs that must Not be included, one per line'>{$mustnot}</textarea></fieldset>\n "; } echo "<fieldset><legend>[ Start Indexing ]</legend>\n "; if ($real_log == '1') { echo "\n <input class='cntr sbmt' type='submit' id='submit' value=' Start ' title='Click to start indexing process' onclick=\"window.open('real_log.php')\" />\n "; } else { echo "\n <input class='cntr sbmt' type='submit' id='submit' value=' Start ' title='Click to start indexing process' />\n "; } echo "\n </fieldset>\n </form>\n </div>\n "; }
private function processregistered(&$value, $charset) { global $VB_API_REQUESTS; if (is_array($value)) { foreach ($value as &$el) { $this->processregistered($el, $charset); } } if (is_string($value)) { $value = preg_replace_callback('/&#([0-9]+);/siU', 'convert_int_to_utf8_callback', to_utf8($value, $charset, true)); $trimmed = trim($value); if ($VB_API_REQUESTS['api_version'] > 1 and ($trimmed == 'checked="checked"' or $trimmed == 'selected="selected"')) { $value = 1; } } if ($VB_API_REQUESTS['api_version'] > 1 and is_bool($value)) { if ($value) { $value = 1; } else { $value = 0; } } }
/** * Redirects to our url if the given uri is not canonical. * * @param string $request_uri - The current uri to check */ public function redirect_canonical_url($request_uri) { // Never redirect a post if ('GET' != $_SERVER['REQUEST_METHOD']) { return; } // Allow hooks to handle non canonical urls ($hook = vBulletinHook::fetch_hook('friendlyurl_redirect_canonical')) ? eval($hook) : false; // Check if canonical enforcement is enabled if (self::CANON_OFF == $this->registry->options['friendlyurl_canonical'] or VB_API) { return; } // Only redirect guests and search engines if ($this->registry->userinfo['userid'] and !$this->registry->options['friendlyurl_canonical_registered']) { return; } // Get the canonical uri if (!isset($canonical_uri)) { // Get the canonical uri $canonical_uri = $this->get_uri(true); } // Whether the request was canonical $canonical = true; // Check Friendly URL method if (FRIENDLY_URL != $this->registry->options['friendlyurl']) { $canonical = false; } // Check URI if ($canonical and self::CANON_STRICT == $this->registry->options['friendlyurl_canonical']) { if ($request_uri != $canonical_uri) { $canonical = false; // request may have been in the current charset, try UTF-8. if ($canonical_uri == to_utf8($request_uri, $this->registry->userinfo['lang_charset'])) { $canonical = true; } // request may have been in UTF-8, try current charset if ($request_uri == to_utf8($canonical_uri, $this->registry->userinfo['lang_charset'])) { $canonical = true; } } } parse_str($_SERVER['QUERY_STRING'], $args); if ($this->registry->options['friendlyurl'] != FRIENDLY_URL_OFF and (isset($args[$this->pagevar]) or isset($args[$this->idkey]))) { $canonical = false; } if ($this->registry->options['friendlyurl'] == FRIENDLY_URL_OFF and !$canonical_uri) { if (isset($this->pagevar)) { $this->ignorelist[] = $this->pagevar; if ($this->pagevar == 'page') { $this->ignorelist[] = 'pagenumber'; } } if ($this->page > 1 and $args[$this->pagevar] != $this->page or $this->page == 1 and isset($args[$this->pagevar])) { $canonical = false; } $canonical = ($canonical and !array_intersect(array_values($this->registry->input->shortvars), array_keys($args))); } // Redirect if incorrect if (!$canonical) { // add the request query string to the pageinfo $this->consume_request_pageinfo(); // redirect url must be raw $url = $this->get_url(false, true); $code = 301; // workaround for goto if (defined('THREADNEXT')) { $url = str_replace('&goto=nextnewest', '', str_replace('&goto=nextoldest', '', str_replace('?goto=nextnewest', '', str_replace('?goto=nextoldest', '', $url)))); $code = 303; } // if its pointing to a post, add the anchor. if ($args['p']) { $url .= '#post' . $args['p']; } // redirect to the correct url exec_header_redirect($url, $code); } }
/** * Handle encoding issues as well as parsing the XML into an array * * @return boolean Success */ function parse_xml() { if ($this->legacy_mode) { return $this->legacy_parse_xml(); } if (preg_match('#(<?xml.*encoding=[\'"])(.*?)([\'"].*?>)#m', $this->xmldata, $match)) { $encoding = strtoupper($match[2]); if ($encoding != 'UTF-8') { // XML will always be UTF-8 at parse time $this->xmldata = str_replace($match[0], "{$match['1']}UTF-8{$match['3']}", $this->xmldata); } if (!$this->encoding) { $this->encoding = $encoding; } } else { if (!$this->encoding) { $this->encoding = 'UTF-8'; } if (strpos($this->xmldata, '<?xml') === false) { // no xml tag, force one $this->xmldata = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $this->xmldata; } else { // xml tag doesn't have an encoding, which is bad $this->xmldata = preg_replace('#(<?xml.*)(\\?>)#', '\\1 encoding="UTF-8" \\2', $this->xmldata); } } // Ensure the XML is UTF-8 if ('UTF-8' !== $this->encoding) { $this->xmldata = to_utf8($this->xmldata, $this->encoding); $this->encoding = 'UTF-8'; } // Parse the XML as UTF-8 if (!$this->parse()) { return false; } return true; }
function mk_rss_xml($the_csn = "") { global $xoopsDB, $xoopsModule, $xoopsConfig; $tadgallery = new tadgallery(); $ok_cat = $tadgallery->chk_cate_power(); if (!empty($the_csn)) { if (in_array($the_csn, $ok_cat)) { $where = "and a.csn='{$the_csn}'"; $cate = $tadgallery->get_tad_gallery_cate($the_csn); $rss_title = $cate['title']; $rss_link = XOOPS_URL . "/modules/tadgallery/index.php?csn={$the_csn}"; $rss_filename = _TADGAL_UP_FILE_DIR . "photos{$the_csn}.rss"; } else { return; } } else { $ok_str = implode("','", $ok_cat); $where = "and a.csn in('{$ok_str}') "; $rss_title = $xoopsConfig['sitename']; $rss_link = XOOPS_URL . "/modules/tadgallery"; $rss_filename = _TADGAL_UP_FILE_DIR . "photos.rss"; } $sql = "select a.sn,a.csn,a.title,a.description,a.filename,a.size,a.dir from " . $xoopsDB->prefix("tad_gallery") . " as a , " . $xoopsDB->prefix("tad_gallery_cate") . " as b where a.csn=b.csn {$where} and b.passwd='' and b.enable_group='' order by a.post_date desc"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error() . "<br>{$sql}"); $main = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n <channel>\n <atom:icon>" . XOOPS_URL . "/modules/tadgallery/images/piclen_logo.png</atom:icon>\n <generator>Tad Gallery</generator>\n <title>{$rss_title}</title>\n <link>{$rss_link}</link>\n <description></description>\n"; while (list($sn, $csn, $title, $description, $filename, $size, $dir) = $xoopsDB->fetchRow($result)) { $title = empty($title) ? $filename : $title; $title = htmlspecialchars($title); $description = htmlspecialchars($description); $filename = urlencode(htmlspecialchars($filename)); $pic_url = $tadgallery->get_pic_url($dir, $sn, $filename); $mpic_url = $tadgallery->get_pic_url($dir, $sn, $filename, "m"); $spic_url = $tadgallery->get_pic_url($dir, $sn, $filename, "s"); $main .= " <item>\n <title>{$title}</title>\n <link>" . XOOPS_URL . "/modules/tadgallery/view.php?sn={$sn}</link>\n <guid>{$sn}-{$csn}</guid>\n <media:thumbnail url=\"{$spic_url}\"/>\n <media:content url=\"{$pic_url}\" fileSize=\"{$size}\" />\n <media:title type=\"plain\">{$title}</media:title>\n <media:description type=\"plain\">{$description}</media:description>\n </item>\n"; } $main .= " </channel>\n</rss>\n"; $main = to_utf8($main); if (!($handle = fopen($rss_filename, 'w'))) { redirect_header($_SERVER['PHP_SELF'], 3, sprintf(_MD_TADPLAYER_CANT_OPEN, $rss_filename)); } if (fwrite($handle, $main) === false) { redirect_header($_SERVER['PHP_SELF'], 3, sprintf(_MD_TADPLAYER_CANT_WRITE, $rss_filename)); } fclose($handle); }
function basic_clean($str, $cut = 0, $is_shortcontent = 0) { if ($is_shortcontent) { $str = preg_replace('/\\[color=.*\\](.*)\\[\\/color\\]/U', '$1', $str); $str = preg_replace('/\\[color=.*\\](.*)/U', '$1', $str); $str = preg_replace('/Code: \\[Select\\]/', 'Code: ', $str); $str = preg_replace('/\\[[u|i|b]\\](.*)\\[\\/[u|i|b]\\]/U', '$1', $str); $str = preg_replace('/-{3}/', '', $str); $str = preg_replace('/\\[quote.*\\](.*?)\\[\\/quote\\]/', '[quote]', $str); $str = preg_replace('/ /', ' ', $str); $str = preg_replace('/&n*b*s*p*$/', '...', $str); } $str = preg_replace('/<a.*?>Quote from:.*?<\\/a>/', ' ', $str); $str = strip_tags($str); $str = to_utf8($str); $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); if (function_exists('censorText')) { censorText($str); } if ($is_shortcontent) { $str = preg_replace('/[\\r\\n]*/', '', $str); } if ($cut > 0) { $str = preg_replace('/\\[url=.*?\\].*?\\[\\/url\\]\\s*\\[quote\\].*?\\[\\/quote\\]/si', '', $str); $str = preg_replace('/\\[.*?\\]/si', '', $str); $str = preg_replace('/[\\n\\r\\t]+/', ' ', $str); $str = preg_replace('/\\s+/', ' ', $str); $str = trim($str); $str = cutstr($str, $cut); } return trim($str); }
/** * convert to utf8 and then make json encode. * */ function json_encode_utf8($in) { return json_encode(to_utf8($in)); }
if (strlen($mimetype) && $mimetype != "text/plain") { continue; } switch ($encoding) { case "quoted-printable": $line = quoted_printable_decode($line); break; case "base64": $line = base64_decode($line); break; } // we can't convert it to UTF, because cvs commits don't have charset info // so its preferable to leave it as-is, and let users choose the correct charset // in their browser. this is specially important for php.doc.* groups if ($charset && strpos(strtolower($charset), 'utf-8') === false) { $line = to_utf8($line, $charset); } $line = $linebuf . $line; if (in_array(substr($line, -1), array("\n", "\r"))) { $linebuf = ''; } else { $linebuf = $line; continue; } # this is some amazingly simplistic code to color quotes/signatures # differently, and turn links into real links. it actually appears # to work fairly well, but could easily be made more sophistimicated. /* NOQUOTES? Why? It creates invalid HTML: http:"x */ $line = htmlentities($line, ENT_QUOTES, "utf-8"); $line = preg_replace("/((mailto|https?|ftp|nntp|news):.+?)(>|\\s|\\)|\\.\\s|\$)/", "<a href=\"\\1\">\\1</a>\\3", $line); if (!$insig && $line == "-- \r\n") {
/** * Starts the process of sending an email - preps it so it's fully ready to send. * Call send() to actually send it. * * @param string Destination email address * @param string Email message subject * @param string Email message body * @param string Optional name/email to use in 'From' header * @param string Additional headers * @param string Username of person sending the email * * @param boolean True on success, false on failure */ function start($toemail, $subject, $message, $from = '', $uheaders = '', $username = '') { $toemail = $this->fetch_first_line($toemail); if (empty($toemail)) { return false; } $delimiter =& $this->delimiter; $vbulletin =& $this->registry; $toemail = unhtmlspecialchars($toemail); $subject = $this->fetch_first_line($subject); $message = preg_replace("#(\r\n|\r|\n)#s", $delimiter, trim($message)); if ((strtolower(vB_Template_Runtime::fetchStyleVar('charset')) == 'iso-8859-1' or vB_Template_Runtime::fetchStyleVar('charset') == '') and preg_match('/&[a-z0-9#]+;/i', $message)) { $message = utf8_encode($message); $subject = utf8_encode($subject); $username = utf8_encode($username); $encoding = 'UTF-8'; $unicode_decode = true; } else { if ($this->registry->options['utf8encode']) { $message = to_utf8($message, vB_Template_Runtime::fetchStyleVar('charset')); $subject = to_utf8($subject, vB_Template_Runtime::fetchStyleVar('charset')); $username = to_utf8($username, vB_Template_Runtime::fetchStyleVar('charset')); $encoding = 'UTF-8'; $unicode_decode = true; } else { // we know nothing about the message's encoding in relation to UTF-8, // so we can't modify the message at all; just set the encoding $encoding = vB_Template_Runtime::fetchStyleVar('charset'); $unicode_decode = false; } } $message = unhtmlspecialchars($message, $unicode_decode); $subject = $this->encode_email_header(unhtmlspecialchars($subject, $unicode_decode), $encoding, false, false); $from = $this->fetch_first_line($from); if (empty($from)) { global $vbphrase; if (isset($vbphrase['x_mailer'])) { $mailfromname = construct_phrase($this->fetch_first_line($vbphrase['x_mailer']), $vbulletin->options['bbtitle']); } else { $mailfromname = $vbulletin->options['bbtitle']; } if ($unicode_decode == true) { $mailfromname = utf8_encode($mailfromname); } $mailfromname = $this->encode_email_header(unhtmlspecialchars($mailfromname, $unicode_decode), $encoding); $headers .= "From: {$mailfromname} <" . $vbulletin->options['webmasteremail'] . '>' . $delimiter; $headers .= 'Auto-Submitted: auto-generated' . $delimiter; // Exchange (Oh Microsoft) doesn't respect auto-generated: http://www.vbulletin.com/forum/project.php?issueid=27687 if ($vbulletin->options['usebulkheader']) { $headers .= 'Precedence: bulk' . $delimiter; } } else { if ($username) { $mailfromname = $username . " - " . $vbulletin->options['bbtitle']; } else { $mailfromname = $from; } if ($unicode_decode == true) { $mailfromname = utf8_encode($mailfromname); } $mailfromname = $this->encode_email_header(unhtmlspecialchars($mailfromname, $unicode_decode), $encoding); $headers .= "From: {$mailfromname} <{$from}>" . $delimiter; $headers .= "Sender: " . $vbulletin->options['webmasteremail'] . $delimiter; } $fromemail = empty($vbulletin->options['bounceemail']) ? $vbulletin->options['webmasteremail'] : $vbulletin->options['bounceemail']; $headers .= 'Return-Path: ' . $fromemail . $delimiter; $http_host = VB_HTTP_HOST; if (!$http_host) { $http_host = substr(md5($message), 12, 18) . '.vb_unknown.unknown'; } $msgid = '<' . gmdate('YmdHis') . '.' . substr(md5($message . microtime()), 0, 12) . '@' . $http_host . '>'; $headers .= 'Message-ID: ' . $msgid . $delimiter; $headers .= preg_replace("#(\r\n|\r|\n)#s", $delimiter, $uheaders); unset($uheaders); $headers .= 'MIME-Version: 1.0' . $delimiter; $headers .= 'Content-Type: text/plain' . iif($encoding, "; charset=\"{$encoding}\"") . $delimiter; $headers .= 'Content-Transfer-Encoding: 8bit' . $delimiter; $headers .= 'X-Priority: 3' . $delimiter; $headers .= 'X-Mailer: vBulletin Mail via PHP' . $delimiter; ($hook = vBulletinHook::fetch_hook('mail_send')) ? eval($hook) : false; $this->toemail = $toemail; $this->subject = $subject; $this->message = $message; $this->headers = $headers; $this->fromemail = $fromemail; return true; }
<?php include_once 'common.php'; require 'http_client.php'; $ticket = gp('ticket'); $body = gp('body', ''); $style = gp('style', 'msg'); $to = gp('to'); $from = $space['uid']; $time = microtime(true) * 1000; if (empty($to) || empty($from)) { echo '{error:true}'; exit; } $client = new HttpClient($_IMC['imsvr'], $_IMC['impost']); $nick = to_unicode(to_utf8(nick($space))); $client->post('/messages', array('domain' => $_IMC['domain'], 'apikey' => $_IMC['apikey'], 'ticket' => $ticket, 'nick' => $nick, 'to' => $to, 'body' => to_unicode($body), 'timestamp' => (string) $time, 'style' => $style)); //TODO: if forward message successfully. $message = array('to' => $to, 'from' => $from, 'style' => $style, 'body' => from_utf8($body), 'timestamp' => $time); inserttable('im_histories', $message); echo "ok";
function url_to_utf8($url) { return to_utf8(rawurldecode($url)); }
function to_utf8($string) { if (preg_match('%^(?: [\\x09\\x0A\\x0D\\x20-\\x7E] # ASCII | [\\xC2-\\xDF][\\x80-\\xBF] # non-overlong 2-byte | \\xE0[\\xA0-\\xBF][\\x80-\\xBF] # excluding overlongs | [\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2} # straight 3-byte | \\xED[\\x80-\\x9F][\\x80-\\xBF] # excluding surrogates | \\xF0[\\x90-\\xBF][\\x80-\\xBF]{2} # planes 1-3 | [\\xF1-\\xF3][\\x80-\\xBF]{3} # planes 4-15 | \\xF4[\\x80-\\x8F][\\x80-\\xBF]{2} # plane 16 )*$%xs', $string)) { return $string; } else { return iconv('CP1252', 'UTF-8', $string); } } session_start(); if ($_SESSION['key'] != $_POST['key'] or $_POST['key'] == "") { echo "<p class=\"EJ_user_error\"><strong>AUTHORISATION ERROR</strong>: Unable to verify key!</p>"; } else { $EJ_initPage = 'ajax'; require '../../init.inc.php'; if (!isset($_POST['id'])) { $query = "INSERT INTO {$EJ_mysql->prefix}module_EJ_events SET EJ_eventTitle='" . urldecode(to_utf8($_POST['title'])) . "', EJ_eventText='" . nl2br(urldecode(to_utf8($_POST['desc']))) . "', EJ_eventCat = {$_POST['cat']}, EJ_eventDate = '" . date("Y-m-d", strtotime($_POST['date'])) . "', EJ_eventImage='" . $_POST['image'] . "', EJ_eventHidden = " . $_POST['hidden'] . ", EJ_eventPoster = '" . $_POST['poster'] . "', EJ_eventTime = '" . $_POST['time'] . "', EJ_eventLoc1 = '" . $_POST['location1'] . "', EJ_eventLoc2 = '" . $_POST['location2'] . "', EJ_eventLoc3 = '" . $_POST['location3'] . "', EJ_eventLoc4 = '" . $_POST['location4'] . "', EJ_eventLoc5 = '" . $_POST['location5'] . "', EJ_eventContact = '" . $_POST['contact'] . "'"; } else { $query = "UPDATE {$EJ_mysql->prefix}module_EJ_events SET EJ_eventTitle='" . urldecode(to_utf8($_POST['title'])) . "', EJ_eventText='" . nl2br(urldecode(to_utf8($_POST['desc']))) . "', EJ_eventCat = " . $_POST['cat'] . ", EJ_eventDate = '" . date("Y-m-d", strtotime($_POST['date'])) . "', EJ_eventImage='" . $_POST['image'] . "', EJ_eventHidden = " . $_POST['hidden'] . ", EJ_eventPoster = '" . $_POST['poster'] . "', EJ_eventTime = '" . $_POST['time'] . "', EJ_eventLoc1 = '" . $_POST['location1'] . "', EJ_eventLoc2 = '" . $_POST['location2'] . "', EJ_eventLoc3 = '" . $_POST['location3'] . "', EJ_eventLoc4 = '" . $_POST['location4'] . "', EJ_eventLoc5 = '" . $_POST['location5'] . "', EJ_eventContact = '" . $_POST['contact'] . "' WHERE EJ_eventId = " . $_POST['id'] . ""; } $EJ_mysql->query($query); echo "OK"; }
private function processregistered(&$value, $charset) { global $VB_API_REQUESTS; if (is_array($value)) { foreach ($value as &$el) { $this->processregistered($el, $charset); } } if (is_string($value)) { $value = unhtmlspecialchars(to_utf8($value, $charset, true), true); $trimmed = trim($value); if ($VB_API_REQUESTS['api_version'] > 1 and ($trimmed == 'checked="checked"' or $trimmed == 'selected="selected"')) { $value = 1; } } if ($VB_API_REQUESTS['api_version'] > 1 and is_bool($value)) { if ($value) { $value = 1; } else { $value = 0; } } }
function get_request_values($varlist) { $vars = explode(",", $varlist); foreach ($vars as $v) { if (isset($_REQUEST[$v])) { if (is_array($_REQUEST[$v])) { $GLOBALS[$v] = $_REQUEST[$v]; } else { $GLOBALS[$v] = to_utf8($_REQUEST[$v]); } if ($v == "submit") { /* Pages with $_ENV["AllowPostWithoutReferer"] set will always pass */ $ok = array_key_exists("AllowPostWithoutReferer", $_ENV) ? true : false; if (array_key_exists("HTTP_REFERER", $_SERVER)) { $proto = array_key_exists("HTTPS", $_SERVER) ? "https://" : "http://"; $ref = strtolower($proto . $_SERVER["HTTP_HOST"]); if (substr(strtolower($_SERVER["HTTP_REFERER"]), 0, strlen($ref)) == $ref) { $ok = true; } } if (!$ok) { # die("Suspected CSRF Attack"); } } } else { switch ($v) { case "rowcount": case "sortorder": break; default: if (!isset($GLOBALS[$v])) { $GLOBALS[$v] = false; } } } } if (!is_array($GLOBALS[$v])) { $GLOBALS["q_" . $v] = "'" . addslashes($GLOBALS[$v]) . "'"; } // can't use database specific yet, not defined. }
/** * Verify Friendly URL * Ensures the requested URL was in the correct format according to the * friendlyurl option. If not, throw a 301 to the correct route. */ public function assertFriendlyUrl() { // API don't need to redirect if (defined('VB_API') and VB_API === true) { return; } // Only redirect on GET if ('GET' != $_SERVER['REQUEST_METHOD']) { return; } // If this route isn't valid then we'll be 404'ing anyway if (!$this->isValid()) { return; } // If we don't have an entry path then there's nothing to do if (!($request_path = vB_Router::getEntryPath())) { return; } // Allow hooks to handle non canonical urls ($hook = vBulletinHook::fetch_hook('friendlyurl_redirect_canonical_route')) ? eval($hook) : false; // Check if we should be enforcing the canonical url if (vB_Friendly_Url::CANON_OFF == vB::$vbulletin->options['friendlyurl_canonical']) { return; } // Only redirect guests and search engines if (vB::$vbulletin->userinfo['userid'] and !vB::$vbulletin->options['friendlyurl_canonical_registered']) { return; } // Get the canonical path if (!isset($canonical_path)) { $canonical_path = $this->getRoutePath(false, vB_Friendly_Url::CANON_STRICT == vB::$vbulletin->options['friendlyurl_canonical'], true); } // Whether the request was canonical $canonical = true; // If no route path is specified then only rewrite can differ if ($request_path == VB_ROUTER_SEGMENT) { //This looks like a bug. The second "==" should be an "AND". This is based on the fact that how its written doesn't //make a lot of sense and the behavior with the change is more consistant. However its a bug with senority at this //point and fixing it will change how urls behave. For the time being leaving it alone is better than the risk of //changing it. if ((FRIENDLY_URL == FRIENDLY_URL_REWRITE) == (vB::$vbulletin->options['friendlyurl'] == FRIENDLY_URL_REWRITE)) { return; } } // Check the Friendly URL method if (FRIENDLY_URL !== intval(vB::$vbulletin->options['friendlyurl'])) { $canonical = false; } // Check URI if ($canonical and vB_Friendly_URL::CANON_STRICT == vB::$vbulletin->options['friendlyurl_canonical']) { if ($request_path != $canonical_path) { // request may have been in the current charset, try utf-8 $request_path = to_utf8($request_path, vB::$vbulletin->userinfo['lang_charset']); if ($request_path != $canonical_path) { $canonical = false; } } } // Redirect if incorrect if (!$canonical) { // Get the raw redirect url $url = $this->getCurrentURL(null, null, '', false, true); // add any query vars $vars = $_GET; unset($vars[vB::$vbulletin->options['route_requestvar']]); unset($vars['pagenumber']); // Remove duplicate created by shortvar code if (!empty($vars)) { $url .= (strpos($url, '?') ? '&' : '?') . urlimplode($vars, false, true); } //do a quick check to ensure that we aren't trying to redirect to the url //we came in on. This is needed primarily because of a special case where the //friendly url logic doesn't correctly detect the rewrite URL version of the //incoming link and will attempt to redirect because they don't match. $url = create_full_url($url); $cleaned_url = vB::$vbulletin->input->xss_clean(vB::$vbulletin->input->strip_sessionhash($url)); $cleaned_url = $this->domain_to_lower($cleaned_url); //if ($url != VB_URL_CLEAN) if (urldecode($cleaned_url) != urldecode($this->domain_to_lower(VB_URL_CLEAN))) { // redirect to the canonical url exec_header_redirect($url, 301); } } }
{ $host = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER["SCRIPT_NAME"]; $pos = strrpos($host, "/game/reg/login2.php"); return substr($host, 0, $pos + 1); } function to_utf8($string) { // From http://w3.org/International/questions/qa-forms-utf-8.html if (preg_match('%^(?: [\\x09\\x0A\\x0D\\x20-\\x7E] # ASCII | [\\xC2-\\xDF][\\x80-\\xBF] # non-overlong 2-byte | \\xE0[\\xA0-\\xBF][\\x80-\\xBF] # excluding overlongs | [\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2} # straight 3-byte | \\xED[\\x80-\\x9F][\\x80-\\xBF] # excluding surrogates | \\xF0[\\x90-\\xBF][\\x80-\\xBF]{2} # planes 1-3 | [\\xF1-\\xF3][\\x80-\\xBF]{3} # planes 4-15 | \\xF4[\\x80-\\x8F][\\x80-\\xBF]{2} # plane 16 )*$%xs', $string)) { return $string; } else { return iconv('CP1252', 'UTF-8', $string); } } if ($_SERVER['REQUEST_METHOD'] === "POST") { Login($_POST['login'], $_POST['pass']); } else { if ($_SERVER['REQUEST_METHOD'] === "GET") { Login(to_utf8($_GET['login']), to_utf8($_GET['pass'])); } } echo "<html><head><meta http-equiv='refresh' content='0;url={$StartPage}' /></head><body></body></html>";
public function Write($h, $txt, $link = '', $fill = 0, $align = '', $ln = false, $stretch = 0) { return parent::Write($h, to_utf8($txt), $link, $fill, $align, $ln, $stretch); }
<?php //言語設定(UTF-8/Base64) mb_language("uni"); //内部文字コード mb_internal_encoding("UTF-8"); //文字コードを UTF-8 に変換する function to_utf8($str) { return mb_convert_encoding($str, "UTF-8", "SJIS"); } //SMTPサーバーの設定(Windows 環境用の設定) ini_set("SMTP", $argv[1]); $subject = to_utf8($argv[4]); $body = to_utf8(stream_get_contents(STDIN)); mb_send_mail($argv[3], $subject, $body, "From: {$argv['2']}");