⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cms.php

📁 PHP+HTML开发,树型结构自动生成HTML文件
💻 PHP
📖 第 1 页 / 共 2 页
字号:
function init(){with(document.getElementById("f").contentWindow.document){open();write((document.getElementById("text").value).replace("\/TEXT AREA","/TEXTAREA").replace("TEXT AREA","TEXTAREA"));close();designMode="on"}window.status=copyright;document.getElementById("f").contentWindow.focus()}
function chmode(){if(format=="HTML"){if(isNav){var html=document.createTextNode(document.getElementById("f").contentWindow.document.body.innerHTML);with(document.getElementById("f").contentWindow.document.body){innerHTML="";appendChild(html)}}else{with(document.getElementById("f").contentWindow){with(document.body){style.fontFamily="Courier";style.fontSize="10pt";innerText=innerHTML}focus();document.body.createTextRange().collapse(false)}}document.getElementById("html").src=img2.src;format="Text"}else{if(isNav){var html=document.getElementById("f").contentWindow.document.body.ownerDocument.createRange();html.selectNodeContents(document.getElementById("f").contentWindow.document.body);document.getElementById("f").contentWindow.document.body.innerHTML=html.toString()}else{with(document.getElementById("f").contentWindow){with(document.body){innerHTML=innerText;style.fontFamily="";style.fontSize=""}focus();document.body.createTextRange().collapse(false)}}document.getElementById("html").src=img1.src;format="HTML"}}
function cmd(c){
if(c=="save"){if(format=="HTML"){
document.getElementById("text").value=document.getElementById("f").contentWindow.document.body.innerHTML;
document.getElementById("t").submit()
}else if(confirm(changemode))chmode()}else if(c=="selectall")document.getElementById("f").contentWindow.document.execCommand(c,false,null);else if(c=="html")chmode();else{
if(format=="HTML"||(c=="cut"||c=="copy"||c=="paste"||c=="undo"||c=="redo")){
var tmp=null;if(c=="iimage"){tmp=document.forms[c].iimage.value;c="insertimage"}
if(c=="ilink"){tmp=document.forms[c].ilink.value;c="createlink"}
if((c.search(/h[1-4]/)!=-1)||c=="p"){tmp="<"+c+">"; c="formatblock"}
if (tmp==null && c=="createlink"){
if(isNav) { tmp=prompt("Enter URL:", "");document.getElementById("f").contentWindow.document.execCommand("CreateLink",false,tmp)}else
document.getElementById("f").contentWindow.document.selection.createRange().execCommand(c,true,tmp)} else if (c=="cut"||c=="copy"||c=="paste") document.getElementById("f").contentWindow.document.selection.createRange().execCommand(c,false,null); else document.getElementById("f").contentWindow.document.execCommand(c,false,tmp);
document.getElementById("f").contentWindow.focus();
}}}function tables(){for(var i=0;i<btns.length;i++){if(btns[i][0]=="ilink")sb(i,ilink);if(btns[i][0]=="iimage")sb(i,iimage);if(btns[i][0]=="tr")document.write("</td></tr></table></td></tr><tr><td class=\"edit\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"edit\">");else{if(btns[i][0]!="")document.write("<img src=\""+getimage+btns[i][0]+"\" id=\""+btns[i][0]+"\" alt=\""+btns[i][1]+"\" title=\""+btns[i][1]+"\" onclick=\"cmd(\'"+btns[i][0]+"\')\" width=\"23\" height=\"22\" style=\"border:outset 1px;\" onmouseover=\"this.style.border=\'inset 1px\';window.status=\'"+btns[i][2]+"\'\" onmouseout=\"this.style.border=\'outset 1px\';window.status=\'"+copyright+"\'\">");else document.write("<img src=\""+getimage+btns[i][0]+"\" alt=\"\" width=\"3\" height=\"22\">")}}}function sb(i,tmp){document.write("</td><td class=\"edit\"><form id=\""+btns[i][0]+"\" style=\"margin:0\"><select id=\""+btns[i][0]+"\" class=\"edit\">");for(var j=0;j<tmp.length;j++)document.write("<option value=\""+ tmp[j][0]+"\">"+tmp[j][1]+"</option>");document.write("</select></form></td><td class=\"edit\">")}function bloker(){return false}document.ondragstart=bloker;
img1=new Image();img1.src=getimage+"html";img2=new Image();img2.src=getimage+"layout";
</script>';
$contentout.='<table width=100% border="1" cellpadding="0" cellspacing="0"><tr><td class="edit"><table border="0" cellpadding="0" cellspacing="0"><tr><td class="edit"><script language="JavaScript">tables();</script></td></tr></table></td></tr><tr><td class="edit"><script language="JavaScript">
document.write(\'<iframe id="f" width="100%" height="\'+('.$height.')+\'"></iframe>\');
</script></td></tr></table><p style="visibility:hidden;position:absolute;left:0;top:0"><form method="post" style="margin:0" id="t" action="'.$scriptname.'"><input type="hidden" name="selected" value="'.$url[$selectednum].'"><input type="hidden" name="function" value="save"><textarea name="text" id="text" style="width: 0; height: 0; visibility: hidden;"><html><head><style type="text/css">'.rmnl(myreadfile($file_stylesheet)).'</style></head><body bgcolor="white">'.preg_replace("/textarea/i","TEXT AREA",$contentarray[$selectednum]).'</body></html></textarea></form></p>';
} else $contentout='<p>Could not locate heading.</p>'; }

} // end protected

// CHECK FILES
$tmp=(($login||$settings)&&$admin);
$error.=chkfile('file_log',$tmp).chkfile('file_template',$tmp).chkfile('file_content',$tmp).chkfile('file_stylesheet',$tmp);
if ($error) { $contentout='<h1>WARNING</h1><ul>'.$error.'</ul>'.$contentout; }

if ($title=='') {if ($selectednum>-1) $title=$heading[$selectednum]; else if ($function!='') $title=ucfirst($function);}

if ($print) {echo '<html>'.head().'<body>'.content().'</body></html>'; exit;}

if (!@include($file_template)) { echo '<html><head><title>ERROR</title></head><body>'.$contentout.'</body></html>'; }

// INTERNAL FUNCTIONS

function mygetcookie($s) {
global $HTTP_COOKIE_VARS; // if above 4.1 use $_COOKIE
if (isset($HTTP_COOKIE_VARS[$s])) return $HTTP_COOKIE_VARS[$s]; else return '';
}

function logincheck() {
if ($GLOBALS['usewwwaut']) return (servervar('PHP_AUTH_USER')==$GLOBALS['username'] && servervar('PHP_AUTH_PW')==$GLOBALS['password']);
else return (mygetcookie('passwd')==$GLOBALS['password']);
// Might be useful for login with FTP-login
// $conn_id=ftp_connect(servervar('SERVER_NAME'));
// $login_result=@ftp_login($conn_id,servervar('PHP_AUTH_USER'),servervar('PHP_AUTH_PW'));
// echo 'RESULT:'.$login_result.'<br>';
// ftp_quit($conn_id);
// echo '<a href="ftp://'.servervar('PHP_AUTH_USER').':'.servervar('PHP_AUTH_PW').'@domain.com">FTP</a>';
}

function writelog($message) {
global $file_log;
if (is_writable($file_log)) {$fp = fopen($file_log, "a");fwrite($fp,$message);
fclose($fp);} else $GLOBALS['error'].='<li>could not write to file_log '.$file_log;}

function rmnl($text) { return preg_replace("/(\r\n|\r|\n)+/","\n",$text); }

function getlost() {global $contentout; global $title;header('HTTP/1.0 401 Unauthorized');$title=$GLOBALS['text_title']['error401'];$contentout='<h1>'.$title.'</h1>'.$contentout;}

function download($file) {
if (!is_readable($file) || ($GLOBALS['download']!='' && !chkdownload($GLOBALS['scriptname'].'?download='.basename($file)))) { global $contentout; global $text_title;header('HTTP/1.0 404 Not Found');$title=$text_title['error404'];$contentout='<h1>'.$title.'</h1><p>File '.$file.'</p>'.$contentout; return; } else {
header('Content-Type: application/save-as');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Length:'.filesize($file));
header('Content-Transfer-Encoding: binary');
$f = fopen($file, "rb");
while (!feof($f)){
$bindata = fread($f, filesize($file));
echo($bindata);
}fclose($f);exit;}}

function chkdownload($file) {
global $folder_download; global $scriptname;
$match=false;
if (is_dir($folder_download)) {
$fd = @opendir($folder_download);
while ( ($part = @readdir($fd)) == true ) {
if (preg_match("/.*\....$/i", $part)) {
if ($file==$scriptname.'?download='.$part) $match=true;
}}if($fd==true) { closedir($fd); }
}return $match;}

function myreadfile($file) {
if (!file_exists($file)) return;
clearstatcache();
if(function_exists('file_get_contents')) { return file_get_contents($file); }
else { return join("\n", file($file)); } }

function chkfile($file,$writable) {
if ($GLOBALS[$file]=='') return '<li>'.$file.' undefined'; else
if (!file_exists($GLOBALS[$file])) return '<li>'.$file.' '.$GLOBALS[$file].' missing'; else
if (!is_readable($GLOBALS[$file])) return '<li>'.$file.' '.$GLOBALS[$file].' not readable'; else
if (!is_writable($GLOBALS[$file]) && $writable) return '<li>'.$file.' '.$GLOBALS[$file].' must be set writable';
}

function read_file_content() {
global $contentarray; global $docstart; global $selected;
global $selectednum; global $heading; global $url;
$url=array();$heading=array();$contentarray=array();
$contentarray=explode('?, preg_replace("/(<h[1-3][^>]*>)/i","禱\1",str_replace('?,'&para;',myreadfile($GLOBALS['file_content']))));
$docstart='';
if (heading(0)=='') $docstart=array_shift($contentarray);
$contentarray[count($contentarray)-1]=preg_replace("/(.*)<\/body>.*<\/html>/i","\\1",$contentarray[count($contentarray)-1]);
$duplicate=1;$empty=1;$level1='';$level2='';$selectednum=-1;
for ($i = 0; $i < count($contentarray); $i++) {
$heading[$i]=heading($i);
if ($heading[$i]=='') { $heading[$i]='EMPTY HEADING '.$empty++; $url[$i]=$heading[$i]; }
if (level($i)==1) { $level1=urlencode($heading[$i]); $url[$i]=$level1; }
if (level($i)==2) { $level2=urlencode($heading[$i]); $url[$i]=$level1.'/'.$level2; }
if (level($i)==3) { $url[$i]=$level1.'/'.$level2.'/'.urlencode($heading[$i]); }
for ($j = 0; $j < count($url)-1; $j++) {
if ($url[$i]==$url[$j]) { $heading[$i]='DUPLICATE HEADING '.$duplicate++; $url[$i]=urlencode($heading[$i]); }
}
if ($selected==$url[$i]) $selectednum=$i;
}}

function heading($num) { return trim(strip_tags(preg_replace("/<h[1-3][^>]*>([^禲*?)<\/h[1-3]>[^禲*/i","\\1",$GLOBALS['contentarray'][$num]))); }

function level($num) { if (isset($GLOBALS['contentarray'][$num])) return preg_replace("/<h([1-3])[^>]*>[^禲*/i","\\1",$GLOBALS['contentarray'][$num]); else return 0; }

function astart($i,$style,$extra) { return '<a href="'.$GLOBALS['scriptname'].'?'.$GLOBALS['url'][$i].$extra.'"'.$style.'>'; }

function trlink($i,$style,$nolevels) { // USED IN toc() AND sitemap()
$boolean=($GLOBALS['selectednum']!=$i);
if ($style!='') $style=' class="'.$style.'"';
$tmp='<tr>';
if (!$nolevels) for ($j = 1; $j <level($i); $j++) $tmp.='<td>&nbsp;</td>';
$tmp.='<td valign="top"'.$style.'>';
if ($boolean) $tmp.=astart($i,$style,'');
$tmp.='<img src="'.$GLOBALS['scriptname'].'?image=';
$tmp.='document';
if (level($i+1)>level($i)) $tmp.='s';
if (!$boolean) $tmp.='&highlight=true';
$tmp.='" border="0" alt="" width="12" height="15">';
if ($boolean) $tmp.='</a>';
$tmp.='</td><td valign="top" width="100%"';
if (!$nolevels) if (level($i)<3) $tmp.=' colspan="'.(4-level($i)).'"';
$tmp.=$style.'>';
if ($boolean) $tmp.=astart($i,$style,'');
$tmp.=$GLOBALS['heading'][$i];
if ($boolean) $tmp.='</a>';
return $tmp.'</td></tr>';
}


// PAGE FUNCTIONS

function head() { return '<title>'.$GLOBALS['title'].'</title><link rel="stylesheet" href="'.$GLOBALS['scriptname'].'?&stylesheet" type="text/css" />'.$GLOBALS['headingjs']; }

function onload() { return $GLOBALS['onload']; }

function toc() {
$style='menulevel'; // 1-3 added
global $selectednum; global $contentarray;
$level=level($selectednum);
$tmp=$GLOBALS['tablestart'];
for ($i = 0; $i < count($contentarray); $i++) {
if (level($i)==1) { $tmp.=trlink($i,$style.level($i),false); $level1=$i; $level2=$i; }
if ($selectednum==$i) { $show3=true;
for ($j = $level1+1; $j < count($contentarray); $j++) {
if (level($j)==1) break;
if (level($j)==2) { $tmp.=trlink($j,$style.level($j),false); $level2=$j; $show3=false; }
if ($selectednum==$j) { for ($k = $level2+1; $k < count($contentarray); $k++) { if (level($k)==3) $tmp.=trlink($k,$style.level($k),false); else { $show3=false; break; }}}
if (level($selectednum)!=3 && level($j)==3 && $show3) $tmp.=trlink($j,$style.level($j),false);
}}
} return $tmp.'</table>';
}

function searchbox() { return '<form name="search" action="'.$GLOBALS['scriptname'].'" method="post" style="margin:0"><input type="text" name="search" size="12" class="search"><input type="hidden" name="function" value="search"> <input type="submit" value="'.$GLOBALS['text_searchbutton'].'" class="search"></form>'; }

function sitemaplink() {
$tmp=null;
if ($GLOBALS['function']!='sitemap') $tmp.='<a href="'.$GLOBALS['scriptname'].'?&sitemap" class="sitemaplink">';
$tmp.=$GLOBALS['text_sitemaplink'];
if ($GLOBALS['function']!='sitemap') $tmp.='</a>';
return $tmp;
}

function printlink() {
global $function;
$tmp='&print';
if ($function=='search') $tmp.='&function=search&search='.$GLOBALS['search']; else if ($function=='file') $tmp.='&file='.$GLOBALS['file']; else if ($function!=''&&$function!='save') $tmp.='&'.$function;
return '<a href="'.$GLOBALS['scriptname'].'?'.$GLOBALS['selected'].$tmp.'" class="printlink">'.$GLOBALS['text_printlink'].'</a>';
}

function loginlink() {
if (!$GLOBALS['usewwwaut']) {
if (!$GLOBALS['admin']) return '<form name="login" id="login" action="'.$GLOBALS['scriptname'].'" method="post" style="margin:0"><input type="hidden" name="login" value="true"><input type="hidden" name="selected" value="'.$GLOBALS['url'][$GLOBALS['selectednum']].'"><input type="hidden" name="passwd" id="passwd" value=""></form><a href="javascript:login()" class="login">'.$GLOBALS['text_loginlink'].'</a>'; else return '';
} else {
if (!$GLOBALS['admin']) return astart($GLOBALS['selectednum'],' class="login"','&login').'login</a>'; else return ''; }
}

function locator() {
global $title;global $selectednum;
if ($title!='' && $GLOBALS['heading'][$selectednum]!=$title) return $title;
$tmp='';$style=' class="locator"';
$level=level($selectednum);
if ($level>1) {
for ($i = $selectednum-1; $i>0 ; $i--) {
if (level($i)<$level) { $tmp=astart($i,$style,'').$GLOBALS['heading'][$i].'</a> &gt; '.$tmp;$level--; }
if ($level<2) break;
}}
if ($selectednum==0) return $GLOBALS['heading'][$selectednum]; else if ($selectednum>0) return astart(0,$style,'').$GLOBALS['heading'][0].'</a> &gt; '.$tmp.$GLOBALS['heading'][$selectednum]; else if ($GLOBALS['function']!='') return ucfirst($GLOBALS['function']); else return '&nbsp;';
}

function editmenu() {
$tmp=null; if ($GLOBALS['admin']) {
$tmp.='<table width="100%" cellpadding="1" cellspacing="0" border="1"><tr><td class="edit" align="left">';
if ($GLOBALS['edit']) $tmp.=astart($GLOBALS['selectednum'],' class="edit"','&normal').'NORMAL MODE</a>'; else $tmp.=astart($GLOBALS['selectednum'],' class="edit"','&edit').'EDIT MODE</a>';
$tmp.='</td><td class="edit" align="center"><a href="'.$GLOBALS['scriptname'].'?&validate" class="edit">VALIDATE LINKS</a></td><td class="edit" align="center"><a href="'.$GLOBALS['scriptname'].'?&images" class="edit">IMAGES</a></td><td class="edit" align="center"><a href="'.$GLOBALS['scriptname'].'?&settings" class="edit">SETTINGS</a><td class="edit" align="center"><a href="http://www.harteg.dk/cms/?Help" class="edit" target="_blank">HELP</td><td class="edit" align="right">'.astart($GLOBALS['selectednum'],' class="edit"','&logout').'LOGOUT</a></td></tr></table>';
} return $tmp; }

function content() {
if ($GLOBALS['selectednum']>-1 && !($GLOBALS['edit']&&$GLOBALS['admin'])) return $GLOBALS['contentout'].$GLOBALS['contentarray'][$GLOBALS['selectednum']]; else return $GLOBALS['contentout'];
}

function submenu() {
global $selectednum; $style='submenu';
if (!(level($selectednum)==1||level($selectednum)==2)) return;
$show3=true; $tmp=null;
for ($i = $selectednum+1; $i < count($GLOBALS['contentarray']); $i++) {
if (level($i)==1) break;
if (level($i)==2) { if (level($selectednum)!=1) break; else { $tmp.=trlink($i,$style,true); $show3=false;} }
if (level($i)==3 && $show3) $tmp.=trlink($i,$style,true);
}
if ($tmp!='') return $GLOBALS['text_submenu'].$GLOBALS['tablestart'].$tmp.'</table>'; else return;
}

function previouspage() {
global $selectednum;
if ($selectednum>0) return astart($selectednum-1,' class="navigator"','').$GLOBALS['text_previouspage'].'</a>';
}

function nextpage() {
global $selectednum;
if ($selectednum+1<count($GLOBALS['contentarray']) && $selectednum!=-1) return astart($selectednum+1,' class="navigator"','').$GLOBALS['text_nextpage'].'</a>';
}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -