@@ -207,7 +207,7 @@ else if($dopost=='save') | |||||
color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight) | color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight) | ||||
VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money', | VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money', | ||||
'$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate', | '$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate', | ||||
'$adminid','$voteid','$notpost','$description','$keywords','$filename','$adminid','$weight');"; | |||||
'$adminid','0','$notpost','$description','$keywords','$filename','$adminid','$weight');"; | |||||
if(!$dsql->ExecuteNoneQuery($query)) | if(!$dsql->ExecuteNoneQuery($query)) | ||||
{ | { | ||||
@@ -11,6 +11,7 @@ | |||||
require_once(dirname(__FILE__).'/../include/common.inc.php'); | require_once(dirname(__FILE__).'/../include/common.inc.php'); | ||||
require_once(DEDEINC.'/userlogin.class.php'); | require_once(DEDEINC.'/userlogin.class.php'); | ||||
if(empty($dopost)) $dopost = ''; | if(empty($dopost)) $dopost = ''; | ||||
if(empty($gotopage)) $gotopage = ''; | |||||
$gotopage = RemoveXSS($gotopage); | $gotopage = RemoveXSS($gotopage); | ||||
@@ -282,7 +282,7 @@ class Archives | |||||
{ | { | ||||
if($this->Fields['litpic'] == '-' || $this->Fields['litpic'] == '') | if($this->Fields['litpic'] == '-' || $this->Fields['litpic'] == '') | ||||
{ | { | ||||
$this->Fields['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$this->Fields['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("#^http:\/\/#i", $this->Fields['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("#^http:\/\/#i", $this->Fields['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -190,7 +190,7 @@ class Caicai extends DataListCP | |||||
$arr['typeurl'] = GetTypeUrl($arr['typeid'], MfTypedir($arr['typedir']), $arr['isdefault'], $arr['defaultname'], | $arr['typeurl'] = GetTypeUrl($arr['typeid'], MfTypedir($arr['typedir']), $arr['isdefault'], $arr['defaultname'], | ||||
$arr['ispart'], $arr['namerule2'], $arr['moresite'], $arr['siteurl'], $arr['sitepath']); | $arr['ispart'], $arr['namerule2'], $arr['moresite'], $arr['siteurl'], $arr['sitepath']); | ||||
if($arr['litpic']=='') $arr['litpic'] = '/images/defaultpic.gif'; | |||||
if($arr['litpic']=='') $arr['litpic'] = '/static/defaultpic.gif'; | |||||
if(!preg_match("#^http:\/\/#", $arr['litpic'])) | if(!preg_match("#^http:\/\/#", $arr['litpic'])) | ||||
{ | { | ||||
@@ -672,7 +672,7 @@ class FreeList | |||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -891,7 +891,7 @@ class ListView | |||||
$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | $row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | ||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -230,7 +230,7 @@ class MemberListview | |||||
$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | $row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | ||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -171,7 +171,7 @@ class RssView | |||||
//处理一些特殊字段 | //处理一些特殊字段 | ||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -737,7 +737,7 @@ class SearchView | |||||
$row["id"] = $row["id"]; | $row["id"] = $row["id"]; | ||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -786,7 +786,7 @@ class SgListView | |||||
$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | $row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | ||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -436,7 +436,7 @@ class SpecView | |||||
$row["id"] = $row["id"]; | $row["id"] = $row["id"]; | ||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -363,7 +363,7 @@ class TagList | |||||
$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | $row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); | ||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -64,7 +64,7 @@ if(function_exists('iconv_substr')) $cfg_is_iconv = TRUE; | |||||
function _RunMagicQuotes(&$svar) | function _RunMagicQuotes(&$svar) | ||||
{ | { | ||||
if(!get_magic_quotes_gpc()) | |||||
if(!@get_magic_quotes_gpc()) | |||||
{ | { | ||||
if( is_array($svar) ) | if( is_array($svar) ) | ||||
{ | { | ||||
@@ -1,4 +1,4 @@ | |||||
<?php if(!defined('DEDEINC')) exit("Request Error!"); | |||||
<?php if (!defined('DEDEINC')) exit("Request Error!"); | |||||
/** | /** | ||||
* 织梦HTTP下载类 | * 织梦HTTP下载类 | ||||
* | * | ||||
@@ -42,45 +42,38 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function PrivateInit($url) | function PrivateInit($url) | ||||
{ | { | ||||
if($url=='') { | |||||
return ; | |||||
if ($url == '') { | |||||
return; | |||||
} | } | ||||
$urls = ''; | $urls = ''; | ||||
$urls = @parse_url($url); | $urls = @parse_url($url); | ||||
$this->m_url = $url; | $this->m_url = $url; | ||||
if(is_array($urls)) | |||||
{ | |||||
if (is_array($urls)) { | |||||
$this->m_host = $urls["host"]; | $this->m_host = $urls["host"]; | ||||
if(!empty($urls["scheme"])) | |||||
{ | |||||
if (!empty($urls["scheme"])) { | |||||
$this->m_scheme = $urls["scheme"]; | $this->m_scheme = $urls["scheme"]; | ||||
} | } | ||||
if(!empty($urls["user"])) | |||||
{ | |||||
if (!empty($urls["user"])) { | |||||
$this->m_user = $urls["user"]; | $this->m_user = $urls["user"]; | ||||
} | } | ||||
if(!empty($urls["pass"])) | |||||
{ | |||||
if (!empty($urls["pass"])) { | |||||
$this->m_pass = $urls["pass"]; | $this->m_pass = $urls["pass"]; | ||||
} | } | ||||
if(!empty($urls["port"])) | |||||
{ | |||||
if (!empty($urls["port"])) { | |||||
$this->m_port = $urls["port"]; | $this->m_port = $urls["port"]; | ||||
} | } | ||||
if(!empty($urls["path"])) | |||||
{ | |||||
if (!empty($urls["path"])) { | |||||
$this->m_path = $urls["path"]; | $this->m_path = $urls["path"]; | ||||
} | } | ||||
$this->m_urlpath = $this->m_path; | $this->m_urlpath = $this->m_path; | ||||
if(!empty($urls["query"])) | |||||
{ | |||||
if (!empty($urls["query"])) { | |||||
$this->m_query = $urls["query"]; | $this->m_query = $urls["query"]; | ||||
$this->m_urlpath .= "?".$this->m_query; | |||||
$this->m_urlpath .= "?" . $this->m_query; | |||||
} | } | ||||
$this->HomeUrl = $urls["host"]; | $this->HomeUrl = $urls["host"]; | ||||
$this->BaseUrlPath = $this->HomeUrl.$urls["path"]; | |||||
$this->BaseUrlPath = preg_replace("/\/([^\/]*)\.(.*)$/","/",$this->BaseUrlPath); | |||||
$this->BaseUrlPath = preg_replace("/\/$/","",$this->BaseUrlPath); | |||||
$this->BaseUrlPath = $this->HomeUrl . $urls["path"]; | |||||
$this->BaseUrlPath = preg_replace("/\/([^\/]*)\.(.*)$/", "/", $this->BaseUrlPath); | |||||
$this->BaseUrlPath = preg_replace("/\/$/", "", $this->BaseUrlPath); | |||||
} | } | ||||
} | } | ||||
@@ -114,11 +107,11 @@ class DedeHttpDown | |||||
* @param string $requestType 请求类型 | * @param string $requestType 请求类型 | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function OpenUrl($url,$requestType="GET") | |||||
function OpenUrl($url, $requestType = "GET") | |||||
{ | { | ||||
$this->ResetAny(); | $this->ResetAny(); | ||||
$this->JumpCount = 0; | $this->JumpCount = 0; | ||||
$this->m_httphead = Array() ; | |||||
$this->m_httphead = array(); | |||||
$this->m_html = ''; | $this->m_html = ''; | ||||
$this->reTry = 0; | $this->reTry = 0; | ||||
$this->Close(); | $this->Close(); | ||||
@@ -139,7 +132,7 @@ class DedeHttpDown | |||||
{ | { | ||||
$this->ResetAny(); | $this->ResetAny(); | ||||
$this->JumpCount++; | $this->JumpCount++; | ||||
$this->m_httphead = Array() ; | |||||
$this->m_httphead = array(); | |||||
$this->m_html = ""; | $this->m_html = ""; | ||||
$this->Close(); | $this->Close(); | ||||
@@ -156,9 +149,11 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function printError() | function printError() | ||||
{ | { | ||||
echo "错误信息:".$this->m_error; | |||||
echo "错误信息:" . $this->m_error; | |||||
echo "<br/>具体返回头:<br/>"; | echo "<br/>具体返回头:<br/>"; | ||||
foreach($this->m_httphead as $k=>$v){ echo "$k => $v <br/>\r\n"; } | |||||
foreach ($this->m_httphead as $k => $v) { | |||||
echo "$k => $v <br/>\r\n"; | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -169,13 +164,10 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function IsGetOK() | function IsGetOK() | ||||
{ | { | ||||
if( preg_match("/^2/",$this->GetHead("http-state")) ) | |||||
{ | |||||
if (preg_match("/^2/", $this->GetHead("http-state"))) { | |||||
return TRUE; | return TRUE; | ||||
} | |||||
else | |||||
{ | |||||
$this->m_error .= $this->GetHead("http-state")." - ".$this->GetHead("http-describe")."<br/>"; | |||||
} else { | |||||
$this->m_error .= $this->GetHead("http-state") . " - " . $this->GetHead("http-describe") . "<br/>"; | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
} | } | ||||
@@ -188,12 +180,9 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function IsText() | function IsText() | ||||
{ | { | ||||
if( preg_match("/^2/",$this->GetHead("http-state")) && preg_match("/text|xml/i",$this->GetHead("content-type")) ) | |||||
{ | |||||
if (preg_match("/^2/", $this->GetHead("http-state")) && preg_match("/text|xml/i", $this->GetHead("content-type"))) { | |||||
return TRUE; | return TRUE; | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
$this->m_error .= "内容为非文本类型或网址重定向<br/>"; | $this->m_error .= "内容为非文本类型或网址重定向<br/>"; | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
@@ -208,12 +197,13 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function IsContentType($ctype) | function IsContentType($ctype) | ||||
{ | { | ||||
if(preg_match("/^2/",$this->GetHead("http-state")) | |||||
&& $this->GetHead("content-type")==strtolower($ctype)) | |||||
{ return TRUE; } | |||||
else | |||||
{ | |||||
$this->m_error .= "类型不对 ".$this->GetHead("content-type")."<br/>"; | |||||
if ( | |||||
preg_match("/^2/", $this->GetHead("http-state")) | |||||
&& $this->GetHead("content-type") == strtolower($ctype) | |||||
) { | |||||
return TRUE; | |||||
} else { | |||||
$this->m_error .= "类型不对 " . $this->GetHead("content-type") . "<br/>"; | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
} | } | ||||
@@ -227,8 +217,7 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function SaveToBin($savefilename) | function SaveToBin($savefilename) | ||||
{ | { | ||||
if(!$this->IsGetOK()) | |||||
{ | |||||
if (!$this->IsGetOK()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
if (function_exists('curl_init') && function_exists('curl_exec')) { | if (function_exists('curl_init') && function_exists('curl_exec')) { | ||||
@@ -236,13 +225,12 @@ class DedeHttpDown | |||||
return TRUE; | return TRUE; | ||||
} | } | ||||
if(@feof($this->m_fp)) | |||||
{ | |||||
$this->m_error = "连接已经关闭!"; return FALSE; | |||||
if (@feof($this->m_fp)) { | |||||
$this->m_error = "连接已经关闭!"; | |||||
return FALSE; | |||||
} | } | ||||
$fp = fopen($savefilename,"w"); | |||||
while(!feof($this->m_fp)) | |||||
{ | |||||
$fp = fopen($savefilename, "w"); | |||||
while (!feof($this->m_fp)) { | |||||
fwrite($fp, fread($this->m_fp, 1024)); | fwrite($fp, fread($this->m_fp, 1024)); | ||||
} | } | ||||
fclose($this->m_fp); | fclose($this->m_fp); | ||||
@@ -259,16 +247,18 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function SaveToText($savefilename) | function SaveToText($savefilename) | ||||
{ | { | ||||
if($this->IsText()) | |||||
{ | |||||
if ($this->IsText()) { | |||||
$this->SaveBinFile($savefilename); | $this->SaveBinFile($savefilename); | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
return ""; | return ""; | ||||
} | } | ||||
} | } | ||||
function SaveBinFile($filename) | |||||
{ | |||||
return $this->SaveBinFile($filename); | |||||
} | |||||
/** | /** | ||||
* 用Http协议获得一个网页的内容 | * 用Http协议获得一个网页的内容 | ||||
* | * | ||||
@@ -277,21 +267,17 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function GetHtml() | function GetHtml() | ||||
{ | { | ||||
if($this->m_html!='') | |||||
{ | |||||
if ($this->m_html != '') { | |||||
return $this->m_html; | return $this->m_html; | ||||
} | } | ||||
if(!$this->IsText()) | |||||
{ | |||||
if (!$this->IsText()) { | |||||
return ''; | return ''; | ||||
} | } | ||||
if(!$this->m_fp||@feof($this->m_fp)) | |||||
{ | |||||
if (!$this->m_fp || @feof($this->m_fp)) { | |||||
return ''; | return ''; | ||||
} | } | ||||
while(!feof($this->m_fp)) | |||||
{ | |||||
$this->m_html .= fgets($this->m_fp,256); | |||||
while (!feof($this->m_fp)) { | |||||
$this->m_html .= fgets($this->m_fp, 256); | |||||
} | } | ||||
@fclose($this->m_fp); | @fclose($this->m_fp); | ||||
return $this->m_html; | return $this->m_html; | ||||
@@ -304,14 +290,14 @@ class DedeHttpDown | |||||
* @param string $requestType 请求类型 | * @param string $requestType 请求类型 | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function PrivateStartSession($requestType="GET") | |||||
function PrivateStartSession($requestType = "GET") | |||||
{ | { | ||||
if ($this->m_scheme == "https") { | if ($this->m_scheme == "https") { | ||||
$this->m_port = "443"; | $this->m_port = "443"; | ||||
} | } | ||||
if (function_exists('curl_init') && function_exists('curl_exec')) { | if (function_exists('curl_init') && function_exists('curl_exec')) { | ||||
$this->m_ch = curl_init(); | $this->m_ch = curl_init(); | ||||
curl_setopt($this->m_ch, CURLOPT_URL, $this->m_scheme.'://'.$this->m_host.':'.$this->m_port.$this->m_path); | |||||
curl_setopt($this->m_ch, CURLOPT_URL, $this->m_scheme . '://' . $this->m_host . ':' . $this->m_port . $this->m_path); | |||||
curl_setopt($this->m_ch, CURLOPT_RETURNTRANSFER, 1); | curl_setopt($this->m_ch, CURLOPT_RETURNTRANSFER, 1); | ||||
curl_setopt($this->m_ch, CURLOPT_FOLLOWLOCATION, 1); | curl_setopt($this->m_ch, CURLOPT_FOLLOWLOCATION, 1); | ||||
if ($requestType == "POST") { | if ($requestType == "POST") { | ||||
@@ -331,32 +317,27 @@ class DedeHttpDown | |||||
$this->m_puthead["Host"] = $this->m_host; | $this->m_puthead["Host"] = $this->m_host; | ||||
//发送用户自定义的请求头 | //发送用户自定义的请求头 | ||||
if(!isset($this->m_puthead["Accept"])) | |||||
{ | |||||
if (!isset($this->m_puthead["Accept"])) { | |||||
$this->m_puthead["Accept"] = "*/*"; | $this->m_puthead["Accept"] = "*/*"; | ||||
} | } | ||||
if(!isset($this->m_puthead["User-Agent"])) | |||||
{ | |||||
if (!isset($this->m_puthead["User-Agent"])) { | |||||
$this->m_puthead["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)"; | $this->m_puthead["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)"; | ||||
} | } | ||||
if(!isset($this->m_puthead["Refer"])) | |||||
{ | |||||
$this->m_puthead["Refer"] = "http://".$this->m_puthead["Host"]; | |||||
if (!isset($this->m_puthead["Refer"])) { | |||||
$this->m_puthead["Refer"] = "http://" . $this->m_puthead["Host"]; | |||||
} | } | ||||
$headers = array(); | $headers = array(); | ||||
foreach($this->m_puthead as $k=>$v) | |||||
{ | |||||
foreach ($this->m_puthead as $k => $v) { | |||||
$k = trim($k); | $k = trim($k); | ||||
$v = trim($v); | $v = trim($v); | ||||
if($k!=""&&$v!="") | |||||
{ | |||||
if ($k != "" && $v != "") { | |||||
$headers[] = "$k: $v"; | $headers[] = "$k: $v"; | ||||
} | } | ||||
} | } | ||||
if (count($headers) > 0) { | if (count($headers) > 0) { | ||||
curl_setopt($this->m_ch, CURLOPT_HTTPHEADER, $headers); | curl_setopt($this->m_ch, CURLOPT_HTTPHEADER, $headers); | ||||
} | } | ||||
curl_setopt($this->m_ch, CURLOPT_CONNECTTIMEOUT, 20); | curl_setopt($this->m_ch, CURLOPT_CONNECTTIMEOUT, 20); | ||||
curl_setopt($this->m_ch, CURLOPT_TIMEOUT, 900); | curl_setopt($this->m_ch, CURLOPT_TIMEOUT, 900); | ||||
@@ -375,168 +356,129 @@ class DedeHttpDown | |||||
return TRUE; | return TRUE; | ||||
} | } | ||||
if(!$this->PrivateOpenHost()) | |||||
{ | |||||
if (!$this->PrivateOpenHost()) { | |||||
$this->m_error .= "打开远程主机出错!"; | $this->m_error .= "打开远程主机出错!"; | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$this->reTry++; | $this->reTry++; | ||||
if($this->GetHead("http-edition")=="HTTP/1.1") | |||||
{ | |||||
if ($this->GetHead("http-edition") == "HTTP/1.1") { | |||||
$httpv = "HTTP/1.1"; | $httpv = "HTTP/1.1"; | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
$httpv = "HTTP/1.0"; | $httpv = "HTTP/1.0"; | ||||
} | } | ||||
$ps = explode('?',$this->m_urlpath); | |||||
$ps = explode('?', $this->m_urlpath); | |||||
$headString = ''; | $headString = ''; | ||||
//发送固定的起始请求头GET、Host信息 | //发送固定的起始请求头GET、Host信息 | ||||
if($requestType=="GET") | |||||
{ | |||||
$headString .= "GET ".$this->m_urlpath." $httpv\r\n"; | |||||
} | |||||
else | |||||
{ | |||||
$headString .= "POST ".$ps[0]." $httpv\r\n"; | |||||
if ($requestType == "GET") { | |||||
$headString .= "GET " . $this->m_urlpath . " $httpv\r\n"; | |||||
} else { | |||||
$headString .= "POST " . $ps[0] . " $httpv\r\n"; | |||||
} | } | ||||
$this->m_puthead["Host"] = $this->m_host; | $this->m_puthead["Host"] = $this->m_host; | ||||
//发送用户自定义的请求头 | //发送用户自定义的请求头 | ||||
if(!isset($this->m_puthead["Accept"])) | |||||
{ | |||||
if (!isset($this->m_puthead["Accept"])) { | |||||
$this->m_puthead["Accept"] = "*/*"; | $this->m_puthead["Accept"] = "*/*"; | ||||
} | } | ||||
if(!isset($this->m_puthead["User-Agent"])) | |||||
{ | |||||
if (!isset($this->m_puthead["User-Agent"])) { | |||||
$this->m_puthead["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)"; | $this->m_puthead["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)"; | ||||
} | } | ||||
if(!isset($this->m_puthead["Refer"])) | |||||
{ | |||||
$this->m_puthead["Refer"] = "http://".$this->m_puthead["Host"]; | |||||
if (!isset($this->m_puthead["Refer"])) { | |||||
$this->m_puthead["Refer"] = "http://" . $this->m_puthead["Host"]; | |||||
} | } | ||||
foreach($this->m_puthead as $k=>$v) | |||||
{ | |||||
foreach ($this->m_puthead as $k => $v) { | |||||
$k = trim($k); | $k = trim($k); | ||||
$v = trim($v); | $v = trim($v); | ||||
if($k!=""&&$v!="") | |||||
{ | |||||
if ($k != "" && $v != "") { | |||||
$headString .= "$k: $v\r\n"; | $headString .= "$k: $v\r\n"; | ||||
} | } | ||||
} | } | ||||
fputs($this->m_fp, $headString); | fputs($this->m_fp, $headString); | ||||
if($requestType=="POST") | |||||
{ | |||||
if ($requestType == "POST") { | |||||
$postdata = ""; | $postdata = ""; | ||||
if(count($ps)>1) | |||||
{ | |||||
for($i=1;$i<count($ps);$i++) | |||||
{ | |||||
if (count($ps) > 1) { | |||||
for ($i = 1; $i < count($ps); $i++) { | |||||
$postdata .= $ps[$i]; | $postdata .= $ps[$i]; | ||||
} | } | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
$postdata = "OK"; | $postdata = "OK"; | ||||
} | } | ||||
$plen = strlen($postdata); | $plen = strlen($postdata); | ||||
fputs($this->m_fp,"Content-Type: application/x-www-form-urlencoded\r\n"); | |||||
fputs($this->m_fp,"Content-Length: $plen\r\n"); | |||||
fputs($this->m_fp, "Content-Type: application/x-www-form-urlencoded\r\n"); | |||||
fputs($this->m_fp, "Content-Length: $plen\r\n"); | |||||
} | } | ||||
//发送固定的结束请求头 | //发送固定的结束请求头 | ||||
//HTTP1.1协议必须指定文档结束后关闭链接,否则读取文档时无法使用feof判断结束 | //HTTP1.1协议必须指定文档结束后关闭链接,否则读取文档时无法使用feof判断结束 | ||||
if($httpv=="HTTP/1.1") | |||||
{ | |||||
fputs($this->m_fp,"Connection: Close\r\n\r\n"); | |||||
if ($httpv == "HTTP/1.1") { | |||||
fputs($this->m_fp, "Connection: Close\r\n\r\n"); | |||||
} else { | |||||
fputs($this->m_fp, "\r\n"); | |||||
} | } | ||||
else | |||||
{ | |||||
fputs($this->m_fp,"\r\n"); | |||||
} | |||||
if($requestType=="POST") | |||||
{ | |||||
fputs($this->m_fp,$postdata); | |||||
if ($requestType == "POST") { | |||||
fputs($this->m_fp, $postdata); | |||||
} | } | ||||
//获取应答头状态信息 | //获取应答头状态信息 | ||||
$httpstas = explode(" ",fgets($this->m_fp,256)); | |||||
$httpstas = explode(" ", fgets($this->m_fp, 256)); | |||||
$this->m_httphead["http-edition"] = trim($httpstas[0]); | $this->m_httphead["http-edition"] = trim($httpstas[0]); | ||||
$this->m_httphead["http-state"] = trim($httpstas[1]); | $this->m_httphead["http-state"] = trim($httpstas[1]); | ||||
$this->m_httphead["http-describe"] = ""; | $this->m_httphead["http-describe"] = ""; | ||||
for($i=2;$i<count($httpstas);$i++) | |||||
{ | |||||
$this->m_httphead["http-describe"] .= " ".trim($httpstas[$i]); | |||||
for ($i = 2; $i < count($httpstas); $i++) { | |||||
$this->m_httphead["http-describe"] .= " " . trim($httpstas[$i]); | |||||
} | } | ||||
//获取详细应答头 | //获取详细应答头 | ||||
while(!feof($this->m_fp)) | |||||
{ | |||||
$line = trim(fgets($this->m_fp,256)); | |||||
if($line == "") | |||||
{ | |||||
while (!feof($this->m_fp)) { | |||||
$line = trim(fgets($this->m_fp, 256)); | |||||
if ($line == "") { | |||||
break; | break; | ||||
} | } | ||||
$hkey = ""; | $hkey = ""; | ||||
$hvalue = ""; | $hvalue = ""; | ||||
$v = 0; | $v = 0; | ||||
for($i=0;$i<strlen($line);$i++) | |||||
{ | |||||
if($v==1) | |||||
{ | |||||
for ($i = 0; $i < strlen($line); $i++) { | |||||
if ($v == 1) { | |||||
$hvalue .= $line[$i]; | $hvalue .= $line[$i]; | ||||
} | } | ||||
if($line[$i]==":") | |||||
{ | |||||
if ($line[$i] == ":") { | |||||
$v = 1; | $v = 1; | ||||
} | } | ||||
if($v==0) | |||||
{ | |||||
if ($v == 0) { | |||||
$hkey .= $line[$i]; | $hkey .= $line[$i]; | ||||
} | } | ||||
} | } | ||||
$hkey = trim($hkey); | $hkey = trim($hkey); | ||||
if($hkey!="") | |||||
{ | |||||
if ($hkey != "") { | |||||
$this->m_httphead[strtolower($hkey)] = trim($hvalue); | $this->m_httphead[strtolower($hkey)] = trim($hvalue); | ||||
} | } | ||||
} | } | ||||
//如果连接被不正常关闭,重试 | //如果连接被不正常关闭,重试 | ||||
if(feof($this->m_fp)) | |||||
{ | |||||
if($this->reTry > 10) | |||||
{ | |||||
if (feof($this->m_fp)) { | |||||
if ($this->reTry > 10) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$this->PrivateStartSession($requestType); | $this->PrivateStartSession($requestType); | ||||
} | } | ||||
//判断是否是3xx开头的应答 | //判断是否是3xx开头的应答 | ||||
if(preg_match("/^3/",$this->m_httphead["http-state"])) | |||||
{ | |||||
if($this->JumpCount > 3) | |||||
{ | |||||
if (preg_match("/^3/", $this->m_httphead["http-state"])) { | |||||
if ($this->JumpCount > 3) { | |||||
return; | return; | ||||
} | } | ||||
if(isset($this->m_httphead["location"])) | |||||
{ | |||||
if (isset($this->m_httphead["location"])) { | |||||
$newurl = $this->m_httphead["location"]; | $newurl = $this->m_httphead["location"]; | ||||
if(preg_match("/^http/i",$newurl)) | |||||
{ | |||||
if (preg_match("/^http/i", $newurl)) { | |||||
$this->JumpOpenUrl($newurl); | $this->JumpOpenUrl($newurl); | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
$newurl = $this->FillUrl($newurl); | $newurl = $this->FillUrl($newurl); | ||||
$this->JumpOpenUrl($newurl); | $this->JumpOpenUrl($newurl); | ||||
} | } | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
$this->m_error = "无法识别的答复!"; | $this->m_error = "无法识别的答复!"; | ||||
} | } | ||||
} | } | ||||
@@ -568,7 +510,7 @@ class DedeHttpDown | |||||
* @param string $svalue 值 | * @param string $svalue 值 | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function SetHead($skey,$svalue) | |||||
function SetHead($skey, $svalue) | |||||
{ | { | ||||
$this->m_puthead[$skey] = $svalue; | $this->m_puthead[$skey] = $svalue; | ||||
} | } | ||||
@@ -581,21 +523,17 @@ class DedeHttpDown | |||||
*/ | */ | ||||
function PrivateOpenHost() | function PrivateOpenHost() | ||||
{ | { | ||||
if($this->m_host=="") | |||||
{ | |||||
if ($this->m_host == "") { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$errno = ""; | $errno = ""; | ||||
$errstr = ""; | $errstr = ""; | ||||
$this->m_fp = @fsockopen($this->m_host, $this->m_port, $errno, $errstr,10); | |||||
if(!$this->m_fp) | |||||
{ | |||||
$this->m_fp = @fsockopen($this->m_host, $this->m_port, $errno, $errstr, 10); | |||||
if (!$this->m_fp) { | |||||
$this->m_error = $errstr; | $this->m_error = $errstr; | ||||
return FALSE; | return FALSE; | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
return TRUE; | return TRUE; | ||||
} | } | ||||
} | } | ||||
@@ -609,7 +547,7 @@ class DedeHttpDown | |||||
function Close() | function Close() | ||||
{ | { | ||||
if (function_exists('curl_init') && function_exists('curl_exec')) { | if (function_exists('curl_init') && function_exists('curl_exec')) { | ||||
curl_close($ch); | |||||
@curl_close($this->m_ch); | |||||
} | } | ||||
@fclose($this->m_fp); | @fclose($this->m_fp); | ||||
} | } | ||||
@@ -629,81 +567,54 @@ class DedeHttpDown | |||||
$okurl = ""; | $okurl = ""; | ||||
$pathStep = 0; | $pathStep = 0; | ||||
$surl = trim($surl); | $surl = trim($surl); | ||||
if($surl=="") | |||||
{ | |||||
if ($surl == "") { | |||||
return ""; | return ""; | ||||
} | } | ||||
$pos = strpos($surl,"#"); | |||||
if($pos>0) | |||||
{ | |||||
$surl = substr($surl,0,$pos); | |||||
$pos = strpos($surl, "#"); | |||||
if ($pos > 0) { | |||||
$surl = substr($surl, 0, $pos); | |||||
} | } | ||||
if($surl[0]=="/") | |||||
{ | |||||
$okurl = "http://".$this->HomeUrl.$surl; | |||||
} | |||||
else if($surl[0]==".") | |||||
{ | |||||
if(strlen($surl)<=1) | |||||
{ | |||||
if ($surl[0] == "/") { | |||||
$okurl = "http://" . $this->HomeUrl . $surl; | |||||
} else if ($surl[0] == ".") { | |||||
if (strlen($surl) <= 1) { | |||||
return ""; | return ""; | ||||
} | |||||
else if($surl[1]=="/") | |||||
{ | |||||
$okurl = "http://".$this->BaseUrlPath."/".substr($surl,2,strlen($surl)-2); | |||||
} | |||||
else | |||||
{ | |||||
$urls = explode("/",$surl); | |||||
foreach($urls as $u) | |||||
{ | |||||
if($u=="..") | |||||
{ | |||||
} else if ($surl[1] == "/") { | |||||
$okurl = "http://" . $this->BaseUrlPath . "/" . substr($surl, 2, strlen($surl) - 2); | |||||
} else { | |||||
$urls = explode("/", $surl); | |||||
foreach ($urls as $u) { | |||||
if ($u == "..") { | |||||
$pathStep++; | $pathStep++; | ||||
} | |||||
else if($i<count($urls)-1) | |||||
{ | |||||
$dstr .= $urls[$i]."/"; | |||||
} | |||||
else | |||||
{ | |||||
} else if ($i < count($urls) - 1) { | |||||
$dstr .= $urls[$i] . "/"; | |||||
} else { | |||||
$dstr .= $urls[$i]; | $dstr .= $urls[$i]; | ||||
} | } | ||||
$i++; | $i++; | ||||
} | } | ||||
$urls = explode("/",$this->BaseUrlPath); | |||||
if(count($urls) <= $pathStep) | |||||
{ | |||||
$urls = explode("/", $this->BaseUrlPath); | |||||
if (count($urls) <= $pathStep) { | |||||
return ""; | return ""; | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
$pstr = "http://"; | $pstr = "http://"; | ||||
for($i=0;$i<count($urls)-$pathStep;$i++) | |||||
{ | |||||
$pstr .= $urls[$i]."/"; | |||||
for ($i = 0; $i < count($urls) - $pathStep; $i++) { | |||||
$pstr .= $urls[$i] . "/"; | |||||
} | } | ||||
$okurl = $pstr.$dstr; | |||||
$okurl = $pstr . $dstr; | |||||
} | } | ||||
} | } | ||||
} | |||||
else | |||||
{ | |||||
if(strlen($surl)<7) | |||||
{ | |||||
$okurl = "http://".$this->BaseUrlPath."/".$surl; | |||||
} | |||||
else if(strtolower(substr($surl,0,7))=="http://") | |||||
{ | |||||
} else { | |||||
if (strlen($surl) < 7) { | |||||
$okurl = "http://" . $this->BaseUrlPath . "/" . $surl; | |||||
} else if (strtolower(substr($surl, 0, 7)) == "http://") { | |||||
$okurl = $surl; | $okurl = $surl; | ||||
} | |||||
else | |||||
{ | |||||
$okurl = "http://".$this->BaseUrlPath."/".$surl; | |||||
} else { | |||||
$okurl = "http://" . $this->BaseUrlPath . "/" . $surl; | |||||
} | } | ||||
} | } | ||||
$okurl = preg_replace("/^(http:\/\/)/i","",$okurl); | |||||
$okurl = preg_replace("/^(http:\/\/)/i", "", $okurl); | |||||
$okurl = preg_replace("/\/{1,}/", "/", $okurl); | $okurl = preg_replace("/\/{1,}/", "/", $okurl); | ||||
return "http://".$okurl; | |||||
return "http://" . $okurl; | |||||
} | } | ||||
}//End Class | }//End Class |
@@ -1,4 +1,4 @@ | |||||
<?php if(!defined('DEDEINC')) exit('dedecms'); | |||||
<?php if (!defined('DEDEINC')) exit('dedecms'); | |||||
/** | /** | ||||
* FTP 操作类 | * FTP 操作类 | ||||
* 不支持 SFTP 和 SSL FTP 协议, 仅支持标准 FTP 协议. | * 不支持 SFTP 和 SSL FTP 协议, 仅支持标准 FTP 协议. | ||||
@@ -16,7 +16,8 @@ | |||||
* @link http://www.dedecms.com | * @link http://www.dedecms.com | ||||
*/ | */ | ||||
@set_time_limit(1000); | @set_time_limit(1000); | ||||
class FTP { | |||||
class FTP | |||||
{ | |||||
var $hostname = ''; | var $hostname = ''; | ||||
var $username = ''; | var $username = ''; | ||||
var $password = ''; | var $password = ''; | ||||
@@ -37,8 +38,7 @@ class FTP { | |||||
*/ | */ | ||||
function FTP($config = array()) | function FTP($config = array()) | ||||
{ | { | ||||
if (count($config) > 0) | |||||
{ | |||||
if (count($config) > 0) { | |||||
$this->initialize($config); | $this->initialize($config); | ||||
} | } | ||||
} | } | ||||
@@ -52,10 +52,8 @@ class FTP { | |||||
*/ | */ | ||||
function initialize($config = array()) | function initialize($config = array()) | ||||
{ | { | ||||
foreach ($config as $key => $val) | |||||
{ | |||||
if (isset($this->$key)) | |||||
{ | |||||
foreach ($config as $key => $val) { | |||||
if (isset($this->$key)) { | |||||
$this->$key = $val; | $this->$key = $val; | ||||
} | } | ||||
} | } | ||||
@@ -73,32 +71,26 @@ class FTP { | |||||
*/ | */ | ||||
function connect($config = array()) | function connect($config = array()) | ||||
{ | { | ||||
if (count($config) > 0) | |||||
{ | |||||
if (count($config) > 0) { | |||||
$this->initialize($config); | $this->initialize($config); | ||||
} | } | ||||
if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port))) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port))) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法链接'); | $this->_error('无法链接'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
if ( ! $this->_login()) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if (!$this->_login()) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法登录'); | $this->_error('无法登录'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
// 如果需要则设置传输模式 | // 如果需要则设置传输模式 | ||||
if ($this->passive == TRUE) | |||||
{ | |||||
if ($this->passive == TRUE) { | |||||
ftp_pasv($this->conn_id, TRUE); | ftp_pasv($this->conn_id, TRUE); | ||||
} | } | ||||
@@ -124,10 +116,8 @@ class FTP { | |||||
*/ | */ | ||||
function _is_conn() | function _is_conn() | ||||
{ | { | ||||
if ( ! is_resource($this->conn_id)) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if (!is_resource($this->conn_id)) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法链接'); | $this->_error('无法链接'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
@@ -149,17 +139,14 @@ class FTP { | |||||
*/ | */ | ||||
function changedir($path = '', $supress_debug = FALSE) | function changedir($path = '', $supress_debug = FALSE) | ||||
{ | { | ||||
if ($path == '' OR ! $this->_is_conn()) | |||||
{ | |||||
if ($path == '' or !$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$result = @ftp_chdir($this->conn_id, $path); | $result = @ftp_chdir($this->conn_id, $path); | ||||
if ($result === FALSE) | |||||
{ | |||||
if ($this->debug == TRUE AND $supress_debug == FALSE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
if ($this->debug == TRUE and $supress_debug == FALSE) { | |||||
$this->_error('无法更改目录'); | $this->_error('无法更改目录'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
@@ -177,25 +164,21 @@ class FTP { | |||||
*/ | */ | ||||
function mkdir($path = '', $permissions = NULL) | function mkdir($path = '', $permissions = NULL) | ||||
{ | { | ||||
if ($path == '' OR ! $this->_is_conn()) | |||||
{ | |||||
if ($path == '' or !$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$result = @ftp_mkdir($this->conn_id, $path); | $result = @ftp_mkdir($this->conn_id, $path); | ||||
if ($result === FALSE) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法创建文件夹'); | $this->_error('无法创建文件夹'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
// 如果需要设置权限 | // 如果需要设置权限 | ||||
if ( ! is_null($permissions)) | |||||
{ | |||||
if (!is_null($permissions)) { | |||||
$this->chmod($path, (int)$permissions); | $this->chmod($path, (int)$permissions); | ||||
} | } | ||||
@@ -211,24 +194,19 @@ class FTP { | |||||
*/ | */ | ||||
function rmkdir($path = '', $pathsymbol = '/') | function rmkdir($path = '', $pathsymbol = '/') | ||||
{ | { | ||||
$pathArray = explode($pathsymbol,$path); | |||||
$pathArray = explode($pathsymbol, $path); | |||||
$pathstr = $pathsymbol; | $pathstr = $pathsymbol; | ||||
foreach($pathArray as $val) | |||||
{ | |||||
if(!empty($val)) | |||||
{ | |||||
foreach ($pathArray as $val) { | |||||
if (!empty($val)) { | |||||
//构建文件夹路径 | //构建文件夹路径 | ||||
$pathstr = $pathstr.$val.$pathsymbol; | |||||
if (! $this->_is_conn()) | |||||
{ | |||||
$pathstr = $pathstr . $val . $pathsymbol; | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$result = @ftp_chdir($this->conn_id, $pathstr); | $result = @ftp_chdir($this->conn_id, $pathstr); | ||||
if($result === FALSE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
//如果不存在这个目录则创建 | //如果不存在这个目录则创建 | ||||
if(!$this->mkdir($pathstr)) | |||||
{ | |||||
if (!$this->mkdir($pathstr)) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
} | } | ||||
@@ -248,20 +226,17 @@ class FTP { | |||||
*/ | */ | ||||
function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL) | function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL) | ||||
{ | { | ||||
if (!$this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
if (!file_exists($locpath)) | |||||
{ | |||||
if (!file_exists($locpath)) { | |||||
$this->_error('不存在源文件'); | $this->_error('不存在源文件'); | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
// 未指定则设置模式 | // 未指定则设置模式 | ||||
if ($mode == 'auto') | |||||
{ | |||||
if ($mode == 'auto') { | |||||
// 获取文件扩展名,以便本类上传类型 | // 获取文件扩展名,以便本类上传类型 | ||||
$ext = $this->_getext($locpath); | $ext = $this->_getext($locpath); | ||||
$mode = $this->_settype($ext); | $mode = $this->_settype($ext); | ||||
@@ -271,18 +246,15 @@ class FTP { | |||||
$result = @ftp_put($this->conn_id, $rempath, $locpath, $mode); | $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode); | ||||
if ($result === FALSE) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法上传'); | $this->_error('无法上传'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
// 如果需要设置文件权限 | // 如果需要设置文件权限 | ||||
if ( ! is_null($permissions)) | |||||
{ | |||||
if (!is_null($permissions)) { | |||||
$this->chmod($rempath, (int)$permissions); | $this->chmod($rempath, (int)$permissions); | ||||
} | } | ||||
@@ -300,17 +272,14 @@ class FTP { | |||||
*/ | */ | ||||
function rename($old_file, $new_file, $move = FALSE) | function rename($old_file, $new_file, $move = FALSE) | ||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$result = @ftp_rename($this->conn_id, $old_file, $new_file); | $result = @ftp_rename($this->conn_id, $old_file, $new_file); | ||||
if ($result === FALSE) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
if ($this->debug == TRUE) { | |||||
$msg = ($move == FALSE) ? '无法重命名' : '无法移动'; | $msg = ($move == FALSE) ? '无法重命名' : '无法移动'; | ||||
$this->_error($msg); | $this->_error($msg); | ||||
@@ -343,17 +312,14 @@ class FTP { | |||||
*/ | */ | ||||
function delete_file($filepath) | function delete_file($filepath) | ||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$result = @ftp_delete($this->conn_id, $filepath); | $result = @ftp_delete($this->conn_id, $filepath); | ||||
if ($result === FALSE) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法删除'); | $this->_error('无法删除'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
@@ -371,8 +337,7 @@ class FTP { | |||||
*/ | */ | ||||
function delete_dir($filepath) | function delete_dir($filepath) | ||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
@@ -381,14 +346,11 @@ class FTP { | |||||
$list = $this->list_files($filepath); | $list = $this->list_files($filepath); | ||||
if ($list !== FALSE AND count($list) > 0) | |||||
{ | |||||
foreach ($list as $item) | |||||
{ | |||||
if ($list !== FALSE and count($list) > 0) { | |||||
foreach ($list as $item) { | |||||
// 如果我们不能删除该项目,它则可能是一个文件夹 | // 如果我们不能删除该项目,它则可能是一个文件夹 | ||||
// 将调用 delete_dir() | // 将调用 delete_dir() | ||||
if ( ! @ftp_delete($this->conn_id, $item)) | |||||
{ | |||||
if (!@ftp_delete($this->conn_id, $item)) { | |||||
$this->delete_dir($item); | $this->delete_dir($item); | ||||
} | } | ||||
} | } | ||||
@@ -396,10 +358,8 @@ class FTP { | |||||
$result = @ftp_rmdir($this->conn_id, $filepath); | $result = @ftp_rmdir($this->conn_id, $filepath); | ||||
if ($result === FALSE) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法删除'); | $this->_error('无法删除'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
@@ -418,16 +378,13 @@ class FTP { | |||||
*/ | */ | ||||
function chmod($path, $perm) | function chmod($path, $perm) | ||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
// 仅PHP5才能运行 | // 仅PHP5才能运行 | ||||
if ( ! function_exists('ftp_chmod')) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if (!function_exists('ftp_chmod')) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法更改权限'); | $this->_error('无法更改权限'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
@@ -435,10 +392,8 @@ class FTP { | |||||
$result = @ftp_chmod($this->conn_id, $perm, $path); | $result = @ftp_chmod($this->conn_id, $perm, $path); | ||||
if ($result === FALSE) | |||||
{ | |||||
if ($this->debug == TRUE) | |||||
{ | |||||
if ($result === FALSE) { | |||||
if ($this->debug == TRUE) { | |||||
$this->_error('无法更改权限'); | $this->_error('无法更改权限'); | ||||
} | } | ||||
return FALSE; | return FALSE; | ||||
@@ -455,8 +410,7 @@ class FTP { | |||||
*/ | */ | ||||
function list_files($path = '.') | function list_files($path = '.') | ||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
@@ -469,42 +423,41 @@ class FTP { | |||||
* @access public | * @access public | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
function list_rawfiles($path = '.', $type='dir') | |||||
function list_rawfiles($path = '.', $type = 'dir') | |||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
$ftp_rawlist = ftp_rawlist($this->conn_id, $path, TRUE); | $ftp_rawlist = ftp_rawlist($this->conn_id, $path, TRUE); | ||||
foreach ($ftp_rawlist as $v) { | |||||
$info = array(); | |||||
$vinfo = preg_split("/[\s]+/", $v, 9); | |||||
if ($vinfo[0] !== "total") { | |||||
$info['chmod'] = $vinfo[0]; | |||||
$info['num'] = $vinfo[1]; | |||||
$info['owner'] = $vinfo[2]; | |||||
$info['group'] = $vinfo[3]; | |||||
$info['size'] = $vinfo[4]; | |||||
$info['month'] = $vinfo[5]; | |||||
$info['day'] = $vinfo[6]; | |||||
$info['time'] = $vinfo[7]; | |||||
$info['name'] = $vinfo[8]; | |||||
$rawlist[$info['name']] = $info; | |||||
} | |||||
} | |||||
$dir = array(); | |||||
$file = array(); | |||||
foreach ($rawlist as $k => $v) { | |||||
if ($v['chmod']{0} == "d") { | |||||
$dir[$k] = $v; | |||||
} elseif ($v['chmod']{0} == "-") { | |||||
$file[$k] = $v; | |||||
} | |||||
} | |||||
return ($type == 'dir')? $dir : $file; | |||||
foreach ($ftp_rawlist as $v) { | |||||
$info = array(); | |||||
$vinfo = preg_split("/[\s]+/", $v, 9); | |||||
if ($vinfo[0] !== "total") { | |||||
$info['chmod'] = $vinfo[0]; | |||||
$info['num'] = $vinfo[1]; | |||||
$info['owner'] = $vinfo[2]; | |||||
$info['group'] = $vinfo[3]; | |||||
$info['size'] = $vinfo[4]; | |||||
$info['month'] = $vinfo[5]; | |||||
$info['day'] = $vinfo[6]; | |||||
$info['time'] = $vinfo[7]; | |||||
$info['name'] = $vinfo[8]; | |||||
$rawlist[$info['name']] = $info; | |||||
} | |||||
} | |||||
$dir = array(); | |||||
$file = array(); | |||||
foreach ($rawlist as $k => $v) { | |||||
if ($v['chmod'][0] == "d") { | |||||
$dir[$k] = $v; | |||||
} elseif ($v['chmod'][0] == "-") { | |||||
$file[$k] = $v; | |||||
} | |||||
} | |||||
return ($type == 'dir') ? $dir : $file; | |||||
} | } | ||||
/** | /** | ||||
@@ -518,38 +471,30 @@ class FTP { | |||||
*/ | */ | ||||
function mirror($locpath, $rempath) | function mirror($locpath, $rempath) | ||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
// 打开本地文件路径 | // 打开本地文件路径 | ||||
if ($fp = @opendir($locpath)) | |||||
{ | |||||
if ($fp = @opendir($locpath)) { | |||||
// 尝试打开远程文件的路径. | // 尝试打开远程文件的路径. | ||||
if ( ! $this->changedir($rempath, TRUE)) | |||||
{ | |||||
if (!$this->changedir($rempath, TRUE)) { | |||||
// 如果不能打开则创建 | // 如果不能打开则创建 | ||||
if ( ! $this->rmkdir($rempath) OR ! $this->changedir($rempath)) | |||||
{ | |||||
if (!$this->rmkdir($rempath) or !$this->changedir($rempath)) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
} | } | ||||
// 递归读取本地目录 | // 递归读取本地目录 | ||||
while (FALSE !== ($file = readdir($fp))) | |||||
{ | |||||
if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.') | |||||
{ | |||||
$this->mirror($locpath.$file."/", $rempath.$file."/"); | |||||
} | |||||
elseif (substr($file, 0, 1) != ".") | |||||
{ | |||||
while (FALSE !== ($file = readdir($fp))) { | |||||
if (@is_dir($locpath . $file) && substr($file, 0, 1) != '.') { | |||||
$this->mirror($locpath . $file . "/", $rempath . $file . "/"); | |||||
} elseif (substr($file, 0, 1) != ".") { | |||||
// 获取文件扩展名,以便本类上传类型 | // 获取文件扩展名,以便本类上传类型 | ||||
$ext = $this->_getext($file); | $ext = $this->_getext($file); | ||||
$mode = $this->_settype($ext); | $mode = $this->_settype($ext); | ||||
$this->upload($locpath.$file, $rempath.$file, $mode); | |||||
$this->upload($locpath . $file, $rempath . $file, $mode); | |||||
} | } | ||||
} | } | ||||
return TRUE; | return TRUE; | ||||
@@ -567,8 +512,7 @@ class FTP { | |||||
*/ | */ | ||||
function _getext($filename) | function _getext($filename) | ||||
{ | { | ||||
if (FALSE === strpos($filename, '.')) | |||||
{ | |||||
if (FALSE === strpos($filename, '.')) { | |||||
return 'txt'; | return 'txt'; | ||||
} | } | ||||
@@ -586,20 +530,20 @@ class FTP { | |||||
function _settype($ext) | function _settype($ext) | ||||
{ | { | ||||
$text_types = array( | $text_types = array( | ||||
'txt', | |||||
'text', | |||||
'php', | |||||
'phps', | |||||
'php4', | |||||
'js', | |||||
'css', | |||||
'htm', | |||||
'html', | |||||
'phtml', | |||||
'shtml', | |||||
'log', | |||||
'xml' | |||||
); | |||||
'txt', | |||||
'text', | |||||
'php', | |||||
'phps', | |||||
'php4', | |||||
'js', | |||||
'css', | |||||
'htm', | |||||
'html', | |||||
'phtml', | |||||
'shtml', | |||||
'log', | |||||
'xml' | |||||
); | |||||
return (in_array($ext, $text_types)) ? 'ascii' : 'binary'; | return (in_array($ext, $text_types)) ? 'ascii' : 'binary'; | ||||
@@ -615,8 +559,7 @@ class FTP { | |||||
*/ | */ | ||||
function close() | function close() | ||||
{ | { | ||||
if ( ! $this->_is_conn()) | |||||
{ | |||||
if (!$this->_is_conn()) { | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
@@ -632,21 +575,21 @@ class FTP { | |||||
*/ | */ | ||||
function _error($msg) | function _error($msg) | ||||
{ | { | ||||
$errorTrackFile = dirname(__FILE__).'/../data/ftp_error_trace.inc'; | |||||
$errorTrackFile = dirname(__FILE__) . '/../data/ftp_error_trace.inc'; | |||||
$emsg = ''; | $emsg = ''; | ||||
$emsg .= "<div><h3>DedeCMS Error Warning!</h3>\r\n"; | $emsg .= "<div><h3>DedeCMS Error Warning!</h3>\r\n"; | ||||
$emsg .= "<div><a href='http://bbs.dedecms.com' target='_blank' style='color:red'>Technical Support: http://bbs.dedecms.com</a></div>"; | $emsg .= "<div><a href='http://bbs.dedecms.com' target='_blank' style='color:red'>Technical Support: http://bbs.dedecms.com</a></div>"; | ||||
$emsg .= "<div style='line-helght:160%;font-size:14px;color:green'>\r\n"; | $emsg .= "<div style='line-helght:160%;font-size:14px;color:green'>\r\n"; | ||||
$emsg .= "<div style='color:blue'><br />Error page: <font color='red'>".$this->GetCurUrl()."</font></div>\r\n"; | |||||
$emsg .= "<div style='color:blue'><br />Error page: <font color='red'>" . $this->GetCurUrl() . "</font></div>\r\n"; | |||||
$emsg .= "<div>Error infos: {$msg}</div>\r\n"; | $emsg .= "<div>Error infos: {$msg}</div>\r\n"; | ||||
$emsg .= "<br /></div></div>\r\n"; | $emsg .= "<br /></div></div>\r\n"; | ||||
echo $emsg; | echo $emsg; | ||||
$savemsg = 'Page: '.$this->GetCurUrl()."\r\nError: ".$msg; | |||||
$savemsg = 'Page: ' . $this->GetCurUrl() . "\r\nError: " . $msg; | |||||
//保存错误日志 | //保存错误日志 | ||||
$fp = @fopen($errorTrackFile, 'a'); | $fp = @fopen($errorTrackFile, 'a'); | ||||
@fwrite($fp, '<'.'?php exit();'."\r\n/*\r\n{$savemsg}\r\n*/\r\n?".">\r\n"); | |||||
@fwrite($fp, '<' . '?php exit();' . "\r\n/*\r\n{$savemsg}\r\n*/\r\n?" . ">\r\n"); | |||||
@fclose($fp); | @fclose($fp); | ||||
} | } | ||||
@@ -658,22 +601,17 @@ class FTP { | |||||
*/ | */ | ||||
function GetCurUrl() | function GetCurUrl() | ||||
{ | { | ||||
if(!empty($_SERVER["REQUEST_URI"])) | |||||
{ | |||||
if (!empty($_SERVER["REQUEST_URI"])) { | |||||
$scriptName = $_SERVER["REQUEST_URI"]; | $scriptName = $_SERVER["REQUEST_URI"]; | ||||
$nowurl = $scriptName; | $nowurl = $scriptName; | ||||
} | |||||
else | |||||
{ | |||||
} else { | |||||
$scriptName = $_SERVER["PHP_SELF"]; | $scriptName = $_SERVER["PHP_SELF"]; | ||||
if(empty($_SERVER["QUERY_STRING"])) { | |||||
if (empty($_SERVER["QUERY_STRING"])) { | |||||
$nowurl = $scriptName; | $nowurl = $scriptName; | ||||
} | |||||
else { | |||||
$nowurl = $scriptName."?".$_SERVER["QUERY_STRING"]; | |||||
} else { | |||||
$nowurl = $scriptName . "?" . $_SERVER["QUERY_STRING"]; | |||||
} | } | ||||
} | } | ||||
return $nowurl; | return $nowurl; | ||||
} | } | ||||
}//End Class | }//End Class |
@@ -500,7 +500,7 @@ function lib_arclistDone(&$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen | |||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -228,7 +228,7 @@ function lib_arclistsg(&$ctag,&$refObj) | |||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -157,7 +157,7 @@ function lib_likearticle(&$ctag,&$refObj) | |||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||
@@ -44,7 +44,7 @@ function plus_spacenewart(&$atts,&$refObj,&$fields) | |||||
if($row['litpic']=='') | if($row['litpic']=='') | ||||
{ | { | ||||
$row['litpic'] = '/images/defaultpic.gif'; | |||||
$row['litpic'] = '/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("#^http:\/\/#i", $row['litpic'])) | if(!preg_match("#^http:\/\/#i", $row['litpic'])) | ||||
{ | { | ||||
@@ -1,4 +1,13 @@ | |||||
<?php | <?php | ||||
/** | |||||
* 文件上传安全校验方法 | |||||
* | |||||
* @version $Id: uploadsafe.inc.php 1 15:59 2020年8月19日Z tianya $ | |||||
* @package DedeCMS.Libraries | |||||
* @copyright Copyright (c) 2007 - 2020, DesDev, Inc. | |||||
* @license http://help.dedecms.com/usersguide/license.html | |||||
* @link http://www.dedecms.com | |||||
*/ | |||||
if(!defined('DEDEINC')) exit('Request Error!'); | if(!defined('DEDEINC')) exit('Request Error!'); | ||||
if(isset($_FILES['GLOBALS'])) exit('Request not allow!'); | if(isset($_FILES['GLOBALS'])) exit('Request not allow!'); | ||||
@@ -32,13 +41,29 @@ foreach($_FILES as $_key=>$_value) | |||||
${$_key.'_name'} = $_FILES[$_key]['name']; | ${$_key.'_name'} = $_FILES[$_key]['name']; | ||||
${$_key.'_type'} = $_FILES[$_key]['type'] = preg_replace('#[^0-9a-z\./]#i', '', $_FILES[$_key]['type']); | ${$_key.'_type'} = $_FILES[$_key]['type'] = preg_replace('#[^0-9a-z\./]#i', '', $_FILES[$_key]['type']); | ||||
${$_key.'_size'} = $_FILES[$_key]['size'] = preg_replace('#[^0-9]#','',$_FILES[$_key]['size']); | ${$_key.'_size'} = $_FILES[$_key]['size'] = preg_replace('#[^0-9]#','',$_FILES[$_key]['size']); | ||||
if(!empty(${$_key.'_name'}) && (preg_match("#\.(".$cfg_not_allowall.")$#i",${$_key.'_name'}) || !preg_match("#\.#", ${$_key.'_name'})) ) | |||||
{ | |||||
if(!defined('DEDEADMIN')) | |||||
if (is_array(${$_key.'_name'})) { | |||||
if (count(${$_key.'_name'}) > 0) { | |||||
foreach (${$_key.'_name'} as $key => $value) { | |||||
if (!empty($value) && (preg_match("#\.(".$cfg_not_allowall.")$#i", $value) || !preg_match("#\.#", $value))) { | |||||
if(!defined('DEDEADMIN')) | |||||
{ | |||||
exit('Not Admin Upload filetype not allow !'); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} else { | |||||
if(!empty(${$_key.'_name'}) && (preg_match("#\.(".$cfg_not_allowall.")$#i",${$_key.'_name'}) || !preg_match("#\.#", ${$_key.'_name'})) ) | |||||
{ | { | ||||
exit('Not Admin Upload filetype not allow !'); | |||||
if(!defined('DEDEADMIN')) | |||||
{ | |||||
exit('Not Admin Upload filetype not allow !'); | |||||
} | |||||
} | } | ||||
} | } | ||||
if(empty(${$_key.'_size'})) | if(empty(${$_key.'_size'})) | ||||
{ | { | ||||
${$_key.'_size'} = @filesize($$_key); | ${$_key.'_size'} = @filesize($$_key); | ||||
@@ -50,13 +75,30 @@ foreach($_FILES as $_key=>$_value) | |||||
"image/xpng", "image/wbmp", "image/bmp" | "image/xpng", "image/wbmp", "image/bmp" | ||||
); | ); | ||||
if(in_array(strtolower(trim(${$_key.'_type'})), $imtypes)) | |||||
{ | |||||
$image_dd = @getimagesize($$_key); | |||||
if (!is_array($image_dd)) | |||||
if (is_array(${$_key.'_type'})) { | |||||
if (count(${$_key.'_type'}) > 0) { | |||||
foreach (${$_key.'_type'} as $key => $value) { | |||||
if(in_array(strtolower(trim($value)), $imtypes)) | |||||
{ | |||||
$image_dd = @getimagesize($$_key); | |||||
if (!is_array($image_dd)) | |||||
{ | |||||
exit('Upload filetype not allow !'); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} else { | |||||
if(in_array(strtolower(trim(${$_key.'_type'})), $imtypes)) | |||||
{ | { | ||||
exit('Upload filetype not allow !'); | |||||
$image_dd = @getimagesize($$_key); | |||||
if (!is_array($image_dd)) | |||||
{ | |||||
exit('Upload filetype not allow !'); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
?> | ?> |
@@ -66,7 +66,7 @@ if($tagid !='') | |||||
if($row['litpic'] == '-' || $row['litpic'] == '') | if($row['litpic'] == '-' || $row['litpic'] == '') | ||||
{ | { | ||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif'; | |||||
} | } | ||||
if(!preg_match("#^http:\/\/#", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | if(!preg_match("#^http:\/\/#", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') | ||||
{ | { | ||||