php木马后门研究
七字铺
七字铺 2021-03-26 09:34:51
0
3
1004

本人是学习不足,拿到一个源码,但是发现有webshell后门,至于是哪些代码,辨别不出来,烦请哪位大神指点一下。

0 && @$val['ifshownav'])) {
$newchannel[]=$val;
$计数++;
}
如果($count==$num){
返回 $newchannel;
}
}
返回 $newchannel;
}
}
foreach($channel as $val){
if($fid==$val['fid']) {
if($shownav==0 || ($shownav>0 && $val['ifshownav'])) {
如果($kind==0){
$newchannel[]=$val;
$计数++;
$newchannel[count($newchannel)-1]['key']=$count;
}elseif($val['ckind']==$kind) {
$newchannel[]=$val;
$计数++;
$newchannel[count($newchannel)-1]['key']=$count;
}
}
}
如果($count==$num){
休息;
}
}
$fidarray=@cnav(cid,1);
foreach($newchannel as $key=>$val){
$newchannel[$key]['onstyle']='';
foreach($fidarray as $fidkey=>$fidval) {
if($val['cid']==$fidval['cid']) {
$newchannel[$key]['onstyle']='on';
休息;
}
}
}
返回 $newchannel;
}
函数 b($cid='',$return=false,$linktag=' > ',$homepage=SystemDir) {
返回 cnav($cid,$return,$linktag,$homepage);
}
函数 i($kind='',$cid=0){
如果($cid===0){
if(!define('cid')) {返回 false;}
$cid=cid;
}
$channel=getchannelcache($cid);
if(!$channel) {
返回 false;
}
如果(空($kind)){
返回$频道;
}elseif($kind=='name' && isset($channel['cname'])) {
返回 $channel['cname'];
}elseif($kind=='topfid') {
$breadcrumb=b($channel['cid'],1);
if(isset($breadcrumb[0]['cid'])) {
返回 $breadcrumb[0]['cid'];
}
}elseif($kind=='url') {
返回 u($channel['cid']);
}elseif($kind=='域') {
返回 @$channel['csetting']['channel_domain'];
}别的 {
if(isset($channel[$kind])) {
返回 $channel[$kind];
}
}
返回 false;
}
函数 uri($uri) {
$uri=ltrim($uri,'/');
如果(网址重写){
返回 SystemDir.$uri;
}别的 {
返回 SystemDir.IndexFile.'/'.$uri;
}
}
函数 f($file){
需要(SystemRoot.TemplateDir.DIRECTORY_SEPARATOR.$file);
}
函数 t($file='',$echo=1) {
如果($echo==1){
echo(SystemDir.TemplateDir.'/'.$file);
}
返回 SystemDir.TemplateDir.'/'.$file;
}
函数列表($where=''){
if(isset($where['page']) && !is_numeric($where['page'])) {
if(isset($_GET[$where['page']]) && $_GET[$where['page']]>0) {
$where['page']=intval($_GET[$where['page']]);
}别的 {
$where['page']=1;
}
}
$nullarticle=array('list'=>array(),'pagecount'=>0,'pagesize'=>1,'page'=>1,);
if(!isset($where['cid']) && !define('cid') && !isset($where['tablename']) && !isset($where['cids'])) {Return $nullarticle ;}
if(!isset($where['tablename']) && !isset($where['cid']) && !isset($where['cids']) && define('cid')) {$where[' cid']=cid;}
if(!isset($where['cid'])) {$where['cid']=0;}
if(is_numeric($where['cid'])) {$where['cid']=intval($where['cid']);}
if(SiteCache && isset($where['cache']) && $where['cache']>0) {
$cachewhere=$where;
$cachehash=md5(json_encode($where));
$res =cacheget($cachehash,$where['cache'],'alist');
if ($res) {return json_decode($res,1);}
}
$sql='';
if($where['cid']!==0) {
$thischannelcache=getchannelcache($where['cid']);
if(!$thischannelcache) {Return $nullarticle;}
$where['cid']=$thischannelcache['cid'];
}
if(!isset($where['tablename'])) {$where['tablename']='';}
if(!isset($where['all']) || $where['all']==1) {
if(!isset($where['cids'])) {$where['cids']='';}
$clistsetting=alist_getson($where['cid'],$where['tablename'],$where['cids']);
if(!isset($clistsetting['sql'])) {Return $nullarticle;}$where['cidsql']=$clistsetting['sql'];
$where['tablename']=$clistsetting['tablename'];
$defaultsetting=getchannelcache($clistsetting['default']);
if(!isset($where['pageurl']) && !isset($clistsetting['pageurl'])) {
取消设置($defaultsetting['csetting']['channel_pageurl']);
}
}别的 {
if(!isset($where['cidsql'])) {
$where['cidsql']=" 和 (cid='".$where['cid']."')";
}
if($where['cid']) {
$defaultsetting=getchannelcache($where['cid']);
if(empty($where['tablename']) && isset($defaultsetting['csetting']['articletable'])) {
$where['tablename']=$defaultsetting['csetting']['articletable'];
}
}
}
$sql.=$where['cidsql'];
if(!isset($where['pagesize'])) {
if(isset($defaultsetting['csetting']['temppage_size']) && !empty($defaultsetting['csetting']['temppage_size'])) {
$where['pagesize']=$defaultsetting['csetting']['temppage_size'];
}
}
if(!isset($where['order'])) {
if(isset($defaultsetting['csetting']['temppage_order']) && !empty($defaultsetting['csetting']['temppage_order'])) {
$where['order']=$defaultsetting['csetting']['temppage_order'];
}
}
isset($where['addslashes']) ? $ifaddslashes=$where['addslashes']:$ifaddslashes=1;
isset($where['表名']) ? $where['tablename']=$where['tablename']:die('no tablename');
isset($where['pagesize']) ? $where['pagesize']=intval($where['pagesize']):$where['pagesize']=9;
isset($where['order']) ? $where['order']='order by '.$where['order']:$where['order']='order by id desc';
isset($where['start']) ? $where['start']=intval($where['start']):$where['start']=0;
isset($where['column']) ? $where['column']=$where['column']:$where['column']='*';
isset($where['rowidstyle']) && !isset($where['rowidname'])? $where['rowidname']='id' :'';
isset($where['linktime'])  ?  1==1 : $where['linktime']='posttime';
isset($where['link'])  ?  1==1 : $where['link']='';
isset($where['domain'])  ?  1==1 : $where['domain']='';
if(trim($where['column'])<>'*') {$where['column'].=',cid';}if(isset($where['where'])) {
if(is_array($w​​here['where'])) {
foreach($where['where'] as $key=>$val) {
$key=addslashes_str($key,$ifaddslashes);
if(is_array($val) && count($val)>0) {
$sql.=" 和 (";
foreach($val 作为 $value){
$sql.=$key."='".addslashes_str($value,$ifaddslashes)."' 或";
}
$sql=substr($sql,0,strlen($sql)-4);
$sql.=")";
}别的 {
$sql.=" 和 ".$key."='".addslashes_str($val,$ifaddslashes)."'";
}
}
}别的 {
$sql.=" 和 ".$where['where'];
}
}
if(isset($where['inwhere'])) {
foreach($where['inwhere'] as $key=>$val) {
if(!is_array($val)) {
$val=数组();
$val[]=$where['inwhere'][$key];
}
$key=addslashes_str($key,$ifaddslashes);
foreach($val as $val1){
if(is_numeric($val1) && $val1>0) {
$sql.=" 和 (".$key."='[".$val1."]' 或 ".$key." 像 '%,".$val1.",%' 或 ".$key." "像'[".$val1.",%'或".$key."像'%,".$val1."]')";
}别的 {
取消设置($where['inwhere'][$key]);
}
}
}
}
if(isset($where['无处'])) {
foreach($where['nowhere'] as $key=>$val) {
$key=addslashes_str($key,$ifaddslashes);
if(is_array($val) && count($val)>0) {
foreach($val 作为 $value){
$sql.=" 和 ".$key."<>'".addslashes_str($value,$ifaddslashes).'\'';
}
}别的 {
$sql.=" 和 ".$key."<>'".addslashes_str($val,$ifaddslashes)."'";
}
}
}
if(isset($where['other']) && !empty($where['other'])) {
$sql.=" 和 ".$where['other'];
}
if(isset($where['keyword']) && !empty($where['keyword'])) {
if(!isset($where['searchcolumn'])) {$where['searchcolumn']='title';}
if(!is_array($w​​here['searchcolumn'])) {$where['searchcolumn']=explode(',',$where['searchcolumn']);}
if(!is_array($w​​here['keyword'])) {$where['keyword']=explode('|',$where['keyword']);}
$sql.=" 和 (";
foreach($where['searchcolumn'] as $key=>$searchcolumn) {
foreach($where['keyword'] as $keywordkey=>$keywordval) {
if($key==0 && $keywordkey==0) {
$sql.="$searchcolumn 就像'%".addslashes_str($keywordval,$ifaddslashes)."%'";
}别的 {
$sql.=" 或 $searchcolumn like '%".addslashes_str($keywordval,$ifaddslashes)."%'";
}
}
}
$sql.=" )";
}
if(!empty($sql)) {
$sql='where'.ltrim($sql,'and');
}
if(isset($where['page'])) {
$where['page']=intval($where['page']);
$where['pagecount'] = $GLOBALS['db'] -> fetchcount("SELECT count(id) FROM".$where['tablename']."$sql");
$where['articlecount']=$where['pagecount'];
$where['start']=($where['page']-1)*$where['pagesize'];
if($where['articlecount']%$where['pagesize']==0) {
$where['pages']=($where['articlecount']/$where['pagesize']);
}别的 {
$where['pages']=intval($where['articlecount']/$where['pagesize'])+1;
}
if(isset($defaultsetting['csetting']['channel_pageurl']) && !empty($defaultsetting['csetting']['channel_pageurl']) && !isset($where['pageurl'])) {
$allpageurl=explode(';',$defaultsetting['csetting']['channel_pageurl']);
如果(网址重写){
$where['pageurl']=$allpageurl[0];
}别的 {
$where['pageurl']=SystemDir.IndexFile.$allpageurl[0];
}
}
}
if(!isset($where['sql'])) {
$where['sql_id']='SELECT id FROM'.$where['tablename'].' '.$sql。' '.$where['order'].' 限制'.$where['start'].','.$where['pagesize'];
$idquery=$GLOBALS['db'] -> 查询($where['sql_id']);
$ids = $GLOBALS['db'] -> fetchall($idquery);
$sql='id in(';
if(count($ids)>0) {
foreach($ids as $key=>$val){
$sql.=$val[0].',';
}
}别的 {
$sql.='0,';
}
$sql=rtrim($sql,',');
$sql.=')';
$where['sql']='SELECT '.$where['column'].' FROM '.$where['表名'].' 其中“.$sql”。 '.$where['订单'];
}
$query = $GLOBALS['db'] ->; 查询($where['sql']);
$articles = $GLOBALS['db'] ->; fetchall($查询);
$i=0;
foreach($文章作为$值) 
{
$i++;
$value['key']=$i;
if(isset($where['stepstyle'])) {
foreach($where['stepstyle'] as $key=>$val) {if($i%$key==0) {$value['stepstyle']=$where['stepstyle'][$key] ;}}
if(!isset($value['stepstyle'])) {$value['stepstyle']='';}
}if(isset($where['rowstyle'])) {
foreach($where['rowstyle'] as $key=>$val) {if($i==$key) {$value['rowstyle']=$where['rowstyle'][$key];} }
if(!isset($value['rowstyle'])) {$value['rowstyle']='';}
}
if(isset($where['rowidstyle'])) {
foreach($where['rowidstyle'] as $key=>$val) {
if($value[$where['rowidname']]==$key) {
$value['rowidstyle']=$val;
}
}
if(!isset($value['rowidstyle'])) {$value['rowidstyle']='';}
}
if(!isset($value[$where['linktime']])) {$value[$where['linktime']]=0;}
$value['link']=aurl($value,$where['link'],$value[$where['linktime']],$where['domain']);
$where['list'][]=$value;
}
if(!isset($where['list'])) {$where['list']=array();}
if(SiteCache && isset($where['cache']) && $where['cache']>0) {
缓存集($cachehash,json_encode($where),$where['cache'],'alist');
}
返回 $where;
}
函数 getkinds($cid,$fid) {
$fid=intval($fid);
$kindsarray=数组($fid);
如果(is_numeric($cid)){
$thichannelcache=getchannelcache($cid);
$defaultsetting=$thichannelcache['csetting'];
if(isset($defaultsetting['articletable']) &&!empty($defaultsetting['articletable'])) {
$kindtable=$defaultsetting['articletable'];
}其他{返回$kindsarray;}
}别的 {
$kindtable=$cid;
}
$query = $GLOBALS['db'] ->; 查询(“从$kindtable中选择id,其中fid='$fid';”);
$link = $GLOBALS['db'] -> fetchall($查询);
foreach($link 作为$value) 
{
$thisallkinds=getkinds($kindtable,$value['id']);
foreach($thisallkinds 作为 $thisvalue) 
{
$kindsarray[]=$thisvalue;
}
}
返回$kindsarray;
}
函数 alist_getson($cid,$tablename,$cids,$first=1) {
if($cid==0 && 空($tablename)) {
$表名=文章表;
}
$数组=数组();
$array['list']=array();
$channels=getchannelscache();
如果($第一个){
if(!is_array($cids)) {$cids=explode(';',$cids);}
$thischannel=getchannelcache($cid);
if($thischannel && @$thischannel['ckind']==2 && (in_array($cid,$cids) || 空($cids[0]))) {
if(isset($thischannel['csetting']['articletable']) && !empty($thischannel['csetting']['articletable']) && empty($tablename)) {
$tablename=$thischannel['csetting']['articletable'];
}if($tablename==$thischannel['csetting']['articletable']) {
$array['list'][]=$thischannel;
if(isset($thischannel['csetting']['channel_pageurl']) && !empty($thischannel['csetting']['channel_pageurl'])) {
$array['pageurl']=$thischannel['csetting']['channel_pageurl'];
}
}
}
$array['表名']=$表名;
}
foreach($channels as $key=>$val) {
if($val['fid']==$cid) {
$thischannel=getchannelcache($val['cid']);
如果(空($表名)){
if($thischannel['ckind']==2 && isset($thischannel['csetting']['articletable']) && (in_array($val['cid'],$cids) || 空($cids[ 0]))) {
$array['list'][]=$val;
$tablename=$thischannel['csetting']['articletable'];
$array['表名']=$表名;
}
}别的 {
if($thischannel['ckind']==2 && isset($thischannel['csetting']['articletable']) && $thischannel['csetting']['articletable']==$tablename && (in_array($ val['cid'],$cids) || 空($cids[0]))) {
$array['list'][]=$val;
}
}
$sonarray=alist_getson($val['cid'],$tablename,$cids,0);
foreach($sonarray['list'] as $key1=>$val1) {
$array['list'][]=$val1;
}
}
}
如果($第一个){
$cids=数组();
$sql='';
foreach($array['list'] as $key=>$val) {
如果($key==0){
$sql.=" 和 (cid='".$val['cid']."'";
}elseif($key==(count($array['list'])-1)) {
$sql.=" 或 cid='".$val['cid']."'";
}别的 {
$sql.=" 或 cid='".$val['cid']."'";
}
}
if(count($array['list'])>0) {$array['sql']=$sql.')';}
if(isset($array['list'][0])) {
$array['default']=$array['list'][0]['cid'];
}别的 {
$数组['默认']=0;
}
返回$数组;
}别的 {
返回$数组;
}
}
函数aurl($value,$rowurl,$rowurltime,$domain=''){
$thissetting=getchannelcache($value['cid']);
如果(空($域名)){
if(isset($thissetting['csetting']['channel_domain']) && !empty($thissetting['csetting']['channel_domain'])) {
$domains=explode(';',$thissetting['csetting']['channel_domain']);
$域名=$域名[0];
foreach($domains 作为 $key){
if($key==server_name()) {
$域=空;
休息;
}
}
}
}
如果(空($rowurl)){
if(空($thissetting['csetting']['channel_articleurl'])) {
返回 '​​';
}
$rowurl=$thissetting['csetting']['channel_articleurl'];
}if(!empty($where['domain'])) {
$domains=explode(';',$where['domain']);
$where['domain']=$domains[0];
foreach($domains 作为 $domain){
if($domain==server_name()) {
$where['domain']=null;
休息;
}
}
}
取消设置($这个设置);
$rowurls=explode(';',$rowurl);
$rowurl=$rowurls[0];
preg_match_all("/{(.*)}|\[(.*)\]|\((.*)\)/isU",$rowurl,$match);
if(count($match[0])>0) {
foreach($match[0] as $key=>$val) {
if($rowurltime>0 && ($val=='(y)' || $val=='(m)' || $val=='(d)')) {
isset($value['y'])  ?  1==1 : $value['y']=date('Y',$rowurltime);
isset($value['m'])  ?  1==1 : $value['m']=date('m',$rowurltime);
isset($value['d'])  ?  1==1 : $value['d']=date('d',$rowurltime);
}
if(isset($value[$match[1][$key]])) {
if(is_numeric($value[$match[1][$key]])) {$rowurl=str_replace($val,$value[$match[1][$key]],$rowurl);}else {$ rowurl=str_replace($val,urlencode($value[$match[1][$key]]),$rowurl);}
}
if(isset($value[$match[2][$key]])) {
if(is_numeric($value[$match[2][$key]])) {$rowurl=str_replace($val,$value[$match[2][$key]],$rowurl); }其他{$rowurl=str_replace($val,urlencode($value[$match[2][$key]]),$rowurl); }
}
if(isset($value[$match[3][$key]])) {
if(is_numeric($value[$match[3][$key]])) {$rowurl=str_replace($val,$value[$match[3][$key]],$rowurl); }其他{$rowurl=str_replace($val,urlencode($value[$match[3][$key]]),$rowurl); }
}
}
}
if(!empty($domain)) {
$domain='//'.$domain.server_port();
}
如果(网址重写){
$rowurl=$domain.$rowurl;
}别的 {
$rowurl=$domain.SystemDir.IndexFile.$rowurl;
}
返回$rowurl;
}
函数 all_list($where=array(),$pagesize=10,$cid='') {
if(!isset($where['cache'])) {$where['cache']=3600;}
$cachehash=md5(json_encode($where).$pagesize.json_encode($cid));
$res =cacheget($cachehash,$where['cache'],'alist');
if ($res) {return json_decode($res,1);}
如果(空($cid)){
$cid=数组();
$allchannels=getchannelscache();
foreach($allchannels as $channel){
if($channel['ckin']==2) {
$cid[]=$channel['cid'];
}
}
}elseif(is_numeric($cid)) {
$cid=数组($cid);
}
$文章=数组();
foreach($cid as $thiscid) {
$where['cid']=$thiscid;
$where['pagesize']=$pagesize;
$where['all']=0;
$thisarticles=alist($where);
foreach($thisarticles['list'] as $thisarticle) {
$文章[]=$这篇文章;
}
}
$posttime=数组();
foreach($articles as $article){
$posttime[] = $article['posttime'];
}$orderarticles=array_multisort($posttime, SORT_DESC, $articles);
$returnarticles=数组();
$i=0;
foreach($articles as $key=>$val) {
$i++;
$val['key']=$i;
$returnarticles[]=$val;
if($key==($pagesize-1)) {
休息;
}
}
if(SiteCache && $where['cache']>0) {
缓存集($cachehash,json_encode($returnarticles),$where['cache'],'alist');
}
返回$returnarticles;
}
函数 ainsert($article,$setting='') {
if(!is_array($article)) {返回 false;}
if(空($setting)) {$setting=array();}
if(!isset($setting['cid']) && !isset($article['cid'])) {
如果(已定义('cid')){
$setting['cid']=cid;
}别的 {
return '设置无 cid';
}
}
if(!isset($setting['addslashes'])) {$setting['addslashes']=1;}
if(!isset($setting['default'])) {$setting['default']=1;}
if(!isset($setting['check'])) {$setting['check']=1;}
if(!isset($setting['cid'])) {$setting['cid']=$article['cid'];}
if(isset($article['cid'])) {unset($article['cid']);}
$channel = getchannelcache($setting['cid']);
if(!$channel) {Return '频道不存在';}
$setting['cid']=$channel['cid'];
$csetting=$channel['csetting'];
if(!isset($setting['tablename']) || empty($setting['tablename'])) {$setting['tablename']=$csetting['articletable'];}
if(count($article)==0) {
return 'where 文章列';
}
foreach($article as $key=>$val){
$article[$key]=addslashes_str($article[$key],$setting['addslashes']);
}
if($setting['检查']) {
$columns=$GLOBALS['db']-> all("select mname,mkind,ifonly,strdefault,msetting from".tableex('moudle')." where cid=".$setting['cid']." order by morder asc;");
foreach($columns as $thiscolumn){
$key=$thiscolumn['mname'];
if(!isset($article[$key]) && $setting['default']) {
$article[$key]=$thiscolumn['strdefault'];
if($thiscolumn['mkind']==9) {
if($thiscolumn['strdefault']=='now') {
$文章[$key]=时间();
}别的{
$thiscolumn['strdefault']=@strtotime($thiscolumn['strdefault']);
if($thiscolumn['strdefault']) {
$article[$key]=$thiscolumn['strdefault'];
}别的 {
$文章[$键]=0;
}
}
}
}if(isset($article[$key])) {
$thismsetting=json_decode($thiscolumn['msetting'],1);
$thismsetting['ifonly']=$thiscolumn['ifonly'];
$thismsetting['表名']=$setting['表名'];
$thismoudlevalue=$article[$key];
if($thismsetting['filterhtml']==1) {
require_once(SystemRoot.AdminDir.'/input/kses.php');
$thisismoudlevalue= kses($thisismoudlevalue);
}elseif($thismsetting['filterhtml']==2) {
$thisismoudlevalue=htmlspecialchars($thisismoudlevalue);
}
$acheck=acheck($key,$thisismoudlevalue,$setting['cid'],$thismsetting);
if($acheck==='error') {返回$key。' 错误';}
if($acheck==='short') {返回 $key。' 短的';}
if($acheck==='long') {返回 $key。' 长的';}
if($acheck==='exist') {返回$key。' 存在';}
$article[$key]=$thismoudlevalue;
}
}
}
$article['cid']=$setting['cid'];
if(!isset($article['posttime'])) {$article['posttime']=time();}
if(!isset($article['adminuid'])) {$article['adminuid']=0;}
$结果 = $GLOBALS['db'] -> 插入($setting['表名'],$article);
if($result) {返回 $result;}else {返回 false;}
}
函数 aedit($article,$setting='') {
if(!isset($article['id']) || !is_numeric($article['id']) || $article['id']<1) {
返回“id 错误”;
}
$id=$article['id'];
取消设置($article['id']);
if(!is_array($article)) {返回 false;}
if(空($setting)) {$setting=array();}
if(!isset($setting['cid']) && !isset($article['cid'])) {
如果(已定义('cid')){
$setting['cid']=cid;
}别的 {
return '设置无 cid';
}
}
if(!isset($setting['addslashes'])) {$setting['addslashes']=1;}
if(!isset($setting['check'])) {$setting['check']=1;}
if(!isset($setting['cid'])) {$setting['cid']=$article['cid'];}
if(isset($article['cid'])) {unset($article['cid']);}
$channel = getchannelcache($setting['cid']);
if(!$channel) {Return '频道不存在';}
$setting['cid']=$channel['cid'];
$csetting=$channel['csetting'];
if(!isset($setting['tablename']) || empty($setting['tablename'])) {$setting['tablename']=$csetting['articletable'];}
if(count($article)==0) {
return 'where 文章列';
}
foreach($article as $key=>$val){
$article[$key]=addslashes_str($article[$key],$setting['addslashes']);
}if($setting['检查']) {
$columns=$GLOBALS['db']-> all("select mname,ifonly,strdefault,msetting from".tableex('moudle')." where cid=".$setting['cid']." order by morder asc;");
foreach($columns as $thiscolumn){
$key=$thiscolumn['mname'];
if(isset($article[$key])) {
$thismsetting=json_decode($thiscolumn['msetting'],1);
$thismsetting['ifonly']=$thiscolumn['ifonly'];
$thismsetting['表名']=$setting['表名'];
$thismoudlevalue=$article[$key];
if($thismsetting['filterhtml']==1) {
require_once(SystemRoot.AdminDir.'/input/kses.php');
$thisismoudlevalue= kses($thisismoudlevalue);
}elseif($thismsetting['filterhtml']==2) {
$thisismoudlevalue=htmlspecialchars($thisismoudlevalue);
}
$acheck=acheck($key,$thisismoudlevalue,$setting['cid'],$thismsetting,$id);
if($acheck==='error') {返回$key。' 错误';}
if($acheck==='short') {返回 $key。' 短的';}
if($acheck==='long') {返回 $key。' 长的';}
if($acheck==='exist') {返回$key。' 存在';}
$article[$key]=$thismoudlevalue;
}
}
}
$结果 = $GLOBALS['db'] -> update($setting['tablename'],"id='$id'",$article);
if($result) {返回 true;}else {返回 false;}
}
函数 adel($cid,$id,$tablename='') {
if(空($cid) && 空($tablename)) {
如果(已定义('cid')){
$cid=cid;
}别的 {
返回“无 cid”;
}
}
if(empty($id)) {Return 'no id';}else {$id=intval($id);}
如果(空($表名)){
$channel = getchannelcache($cid);
if(!$channel) {Return '频道不存在';}
$cid=$channel['cid'];
$csetting=$channel['csetting'];
$tablename=$csetting['articletable'];
}
$query = $GLOBALS['db'] ->; 查询(“从`$tablename`WHERE id='$id'删除”);
如果($查询){
返回 true;
}别的 {
返回 false;
}
}
函数acheck($mname,$value,$cid='',$thismsetting='',$id=0){
如果($cid==''){
如果(已定义('cid')){
$cid=cid;
}别的 {
返回“无 cid”;
}
}if($thismsetting=='') {
$column=$GLOBALS['db']-> one("select mname,ifonly,msetting from".tableex('moudle')." where cid='".$cid."' and mname='".$mname."' limit 1;");
$thismsetting=json_decode($column['msetting'],1);
$thismsetting['ifonly']=$column['ifonly'];
}
if(isset($thismsetting['regular']) && strlen($thismsetting['regular'])>3 && !empty($value)) {
if(!preg_match($thismsetting['regular'],$value)){
返回“错误”;
}
}
if(isset($thismsetting['lenmin']) && is_numeric($thismsetting['lenmin']) && $thismsetting['lenmin']>0) {
if(strlen($value)<$thismsetting['lenmin']) {
返回“短”;
}
}
if(isset($thismsetting['lenmax']) && is_numeric($thismsetting['lenmax']) && $thismsetting['lenmax']>0) {
if(strlen($value)>$thismsetting['lenmax']) {
返回“长”;
}
}
if($thismsetting['ifonly']==1) {
if(!isset($thismsetting['tablename'])) {
$channel = getchannelcache($cid);
$thismsetting['tablename']=$channel['csetting']['articletable'];
}
如果($id>0){
$pagecount = $GLOBALS['db'] ->; fetchcount("SELECT id FROM".$thismsetting['tablename']." where $mname='$value' and cid='".$cid."' and id<>'$id' limit 1;") ;
}别的 {
$pagecount = $GLOBALS['db'] ->; fetchcount("SELECT id FROM".$thismsetting['tablename']." where $mname='$value' and cid='".$cid."' limit 1;");
}
if($pagecount) {
返回“存在”;
}
}
返回 true;
}
函数addslashes_str($val,$addslashes){
如果($addslashes){
返回 dbstr($val);
}别的 {
返回$val;
}
}
函数 pagelist($alist,$url='',$returnarray=0)
{
if(!isset($alist['pagecount']) || !isset($alist['page'])) {
返回 false;
}
$recordcount=$alist['pagecount'];
$pagesize=$alist['pagesize'];
$curpage=$alist['页面'];
$pages=isset($alist['showpages']) ? $alist['showpages'] :3 ;
if(empty($url) && isset($alist['pageurl']) && !empty($alist['pageurl'])) {
$url=$alist['pageurl'];
if(isset($alist['cid'])) {
$url=str_replace('(cid)',$alist['cid'],$url);
}
}别的 {
如果(网址重写){
$url=$_SERVER['REQUEST_URI'];
}别的 {
$url=$_SERVER['SCRIPT_NAME'].$_SERVER['REQUEST_URI'];
}
if(stripos($url,'page=')===false) {
if(stripos($url,'?')===false) {
$url=$url."?page=(页面)";
}别的 {
$url=$url."&page=(页面)";
}
}
$url = preg_replace("/page=([0-9]+)/is", "page=(page)", $url);
}
if($pagesize<1) {
$页面大小=1;
}
$pagesarray=数组();
$totalpage = max(ceil($recordcount/$pagesize),1);
if($curpage<0 || $curpage>$totalpage) $curpage=1;
$outhtml = "";
$pageno = $curpage;
if($pageno<0 || $pageno>$totalpage) $pageno=1;
if($pageno==1) {
$pagesarray[]=array('url'=>str_replace('(page)','1',$url),'title'=>'<<','class'=>'已禁用');
}别的 {
$pagesarray[]=array('url'=>str_replace('(page)','1',$url),'title'=>'<<','class'=>'' );
}
if($pages>$totalpage){
$起始页=1;
$endpage=min($startpage+$pages,$totalpage);
}别的{
$startpage=max($totalpage-$pages,1);
$startpage=min($startpage,$curpage);
$endpage=min($startpage+$pages,$totalpage);
}
if($pageno>1){
$pagesarray[]=array('url'=>str_replace('(page)',$pageno-1,$url),'title'=>'<','class'=>'') ;
}别的{
$pagesarray[]=array('url'=>str_replace('(page)',1,$url),'title'=>'<','class'=>'禁用');
}
for($i=$startpage;$i<=$endpage;$i++)
{
如果($curpage==$i){
$pagesarray[]=array('url'=>str_replace('(page)',$i,$url),'title'=>$i,'class'=>'on');
}别的{
$pagesarray[]=array('url'=>str_replace('(page)',$i,$url),'title'=>$i,'class'=>'');
}
 }
if($pageno<$totalpage){
$pagesarray[]=array('url'=>str_replace('(page)',$pageno+1,$url),'title'=>'>','class'=>'') ;
}别的{
$pagesarray[]=array('url'=>str_replace('(page)',$totalpage,$url),'title'=>'>','class'=>'禁用');
}
if($pageno==$totalpage) {
$pagesarray[]=array('url'=>str_replace('(page)',$totalpage,$url),'title'=>'>>','class'=>'禁用' );
}别的 {
$pagesarray[]=array('url'=>str_replace('(page)',$totalpage,$url),'title'=>'>>','class'=>'') ;
}
if($returnarray) {
返回$pagesarray;
}别的 {
$outhtml='';
foreach($pagesarray as $val){
if(!empty($val['class'])) {
$val['class']=' class="'.$val['class'].'"';
}
$outhtml.=''.$val['title'] .'</a></li>';
}
}
回声 $outhtml;
}
函数导航($where=0){
$通道数组=数组();
if(!is_array($w​​here)) {
$thiscid=$where;
$where=数组();
$where['cid']=$thiscid;
}
if(!isset($where['cid'])) {
$where['cid']=0;
}
$cid=$where['cid'];
if(!isset($where['oncid'])) {
如果(已定义('cid')){
$where['oncid']=cid;
}别的 {
$where['oncid']=0;
}
// 取出所有的id
}
if(!isset($where['onstyle'])) {
$where['onstyle']=' class="on"';
}
if(!isset($where['bro'])) {$where['bro']=1;}
if(!isset($where['papa'])) {$where['papa']=1;}
if($where['cid']==0) {
if(!isset($where['主页'])) {
$where['主页']['名称']='首页';
$where['homepage']['url']=gethomeurl();
$where['主页']['目标']='';
}别的 {
if(is_array($w​​here['主页'])) {
if(!isset($where['主页']['名称'])) {
$where['主页']['名称']='首页';
}
if(!isset($where['主页']['url'])) {
$where['homepage']['url']=gethomeurl();
}
if(!isset($where['主页']['目标'])) {
$where['主页']['目标']='';
}
}
}
if(is_array($w​​here['主页'])) {
$channelarray[]=array('cid'=>'0','fid'=>'0','name'=>$where['homepage']['name'],'url'= >$where['homepage']['url'],'target'=>$where['homepage']['target']);
}
}
$allchannels=getchannelscache();
$通道=数组();
foreach($allchannels as $val) {
if($val['ifshownav']==1) {
$channels[]=$val;
}
}
$计数=0;
$myfid=0;
$付费=0;
foreach($channels 作为 $channel){
如果(is_numeric($cid)){
if($channel['cid']==$cid) {
$myfid=$channel['fid'];
if($cid>0 && $where['papa']==1) {
$channelarray['papa']=$myfid;//显示父栏目
$papaid=$myfid;
}
}
if($channel['fid']==$cid) {
$计数=1;
$channelarray[]=$channel;
}
}elseif(is_array($cid)) {
if(in_array($channel['cid'],$cid)) {
$计数=1;
$channelarray[]=$channel;
}
}
}if($count>0 && is_numeric($cid) && $cid>0 && $where['papa']==1) {
$channelarray['papa']=$cid;
}
如果($count==0){
$noonpapaid=$myfid;
}别的 {
$noonpapaid=假;
}
if(isset($channelarray['papa']) && $channelarray['papa']>0) {
foreach($channels 作为 $channel){
if($channel['cid']==$channelarray['papa']) {
$channelarray['papa']=$channel;
}
}
}别的 {
取消设置($channelarray['papa']);
}
if(isset($where['bro']) && $where['bro']==1 && $count==0 &&  is_numeric($cid)) {
// 显示兄弟栏目
if(isset($myfid) && $myfid>0) {
foreach($channels as $key=>$channel){
if($channel['fid']==$myfid) {$channelarray[]=$channel;}
}
}elseif(isset($myfid) && $myfid==0) {
foreach($channels as $key=>$channel){
if($channel['cid']==$cid) {$channelarray[]=$channel;}
}
}
}
$onarray=数组();
如果(已定义('cid')){
$thiscid=cid;
而(1<2){
$ifin=假;
foreach($channels 作为 $channel){
if($channel['cid']==$thiscid && $channel['cid']!=$noonpapaid) {
$onarray[]=$channel['cid'];
$thiscid=$channel['fid'];
$ifin=真;
休息;
}
}
if($ifin===false || $thiscid==0) {
休息;
}
}
}
$returnarray=数组();
$returnstr='';
if(!isset($where['html'])) {
$where['html']='<li{onstyle}><a href="{url}"{target}>{name}</a></li>';
}
if(isset($GLOBALS['nav'][$cid])) {
if(is_array($GLOBALS['nav'][$cid])) {
$channelarray=$GLOBALS['nav'][$cid];
}elseif(function_exists($GLOBALS['nav'][$cid])){
$channelarray=$GLOBALS['nav'][$cid]($cid);
}
}
foreach($channelarray as $key=>$channel){
$thisstr=$where['html'];
if(!isset($channel['onstyle']) || empty($channel['onstyle'])) {
if(in_array($channel['cid'],$onarray)) {
$channel['onstyle']=$where['onstyle'];
}别的 {
$channel['onstyle']='';
}
}
if(define('cid') && cid==0 && $channel['cid']==0) {//主页
$channel['onstyle']=$where['onstyle'];
}
$returnarray[]=$channel;
if(!isset($where['returnarray']) || $where['returnarray']==0) {
$thisstr=str_replace('{url}',@$channel['url'],$thisstr);
$thisstr=str_replace('{target}',@$channel['target'],$thisstr);
$thisstr=str_replace('{name}',@$channel['name'],$thisstr);
$thisstr=str_replace('{onstyle}',@$channel['onstyle'],$thisstr);
$returnstr.=$thisstr."\r\n";
}
}
if(!isset($where['returnarray']) || $where['returnarray']==0) {
返回 $returnstr;
}别的{
返回$returnarray;
}
}
函数 cnav($cid='',$returnarray=false,$linktag=' > ',$homepage=SystemDir) {
如果(空($cid)){
如果(定义('cid')){
$cid=cid;
}别的 {
$cid=0;
}
}
$channels=getchannelscache();
$面包屑='';
$breadcrumbarray=数组();
而(1<2)
{
$这个频道=假;
foreach($channels 作为 $channel){
if($channel['cid']==$cid) {
$这个频道=$频道;
}
}
如果($这个频道==假){
if($breadcrumb=='') {
$breadcrumb='首页';
}别的 {
$breadcrumb='首页'.$linktag.$breadcrumb;
}
if($returnarray) {
返回 array_reverse($breadcrumbarray);
}别的 {
返回$breadcrumb;
}
}别的 {
if($breadcrumb=='') {
$breadcrumb=''.$thischannel['name'].'</a>';
}别的 {
$breadcrumb='<a href="'.$thischannel['url'].'">'.$thischannel['name'].'</a>'.$linktag.$breadcrumb;
}
$breadcrumbarray[]=$这个频道;
$cid=$thischannel['fid'];
}
}
}
函数 getallchannelscache() {
if(isset($GLOBALS['allchannelscache'])) {
返回 $GLOBALS['allchannelscache'];
}
$channelcachekeyname='allchannelscache';
$channelcache=cacheget($channelcachekeyname,604800,'通道');
if($channelcache) {
$channels=json_decode($channelcache,1);
}别的 {
$channelslist=$GLOBALS['db']->all("从 ".tableex('channel') 中选择 cid,fid,ifshownav,cname,ckind,cvalue,newwindow,csetting。" 其中 ckind<>'4 '按编码升序排序");
if($channelslist) {
$通道=数组();
foreach($channelslist as $val){
取消设置($这个频道);
$这个频道=数组();
$thischannel['cid']=$val['cid'];
$thischannel['fid']=$val['fid'];
$thischannel['ckind']=$val['ckind'];
$thischannel['ifshownav']=$val['ifshownav'];
$thischannel['name']=$val['cname'];
if($val['newwindow']==1) {
$thischannel['target']=' target="_blank" ';
}别的 {
$thischannel['目标']='';
}
$thischannel['url']=getchannelurl($val);
如果(空($thischannel['url'])){
$thischannel['url']='#';
$thischannel['target']='';
}$channels[]=$这个频道;
}
缓存集($channelcachekeyname,json_encode($channels),604800,'channel');
}别的 {
返回数组();
}
}
$GLOBALS['allchannelscache']=$channels;
返回 $channels;
}
函数 getchannelscache() {
if(isset($GLOBALS['channelscache'])) {
返回 $GLOBALS['channelscache'];
}
$channelcachekeyname='channelscache';
$channelcache=cacheget($channelcachekeyname,604800,'通道');
if($channelcache) {
$channels=json_decode($channelcache,1);
}别的 {
$channelslist=$GLOBALS['db']->all("从 ".tableex('channel') 中选择 cid,fid,ifshownav,cname,ckind,cvalue,newwindow,csetting。" 其中 ckind<>'4 ' 和 ifshow=1 按编码 asc 排序");
if($channelslist) {
$通道=数组();
foreach($channelslist as $val){
取消设置($这个频道);
$这个频道=数组();
$thischannel['cid']=$val['cid'];
$thischannel['fid']=$val['fid'];
$thischannel['ckind']=$val['ckind'];
$thischannel['ifshownav']=$val['ifshownav'];
$thischannel['name']=$val['cname'];
if($val['newwindow']==1) {
$thischannel['target']=' target="_blank" ';
}别的 {
$thischannel['target']='';
}
$thischannel['url']=getchannelurl($val);
如果(空($thischannel['url'])){
$thischannel['url']='#';
$thischannel['target']='';
}
$channels[]=$这个频道;
}
缓存集($channelcachekeyname,json_encode($channels),604800,'channel');
}别的 {
返回数组();
}
}
$GLOBALS['channelscache']=$channels;
返回 $channels;
}
函数 getchannelcache($cid){
if(isset($GLOBALS['channelcache'][$cid])) {
返回 $GLOBALS['channelcache'][$cid];
}
$channelcachekeyname='channelcache_'.$cid;
$channelcache=cacheget($channelcachekeyname,604800,'通道');
if($channelcache) {
$channelcache=json_decode($channelcache,1);
}别的 {
如果(is_numeric($cid)){
$channelcache=$GLOBALS['db']->one("SELECT * FROM".tableex('channel')." where cid='$cid' limit 1");
}别的 {
$channelcache=$GLOBALS['db']->one("SELECT * FROM".tableex('channel')." where cname='$cid' limit 1");
}
if($channelcache) {
$channelcache['csetting']=json_decode($channelcache['csetting'],1);
缓存集($channelcachekeyname,json_encode($channelcache),604800,'channel');
}别的 {
返回 false;
}
}
$GLOBALS['channelcache'][$cid]=$channelcache;
返回$channelcache;
}函数 getchannelurl($cid){
if(!is_array($cid)) {
$cid=getchannelcache($cid);
if(!$cid) {返回 false;}
$csetting=$cid['csetting'];
}别的 {
$csetting=json_decode($cid['csetting'],1);
}
$频道=$cid;
if($channel['ckind']==3 || $channel['ckind']==4 || $channel['ckind']==5) {
返回 $channel['cvalue'];
}elseif($channel['ckind']==1 || $channel['ckind']==2) {
if(isset($csetting['template']) && 空($csetting['template'])) {
返回 '​​';
}
}
if(!isset($csetting['channel_url'])) {Return '';}
$channelurls=explode(';',$csetting['channel_url']);
$channelurl=str_replace("(cid)",$cid['cid'],$channelurls[0]);
如果(空($channelurl)){
返回 '​​';
}
if(!isset($csetting['channel_domain']) || empty($csetting['channel_domain'])) {
$csetting['channel_domain']=系统域;
}
if(isset($csetting['channel_domain']) && $csetting['channel_domain']<>'') {
$channel_domains=explode(';',$csetting['channel_domain']);
$csetting['channel_domain']=$channel_domains[0];
foreach($channel_domains 作为 $channel_domain){
if(stripos($channel_domain,'*')===false) {
$csetting['channel_domain']=$channel_domain;
休息;
}
}
foreach($channel_domains 作为 $channel_domain){
if(server_name()==$channel_domain) {
$csetting['channel_domain']='';
休息;
}
}
}
如果(网址重写){
if(空($csetting['channel_domain'])) {
$thisurl=$channelurl;
}别的 {
$thisurl='//'.$csetting['channel_domain'].server_port().$channelurl;
}
}别的 {
if(空($csetting['channel_domain'])) {
$thisurl=SystemDir.IndexFile.$channelurl;
}别的 {
$thisurl='//'.$csetting['channel_domain'].server_port().SystemDir.IndexFile.$channelurl;
}
}
返回$thisurl;
}
函数 gethomeurl(){
if(isset($GLOBALS['homeurl'])) {
返回 $GLOBALS['homeurl'];
}
if(!UrlRewrite) {
$indexfile=索引文件;
}别的 {
$indexfile='';
}
$domains=explode(';',SystemDomain);
foreach($domains 作为 $domain){
$域=修剪($域);
if($domain==server_name()) {
$GLOBALS['homeurl']=SystemDir.$indexfile;
返回 $GLOBALS['homeurl'];
}
}
if(SystemDomain=='') {$GLOBALS['homeurl']=SystemDir.$indexfile;Return&            
七字铺
七字铺

全部回复(2)
欧阳

你这个文件,全部是方法,还必须用数据库。 这咋看?

那你只能一个方法一个方法的试。你导入数据库,看看是不是有数据库注入了。 

  • 回复 好的,我还是入门级别,多谢大神的指点。
    七字铺 作者 2021-03-28 14:20:30
七字铺

帖子无法重新编辑,由于代码太长,好像显示不全,这里用网盘传文件了,

下载:https://wwa.lanzous.com/iTtK9nbjdja 密码:f2p0

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板