checkUser($userid,$pwd);
//成功登录
if($res==1){
$cuserLogin->keepUser();
/*
if(!empty($gotopage)){
ShowMsg("成功登录,正在转向管理管理主页!",$gotopage);
exit();
}
else{
ShowMsg("成功登录,正在转向管理管理主页!","index.php");
exit();
}
*/
}
else if($res==-1){
echo("[err]你的用户名不存在![/err]");
exit();
//ShowMsg("你的用户名不存在!","");
}
else{
echo("[err]你的密码错误![/err]");
exit();
//ShowMsg("你的密码错误!","");
}
}//<-密码不为空
else{
//ShowMsg("用户和密码没填写完整!","");
echo("[err]用户和密码没填写完整![/err]");
exit();
}
/*
if($cuserLogin->getUserID()==-1)
{
header("location:login.php?gotopage=".urlencode($dedeNowurl));
exit();
}
*/
if($cfg_dede_log=='是'){
$s_nologfile = "_main|_list";
$s_needlogfile = "sys_|file_";
isset($_SERVER['REQUEST_METHOD']) ? $s_method=$_SERVER['REQUEST_METHOD'] : $s_method="";
isset($dedeNowurls[1]) ? $s_query = $dedeNowurls[1] : $s_query = "";
$s_scriptNames = explode('/',$s_scriptName);
$s_scriptNames = $s_scriptNames[count($s_scriptNames)-1];
$s_userip = GetIP();
if( $s_method=='POST'
|| (!eregi($s_nologfile,$s_scriptNames) && $s_query!='')
|| eregi($s_needlogfile,$s_scriptNames) )
{
$dsql = new DedeSql(false);
$inquery = "INSERT INTO #@__log(adminid,filename,method,query,cip,dtime)
VALUES ('".$cuserLogin->getUserID()."','{$s_scriptNames}','{$s_method}','".addslashes($s_query)."','{$s_userip}','".mytime()."');";
$dsql->ExecuteNoneQuery($inquery);
$dsql->Close();
}
}
/*
function GetTypeidSel($fname,$f1,$f2,$cc,$selv='0',$selname='请选择...',$pos=''){
global $opall;
if(empty($opall)) $opall = 0;
$rstr = "\r\n";
$rstr .= "\r\n";
return $rstr;
}
*/
//CheckPurview('a_New,a_AccNew');
if(!TestPurview('a_New,a_AccNew')){
echo("[err]对不起,你没有权限执行此操作![/err]");
exit();
}
require_once(dirname(__FILE__)."/../include/inc_photograph.php");
require_once(dirname(__FILE__)."/../include/pub_oxwindow.php");
//require_once(dirname(__FILE__)."/inc/inc_archives_functions.php");
//以下为DEDE/inc/inc_archives_functions.php的内容
require_once(dirname(__FILE__)."/../include/pub_httpdown.php");
require_once(dirname(__FILE__)."/../include/inc_archives_view.php");
//---------------------------
//获得文章body里的外部资源
//---------------------------
function GetCurContent($body)
{
global $cfg_multi_site,$cfg_basehost;
$cfg_uploaddir = $GLOBALS['cfg_image_dir'];
$cfg_basedir = $GLOBALS['cfg_basedir'];
$htd = new DedeHttpDown();
$basehost = "http://".$_SERVER["HTTP_HOST"];
if($cfg_multi_site == '否'){
$body = str_replace(strtolower($basehost),"",$body);
$body = str_replace(strtoupper($basehost),"",$body);
}else{
if($cfg_basehost!=$basehost){
$body = str_replace(strtolower($basehost),$cfg_basehost,$body);
$body = str_replace(strtoupper($basehost),$cfg_basehost,$body);
}
}
$img_array = array();
preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\/\/(.*)\.(gif|jpg|jpeg|bmp|png))/isU",$body,$img_array);
$img_array = array_unique($img_array[2]);
$imgUrl = $cfg_uploaddir."/".strftime("%y%m%d",mytime());
$imgPath = $cfg_basedir.$imgUrl;
if(!is_dir($imgPath."/")){
MkdirAll($imgPath,777);
CloseFtp();
}
$milliSecond = strftime("%H%M%S",mytime());
foreach($img_array as $key=>$value)
{
if(eregi($basehost,$value)) continue;
if($cfg_basehost!=$basehost && eregi($cfg_basehost,$value)) continue;
if(!eregi("^http://",$value)) continue;
//随机命名文件
$htd->OpenUrl($value);
$itype = $htd->GetHead("content-type");
if($itype=="image/gif") $itype = ".gif";
else if($itype=="image/png") $itype = ".png";
else $itype = ".jpg";
$value = trim($value);
$rndFileName = $imgPath."/".$milliSecond.$key.$itype;
$fileurl = $imgUrl."/".$milliSecond.$key.$itype;
//下载并保存文件
$rs = $htd->SaveToBin($rndFileName);
if($rs){
$body = str_replace($value,$fileurl,$body);
@WaterImg($rndFileName,'down');
}
}
$htd->Close();
return $body;
}
//------------------------------
//获取一个远程图片
//------------------------------
function GetRemoteImage($url,$uid=0)
{
$cfg_uploaddir = $GLOBALS['cfg_image_dir'];
$cfg_basedir = $GLOBALS['cfg_basedir'];
$revalues = Array();
$ok = false;
$htd = new DedeHttpDown();
$htd->OpenUrl($url);
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png","image/x-png","image/wbmp");
if(!in_array($htd->GetHead("content-type"),$sparr)){
return "";
}else{
$imgUrl = $cfg_uploaddir."/".strftime("%y%m%d",mytime());
$imgPath = $cfg_basedir.$imgUrl;
CreateDir($imgUrl);
$itype = $htd->GetHead("content-type");
if($itype=="image/gif") $itype = ".gif";
else if($itype=="image/png") $itype = ".png";
else if($itype=="image/wbmp") $itype = ".bmp";
else $itype = ".jpg";
$rndname = dd2char($uid."_".strftime("%H%M%S",mytime()).mt_rand(1000,9999));
$rndtrueName = $imgPath."/".$rndname.$itype;
$fileurl = $imgUrl."/".$rndname.$itype;
$ok = $htd->SaveToBin($rndtrueName);
@WaterImg($rndtrueName,'down');
if($ok){
$data = GetImageSize($rndtrueName);
$revalues[0] = $fileurl;
$revalues[1] = $data[0];
$revalues[2] = $data[1];
}
}
$htd->Close();
if($ok) return $revalues;
else return "";
}
//------------------------------
//获取一个远程Flash文件
//------------------------------
function GetRemoteFlash($url,$uid=0)
{
$cfg_uploaddir = $GLOBALS['media_dir'];
$cfg_basedir = $GLOBALS['cfg_basedir'];
$revalues = "";
$sparr = "application/x-shockwave-flash";
$htd = new DedeHttpDown();
$htd->OpenUrl($url);
if($htd->GetHead("content-type")!=$sparr){
return "";
}else{
$imgUrl = $cfg_uploaddir."/".strftime("%y%m%d",mytime());
$imgPath = $cfg_basedir.$imgUrl;
CreateDir($imgUrl);
$itype = ".swf";
$milliSecond = $uid."_".strftime("%H%M%S",mytime());
$rndFileName = $imgPath."/".$milliSecond.$itype;
$fileurl = $imgUrl."/".$milliSecond.$itype;
$ok = $htd->SaveToBin($rndFileName);
if($ok) $revalues = $fileurl;
}
$htd->Close();
return $revalues;
}
//---------------
//检测频道ID
//---------------
function CheckChannel($typeid,$channelid)
{
if($typeid==0) return true;
$dsql = new DedeSql(false);
$row = $dsql->GetOne("Select ispart,channeltype From #@__arctype where ID='$typeid' ");
$dsql->Close();
if($row['ispart']!=0 || $row['channeltype']!=$channelid) { return false; }
else { return true; }
}
//---------------
//检测档案权限
//---------------
function CheckArcAdmin($aid,$adminid)
{
$dsql = new DedeSql(false);
$row = $dsql->GetOne("Select adminid From #@__archives where ID='$aid' ");
$dsql->Close();
if($row['adminid']!=$adminid) return false;
else return true;
}
//---------------
//文档自动分页
//---------------
function SpLongBody($mybody,$spsize,$sptag)
{
if(strlen($mybody)<$spsize) return $mybody;
$bds = explode('<',$mybody);
$npageBody = "";
$istable = 0;
$mybody = "";
foreach($bds as $i=>$k)
{
if($i==0){ $npageBody .= $bds[$i]; continue;}
$bds[$i] = "<".$bds[$i];
if(strlen($bds[$i])>6){
$tname = substr($bds[$i],1,5);
if(strtolower($tname)=='table') $istable++;
else if(strtolower($tname)=='/tabl') $istable--;
if($istable>0){ $npageBody .= $bds[$i]; continue; }
else $npageBody .= $bds[$i];
}else{
$npageBody .= $bds[$i];
}
if(strlen($npageBody)>$spsize){
$mybody .= $npageBody.$sptag;
$npageBody = "";
}
}
if($npageBody!="") $mybody .= $npageBody;
return $mybody;
}
//-----------------------
//创建指定ID的文档
//-----------------------
function MakeArt($aid,$checkLike=false)
{
global $cfg_makeindex,$cfg_basedir,$cfg_templets_dir,$cfg_df_style;
$arc = new Archives($aid);
$reurl = $arc->MakeHtml();
$arc->dsql = new DedeSql(false);
$preRow = $arc->dsql->GetOne("Select ID From #@__archives where ID<$aid order by ID desc");
$nextRow = $arc->dsql->GetOne("Select ID From #@__archives where ID>$aid order by ID asc");
if(is_array($preRow)){
$arc->Close();
$arc = new Archives($preRow['ID']);
$arc->MakeHtml();
}
if(is_array($nextRow)){
$arc->Close();
$arc = new Archives($nextRow['ID']);
$arc->MakeHtml();
}
if($cfg_makeindex=='是'){
$pv = new PartView();
$row = $pv->dsql->GetOne("Select * From #@__homepageset");
$templet = str_replace("{style}",$cfg_df_style,$row['templet']);
$homeFile = dirname(__FILE__)."/".$row['position'];
//$homeFile = dirname(__FILE__)."/../".$row['position'];
$homeFile = str_replace("\\","/",$homeFile);
$homeFile = str_replace("//","/",$homeFile);
$fp = fopen($homeFile,"w") or die("首页文件路径错误,无法创建文件");
fclose($fp);
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
$pv->SaveToHtml($homeFile);
$pv->Close();
}
$arc->Close();
return $reurl;
}
//------------------
//获得缩略图
//------------------
function GetDDImage($litpic,$picname,$isremote)
{
global $cuserLogin,$cfg_ddimg_width,$cfg_ddimg_height,$cfg_basedir,$ddcfg_image_dir;
$ntime = mytime();
if(($litpic!='none'||$litpic!='ddfirst') &&
!empty($_FILES[$litpic]['tmp_name']) && is_uploaded_file($_FILES[$litpic]['tmp_name']))
//如果用户自行上传缩略图
{
$istype = 0;
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png");
$_FILES[$litpic]['type'] = strtolower(trim($_FILES[$litpic]['type']));
if(!in_array($_FILES[$litpic]['type'],$sparr)){
ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG格式的其中一种!","-1");
exit();
}
$savepath = $ddcfg_image_dir."/".strftime("%y%m%d",$ntime);
CreateDir($savepath);
$fullUrl = $savepath."/".dd2char(strftime("%H%M%S",$ntime).$cuserLogin->getUserID().mt_rand(1000,9999));
if(strtolower($_FILES[$litpic]['type'])=="image/gif") $fullUrl = $fullUrl.".gif";
else if(strtolower($_FILES[$litpic]['type'])=="image/png") $fullUrl = $fullUrl.".png";
else $fullUrl = $fullUrl.".jpg";
@move_uploaded_file($_FILES[$litpic]['tmp_name'],$cfg_basedir.$fullUrl);
$litpic = $fullUrl;
@ImageResize($cfg_basedir.$fullUrl,$cfg_ddimg_width,$cfg_ddimg_height);
}else{
$picname = trim($picname);
if($isremote==1 && eregi("^http://",$picname)){
$litpic = $picname;
$ddinfos = GetRemoteImage($litpic,$cuserLogin->getUserID());
if(!is_array($ddinfos)) $litpic = "";
else{
$litpic = $ddinfos[0];
if($ddinfos[1] > $cfg_ddimg_width || $ddinfos[2] > $cfg_ddimg_height){
@ImageResize($cfg_basedir.$litpic,$cfg_ddimg_width,$cfg_ddimg_height);
}
}
}else{
if($litpic=='ddfirst' && !eregi("^http://",$picname)){
$oldpic = $cfg_basedir.$picname;
$litpic = str_replace('.','_lit.',$picname);
@ImageResize($oldpic,$cfg_ddimg_width,$cfg_ddimg_height,$cfg_basedir.$litpic);
}
else $litpic = $picname;
}
}
if($litpic=='litpic'||$litpic=='ddfirst') $litpic = "";
return $litpic;
}
//检测栏目是否设置了浏览权限
function GetCoRank($arcrank,$typeid){
$dsql = new DedeSql(false);
$row = $dsql->GetOne("Select corank From #@__arctype where ID='$typeid' ");
$dsql->Close();
if($row['corank']!=0) return $row['corank'];
else return $arcrank;
}
//以上为dede/inc/inc_archives_functions.php内容
if(!isset($typeid)) $typeid = 0;
if(!isset($typeid2)) $typeid2 = 0;
if(!isset($iscommend)) $iscommend = 0;
if(!isset($isjump)) $isjump = 0;
if(!isset($isbold)) $isbold = 0;
if(!isset($autokey)) $autokey = 0;
if(!isset($remote)) $remote = 0;
if(!isset($dellink)) $dellink = 0;
if(!isset($autolitpic)) $autolitpic = 0;
if(!isset($spsize)) $spsize = $cfg_arcautosp_size;
if(!isset($sortup)) $sortup = 0;
if(!isset($shorttitle)) $shorttitle ="";
if(!isset($color)) $color = "";
if(!isset($writer)) $writer = "";
if(!isset($description)) $description = "";
if(!isset($keywords)) $keywords = "";
if(!isset($sptype)) $sptype = "hand";
if(!isset($litpic)) $litpic = "";
if(!isset($money)) $money = 0;
if(!isset($arcatt)) $arcatt = 0;
if(!isset($templet)) $templet = "";
if(!isset($redirecturl)) $redirecturl = "";
$channelid = 1;
$pubdate = time();
if($typeid==0){
//ShowMsg("请指定文档的栏目!","-1");
echo("[err]请指定文档的栏目![/err]");
exit();
}
if(empty($channelid)){
//ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!","-1");
echo("[err]文档为非指定的类型![/err]");
exit();
}
if(!CheckChannel($typeid,$channelid) || !CheckChannel($typeid2,$channelid)){
//ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!","-1");
echo("[err]你所选择的栏目与当前模型不相符![/err]");
exit();
}
/*
if(!TestPurview('a_New')) {
CheckCatalog($typeid,"对不起,你没有操作栏目 {$typeid} 的权限!");
if($typeid2!=0) CheckCatalog($typeid2,"对不起,你没有操作栏目 {$typeid2} 的权限!");
}
*/
$arcrank = GetCoRank($arcrank,$typeid);
//对保存的内容进行处理
//--------------------------------
$iscommend = $iscommend + $isbold;
$pubdate = GetMkTime($pubdate);
$senddate = mytime();
$sortrank = AddDay($senddate,$sortup);
if($ishtml==1) $ismake = 0;
else $ismake = -1;
$shorttitle = cn_substr($shorttitle,36);
$color = cn_substr($color,10);
$writer = cn_substr($writer,30);
$source = cn_substr($source,50);
$description = cn_substr($description,250);
$keywords = cn_substr($keywords,60);
//if(!TestPurview('a_Check,a_AccCheck,a_MyCheck')){ $arcrank = -1; }
//处理上传的缩略图
//if(empty($ddisremote)) $ddisremote = 0;
//$litpic = GetDDImage('litpic',$picname,$ddisremote);
$body = stripslashes($body);
//自动摘要
if($description=="" && $cfg_auot_description>0){
$description = stripslashes(cn_substr(html2text($body),$cfg_auot_description));
$description = trim(preg_replace("/#p#|#e#/","",$description));
$description = addslashes($description);
}
//把内容中远程的图片资源本地化
//------------------------------------
if($isUrlOpen && $remote==1){
$body = GetCurContent($body);
}
//去除内容中的站外链接
//------------------------------------
if($dellink==1){
$body = str_replace($cfg_basehost,'#basehost#',$body);
$body = preg_replace("/(]*)>)|(<\/a>)/isU","",$body);
$body = str_replace('#basehost#',$cfg_basehost,$body);
}
//自动获取文章中的关键字
//----------------------------------
if($autokey==1||$keywords==""){
require_once(dirname(__FILE__)."/../include/pub_splitword_www.php");
$keywords = "";
$sp = new SplitWord();
$titleindexs = explode(" ",trim($sp->GetIndexText($sp->SplitRMM($title))));
$allindexs = explode(" ",trim($sp->GetIndexText($sp->SplitRMM(Html2Text($body)),200)));
if(is_array($allindexs) && is_array($titleindexs)){
foreach($titleindexs as $k){
if(strlen($keywords)>=50) break;
else $keywords .= $k." ";
}
foreach($allindexs as $k){
if(strlen($keywords)>=50) break;
else if(!in_array($k,$titleindexs)) $keywords .= $k." ";
}
}
$sp->Clear();
unset($sp);
$keywords = preg_replace("/#p#|#e#/","",$keywords);
$keywords = addslashes($keywords);
}
//自动分页
if($sptype=="auto"){
$body = SpLongBody($body,$spsize*1024,"#p#分页标题#e#");
}
//自动获取缩略图
if($autolitpic==1 && $litpic==''){
$cfg_medias_dir = str_replace('/','\/',$cfg_medias_dir);
$picname = preg_replace("/.+?".$cfg_medias_dir."(.*)( |\"|').*$/isU",$cfg_medias_dir."$1",$body);
if(eregi("\.(jpg|gif|png)$",$picname)) $litpic = GetDDImage('ddfirst',$picname,0);
}
$body = addslashes($body);
if($keywords!="") $keywords = trim(cn_substr($keywords,60))." ";
$adminID = $cuserLogin->getUserID();
//加入数据库的SQL语句
//----------------------------------
$inQuery = "INSERT INTO #@__archives(
typeid,typeid2,sortrank,iscommend,ismake,channel,
arcrank,click,money,title,shorttitle,color,writer,source,litpic,
pubdate,senddate,arcatt,adminID,memberID,description,keywords,templet,redirecturl)
VALUES ('$typeid','$typeid2','$sortrank','$iscommend','$ismake','$channelid',
'$arcrank','0','$money','$title','$shorttitle','$color','$writer','$source','$litpic',
'$pubdate','$senddate','$arcatt','$adminID','0','$description','$keywords','$templet','$redirecturl');";
$dsql = new DedeSql();
$dsql->SetQuery($inQuery);
if(!$dsql->ExecuteNoneQuery()){
$dsql->Close();
//ShowMsg("把数据保存到数据库archives表时出错,请检查!","-1");
echo("[err]把数据保存到数据库archives表时出错,请检查![/err]");
exit();
}
$arcID = $dsql->GetLastID();
$dsql->SetQuery("INSERT INTO #@__addonarticle(aid,typeid,body) Values('$arcID','$typeid','$body')");
if(!$dsql->ExecuteNoneQuery()){
$dsql->SetQuery("Delete From #@__archives where ID='$arcID'");
$dsql->ExecuteNoneQuery();
$dsql->Close();
echo("[err]把数据保存到数据库附加表addonarticle时出错,请检查原因![/err]");
//ShowMsg("把数据保存到数据库附加表addonarticle时出错,请检查原因!","-1");
exit();
}
$dsql->Close();
//生成HTML
//---------------------------------
$artUrl = MakeArt($arcID,true);
//if($artUrl=="") $artUrl = $cfg_plus_dir."/view.php?aid=$arcID";
//---------------------------------
//返回成功信息
//----------------------------------
echo('1');
exit();
/*
$msg = "
请选择你的后续操作:
继续发布文章
查看文章
更改文章
已发布文章管理
网站栏目管理
";
$wintitle = "成功发布文章!";
$wecome_info = "文章管理::发布文章";
$win = new OxWindow();
$win->AddTitle("成功发布文章:");
$win->AddMsgItem($msg);
$winform = $win->GetWindow("hand"," ",false);
$win->Display();
*/
?>