Esempio n. 1
0
function Ebak_DoEbak($add)
{
    global $empire, $bakpath, $fun_r, $phome_db_ver;
    $dbname = RepPostVar($add['mydbname']);
    if (empty($dbname)) {
        printerror('NotChangeDb', 'history.go(-1)');
    }
    $tablename = $add['tablename'];
    $count = count($tablename);
    if (empty($count)) {
        printerror('EmptyChangeTb', 'history.go(-1)');
    }
    $add['baktype'] = (int) $add['baktype'];
    $add['filesize'] = (int) $add['filesize'];
    $add['bakline'] = (int) $add['bakline'];
    $add['autoauf'] = (int) $add['autoauf'];
    if (!$add['filesize'] && !$add['baktype'] || !$add['bakline'] && $add['baktype']) {
        printerror('EmptyBakFilesize', 'history.go(-1)');
    }
    if (empty($add['mypath'])) {
        $add['mypath'] = $dbname . '_' . date('YmdHis');
    }
    DoMkdir($bakpath . '/' . $add['mypath']);
    $readme = $add['readme'];
    $rfile = $bakpath . '/' . $add['mypath'] . '/readme.txt';
    $readme .= "\r\n\r\nBaktime: " . date('Y-m-d H:i:s');
    WriteFiletext_n($rfile, $readme);
    $b_table = '';
    $d_table = '';
    for ($i = 0; $i < $count; $i++) {
        $b_table .= $tablename[$i] . ',';
        $d_table .= "\$tb[" . $tablename[$i] . "]=0;\r\n";
    }
    $b_table = substr($b_table, 0, strlen($b_table) - 1);
    $bakstru = (int) $add['bakstru'];
    $bakstrufour = (int) $add['bakstrufour'];
    $beover = (int) $add['beover'];
    $waitbaktime = (int) $add['waitbaktime'];
    $bakdatatype = (int) $add['bakdatatype'];
    if ($add['insertf'] == 'insert') {
        $insertf = 'insert';
    } else {
        $insertf = 'replace';
    }
    if ($phome_db_ver == '4.0' && $add['dbchar'] == 'auto') {
        $add['dbchar'] = '';
    }
    $string = "<?php\n\t\$b_table=\"" . $b_table . "\";\n\t" . $d_table . "\n\t\$b_baktype=" . $add['baktype'] . ";\n\t\$b_filesize=" . $add['filesize'] . ";\n\t\$b_bakline=" . $add['bakline'] . ";\n\t\$b_autoauf=" . $add['autoauf'] . ";\n\t\$b_dbname=\"" . $dbname . "\";\n\t\$b_stru=" . $bakstru . ";\n\t\$b_strufour=" . $bakstrufour . ";\n\t\$b_dbchar=\"" . addslashes($add['dbchar']) . "\";\n\t\$b_beover=" . $beover . ";\n\t\$b_insertf=\"" . addslashes($insertf) . "\";\n\t\$b_autofield=\"," . addslashes($add['autofield']) . ",\";\n\t\$b_bakdatatype=" . $bakdatatype . ';
	?>';
    $cfile = $bakpath . '/' . $add['mypath'] . '/config.php';
    WriteFiletext_n($cfile, $string);
    if ($add['baktype']) {
        $phome = 'BakExeT';
    } else {
        $phome = 'BakExe';
    }
    echo $fun_r['StartToBak'] . "<script>self.location.href='phomebak.php?phome={$phome}&t=0&s=0&p=0&mypath={$add['mypath']}&waitbaktime={$waitbaktime}';</script>";
    exit;
}
Esempio n. 2
0
function Ebak_DoEbak($add){
	global $empire,$bakpath,$fun_r,$phome_db_ver;
	$dbname=RepPostVar($add['mydbname']);
	if(empty($dbname))
	{
		printerror("NotChangeDb","history.go(-1)");
	}
	$tablename=$add['tablename'];
	$count=count($tablename);
	if(empty($count))
	{
		printerror("EmptyChangeTb","history.go(-1)");
	}
	$add['baktype']=(int)$add['baktype'];
	$add['filesize']=(int)$add['filesize'];
	$add['bakline']=(int)$add['bakline'];
	$add['autoauf']=(int)$add['autoauf'];
	if((!$add['filesize']&&!$add['baktype'])||(!$add['bakline']&&$add['baktype']))
	{
		printerror("EmptyBakFilesize","history.go(-1)");
	}
	//目录名
	if(empty($add['mypath']))
	{
		$add['mypath']=$dbname."_".date("YmdHis");
	}
    DoMkdir($bakpath."/".$add['mypath']);
	//生成说明文件
	$readme=$add['readme'];
	$rfile=$bakpath."/".$add['mypath']."/readme.txt";
	$readme.="\r\n\r\nBaktime: ".date("Y-m-d H:i:s");
	WriteFiletext_n($rfile,$readme);

	$b_table="";
	$d_table="";
	for($i=0;$i<$count;$i++)
	{
		$b_table.=$tablename[$i].",";
		$d_table.="\$tb[".$tablename[$i]."]=0;\r\n";
    }
	//去掉最后一个,
	$b_table=substr($b_table,0,strlen($b_table)-1);
	$bakstru=(int)$add['bakstru'];
	$bakstrufour=(int)$add['bakstrufour'];
	$beover=(int)$add['beover'];
	$waitbaktime=(int)$add['waitbaktime'];
	$bakdatatype=(int)$add['bakdatatype'];
	if($add['insertf']=='insert')
	{
		$insertf='insert';
	}
	else
	{
		$insertf='replace';
	}
	if($phome_db_ver=='4.0'&&$add['dbchar']=='auto')
	{
		$add['dbchar']='';
	}
	$string="<?php
	\$b_table=\"".$b_table."\";
	".$d_table."
	\$b_baktype=".$add['baktype'].";
	\$b_filesize=".$add['filesize'].";
	\$b_bakline=".$add['bakline'].";
	\$b_autoauf=".$add['autoauf'].";
	\$b_dbname=\"".$dbname."\";
	\$b_stru=".$bakstru.";
	\$b_strufour=".$bakstrufour.";
	\$b_dbchar=\"".addslashes($add['dbchar'])."\";
	\$b_beover=".$beover.";
	\$b_insertf=\"".addslashes($insertf)."\";
	\$b_autofield=\",".addslashes($add['autofield']).",\";
	\$b_bakdatatype=".$bakdatatype.";
	?>";
	$cfile=$bakpath."/".$add['mypath']."/config.php";
	WriteFiletext_n($cfile,$string);
	if($add['baktype'])
	{
		$phome='BakExeT';
	}
	else
	{
		$phome='BakExe';
	}
	echo $fun_r['StartToBak']."<script>self.location.href='phomebak.php?phome=$phome&t=0&s=0&p=0&mypath=$add[mypath]&waitbaktime=$waitbaktime';</script>";
	exit();
}
Esempio n. 3
0
function MoveClassNews($add, $userid, $username)
{
    global $empire, $class_r, $dbtbpre, $emod_r;
    $add[classid] = (int) $add[classid];
    $add[toclassid] = (int) $add[toclassid];
    if (empty($add[classid]) || empty($add[toclassid])) {
        printerror("EmptyMovetoClassid", "history.go(-1)");
    }
    if ($class_r[$add[classid]][modid] != $class_r[$add[toclassid]][modid]) {
        printerror("DefModid", "history.go(-1)");
    }
    //验证权限
    CheckLevel($userid, $username, $classid, "movenews");
    //终极栏目
    if (!$class_r[$add[classid]][islast] || !$class_r[$add[toclassid]][islast]) {
        printerror("MovetoClassidMustLastid", "history.go(-1)");
    }
    if ($add[classid] == $add[toclassid]) {
        printerror("MoveClassidsame", "history.go(-1)");
    }
    $mid = $class_r[$add[classid]][modid];
    $tbname = $class_r[$add[classid]][tbname];
    //主表
    $indexsql = $empire->query("update {$dbtbpre}ecms_" . $tbname . "_index set classid={$add['toclassid']} where classid='{$add['classid']}'");
    $sql = $empire->query("update {$dbtbpre}ecms_" . $tbname . " set classid={$add['toclassid']} where classid='{$add['classid']}'");
    $empire->query("update {$dbtbpre}ecms_" . $tbname . "_check set classid={$add['toclassid']} where classid='{$add['classid']}'");
    $empire->query("update {$dbtbpre}ecms_" . $tbname . "_doc set classid={$add['toclassid']} where classid='{$add['classid']}'");
    //副表
    UpdateAllDataTbField($tbname, "classid='{$add['toclassid']}'", " where classid='{$add['classid']}'", 1, 1);
    //更新栏目信息数
    $cr = $empire->fetch1("select classid,allinfos,infos from {$dbtbpre}enewsclass where classid='{$add['classid']}'");
    AddClassInfos($add[classid], '-' . $cr[allinfos], '-' . $cr[infos]);
    $tocr = $empire->fetch1("select classid,allinfos,infos from {$dbtbpre}enewsclass where classid='{$add['toclassid']}'");
    AddClassInfos($add[toclassid], '+' . $cr[allinfos], '+' . $cr[infos]);
    //更新信息附加表与附件表
    UpdateMoreInfoOtherData($add[classid], $add[toclassid], 0, 0);
    //生成信息列表
    ListHtml($add[toclassid], $ret_r, 0);
    //移动数据
    $opath = ECMS_PATH . $class_r[$add[classid]][classpath];
    DelPath($opath);
    //删除旧的栏目目录
    $mk = DoMkdir($opath);
    if ($sql) {
        //操作日志
        insert_dolog("classid=" . $add[classid] . "&nbsp;(" . $class_r[$add[classid]][classname] . ")<br>toclassid=" . $add[toclassid] . "(" . $class_r[$add[toclassid]][classname] . ")");
        printerror("MoveClassNewsSuccess", "MoveClassNews.php" . hReturnEcmsHashStrHref2(1));
    } else {
        printerror("DbError", "history.go(-1)");
    }
}
Esempio n. 4
0
function GetHtml($add, $fields, $doall = 0)
{
    global $public_r, $class_r, $class_zr, $fun_r, $empire, $dbtbpre, $emod_r, $class_tr, $level_r, $etable_r;
    if (empty($doall)) {
        if ($add['titleurl'] || $add['checked'] == 0 || $class_r[$add[classid]][showdt] == 2 || strstr($public_r['nreinfo'], ',' . $add['classid'] . ',')) {
            return '';
        }
    }
    $mid = $class_r[$add[classid]]['modid'];
    $tbname = $class_r[$add[classid]][tbname];
    //副表
    if ($emod_r[$mid]['tbdataf'] && $emod_r[$mid]['tbdataf'] != ',') {
        $selectdataf = substr($emod_r[$mid]['tbdataf'], 1, -1);
        $addr = $empire->fetch1("select " . $selectdataf . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $add[stb] . " where id='{$add['id']}'");
        $add = array_merge($add, $addr);
    }
    $iclasspath = ReturnSaveInfoPath($add[classid], $add[id]);
    $doclasspath = ECMS_PATH . $iclasspath;
    $createinfopath = $doclasspath;
    //建立日期目录
    $newspath = '';
    if ($add[newspath]) {
        $createpath = $doclasspath . $add[newspath];
        if (!file_exists($createpath)) {
            $r[newspath] = FormatPath($add[classid], $add[newspath], 1);
        }
        $createinfopath .= $add[newspath] . '/';
        $newspath = $add[newspath] . '/';
    }
    //新建存放目录
    if ($class_r[$add[classid]][filename] == 3) {
        $createinfopath .= ReturnInfoSPath($add['filename']);
        DoMkdir($createinfopath);
        $fn3 = 1;
    }
    //存文本
    if ($emod_r[$mid]['savetxtf']) {
        $stf = $emod_r[$mid]['savetxtf'];
        if ($add[$stf]) {
            $add[$stf] = GetTxtFieldText($add[$stf]);
        }
    }
    $GLOBALS['navclassid'] = $add[classid];
    $GLOBALS['navinfor'] = $add;
    //取得内容模板
    $add[newstempid] = $add[newstempid] ? $add[newstempid] : $class_r[$add[classid]][newstempid];
    $newstemp_r = GetNewsTemp($add[newstempid]);
    $newstemptext = $newstemp_r[temptext];
    $formatdate = $newstemp_r[showdate];
    //页面
    $pagetitle = htmlspecialchars($add[title]);
    $url = ReturnClassLink($add[classid]);
    //导航
    $newstemptext = Info_ReplaceSvars($newstemptext, $url, $add[classid], $pagetitle, $add[keyboard], $pagetitle);
    //文件类型/权限
    if ($add[groupid] || $class_r[$add[classid]]['cgtoinfo']) {
        if (empty($add[newspath])) {
            $include = '';
        } else {
            $pr = explode('/', $add[newspath]);
            for ($i = 0; $i < count($pr); $i++) {
                $include .= '../';
            }
        }
        if ($fn3 == 1) {
            $include .= '../';
        }
        $pr = explode('/', $iclasspath);
        $pcount = count($pr);
        for ($i = 0; $i < $pcount - 1; $i++) {
            $include .= '../';
        }
        $include1 = $include;
        $include .= 'e/class/CheckLevel.php';
        $filetype = '.php';
        $addlevel = "<?php\r\n\t\tdefine('empirecms','wm_chief');\r\n\t\t\$check_tbname='" . $class_r[$add[classid]][tbname] . "';\r\n\t\t\$check_infoid=" . $add[id] . ";\r\n\t\t\$check_classid=" . $add[classid] . ";\r\n\t\t\$check_path=\"" . $include1 . "\";\r\n\t\trequire(\"" . $include . "\");\r\n\t\t?>";
    } else {
        $filetype = $class_r[$add[classid]][filetype];
        $addlevel = '';
    }
    //取得本目录链接
    if ($class_r[$add[classid]][classurl] && $class_r[$add[classid]][ipath] == '') {
        $dolink = $class_r[$add[classid]][classurl] . '/' . $newspath;
    } else {
        $dolink = $public_r[newsurl] . $iclasspath . $newspath;
    }
    //相关信息
    if (strstr($newstemptext, '[!--other.link--]')) {
        $keyboardtext = GetKeyboard($add[keyboard], $add[keyid], $add[classid], $add[id], $class_r[$add[classid]][link_num]);
    }
    $onclick = "<script src='" . $public_r[newsurl] . "e/public/onclick?enews=donews&classid={$add['classid']}&id=" . $add[id] . "'></script>";
    //返回替换验证字符
    $docheckrep = ReturnCheckDoRepStr();
    if ($add[newstext]) {
        if (empty($public_r['dorepword']) && $docheckrep[3]) {
            $add[newstext] = ReplaceWord($add[newstext]);
            //过滤字符
        }
        if (empty($public_r['dorepkey']) && $docheckrep[4] && !empty($add[dokey])) {
            $add[newstext] = ReplaceKey($add[newstext]);
        }
        if ($public_r['opencopytext']) {
            $add[newstext] = AddNotCopyRndStr($add[newstext]);
            //随机复制字符
        }
    }
    //分页字段
    $expage = '[!--empirenews.page--]';
    //分页符
    $pf = $emod_r[$mid]['pagef'];
    //变量
    $tempf = $emod_r[$mid]['tempf'];
    if ($pf && strstr($add[$pf], $expage)) {
        $tempf = str_replace(',' . $pf . ',', ',', $tempf);
    }
    $fr = explode(',', $tempf);
    $fcount = count($fr) - 1;
    //变量替换
    $newstempstr = $newstemptext;
    //模板
    for ($i = 1; $i < $fcount; $i++) {
        $f = $fr[$i];
        $value = $add[$f];
        if ($f == 'downpath') {
            if (strstr($newstemptext, '[!--downpath--]')) {
                $value = ReturnDownSoftHtml($add);
            }
        } elseif ($f == 'onlinepath') {
            if (strstr($newstemptext, '[!--onlinepath--]')) {
                $value = ReturnOnlinepathHtml($add);
            }
        } elseif ($f == 'morepic') {
            if (strstr($newstemptext, '[!--morepic--]')) {
                $value = ReturnMorepicpathHtml($add);
            }
        } elseif ($f == 'newstime') {
            if (strstr($newstemptext, '[!--newstime--]')) {
                $value = date($formatdate, $value);
            }
        } elseif ($f == 'befrom') {
            if ($docheckrep[1] && strstr($newstemptext, '[!--befrom--]')) {
                $value = ReplaceBefrom($value);
            }
        } elseif ($f == 'writer') {
            if ($docheckrep[2] && strstr($newstemptext, '[!--writer--]')) {
                $value = ReplaceWriter($value);
            }
        } elseif ($f == 'titlepic') {
            if (empty($value)) {
                $value = $public_r[newsurl] . 'e/data/images/notimg.gif';
            }
        } elseif ($f == 'title') {
        } else {
            if (!strstr($emod_r[$mid]['editorf'], ',' . $f . ',')) {
                if (strstr($emod_r[$mid]['tobrf'], ',' . $f . ',')) {
                    $value = nl2br($value);
                }
                if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $f . ',')) {
                    $value = RepFieldtextNbsp(htmlspecialchars($value));
                }
            }
        }
        $newstempstr = str_replace('[!--' . $f . '--]', $value, $newstempstr);
    }
    //固定变量
    $newstempstr = str_replace('[!--id--]', $add[id], $newstempstr);
    $newstempstr = str_replace('[!--classid--]', $add[classid], $newstempstr);
    $newstempstr = str_replace('[!--class.name--]', $class_r[$add[classid]][classname], $newstempstr);
    $newstempstr = str_replace('[!--ttid--]', $add[ttid], $newstempstr);
    $newstempstr = str_replace('[!--tt.name--]', $class_tr[$add[ttid]][tname], $newstempstr);
    $newstempstr = str_replace('[!--onclick--]', $add[onclick], $newstempstr);
    $newstempstr = str_replace('[!--userfen--]', $add[userfen], $newstempstr);
    $newstempstr = str_replace('[!--username--]', $add[username], $newstempstr);
    //带链接的用户名
    if ($add[ismember] == 1 && $add[userid]) {
        $newstempstr = str_replace('[!--linkusername--]', "<a href='" . $public_r[newsurl] . "e/space/?userid=" . $add[userid] . "' target=_blank>" . $add[username] . "</a>", $newstempstr);
    } else {
        $newstempstr = str_replace('[!--linkusername--]', $add[username], $newstempstr);
    }
    $newstempstr = str_replace('[!--userid--]', $add[userid], $newstempstr);
    $newstempstr = str_replace('[!--other.link--]', $keyboardtext, $newstempstr);
    $newstempstr = str_replace('[!--news.url--]', $public_r[newsurl], $newstempstr);
    $newstempstr = str_replace('[!--plnum--]', $add[plnum], $newstempstr);
    $newstempstr = str_replace('[!--totaldown--]', $add[totaldown], $newstempstr);
    $newstempstr = str_replace('[!--keyboard--]', $add[keyboard], $newstempstr);
    //链接
    $titleurl = sys_ReturnBqTitleLink($add);
    $newstempstr = str_replace('[!--titleurl--]', $titleurl, $newstempstr);
    $newstempstr = str_replace('[!--page.stats--]', $onclick, $newstempstr);
    $classurl = sys_ReturnBqClassname($add, 9);
    $newstempstr = str_replace('[!--class.url--]', $classurl, $newstempstr);
    //下一篇
    if (strstr($newstemptext, '[!--info.next--]')) {
        $next_r = $empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id>{$add['id']} and classid='{$add['classid']}' and checked=1 order by id limit 1");
        if (empty($next_r[id])) {
            $infonext = "<a href='" . $classurl . "'>" . $fun_r['HaveNoNextLink'] . "</a>";
        } else {
            //链接
            $nexttitleurl = sys_ReturnBqTitleLink($next_r);
            $infonext = "<a href='" . $nexttitleurl . "'>" . $next_r[title] . "</a>";
        }
        $newstempstr = str_replace('[!--info.next--]', $infonext, $newstempstr);
    }
    //上一篇
    if (strstr($newstemptext, '[!--info.pre--]')) {
        $next_r = $empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id<{$add['id']} and classid='{$add['classid']}' and checked=1 order by id desc limit 1");
        if (empty($next_r[id])) {
            $infonext = "<a href='" . $classurl . "'>" . $fun_r['HaveNoNextLink'] . "</a>";
        } else {
            //链接
            $nexttitleurl = sys_ReturnBqTitleLink($next_r);
            $infonext = "<a href='" . $nexttitleurl . "'>" . $next_r[title] . "</a>";
        }
        $newstempstr = str_replace('[!--info.pre--]', $infonext, $newstempstr);
    }
    //投票
    if (strstr($newstemptext, '[!--info.vote--]')) {
        $myvotetext = sys_GetInfoVote($add[classid], $add[id]);
        $newstempstr = str_replace('[!--info.vote--]', $myvotetext, $newstempstr);
    }
    //评分
    if (strstr($newstemptext, '[!--pinfopfen--]')) {
        $pinfopfen = $add[infopfennum] ? round($add[infopfen] / $add[infopfennum]) : 0;
        $newstempstr = str_replace('[!--pinfopfen--]', $pinfopfen, $newstempstr);
        $newstempstr = str_replace('[!--infopfennum--]', $add[infopfennum], $newstempstr);
    }
    if ($pf && strstr($add[$pf], $expage)) {
        $n_r = explode($expage, $add[$pf]);
        $thispagenum = count($n_r);
        //取得分页
        $thefun = $public_r['textpagefun'] ? $public_r['textpagefun'] : 'sys_ShowTextPage';
        //下拉式分页
        if (strstr($newstemptext, '[!--title.select--]')) {
            $dotitleselect = sys_ShowTextPageSelect($thispagenum, $dolink, $add, $filetype, $n_r);
        }
        for ($j = 1; $j <= $thispagenum; $j++) {
            $string = $newstempstr;
            //模板
            $truepage = '';
            $titleselect = '';
            //下一页链接
            if ($thispagenum == $j) {
                $thisnextlink = $dolink . $add[filename] . $filetype;
            } else {
                $thisj = $j + 1;
                $thisnextlink = $dolink . $add[filename] . '_' . $thisj . $filetype;
            }
            $k = $j - 1;
            if ($j == 1) {
                $file = $doclasspath . $newspath . $add[filename] . $filetype;
                $ptitle = $add[title];
            } else {
                $file = $doclasspath . $newspath . $add[filename] . '_' . $j . $filetype;
                $ti_r = explode('[/!--empirenews.page--]', $n_r[$k]);
                if (count($ti_r) >= 2) {
                    $ptitle = $ti_r[0];
                    $n_r[$k] = $ti_r[1];
                } else {
                    $ptitle = $add[title] . '(' . $j . ')';
                }
            }
            //取得当前页
            if ($thispagenum != 1) {
                $truepage = $thefun($thispagenum, $j, $dolink, $add, $filetype, '');
                $titleselect = str_replace("?" . $j . "\">", "?" . $j . "\" selected>", $dotitleselect);
            }
            //替换变量
            $newstext = $n_r[$k];
            if (!strstr($emod_r[$mid]['editorf'], ',' . $pf . ',')) {
                if (strstr($emod_r[$mid]['tobrf'], ',' . $pf . ',')) {
                    $newstext = nl2br($newstext);
                }
                if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $pf . ',')) {
                    $newstext = htmlspecialchars($newstext);
                    $newstext = RepFieldtextNbsp($newstext);
                }
            }
            $string = str_replace('[!--' . $pf . '--]', $newstext, $string);
            $string = str_replace('[!--p.title--]', $ptitle, $string);
            $string = str_replace('[!--next.page--]', $thisnextlink, $string);
            $string = str_replace('[!--page.url--]', $truepage, $string);
            $string = str_replace('[!--title.select--]', $titleselect, $string);
            //写文件
            WriteFiletext($file, $addlevel . $string);
        }
    } else {
        $file = $doclasspath . $newspath . $add[filename] . $filetype;
        $string = $newstempstr;
        //模板
        //替换变量
        $string = str_replace('[!--p.title--]', $add[title], $string);
        $string = str_replace('[!--next.page--]', '', $string);
        $string = str_replace('[!--page.url--]', '', $string);
        $string = str_replace('[!--title.select--]', '', $string);
        //写文件
        WriteFiletext($file, $addlevel . $string);
    }
    //设为已生成
    if (empty($add['havehtml'])) {
        $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " set havehtml=1 where id='{$add['id']}' limit 1");
    }
}
Esempio n. 5
0
function Ebak_DoEbak($add,$userid,$username){
	global $empire,$public_r,$fun_r,$ecms_config;
	//验证权限
	CheckLevel($userid,$username,$classid,"dbdata");
	$dbname=RepPostVar($add['mydbname']);
	if(empty($dbname)){
		printerror("NotChangeDbname","history.go(-1)");
	}
	$tablename=$add['tablename'];
	$count=count($tablename);
	if(empty($count)){
		printerror("MustChangeOneTable","history.go(-1)");
	}
	$add['baktype']=(int)$add['baktype'];
	$add['filesize']=(int)$add['filesize'];
	$add['bakline']=(int)$add['bakline'];
	$add['autoauf']=(int)$add['autoauf'];
	if((!$add['filesize']&&!$add['baktype'])||(!$add['bakline']&&$add['baktype'])){
		printerror("FileSizeEmpty","history.go(-1)");
	}
	//目录名
	$add['mypath']=RepPostStr($add['mypath'],1);
	$bakpath=$public_r['bakdbpath'];
	if(empty($add['mypath'])){
		$add['mypath']=$dbname."_".date("YmdHis");
	}
    DoMkdir($bakpath."/".$add['mypath']);
	//生成说明文件
	$readme=$add['readme'];
	$rfile=$bakpath."/".$add['mypath']."/readme.txt";
	$readme.="\r\n\r\nBaktime: ".date("Y-m-d H:i:s");
	WriteFiletext_n($rfile,$readme);

	$b_table="";
	$d_table="";
	for($i=0;$i<$count;$i++){
		$tablename[$i]=RepPostVar($tablename[$i]);
		$b_table.=$tablename[$i].",";
		$d_table.="\$tb[".$tablename[$i]."]=0;\r\n";
    }
	//去掉最后一个,
	$b_table=substr($b_table,0,strlen($b_table)-1);
	$bakstru=(int)$add['bakstru'];
	$bakstrufour=(int)$add['bakstrufour'];
	$beover=(int)$add['beover'];
	$waitbaktime=(int)$add['waitbaktime'];
	$bakdatatype=(int)$add['bakdatatype'];
	if($add['insertf']=='insert'){
		$insertf='insert';
	}
	else{
		$insertf='replace';
	}
	if($ecms_config['db']['dbver']=='4.0'&&$add['dbchar']=='auto')
	{
		$add['dbchar']='';
	}
	$string="<?php
	\$b_table=\"".$b_table."\";
	".$d_table."
	\$b_baktype=".$add['baktype'].";
	\$b_filesize=".$add['filesize'].";
	\$b_bakline=".$add['bakline'].";
	\$b_autoauf=".$add['autoauf'].";
	\$b_dbname=\"".$dbname."\";
	\$b_stru=".$bakstru.";
	\$b_strufour=".$bakstrufour.";
	\$b_dbchar=\"".addslashes($add['dbchar'])."\";
	\$b_beover=".$beover.";
	\$b_insertf=\"".addslashes($insertf)."\";
	\$b_autofield=\",".addslashes($add['autofield']).",\";
	\$b_bakdatatype=".$bakdatatype.";
	?>";
	$cfile=$bakpath."/".$add['mypath']."/config.php";
	WriteFiletext_n($cfile,$string);
	if($add['baktype']){
		$phome='BakExeT';
	}
	else{
		$phome='BakExe';
	}
	echo $fun_r['FirstBakSuccess']."<script>self.location.href='phome.php?phome=$phome&t=0&s=0&p=0&mypath=$add[mypath]&waitbaktime=$waitbaktime".hReturnEcmsHashStrHref(0)."';</script>";
	exit();
}
Esempio n. 6
0
function MoveClassNews($add, $userid, $username)
{
    global $empire, $class_r, $dbtbpre, $emod_r;
    $add[classid] = (int) $add[classid];
    $add[toclassid] = (int) $add[toclassid];
    if (empty($add[classid]) || empty($add[toclassid])) {
        printerror("EmptyMovetoClassid", "history.go(-1)");
    }
    if ($class_r[$add[classid]][modid] != $class_r[$add[toclassid]][modid]) {
        printerror("DefModid", "history.go(-1)");
    }
    //验证权限
    CheckLevel($userid, $username, $classid, "movenews");
    //终极栏目
    if (!$class_r[$add[classid]][islast] || !$class_r[$add[toclassid]][islast]) {
        printerror("MovetoClassidMustLastid", "history.go(-1)");
    }
    if ($add[classid] == $add[toclassid]) {
        printerror("MoveClassidsame", "history.go(-1)");
    }
    $mid = $class_r[$add[classid]][modid];
    $tbname = $class_r[$add[classid]][tbname];
    $sql = $empire->query("update {$dbtbpre}ecms_" . $tbname . " set classid={$add['toclassid']} where classid='{$add['classid']}'");
    //副表
    $dtbr = explode(',', $emod_r[$mid][datatbs]);
    $tbcount = count($dtbr);
    for ($i = 1; $i < $tbcount - 1; $i++) {
        $empire->query("update {$dbtbpre}ecms_" . $tbname . "_data_" . $dtbr[$i] . " set classid={$add['toclassid']} where classid='{$add['classid']}'");
    }
    //评论转换
    $uplsql = $empire->query("update {$dbtbpre}enewspl set classid={$add['toclassid']} where classid='{$add['classid']}'");
    $upltbr = $empire->fetch1("select pldatatbs from {$dbtbpre}enewspublic limit 1");
    if ($upltbr['pldatatbs']) {
        $pldtbr = explode(',', $upltbr['pldatatbs']);
        $count = count($pldtbr) - 1;
        for ($i = 1; $i < $count; $i++) {
            $empire->query("update {$dbtbpre}enewspl_data_" . $pldtbr[$i] . " set classid={$add['toclassid']} where classid='{$add['classid']}'");
        }
    }
    //签发转换
    $uqfsql = $empire->query("update {$dbtbpre}enewswfinfo set classid={$add['toclassid']} where classid='{$add['classid']}'");
    $uqfsql = $empire->query("update {$dbtbpre}enewswfinfolog set classid={$add['toclassid']} where classid='{$add['classid']}'");
    //投票
    $uvotesql = $empire->query("update {$dbtbpre}enewsinfovote set classid={$add['toclassid']} where classid='{$add['classid']}'");
    //digg
    $empire->query("update {$dbtbpre}enewsdiggips set classid={$add['toclassid']} where classid='{$add['classid']}'");
    //生成信息列表
    ListHtml($add[toclassid], $ret_r, 0);
    //移动数据
    $opath = ECMS_PATH . $class_r[$add[classid]][classpath];
    DelPath($opath);
    //删除旧的栏目目录
    $mk = DoMkdir($opath);
    if ($sql) {
        //操作日志
        insert_dolog("classid=" . $add[classid] . "&nbsp;(" . $class_r[$add[classid]][classname] . ")<br>toclassid=" . $add[toclassid] . "(" . $class_r[$add[toclassid]][classname] . ")");
        printerror("MoveClassNewsSuccess", "MoveClassNews.php");
    } else {
        printerror("DbError", "history.go(-1)");
    }
}
Esempio n. 7
0
function GetHtml($classid, $id, $add, $ecms = 0, $doall = 0)
{
    global $public_r, $class_r, $class_zr, $fun_r, $empire, $dbtbpre, $emod_r, $class_tr, $level_r, $etable_r;
    $mid = $class_r[$classid]['modid'];
    $tbname = $class_r[$classid][tbname];
    if (InfoIsInTable($tbname)) {
        return '';
    }
    if ($ecms == 0) {
        $add = $empire->fetch1("select " . ReturnSqlTextF($mid, 1) . " from {$dbtbpre}ecms_" . $tbname . " where id='{$id}' limit 1");
    }
    $add['id'] = $id;
    $add['classid'] = $classid;
    if ($add['isurl']) {
        return '';
    }
    if (empty($doall)) {
        if (!$add['stb'] || $class_r[$add[classid]][showdt] == 2 || strstr($public_r['nreinfo'], ',' . $add['classid'] . ',')) {
            return '';
        }
    }
    //副表
    $addr = $empire->fetch1("select " . ReturnSqlFtextF($mid) . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $add[stb] . " where id='{$add['id']}' limit 1");
    $add = array_merge($add, $addr);
    //路径
    $iclasspath = ReturnSaveInfoPath($add[classid], $add[id]);
    $doclasspath = eReturnTrueEcmsPath() . $iclasspath;
    //moreport
    $createinfopath = $doclasspath;
    //建立日期目录
    $newspath = '';
    if ($add[newspath]) {
        $createpath = $doclasspath . $add[newspath];
        if (!file_exists($createpath)) {
            $r[newspath] = FormatPath($add[classid], $add[newspath], 1);
        }
        $createinfopath .= $add[newspath] . '/';
        $newspath = $add[newspath] . '/';
    }
    //新建存放目录
    if ($class_r[$add[classid]][filename] == 3) {
        $createinfopath .= ReturnInfoSPath($add['filename']);
        DoMkdir($createinfopath);
        $fn3 = 1;
    }
    //存文本
    if ($emod_r[$mid]['savetxtf']) {
        $stf = $emod_r[$mid]['savetxtf'];
        if ($add[$stf]) {
            $add[$stf] = GetTxtFieldText($add[$stf]);
        }
    }
    $GLOBALS['navclassid'] = $add[classid];
    $GLOBALS['navinfor'] = $add;
    //取得内容模板
    $add[newstempid] = $add[newstempid] ? $add[newstempid] : $class_r[$add[classid]][newstempid];
    $newstemp_r = $empire->fetch1("select temptext,showdate from " . GetTemptb("enewsnewstemp") . " where tempid='{$add['newstempid']}' limit 1");
    $newstemp_r['tempid'] = $add['newstempid'];
    if ($public_r['opennotcj']) {
        $newstemp_r['temptext'] = ReturnNotcj($newstemp_r['temptext']);
    }
    $newstemptext = $newstemp_r[temptext];
    $formatdate = $newstemp_r[showdate];
    //文件类型/权限
    if ($add[groupid] || $class_r[$add[classid]]['cgtoinfo']) {
        if (empty($add[newspath])) {
            $include = '';
        } else {
            $pr = explode('/', $add[newspath]);
            for ($i = 0; $i < count($pr); $i++) {
                $include .= '../';
            }
        }
        if ($fn3 == 1) {
            $include .= '../';
        }
        $pr = explode('/', $iclasspath);
        $pcount = count($pr);
        for ($i = 0; $i < $pcount - 1; $i++) {
            $include .= '../';
        }
        $include1 = $include;
        $include .= 'e/class/CheckLevel.php';
        $filetype = '.php';
        $addlevel = "<?php\n\t\tdefine('empirecms','wm_chief');\n\t\t\$check_tbname='" . $class_r[$add[classid]][tbname] . "';\n\t\t\$check_infoid=" . $add[id] . ";\n\t\t\$check_classid=" . $add[classid] . ";\n\t\t\$check_path=\"" . $include1 . "\";\n\t\trequire(\"" . $include . "\");\n\t\t?>";
    } else {
        $filetype = $class_r[$add[classid]][filetype];
        $addlevel = '';
    }
    //取得本目录链接
    if ($class_r[$add[classid]][classurl] && $class_r[$add[classid]][ipath] == '') {
        $dolink = $class_r[$add[classid]][classurl] . '/' . $newspath;
    } else {
        $dolink = $public_r[newsurl] . $iclasspath . $newspath;
    }
    //返回替换验证字符
    $docheckrep = ReturnCheckDoRepStr();
    if ($add[newstext]) {
        if (empty($public_r['dorepword']) && $docheckrep[3]) {
            $add[newstext] = ReplaceWord($add[newstext]);
            //过滤字符
        }
        if (empty($public_r['dorepkey']) && $docheckrep[4] && !empty($add[dokey])) {
            $add[newstext] = ReplaceKey($add['newstext'], $add['classid']);
        }
        if ($public_r['opencopytext']) {
            $add[newstext] = AddNotCopyRndStr($add[newstext]);
            //随机复制字符
        }
    }
    //返回编译
    $newstemptext = GetInfoNewsBq($classid, $newstemp_r, $add, $docheckrep);
    //分页字段
    $expage = '[!--empirenews.page--]';
    //分页符
    $pf = $emod_r[$mid]['pagef'];
    //变量替换
    $newstempstr = $newstemptext;
    //模板
    //分页
    if ($pf && strstr($add[$pf], $expage)) {
        $n_r = explode($expage, $add[$pf]);
        $thispagenum = count($n_r);
        //取得分页
        $thefun = $public_r['textpagefun'] ? $public_r['textpagefun'] : 'sys_ShowTextPage';
        //下拉式分页
        if (strstr($newstemptext, '[!--title.select--]')) {
            $dotitleselect = sys_ShowTextPageSelect($thispagenum, $dolink, $add, $filetype, $n_r);
        }
        for ($j = 1; $j <= $thispagenum; $j++) {
            $string = $newstempstr;
            //模板
            $truepage = '';
            $titleselect = '';
            //下一页链接
            if ($thispagenum == $j) {
                $thisnextlink = $dolink . $add[filename] . $filetype;
            } else {
                $thisj = $j + 1;
                $thisnextlink = $dolink . $add[filename] . '_' . $thisj . $filetype;
            }
            $k = $j - 1;
            if ($j == 1) {
                $file = $doclasspath . $newspath . $add[filename] . $filetype;
                $ptitle = $add[title];
            } else {
                $file = $doclasspath . $newspath . $add[filename] . '_' . $j . $filetype;
                $ti_r = explode('[/!--empirenews.page--]', $n_r[$k]);
                if (count($ti_r) >= 2) {
                    $ptitle = $ti_r[0];
                    $n_r[$k] = $ti_r[1];
                } else {
                    $ptitle = $add[title] . '(' . $j . ')';
                }
            }
            //取得当前页
            if ($thispagenum != 1) {
                $truepage = $thefun($thispagenum, $j, $dolink, $add, $filetype, '');
                $titleselect = str_replace("?" . $j . "\">", "?" . $j . "\" selected>", $dotitleselect);
            }
            //替换变量
            $newstext = $n_r[$k];
            if (!strstr($emod_r[$mid]['editorf'], ',' . $pf . ',')) {
                if (strstr($emod_r[$mid]['tobrf'], ',' . $pf . ',')) {
                    $newstext = nl2br($newstext);
                }
                if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $pf . ',')) {
                    $newstext = ehtmlspecialchars($newstext);
                    $newstext = RepFieldtextNbsp($newstext);
                }
            }
            $string = str_replace('[!--' . $pf . '--]', $newstext, $string);
            $string = str_replace('[!--p.title--]', strip_tags($ptitle), $string);
            $string = str_replace('[!--next.page--]', $thisnextlink, $string);
            $string = str_replace('[!--page.url--]', $truepage, $string);
            $string = str_replace('[!--title.select--]', $titleselect, $string);
            //写文件
            WriteFiletext($file, $addlevel . $string);
        }
    } else {
        $file = $doclasspath . $newspath . $add[filename] . $filetype;
        $string = $newstempstr;
        //模板
        //替换变量
        $string = str_replace('[!--p.title--]', $add[title], $string);
        $string = str_replace('[!--next.page--]', '', $string);
        $string = str_replace('[!--page.url--]', '', $string);
        $string = str_replace('[!--title.select--]', '', $string);
        //写文件
        WriteFiletext($file, $addlevel . $string);
    }
    //设为已生成
    if (empty($doall) && empty($add['havehtml'])) {
        $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . "_index set havehtml=1 where id='{$add['id']}' limit 1");
        $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " set havehtml=1 where id='{$add['id']}' limit 1");
    }
}
Esempio n. 8
0
function BackupDatabaseInit($add)
{
    global $db, $fun_r, $phpyun_db_ver, $config, $adminDir;
    $res = $db->query("select VERSION()");
    $row = mysql_fetch_row($res);
    $phpyun_db_ver = $row[0];
    $dbname = $add['mydbname'];
    $bakpath = $add['backuppath'];
    if (empty($dbname)) {
    }
    $tablename = $add['tablename'];
    if (is_array($tablename)) {
        $count = count($tablename);
    } else {
        $count = 1;
        $tablename = array($tablename);
    }
    if (empty($count)) {
    }
    $add['baktype'] = (int) $add['baktype'];
    $add['filesize'] = (int) $add['filesize'];
    $add['bakline'] = (int) $add['bakline'];
    $add['autoauf'] = (int) $add['autoauf'];
    if (!$add['filesize'] && !$add['baktype'] || !$add['bakline'] && $add['baktype']) {
    }
    if (is_array($add['tablename'])) {
        if (empty($add['mypath'])) {
            $add['mypath'] = $dbname . "_" . date("YmdHis");
        }
    } else {
        if (empty($add['mypath'])) {
            $add['mypath'] = $dbname . "_" . $add['tablename'] . "_" . date("YmdHis");
        }
    }
    DoMkdir($bakpath . "/" . $add['mypath']);
    $readme = $add['readme'];
    $rfile = $bakpath . "/" . $add['mypath'] . "/readme.txt";
    $readme .= "\r\n\r\nBaktime: " . date("Y-m-d H:i:s");
    WriteString2File($rfile, $readme);
    $b_table = "";
    $d_table = "";
    for ($i = 0; $i < $count; $i++) {
        $b_table .= $tablename[$i] . ",";
        $d_table .= "\$tb[" . $tablename[$i] . "]=0;\r\n";
    }
    $b_table = substr($b_table, 0, strlen($b_table) - 1);
    $bakstru = (int) $add['bakstru'];
    $bakstrufour = (int) $add['bakstrufour'];
    $beover = (int) $add['beover'];
    $waitbaktime = (int) $add['waitbaktime'];
    $bakdatatype = (int) $add['bakdatatype'];
    if ($add['insertf'] == 'insert') {
        $insertf = 'insert';
    } else {
        $insertf = 'replace';
    }
    if ($phpyun_db_ver == '4.0' && $add['dbchar'] == 'auto') {
        $add['dbchar'] = '';
    }
    $string = "<?php\r\n\t\$b_table=\"" . $b_table . "\";\r\n\t" . $d_table . "\r\n\t\$b_baktype=" . $add['baktype'] . ";\r\n\t\$b_filesize=" . $add['filesize'] . ";\r\n\t\$b_bakline=" . $add['bakline'] . ";\r\n\t\$b_autoauf=" . $add['autoauf'] . ";\r\n\t\$b_dbname=\"" . $dbname . "\";\r\n\t\$b_stru=" . $bakstru . ";\r\n    \$b_version=\"" . $phpyun_db_ver . "\";\r\n    \$b_time=\"" . time() . "\";\r\n\t\$b_strufour=" . $bakstrufour . ";\r\n\t\$b_dbchar=\"" . addslashes($add['dbchar']) . "\";\r\n\t\$b_beover=" . $beover . ";\r\n\t\$b_insertf=\"" . addslashes($insertf) . "\";\r\n\t\$b_autofield=\"," . addslashes($add['autofield']) . ",\";\r\n\t\$b_bakdatatype=" . $bakdatatype . ";\r\n\t?>";
    $cfile = $bakpath . "/" . $add['mypath'] . "/config.php";
    WriteString2File($cfile, $string);
    if ($add['baktype']) {
        $phome = 'BackupDatabaseRecordNum';
    } else {
        $phome = 'BackupDatabaseFileSize';
    }
    echo "<script>self.location.href='" . $config['sy_weburl'] . "/" . $adminDir . "/index.php?m=database&c={$phome}&t=0&s=0&p=0&mypath={$add['mypath']}&waitbaktime={$waitbaktime}';</script>";
    exit;
}
Esempio n. 9
0
File: v.php Progetto: gaoerjun/Web
         $jsonstr = file_get_contents($jsonfile);
         $infos = json_decode($jsonstr, TRUE);
     }
     $total = count($infos);
     include admin_tpl('v_index');
     break;
 case 'add':
     if (isset($_POST['trid']) && !empty($_POST['trid'])) {
         $jsonarr = array();
         $data = $_POST['info'];
         if (empty($_POST['inputtime'])) {
             showmessage('请选择日期');
         }
         $savepath = 'data/' . $cid . '/' . $_POST['inputtime'] . '/';
         //文件保存路径
         $savepath = DoMkdir($savepath);
         foreach ($data as $k => $v) {
             $filename = $newfile = '';
             //记录文件名
             //检查是否有上传文件
             if (isset($_FILES) && $_FILES['myfile'][error][$k] == UPLOAD_ERR_OK) {
                 //上传成功
                 if ($_FILES["myfile"]["tmp_name"][$k]) {
                     $tmp_name = $_FILES["myfile"]["tmp_name"][$k];
                     $name = $_FILES["myfile"]["name"][$k];
                     $filer = explode(".", $name);
                     $count = count($filer) - 1;
                     $filetype = strtolower($filer[$count]);
                     $filename = str_replace('.' . $filetype, '', $name);
                     $newfile = $savepath . $name;
                     if (in_array('.' . $filetype, $_filetype)) {
Esempio n. 10
0
function MkDirTxtFile($date, $file)
{
    global $ecms_config;
    $r = explode("/", $date);
    $path = $ecms_config['sets']['txtpath'] . $r[0];
    DoMkdir($path);
    $path = $ecms_config['sets']['txtpath'] . $date;
    DoMkdir($path);
    $returnpath = $date . "/" . $file;
    return $returnpath;
}
Esempio n. 11
0
function MkDirTxtFile($date, $file)
{
    global $do_txtpath;
    $r = explode("/", $date);
    $path = $do_txtpath . $r[0];
    DoMkdir($path);
    $path = $do_txtpath . $date;
    DoMkdir($path);
    $returnpath = $date . "/" . $file;
    return $returnpath;
}