コード例 #1
0
ファイル: inc_coonepage.php プロジェクト: hensonvip/ymroad
/**
 *  获取一个页面
 *
 * @access    public
 * @param     string  $gurl  操作地址
 * @return    string
 */
function CoOnePage($gurl)
{
    global $dsql, $cfg_auot_description, $cfg_soft_lang;
    $redatas = array('title' => '', 'body' => '', 'source' => '', 'writer' => '', 'description' => '', 'keywords' => '');
    $redatas['source'] = preg_replace("/http:\\/\\//i", "", $gurl);
    $redatas['source'] = preg_replace("/\\/(.*)\$/i", "", $redatas['source']);
    $row = $dsql->GetOne("SELECT * FROM `#@__co_onepage` WHERE url LIKE '" . $redatas['source'] . "' ");
    $s = $e = '';
    if (is_array($row)) {
        list($s, $e) = explode('{@body}', $row['rule']);
        $s = trim($s);
        $e = trim($e);
        if ($row['issource'] == 1) {
            $redatas['source'] = $row['title'];
        }
    }
    $htd = new DedeHttpDown();
    $htd->OpenUrl($gurl);
    $body = $htd->GetHtml();
    if ($body != '') {
        //编码自动转换
        if ($cfg_soft_lang == 'utf-8') {
            if ($row['lang'] == 'gb2312') {
                $body = gb2utf8($body);
            }
        } else {
            if ($cfg_soft_lang == 'gb2312') {
                if ($row['lang'] == 'utf-8') {
                    $body = utf82gb($body);
                }
            }
        }
        //获取标题
        $inarr = array();
        preg_match("/<title>(.*)<\\/title>/isU", $body, $inarr);
        if (isset($inarr[1])) {
            $redatas['title'] = $inarr[1];
        }
        //获取关键词
        $inarr = array();
        preg_match("/<meta[\\s]+name=['\"]keywords['\"] content=['\"](.*)['\"]/isU", $body, $inarr);
        if (isset($inarr[1])) {
            $redatas['keywords'] = cn_substr(html2text($inarr[1]), 30);
        }
        //获取摘要
        $inarr = array();
        preg_match("/<meta[\\s]+name=['\"]description['\"] content=['\"](.*)['\"]/isU", $body, $inarr);
        if (isset($inarr[1])) {
            $redatas['description'] = cn_substr(html2text($inarr[1]), $cfg_auot_description);
        }
        //获取内容
        if ($s != '' && $e != '') {
            $redatas['body'] = GetHtmlAreaA($s, $e, $body);
            if ($redatas['body'] != '' && $redatas['description'] == '') {
                $redatas['description'] = cn_substr(html2text($redatas['body']), $GLOBALS['cfg_auot_description']);
            }
        }
    }
    return $redatas;
}
コード例 #2
0
ファイル: flink.lib.php プロジェクト: JaniseSheng/wwwroot
function lib_flink(&$ctag, &$refObj)
{
    global $dsql, $cfg_soft_lang;
    $attlist = "type|textall,row|24,titlelen|24,linktype|1,typeid|0";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $totalrow = $row;
    $revalue = '';
    if (isset($GLOBALS['envs']['flinkid'])) {
        $typeid = $GLOBALS['envs']['flinkid'];
    }
    $wsql = " where ischeck >= '{$linktype}' ";
    if ($typeid == 0) {
        $wsql .= '';
    } else {
        if ($typeid == 999) {
            require DEDEDATA . '/admin/config_update.php';
            if (!class_exists('DedeHttpDown', false)) {
                require_once DEDEINC . '/dedehttpdown.class.php';
            }
            $del = new DedeHttpDown();
            $del->OpenUrl($linkHost);
            $linkUrl = $del->GetHtml() . "flink.php?lang={$cfg_soft_lang}&site={$_SERVER['SERVER_NAME']}";
            $del->OpenUrl($linkUrl);
            $linkInfo = $del->GetHtml();
            if (!empty($linkInfo)) {
                $dedelink = explode("\t", $linkInfo);
                for ($i = 0; $i < count($dedelink); $i++) {
                    if ($i % 5 == 0 && $i != count($dedelink)) {
                        $revalue .= "<li><a href='http://" . @$dedelink[$i + 1] . "' target='_blank' title='" . @$dedelink[$i + 4] . "'>" . @$dedelink[$i] . "</a></li>";
                    }
                }
            }
            return $revalue;
        } else {
            $wsql .= "And typeid = '{$typeid}'";
        }
    }
    if ($type == 'image') {
        $wsql .= " And logo<>'' ";
    } else {
        if ($type == 'text') {
            $wsql .= " And logo='' ";
        }
    }
    $equery = "SELECT * FROM #@__flink {$wsql} order by sortrank asc limit 0,{$totalrow}";
    if (trim($ctag->GetInnerText()) == '') {
        $innertext = "<li>[field:link /]</li>";
    } else {
        $innertext = $ctag->GetInnerText();
    }
    $dsql->SetQuery($equery);
    $dsql->Execute();
    while ($dbrow = $dsql->GetObject()) {
        if ($type == 'text' || $type == 'textall') {
            $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
        } else {
            if ($type == 'image') {
                $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='88' height='31' border='0'></a> ";
            } else {
                if ($dbrow->logo == '') {
                    $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
                } else {
                    $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='88' height='31' border='0'></a> ";
                }
            }
        }
        $rbtext = preg_replace("/\\[field:url([\\/\\s]{0,})\\]/isU", $row['url'], $innertext);
        $rbtext = preg_replace("/\\[field:webname([\\/\\s]{0,})\\]/isU", $row['webname'], $rbtext);
        $rbtext = preg_replace("/\\[field:logo([\\/\\s]{0,})\\]/isU", $row['logo'], $rbtext);
        $rbtext = preg_replace("/\\[field:link([\\/\\s]{0,})\\]/isU", $link, $rbtext);
        $revalue .= $rbtext;
    }
    return $revalue;
}
コード例 #3
0
ファイル: dedemodule.class.php プロジェクト: iabing/mzzyc
 /**
  *  从远程获取模块信息
  *
  * @access    public
  * @param     string   $moduletype   模块类型
  * @return    string
  */
 function GetModuleUrlList($moduletype = '', $url = '')
 {
     $dh = dir($this->modulesPath) or die("没找到模块目录:({$this->modulesPath})!");
     $fp = @fopen($this->modulesPath . '/modulescache.php', 'w') or die('读取文件权限出错,目录文件' . $this->modulesPath . '/modulescache.php不可写!');
     $cachefile = DEDEDATA . '/module/moduleurllist.txt';
     $remotelist = '';
     if (file_exists($cachefile) && filemtime($cachefile) + 60 * 30 > time()) {
         // 30分钟本地缓存一次
         $remotelist = file_get_contents($cachefile);
     } else {
         $del = new DedeHttpDown();
         $del->OpenUrl($url);
         $remotelist = $del->GetHtml();
         PutFile($cachefile, $remotelist);
     }
     if (empty($remotelist)) {
         return false;
     }
     $modules = unserialize($remotelist);
     if (empty($moduletype)) {
         return $modules;
     }
     $return = array();
     foreach ($modules as $arrow => $data) {
         if ($data['moduletype'] == $moduletype) {
             $return[] = $data;
         }
     }
     return $return;
 }
コード例 #4
0
ファイル: dedecollection.func.php プロジェクト: stonelf/mcgmh
/**
 *  分析RSS里的链接
 *
 * @access    public
 * @param     string  $rssurl  rss地址
 * @return    string
 */
function GetRssLinks($rssurl)
{
    global $cfg_soft_lang;
    $dhd = new DedeHttpDown();
    $dhd->OpenUrl($rssurl);
    $rsshtml = $dhd->GetHtml();
    //分析编码
    preg_match("/encoding=[\"']([^\"']*)[\"']/is", $rsshtml, $infos);
    if (isset($infos[1])) {
        $pcode = strtolower(trim($infos[1]));
    } else {
        $pcode = strtolower($cfg_soft_lang);
    }
    if ($cfg_soft_lang == 'gb2312') {
        if ($pcode == 'utf-8') {
            $rsshtml = utf82gb($rsshtml);
        } else {
            if ($pcode == 'big5') {
                $rsshtml = big52gb($rsshtml);
            }
        }
    } else {
        if ($cfg_soft_lang == 'utf-8') {
            if ($pcode == 'gbk' || $pcode == 'gb2312') {
                $rsshtml = gb2utf8($rsshtml);
            } else {
                if ($pcode == 'big5') {
                    $rsshtml = gb2utf8(big52gb($rsshtml));
                }
            }
        }
    }
    $rsarr = array();
    preg_match_all("/<item(.*)<title>(.*)<\\/title>/isU", $rsshtml, $titles);
    preg_match_all("/<item(.*)<link>(.*)<\\/link>/isU", $rsshtml, $links);
    preg_match_all("/<item(.*)<description>(.*)<\\/description>/isU", $rsshtml, $descriptions);
    if (!isset($links[2])) {
        return '';
    }
    foreach ($links[2] as $k => $v) {
        $rsarr[$k]['link'] = RpCdata($v);
        if (isset($titles[2][$k])) {
            $rsarr[$k]['title'] = RpCdata($titles[2][$k]);
        } else {
            $rsarr[$k]['title'] = preg_replace("/^(.*)\\//i", "", RpCdata($titles[2][$k]));
        }
        if (isset($descriptions[2][$k])) {
            $rsarr[$k]['image'] = GetddImgFromRss($descriptions[2][$k], $rssurl);
        } else {
            $rsarr[$k]['image'] = '';
        }
    }
    return $rsarr;
}
コード例 #5
0
ファイル: getdedesysmsg.php プロジェクト: iabing/mzzyc
<?php

/**
 * 获取dede系统提示信息
 *
 * @version        $Id: getdedesysmsg.php 1 11:06 2010年7月13日Z tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once dirname(__FILE__) . '/config.php';
require_once DEDEINC . '/dedehttpdown.class.php';
AjaxHead();
$dhd = new DedeHttpDown();
$dhd->OpenUrl('http://www.dedecms.com/officialinfo.html');
$str = trim($dhd->GetHtml());
$dhd->Close();
if ($cfg_soft_lang == 'utf-8') {
    $str = gb2utf8($str);
}
echo $str;
コード例 #6
0
ファイル: sys_verifies.php プロジェクト: klr2003/sourceread
                 }
             }
         }
     }
     $badmsg = '!';
     if ($badcp > 0) {
         $badmsg = ",其 {$badcp} 个文件效验码不正确或复制失败,<br />请从临时目录[../data/{$tmpdir}]中取出这几个文件手动还原。";
     }
     ShowMsg("成功完成还原指定文件{$badmsg}", "javascript:;");
     exit;
 } else {
     if ($action == 'update') {
         $rmFile = $updateHost . $cfg_soft_lang . '/verifys.txt';
         $dhd = new DedeHttpDown();
         $dhd->OpenUrl($rmFile);
         $ct = $dhd->GetHtml();
         $dhd->Close();
         $cts = split("[\r\n]{1,}", $ct);
         foreach ($cts as $ct) {
             $ct = trim($ct);
             if (empty($ct)) {
                 continue;
             }
             list($nameid, $cthash, $fname) = explode("\t", $ct);
             $row = $dsql->GetOne("Select * From `#@__verifies` where nameid='{$nameid}' ");
             if (!is_array($row) || $row['method'] == 'official' && $row['cthash'] != $cthash) {
                 $dsql->ExecuteNoneQuery("Replace Into `#@__verifies`(nameid,cthash,method,filename) values ('{$nameid}','{$cthash}','official','{$fname}'); ");
             }
         }
         $fp = fopen($verifiesLockFile, 'w');
         fwrite($fp, MyDate('Ymd', time()));
コード例 #7
0
ファイル: cjx.class.php プロジェクト: soonfine/leread
 /**
  * caijixia for dedecms
  * @version        $Id: cjx.class.php 112 2013-05-28 01:22:57Z qinjinpeng $
  * @copyright Copyright (c) 2011,caijixia for dedecms,caijixia.com.
  * @license   This is NOT a freeware, use is subject to license terms
  *
  * @param     NULL
  * @return    NULL
 */
 function downfile($s)
 {
     $c = '';
     $useragent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)';
     if (function_exists('fsockopen')) {
         $httpdown = new DedeHttpDown();
         $httpdown->OpenUrl($s);
         $c = $httpdown->GetHtml();
         $httpdown->Close();
     } else {
         if (function_exists('curl_init') && function_exists('curl_exec')) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $s);
             curl_setopt($ch, CURLOPT_TIMEOUT, 15);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
             curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
             $c = curl_exec($ch);
             curl_close($ch);
         }
     }
     if (empty($c) && ini_get('allow_url_fopen')) {
         $c = file_get_contents($s);
     } else {
         if (empty($c) && function_exists('pfsockopen')) {
             exit('系统无法采集,可能需要调整!');
         }
     }
     return $c;
 }
コード例 #8
0
ファイル: update_guide.php プロジェクト: klr2003/sourceread
         MkTmpDir($tmpdir, $files[$curfile]);
         $downfile = $updateHost . $cfg_soft_lang . '/source/' . $files[$curfile];
         $dhd = new DedeHttpDown();
         $dhd->OpenUrl($downfile);
         $dhd->SaveToBin(DEDEROOT . '/data/' . $tmpdir . '/' . $files[$curfile]);
         $dhd->Close();
         ShowMsg("成功下载并保存文件:{$files[$curfile]}; 继续下载下一个文件。", "update_guide.php?dopost=down&curfile=" . ($curfile + 1));
         exit;
     } else {
         MkTmpDir($tmpdir, 'sql.txt');
         $dhd = new DedeHttpDown();
         $ct = '';
         foreach ($sqls as $sql) {
             $downfile = $updateHost . $cfg_soft_lang . '/' . $sql;
             $dhd->OpenUrl($downfile);
             $ct .= $dhd->GetHtml();
         }
         $dhd->Close();
         $truefile = DEDEROOT . '/data/' . $tmpdir . '/sql.txt';
         $fp = fopen($truefile, 'w');
         fwrite($fp, $ct);
         fclose($fp);
         ShowMsg("完成所有远程文件获取操作:<a href='update_guide.php?dopost=apply'>&lt;&lt;点击此开始直接升级&gt;&gt;</a><br />你也可以直接使用[../data/{$tmpdir}]目录的文件手动升级。", "javascript:;");
         exit;
     }
     exit;
 } else {
     if ($dopost == 'apply') {
         $cacheFiles = DEDEROOT . '/data/cache/updatetmp.inc';
         require_once $cacheFiles;
         if (empty($step)) {