<?php /* * Created on 2008/09/04 by nao-pon http://hypweb.net/ * License: GPL v2 or (at your option) any later version * $Id: redirect.php,v 1.4 2011/11/22 09:07:53 nao-pon Exp $ */ // clear output buffer while (ob_get_level()) { ob_end_clean(); } define('UNIX_TIME', isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time()); if (isset($_GET['l'])) { $url = $_GET['l']; $info = get_url_info($url); $mobile = $info['handheld'] ? '<p>Mobile: <a href="' . $info['handheld'] . '">' . $info['handheld'] . '</a><p>' : ''; $lasturl = $type = $size = ''; if ($info['header']) { if (preg_match('/^Content-Type:\\s*(.+)$/mi', $info['header'], $match)) { $type = '<p>Content type: ' . htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8') . '</p>'; } if (preg_match('/^Content-Length:\\s*([\\d]+)/mi', $info['header'], $match)) { $size = '<p>Content size: ' . floor($match[1] / 1024) . 'KB' . '</p>'; } } if ($info['lasturl']) { $lasturl = '<br />(' . htmlspecialchars($info['lasturl'], ENT_COMPAT, 'UTF-8') . ')'; } $google = 'http://www.google.co.jp/gwt/n?u=' . rawurlencode($url); $url = str_replace('&', '&', htmlspecialchars($_GET['l'], ENT_COMPAT, 'UTF-8')); $lang = XOOPS_TRUST_PATH . '/class/hyp_common/language/' . $xoopsConfig['language'] . '/redirect.lng.php';
function _process_content($content, $topic_info = array()) { $return = array(); $content .= ' '; $cont_sch = $cont_rpl = $at_uids = $tags = $urls = array(); # @user if (false !== strpos($content, '@')) { if (preg_match_all('~\\@([\\w\\d\\_\\-\\x7f-\\xff]+)(?:[\\r\\n\\t\\s ]+|[\\xa1\\xa1]+)~', $content, $match)) { if (is_array($match[1]) && count($match[1])) { foreach ($match[1] as $k => $v) { $v = trim($v); if (' ' == substr($v, -2)) { $v = substr($v, 0, -2); } if ($v && strlen($v) < 16) { $match[1][$k] = $v; } } $sql = "select `uid`,`uname`,`uemail` from `" . "user` where `uname` in ('" . implode("','", $match[1]) . "')"; $query = $this->DatabaseHandler->Query($sql); while (false != ($row = $query->GetRow())) { $_at = "@{$row['uname']} "; $cont_sch[$_at] = $_at; $cont_rpl[$_at] = "<M {$row['uid']}>@{$row['uid']}</M> "; $at_uids[$row['uid']] = $row['uid']; } } } } if (false !== strpos($content, '#')) { if (preg_match_all('~\\#([^\\-\\#\\$\\{\\}\\(\\)\\;\\<\\>\\\\]+?)\\#~', $content, $match)) { $i = 0; foreach ($match[1] as $v) { $v = trim($v); if (($vl = strlen($v)) < 2 || $vl > 50) { continue; } $tags[$v] = $v; $_tag = "#{$v}#"; $cont_sch[$_tag] = $_tag; $cont_rpl[$_tag] = "<T>#{$v}#</T>"; if (++$i >= $tag_num) { break; } } } } if (false !== strpos($content, ':/' . '/') || false !== strpos($content, 'www.')) { if (preg_match_all('~(?:https?\\:\\/\\/|www\\.)(?:[A-Za-z0-9\\_\\-]+\\.)+[A-Za-z0-9]{1,4}(?:\\:\\d{1,6})?(?:\\/[\\w\\d\\/=\\?%\\-\\&\\;_\\~\\`\\:\\+\\#\\.\\@\\[\\]]*(?:[^\\<\\>\'\\"\\n\\r\\t\\s\\x7f-\\xff])*)?~i', $content, $match)) { foreach ($match[0] as $v) { $v = trim($v); if (($vl = strlen($v)) < 8) { continue; } if (strtolower($this->Config['site_url']) == strtolower(substr($v, 0, strlen($this->Config['site_url'])))) { continue; } if (!($arr = get_url_info($v))) { continue; } $_process_result = array(); if (!isset($urls[$v]) && ($_process_result = $this->_process_url($v))) { $urls[$v] = $_process_result; } $rpl = ($_process_result['content'] ? " {$_process_result['content']} " : "") . "<U {$arr['key']}>{$v}</U>"; if ('image' == $_process_result['type']) { $rpl = ' '; if (strlen(trim($content)) <= strlen($v)) { $rpl = ' 分享图片 '; } } elseif ('music' == $_process_result['type']) { $rpl = ' '; if (strlen(trim($content)) <= strlen($v)) { $rpl = ' 分享音乐 '; } } $cont_sch[$v] = "{$v}"; $cont_rpl[$v] = $rpl; } } } if ($cont_sch && $cont_rpl) { uasort($cont_sch, create_function('$a, $b', 'return (strlen($a)<strlen($b));')); foreach ($cont_sch as $k => $v) { if ($v && isset($cont_rpl[$k])) { $content = str_replace($v, $cont_rpl[$k], $content); } } } $content = trim($content); $return['content'] = $content; $return['at_uids'] = $at_uids; $return['tags'] = $tags; $return['urls'] = $urls; return $return; }