コード例 #1
0
ファイル: misc.func.php プロジェクト: hongz1125/devil
function convertip($ip)
{
    $return = '';
    if (preg_match("/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\$/", $ip)) {
        $iparray = explode('.', $ip);
        if ($iparray[0] == 10 || $iparray[0] == 127 || $iparray[0] == 192 && $iparray[1] == 168 || $iparray[0] == 172 && ($iparray[1] >= 16 && $iparray[1] <= 31)) {
            $return = '- LAN';
        } elseif ($iparray[0] > 255 || $iparray[1] > 255 || $iparray[2] > 255 || $iparray[3] > 255) {
            $return = '- Invalid IP Address';
        } else {
            $tinyipfile = S_ROOT . './data/ipdata/tinyipdata.dat';
            $fullipfile = S_ROOT . './data/ipdata/wry.dat';
            if (@file_exists($tinyipfile)) {
                $return = encodeconvert('GBK', convertip_tiny($ip, $tinyipfile));
            } elseif (@file_exists($fullipfile)) {
                $return = encodeconvert('GBK', convertip_full($ip, $fullipfile));
            }
        }
    }
    return $return;
}
コード例 #2
0
ファイル: admin_robots.php プロジェクト: superman1982/ng-cms
function geturlfile($url, $encode = 1)
{
    global $thevalue, $_SCONFIG;
    $text = '';
    if (!empty($url)) {
        if (function_exists('file_get_contents')) {
            @($text = file_get_contents($url));
        } else {
            @($carr = file($url));
            if (!empty($carr) && is_array($carr)) {
                $text = implode('', $carr);
            }
        }
    }
    $text = str_replace('·', '', $text);
    if (!empty($thevalue['encode']) && $encode == 1) {
        if (function_exists('iconv')) {
            $text = iconv($thevalue['encode'], $_SCONFIG['charset'], $text);
        } else {
            $text = encodeconvert($thevalue['encode'], $text);
        }
    }
    return $text;
}
コード例 #3
0
ファイル: robot.func.php プロジェクト: superman1982/ng-cms
function getrobotmeg($referurl, $robotlevel = 2)
{
    global $_SCONFIG;
    $searchcursory = array("/\\<(script|style|textarea)[^\\>]*?\\>.*?\\<\\/(\\1)\\>/si", "/\\<!*(--|doctype|html|head|meta|link|body)[^\\>]*?\\>/si", "/<\\/(html|head|meta|link|body)\\>/si", "/([\r\n])\\s+/", "/\\<(table|div)[^\\>]*?\\>/si", "/\\<\\/(table|div)\\>/si");
    $replacecursory = array("", "", "", "\\1", "\n\n###table div explode###\n\n", "\n\n###table div explode###\n\n");
    $searchaborative = array("/\\<(iframe)[^\\>]*?\\>.*?\\<\\/(\\1)\\>/si", "/\\<[\\/\\!]*?[^\\<\\>]*?\\>/si", "/\t/", "/[\r\n]+/", "/(^[\r\n]|[\r\n]\$)+/", "/&(quot|#34);/i", "/&(amp|#38);/i", "/&(lt|#60);/i", "/&(gt|#62);/i", "/&(nbsp|#160|\t);/i", "/&(iexcl|#161);/i", "/&(cent|#162);/i", "/&(pound|#163);/i", "/&(copy|#169);/i", "/&#(\\d+);/e");
    $replaceaborative = array("", "", "", "\n", "", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)");
    $arrayrobotmeg = array();
    $sourcehtml = sreadfile($referurl, 'r', 1);
    //¶ÁÈ¡ÍøÒ³
    $sourcecharset = postget('charset');
    if (empty($sourcecharset) && $sourcecharset == '') {
        preg_match_all("/\\<meta[^\\<\\>]+charset=([^\\<\\>\"\\'\\s]+)[^\\<\\>]*\\>/i", $sourcehtml, $temp, PREG_SET_ORDER);
        $sourcecharset = isset($temp) && !empty($temp) ? trim(strtoupper($temp[0][1])) : $_SCONFIG['charset'];
    }
    $sourcehtml = encodeconvert($sourcecharset, $sourcehtml);
    $sourcetext = getimageurl($referurl, preg_replace($searchcursory, $replacecursory, $sourcehtml));
    if ($robotlevel == 1) {
        $leachsubject = '';
        preg_match_all("/\\<title[^\\>]*?\\>(.*)\\<\\/title\\>/is", $sourcetext, $temp, PREG_SET_ORDER);
        $leachsubject = $temp[0][1];
        $sourcetext = preg_replace("/\n\n###table div explode###\n\n/", '', $sourcetext);
        $leachmessage = preg_replace("/[\r\n]+/", '<br />', preg_replace($searchaborative, $replaceaborative, $sourcetext));
    } elseif ($robotlevel == 2) {
        $arraysource = explode("\n\n###table div explode###\n\n", $sourcetext);
        $arraycell = array();
        foreach ($arraysource as $value) {
            $cell = array('code' => $value, 'text' => preg_replace("/[\n\r\\s]*?/is", "", preg_replace($searchaborative, $replaceaborative, $value)), 'pr' => 0, 'title' => '', 'process' => '');
            if ($cell['text'] != '') {
                $arraycell[] = getpr($cell, $searchaborative, $replaceaborative);
            }
        }
        $arraysubject = $arraymessage = array();
        $leachsubject = $leachmessage = '';
        foreach ($arraycell as $value) {
            if ($value['title'] == 'title') {
                $arraysubject[] = $value;
            } elseif ($value['pr'] >= 0) {
                $arraymessage[] = $value['code'];
            }
        }
        $pr = '';
        foreach ($arraysubject as $value) {
            if ($pr < $value['pr'] || empty($pr)) {
                $leachsubject = $value['text'];
            }
            $pr = $value['pr'];
        }
        $leachmessage = preg_replace("/\\<(p|br)[^\\>]*?\\>/si", "\n", implode("\n", $arraymessage));
        $arraymessage = explode("\n", preg_replace($searchaborative, $replaceaborative, $leachmessage));
        $leachmessage = '';
        foreach ($arraymessage as $value) {
            if (trim($value) != '') {
                $leachmessage .= "<p>\t" . trim($value) . "</p>";
            }
        }
    }
    $arrayrobotmeg['leachsubject'] = $leachsubject;
    $arrayrobotmeg['leachmessage'] = $leachmessage;
    $arrayrobotmeg['charset'] = $sourcecharset;
    return $arrayrobotmeg;
}
コード例 #4
0
ファイル: batch.common.php プロジェクト: jonycookie/projectm2
} elseif ($action == 'relatekw') {
    $subjectenc = rawurlencode(strip_tags($_GET['subjectenc']));
    $messageenc = rawurlencode(strip_tags($_GET['messageenc']));
    $return = '';
    $data = @implode('', file("http://keyword.discuz.com/related_kw.html?title={$subjectenc}&content={$messageenc}&ics={$charset}&ocs={$charset}"));
    if ($data) {
        $parser = xml_parser_create();
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
        xml_parse_into_struct($parser, $data, $values, $index);
        xml_parser_free($parser);
        $kws = array();
        foreach ($values as $valuearray) {
            if ($valuearray['tag'] == 'kw' || $valuearray['tag'] == 'ekw') {
                if (PHP_VERSION > '5' && $charset != 'utf-8') {
                    $valuearray['value'] = encodeconvert("UTF-8", $valuearray['value']);
                } else {
                    $valuearray['value'] = trim($valuearray['value']);
                }
                $kws[] = $valuearray['value'];
            }
        }
        if ($kws) {
            foreach ($kws as $kw) {
                $kw = htmlspecialchars($kw);
                $return .= $kw . ' ';
            }
            $return = htmlspecialchars($return);
        }
    }
    showxml($return);