Esempio n. 1
0
/**
 *  获取一个页面
 *
 * @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;
}
function GetRemoteImage($url,$uid=0)
{
	global $title,$cfg_mb_rmdown,$cfg_photo_typenames,$cfg_ml;
	if($cfg_mb_rmdown=='N') return '';
	$cfg_uploaddir = $GLOBALS['cfg_user_dir'];
	$cfg_basedir = $GLOBALS['cfg_basedir'];
	$revalues = Array();
	$revalues[0] = '';
	$revalues[1] = '';
	$revalues[2] = '';
	$ok = false;
	$htd = new DedeHttpDown();
	$htd->OpenUrl($url);
	$sparr = $cfg_photo_typenames;
	if(!in_array($htd->GetHead("content-type"),$sparr)){
		return "";
	}else{
  	$imgUrl = $cfg_uploaddir."/".$cfg_ml->M_ID;
	  $imgPath = $cfg_basedir.$imgUrl;
	  CreateDir($imgUrl);
  	$itype = $htd->GetHead("content-type");
		if($itype=="image/gif") $itype = ".gif";
		else if($itype=="image/png") $itype = ".png";
		else if($itype=="image/wbmp") $itype = ".bmp";
		else $itype = ".jpg";
		$rndname = dd2char($cfg_ml->M_ID."0".strftime("%y%m%d%H%M%S",$nowtme)."0".mt_rand(1000,9999)).'-rm';
		$rndtrueName = $imgPath."/".$rndname.$itype;
		$fileurl = $imgUrl."/".$rndname.$itype;
  	$ok = $htd->SaveToBin($rndtrueName);
  	if($ok){
  	  $info = "";
  	  $data = GetImageSize($rndtrueName,$info);
  	  $revalues[0] = $fileurl;
	    $revalues[1] = $data[0];
	    $revalues[2] = $data[1];
	  }
	  @WaterImg($rndtrueName,'down');
	  //保存用户上传的记录到数据库
	  if($title=='') $title = '用户保存的远程图片';
	  $addinfos[0] = $data[0];
	  $addinfos[1] = $data[1];
	  $addinfos[2] = filesize($rndtrueName);
	  SaveUploadInfo($title."(远程图片)",$fileurl,1,$addinfos);
  }
	$htd->Close();
	if($ok) return $revalues;
	else return '';
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
 /**
  *  从远程获取模块信息
  *
  * @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;
 }
Esempio n. 5
0
/**
 *  分析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;
}
/**
 *  获取远程flash
 *
 * @access    public
 * @param     string  $url  地址
 * @param     int  $uid  用户id
 * @return    string
 */
function GetRemoteFlash($url, $uid = 0)
{
    global $cfg_addon_savetype, $cfg_media_dir, $cfg_basedir;
    $cfg_uploaddir = $cfg_media_dir;
    $revalues = '';
    $sparr = 'application/x-shockwave-flash';
    $htd = new DedeHttpDown();
    $htd->OpenUrl($url);
    if ($htd->GetHead("content-type") != $sparr) {
        return '';
    } else {
        $imgUrl = $cfg_uploaddir . '/' . MyDate($cfg_addon_savetype, time());
        $imgPath = $cfg_basedir . $imgUrl;
        CreateDir($imgUrl);
        $itype = '.swf';
        $milliSecond = $uid . '_' . MyDate('mdHis', time());
        $rndFileName = $imgPath . '/' . $milliSecond . $itype;
        $fileurl = $imgUrl . '/' . $milliSecond . $itype;
        $ok = $htd->SaveToBin($rndFileName);
        if ($ok) {
            $revalues = $fileurl;
        }
    }
    $htd->Close();
    return $revalues;
}
function GetRemoteFlash($url,$uid=0)
{
	$cfg_uploaddir = $GLOBALS['media_dir'];
	$cfg_basedir = $GLOBALS['cfg_basedir'];
	$revalues = "";
	$sparr = "application/x-shockwave-flash";
	$htd = new DedeHttpDown();
	$htd->OpenUrl($url);
	if($htd->GetHead("content-type")!=$sparr){
		return "";
	}else{  	
  	$imgUrl = $cfg_uploaddir."/".strftime("%y%m%d",time());
	  $imgPath = $cfg_basedir.$imgUrl;
	  CreateDir($imgUrl);
  	$itype = ".swf";
		$milliSecond = $uid."_".strftime("%H%M%S",time());
		$rndFileName = $imgPath."/".$milliSecond.$itype;
		$fileurl = $imgUrl."/".$milliSecond.$itype;
  	$ok = $htd->SaveToBin($rndFileName);
  	if($ok) $revalues = $fileurl;
  }
	$htd->Close();
	return $revalues;
}
Esempio n. 8
0
<?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;
Esempio n. 9
0
                         $badcp++;
                     }
                 }
             }
         }
     }
     $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}'); ");
             }
         }
/**
 *  获得文章body里的外部资源
 *
 * @access    public
 * @param     string  $body  内容
 * @return    string
 */
function GetCurContent(&$body)
{
    global $cfg_multi_site, $cfg_basehost, $cfg_basedir, $cfg_user_dir, $title, $cfg_ml;
    include_once DEDEINC . "/dedecollection.func.php";
    $htd = new DedeHttpDown();
    $basehost = "http://" . $_SERVER["HTTP_HOST"];
    $img_array = array();
    preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\\/\\/([^>]*)\\.(gif|jpg|png))/isU", $body, $img_array);
    $img_array = array_unique($img_array[2]);
    $imgUrl = $cfg_user_dir . "/" . $cfg_ml->M_ID;
    $imgPath = $cfg_basedir . $imgUrl;
    if (!is_dir($imgPath . "/")) {
        MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']);
        CloseFtp();
    }
    $milliSecond = MyDate("ymdHis", time());
    foreach ($img_array as $key => $value) {
        if (preg_match("#" . $basehost . "#i", $value)) {
            continue;
        }
        if ($cfg_basehost != $basehost && preg_match("#" . $cfg_basehost . "#i", $value)) {
            continue;
        }
        if (!preg_match("#^http:\\/\\/#i", $value)) {
            continue;
        }
        $htd->OpenUrl($value);
        $itype = $htd->GetHead("content-type");
        $itype = substr($value, -4, 4);
        if (!preg_match("#\\.(jpg|gif|png)#i", $itype)) {
            if ($itype == 'image/gif') {
                $itype = ".gif";
            } else {
                if ($itype == 'image/png') {
                    $itype = ".png";
                } else {
                    $itype = '.jpg';
                }
            }
        }
        $milliSecondN = dd2char($milliSecond . '-' . mt_rand(1000, 8000));
        $value = trim($value);
        $rndFileName = $imgPath . "/" . $milliSecondN . '-' . $key . $itype;
        $fileurl = $imgUrl . "/" . $milliSecondN . '-' . $key . $itype;
        $rs = $htd->SaveToBin($rndFileName);
        if ($rs) {
            $body = str_replace($value, $fileurl, $body);
            @WaterImg($rndFileName, 'down');
        }
        $info = '';
        $imginfos = GetImageSize($rndFileName, $info);
        SaveUploadInfo($title, $fileurl, 1, $imginfos);
    }
    $htd->Close();
    return $body;
}
Esempio n. 11
0
 /**
  * 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;
 }
Esempio n. 12
0
     if ($fileConut == -1 || $curfile > $fileConut) {
         ShowMsg("已下载所有文件,开始下载数据库升级文件...", "update_guide.php?dopost=down&startup=1");
         exit;
     }
     //检查临时文件保存目录是否可用
     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;