function GetOptionList($selid=0,$userCatalog=0,$channeltype=0) { global $OptionArrayList,$channels,$dsql; if(!is_object($dsql)) $dsql = new DedeSql(false); $dsql->SetQuery("Select ID,typename From #@__channeltype "); $dsql->Execute(); $channels = Array(); while($row = $dsql->GetObject()) $channels[$row->ID] = $row->typename; $OptionArrayList = ""; $query = "Select ID,typename,ispart,channeltype,issend From #@__arctype where ispart<>2 And reID=0 order by sortrank asc "; $dsql->SetQuery($query); $dsql->Execute(); while($row=$dsql->GetObject()) { if($row->channeltype==$channeltype && $row->issend==1){ if($row->ispart==0) $OptionArrayList .= "<option value='".$row->ID."' class='option3'>".$row->typename."</option>\r\n"; else if($row->ispart==1) $OptionArrayList .= "<option value='".$row->ID."' class='option2'>".$row->typename."</option>\r\n"; } LogicGetOptionArray($row->ID,"─",$channeltype,$dsql); } return $OptionArrayList; }
function GetRankName($arcrank) { global $arcArray,$dsql; if(!is_array($arcArray)){ $dsql = new DedeSql(false); $dsql->SetQuery("Select * from #@__arcrank"); $dsql->Execute('rn1'); while($row = $dsql->GetObject('rn1')){ $arcArray[$row->rank]=$row->membername; } } if(isset($arcArray[$arcrank])) return $arcArray[$arcrank]; else return "不限"; }
$tjQuery = "Select count(*) as dd From #@__full_search where channelid='{$channel}' $addquery"; $row = $dsql->GetOne($tjQuery); $totalnum = $row['dd']; } if($totalnum > 0){ $addquery = ""; if($sid!=0) $addquery = " And maintable.ID>='$sid' "; if($eid!=0) $addquery = " And maintable.ID<='$eid' "; $fquery = " Select maintable.ID,maintable.title,maintable.description,addtable.{$rpfield} as body From $maintable maintable left join {$addtable} addtable on addtable.aid=maintable.ID where maintable.channel='{$channel}' $addquery limit $startdd,$pagesize ; "; $dsql->SetQuery($fquery); $dsql->Execute(); while($row=$dsql->GetArray()) { $body = $row['body']; $description = $row['description']; if(strlen($description)>10 || $description=='-') continue; $bodytext = preg_replace("/#p#|#e#|副标题|分页标题/isU","",Html2Text($body)); if(strlen($bodytext) < $msize) continue; $des = trim(addslashes(cn_substr($bodytext,$dsize))); if(strlen($des)<3) $des = "-"; $dsql->ExecuteNoneQuery("Update $maintable set description='{$des}' where ID='{$row['ID']}';"); $dsql->ExecuteNoneQuery("Update #@__full_search set addinfos='{$des}' where aid='{$row['ID']}';"); } //返回进度信息 $startdd = $startdd + $pagesize; if($totalnum > $startdd){
function checkUser($username,$userpwd) { //只允许用户名和密码用0-9,a-z,A-Z,'@','_','.','-'这些字符 $this->userName = ereg_replace("[^0-9a-zA-Z_@\!\.-]",'',$username); $this->userPwd = ereg_replace("[^0-9a-zA-Z_@\!\.-]",'',$userpwd); $pwd = substr(md5($this->userPwd),0,24); $dsql = new DedeSql(false); $dsql->SetQuery("Select * From #@__admin where userid='".$this->userName."' limit 0,1"); $dsql->Execute(); $row = $dsql->GetObject(); if(!isset($row->pwd)){ $dsql->Close(); return -1; } else if($pwd!=$row->pwd){ $dsql->Close(); return -2; } else{ $loginip = GetIP(); $this->userID = $row->ID; $this->userType = $row->usertype; $this->userChannel = $row->typeid; $this->userName = $row->uname; $groupSet = $dsql->GetOne("Select * From #@__admintype where rank='".$row->usertype."'"); $this->userPurview = $groupSet['purviews']; $dsql->SetQuery("update #@__admin set loginip='$loginip',logintime='".strftime("%Y-%m-%d %H:%M:%S",time())."' where ID='".$row->ID."'"); $dsql->ExecuteNoneQuery(); $dsql->Close(); return 1; } }
$savesql = new DedeSql(false); foreach ($_POST as $k => $v) { if (ereg("^edit___", $k)) { $v = ${$k}; } else { continue; } $k = ereg_replace("^edit___", "", $k); if (strlen($v) > 250) { showmsg("{$k} 太长,不能超过250字节", '-1'); exit; } $savesql->ExecuteNoneQuery("Update #@__config set `config_value`='{$v}' where `config_name`='{$k}' "); } $savesql->SetQuery("Select `config_name`,`config_value` From `#@__config` order by `id` asc"); $savesql->Execute(); if ($savesql->GetTotalRow() <= 0) { $savesql->Close(); ShowMsg("成功保存变量但从数据库读取所有数据时失败,无法更新配置文件!", "javascript:;"); exit; } @copy($configfile, $configfile_bak); $fp = @fopen($configfile, 'w'); @flock($fp, 3); @fwrite($fp, "<" . "?php\r\n") or die("配置文件'{$configfile}'不支持写入,本次操作无效!<a href='system_basic.php'>返回</a>"); while ($row = $savesql->GetArray()) { $row['value'] = str_replace("'", "\\'", $row['config_value']); fwrite($fp, "\${$row['config_name']} = '" . $row['config_value'] . "';\r\n"); } fwrite($fp, "?>"); fclose($fp);
$fp = fopen($filename,"w") or die("创建:{$filename} 失败,可能是没有权限!"); fwrite($fp,$row['body']); fclose($fp); } $dsql->Close(); ShowMsg("成功更新一个页面!",$fileurl); exit(); } /*---------------------- function __makeAll(); -------------------*/ else if($dopost=="makeall") { require_once(dirname(__FILE__)."/../include/inc_arcpart_view.php"); $dsql->ExecuteNoneQuery("update #@__sgpage set uptime='".time()."'"); $row = $dsql->Execute('meoutside',"Select * From #@__sgpage "); while($row = $dsql->GetArray('meoutside')) { $fileurl = $cfg_cmspath."/".$row['filename']; $filename = $cfg_basedir.$cfg_cmspath."/".$row['filename']; if($row['ismake']==1) { $pv = new PartView(); $pv->SetTemplet($row['body'],"string"); $pv->SaveToHtml($filename); } else { $fp = fopen($filename,"w") or die("创建:{$filename} 失败,可能是没有权限!"); fwrite($fp,$row['body']); fclose($fp);
<?php require_once(dirname(__FILE__)."/config.php"); CheckPurview('sys_Data'); //获取系统存在的表信息 $otherTables = Array(); $dedeSysTables = Array(); $channelTables = Array(); $dsql = new DedeSql(false); $dsql->SetQuery("Select addtable From #@__channeltype"); $dsql->Execute(); while($row = $dsql->GetObject()){ $channelTables[] = $row->addtable; } $dsql->SetQuery("Show Tables"); $dsql->Execute('t'); while($row = $dsql->GetArray('t')){ if(ereg("^{$cfg_dbprefix}",$row[0])||in_array($row[0],$channelTables)) { $dedeSysTables[] = $row[0]; } else{ $otherTables[] = $row[0]; } } function TjCount($tbname,$dsql){ $row = $dsql->GetOne("Select count(*) as dd From $tbname"); return $row['dd']; } $mysql_version = $dsql->GetVersion(); $mysql_versions = explode(".",trim($mysql_version)); $mysql_version = $mysql_versions[0].".".$mysql_versions[1];
ShowMsg("你修改的是系统专用类型的数据,禁止操作!","-1"); exit(); } //检测数据库是否存在附加表,不存在则新建一个 $tabsql = "CREATE TABLE IF NOT EXISTS `{$row['addtable']}`( `aid` int(11) NOT NULL default '0',\r\n `typeid` int(11) NOT NULL default '0',\r\n "; if($mysql_version < 4.1) $tabsql .= " PRIMARY KEY (`aid`), KEY `".$trueTable."_index` (`typeid`)\r\n) TYPE=MyISAM; "; else $tabsql .= " PRIMARY KEY (`aid`), KEY `".$trueTable."_index` (`typeid`)\r\n) ENGINE=MyISAM DEFAULT CHARSET=".$cfg_db_language."; "; $dsql->ExecuteNoneQuery($tabsql); //检测附加表里含有的字段 $fields = array(); $rs = $dsql->SetQuery("show fields from `{$row['addtable']}`"); $dsql->Execute('a'); while($nrow = $dsql->GetArray('a',MYSQL_ASSOC)){ $fields[ strtolower($nrow['Field']) ] = $nrow['Type']; } //修改字段配置信息 $dfvalue = $vdefault; $isnull = ($isnull==1 ? "true" : "false"); $mxlen = $maxlength; $fieldname = strtolower($fname); //检测被修改的字段类型,并更新数据表 $fieldinfos = GetFieldMake($dtype,$fieldname,$dfvalue,$mxlen); $ntabsql = $fieldinfos[0];
function pr_str_replace($str) { $dsql = new DedeSql(false); $dsql->SetQuery("SELECT * FROM `#@__str_replace`"); $dsql->Execute(); while ($row = $dsql->GetArray()) { if ($row['interconvert'] == 1) { $str = str_replace($row['find'], "@@@@", $str); $str = str_replace($row['replace'], $row['find'], $str); $str = str_replace("@@@@", $row['replace'], $str); } else { if ($row['interconvert'] == 0) { $str = str_replace($row['find'], $row['replace'], $str); } } } return $str; }
<?php require_once(dirname(__FILE__)."/config.php"); $db = new DedeSql(false); if(empty($action)){ $sectors = $topsectors = $subsectors = array(); $sectorscache = ''; $sql = "select * from #@__area order by disorder asc, id asc"; $db->SetQuery($sql); $db->Execute(); while($row = $db->GetArray()) { if($row['reid'] == 0) { $topsectors[] = $row; }else { $subsectors[] = $row; } } foreach($topsectors as $topsector) { $sectors[] = $topsector; $sectorscache .= '<option value="'.$topsector['id'].'">|- '.$topsector['name'].'</option>'; foreach($subsectors as $subsector) { if($subsector['reid'] == $topsector['id']) { $sectors[] = $subsector; } }
if($adminid>0) $where .= " And #@__log.adminid='$adminid' "; if($cip!="") $where .= " And #@__log.cip like '%$cip%' "; if($dtime>0){ $nowtime = time(); $starttime = $nowtime - ($dtime*24*3600); $where .= " And #@__log.dtime>'$starttime' "; } $sql = "Select #@__log.*,#@__admin.userid From #@__log left join #@__admin on #@__admin.ID=#@__log.adminid where 1=1 $where order by #@__log.lid desc"; $adminlist = ""; $dsql = new DedeSql(false); $dsql->SetQuery("Select ID,uname From #@__admin"); $dsql->Execute('admin'); while($myrow = $dsql->GetObject('admin')){ $adminlist .="<option value='{$myrow->ID}'>{$myrow->uname}</option>\r\n"; } $dsql->Close(); $dlist = new DataList(); $dlist->Init(); $dlist->pageSize = 20; $dlist->SetParameter("adminid",$adminid); $dlist->SetParameter("cip",$cip); $dlist->SetParameter("dtime",$dtime); $dlist->SetSource($sql); include(dirname(__FILE__)."/templets/log_list.htm"); $dlist->Close();
exit(); } if($myrow['maintable']=='') $myrow['maintable'] = '#@__archives'; //检查频道的表是否独占数据表 $maintable = str_replace($cfg_dbprefix,'',str_replace('#@__',$cfg_dbprefix,$myrow['maintable'])); $addtable = str_replace($cfg_dbprefix,'',str_replace('#@__',$cfg_dbprefix,$myrow['addtable'])); $row = $dsql->GetOne("Select count(ID) as dd From `#@__channeltype` where maintable like '{$cfg_dbprefix}{$maintable}' Or maintable like CONCAT('#','@','__','$maintable') ; "); $isExclusive1 = ($row['dd']>1 ? 0 : 1 ); $row = $dsql->GetOne("Select count(ID) as dd From `#@__channeltype` where addtable like '{$cfg_dbprefix}{$addtable}' Or addtable like CONCAT('#','@','__','$addtable') ; "); $isExclusive2 = ($row['dd']>1 ? 0 : 1 ); //获取与频道关连的所有栏目ID $tids = ''; $dsql->Execute('qm',"Select ID From `#@__arctype` where channeltype='$ID'"); while($row = $dsql->GetArray('qm')){ $tids .= ($tids=='' ? $row['ID'] : ','.$row['ID']); } //删除主表 if($isExclusive1==1) $dsql->ExecuteNoneQuery("DROP TABLE IF EXISTS `{$cfg_dbprefix}{$maintable}`;"); else { if($tids!=''){ $dsql->ExecuteNoneQuery("Delete From `{$myrow['maintable']}` where typeid in($tids); "); $dsql->ExecuteNoneQuery("update `{$myrow['maintable']}` set typeid2=0 where typeid2 in ($tids); "); } } //删除附加表
function GetOptionList($selid=0,$userCatalog=0,$channeltype=0) { global $OptionArrayList,$channels,$adminCats,$adminCatstrs,$suserCatalog; $suserCatalog = $userCatalog; $dsql = new DedeSql(false); //读取频道模型信息 $dsql->SetQuery("Select ID,typename From #@__channeltype "); $dsql->Execute(); $channels = Array(); while($row = $dsql->GetObject()) $channels[$row->ID] = $row->typename; $OptionArrayList = ""; $adminCats = array(); if(!empty($userCatalog) && $userCatalog!='-1') { $adminCats = explode(',',$userCatalog); $adminCatstrs = $userCatalog; } if($selid==0) { $query = "Select ID,typename,ispart,channeltype From #@__arctype where ispart<2 And reID=0 order by sortrank asc "; $dsql->SetQuery($query); $dsql->Execute(); while($row=$dsql->GetObject()) { if(TestHasChannel($row->ID,$channeltype)==0) continue; if( TestAdmin() || $userCatalog==-1 ) { if($row->ispart==1) $OptionArrayList .= "<option value='".$row->ID."' class='option1'>".$row->typename."(封面频道)</option>\r\n"; else if($row->ispart==2) $OptionArrayList .= ""; else if($row->channeltype!=$channeltype) $OptionArrayList .= "<option value='".$row->ID."' class='option2'>".$row->typename."(".$channels[$row->channeltype].")</option>\r\n"; else $OptionArrayList .= "<option value='".$row->ID."' class='option3'>".$row->typename."</option>\r\n"; LogicGetOptionArray($row->ID,"─",$channeltype,$dsql); }else { if(in_array($row->ID,$adminCats)) { if($row->ispart==1) $OptionArrayList .= "<option value='".$row->ID."' class='option1'>".$row->typename."(封面频道)</option>\r\n"; else if($row->ispart==2) $OptionArrayList .= ""; else if($row->channeltype!=$channeltype) $OptionArrayList .= "<option value='".$row->ID."' class='option2'>".$row->typename."(".$channels[$row->channeltype].")</option>\r\n"; else $OptionArrayList .= "<option value='".$row->ID."' class='option3'>".$row->typename."</option>\r\n"; LogicGetOptionArray($row->ID,"─",$channeltype,$dsql,false); }else { $haspurcat = false; $query = "Select ID From #@__arctype where ispart<2 And reID={$row->ID} order by sortrank asc "; $dsql->Execute('sel'.$row->ID,$query); while($nrow = $dsql->GetObject('sel'.$row->ID)){ if(in_array($nrow->ID,$adminCats)){ $haspurcat=true; break; } } if($haspurcat){ $OptionArrayList .= "<option value='".$row->ID."' class='option1'>".$row->typename."(没权限)</option>\r\n"; LogicGetOptionArray($row->ID,"─",$channeltype,$dsql); } } } } }else { $row = $dsql->GetOne("Select ID,typename,ispart,channeltype From #@__arctype where ID='$selid'"); $channeltype = $row['channeltype']; if($row['ispart']==1) $OptionArrayList .= "<option value='$selid' class='option1' selected>".$row['typename']."(封面频道)</option>\r\n"; else $OptionArrayList .= "<option value='$selid' class='option3' selected>".$row['typename']."</option>\r\n"; LogicGetOptionArray($selid,"─",$channeltype,$dsql,false); } return $OptionArrayList; }