Location: PHPKode > projects > BlogNEasy > admin.php
<?php
/*++++++++++++++++++++++++++++++++++++++++++++++++++++
| BlogNEasy
| Copyright 2012 Fernando Baptista
++++++++++++++++++++++++++++++++++++++++++++++++++++++
| admin.php admin functions module
| Version 0.9
++++++++++++++++++++++++++++++++++++++++++++++++++++++
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

if($_POST['categories']=="Add Category" || $_POST['categories']=="Edit Category") {
	$filename="data/categories.dat";
	$aaa=trim(@file_get_contents($filename));
	unset($newsscat);
	$newsscat=explode("||",$aaa);
	$count=0;
	$maxid=0;
	while($newsscat[$count] != "") {
		$categories[$count]=explode("|",$newsscat[$count]);
		if($categories[$count][0]>$maxid)
			$maxid=$categories[$count][0];
		$count++;
	}
	$maxid++;
	if($_POST['categories']=="Add Category") { // add
		if(!$fp=fopen($filename,"a")) die($langmessage[106]);
		fwrite($fp,$maxid."|".encode($_POST['name'])."|".encode($_POST['descr'])."|".$_POST['comments']."||");
	} else {
		if(!$fp=fopen($filename,"w")) die($langmessage[106]);
		$count=0;
		while($newscat[$count][0]!="") {
			if($newscat[$count][0]==$_POST['id'])
				fwrite($fp,$_POST['id']."|".encode($_POST['name'])."|".encode($_POST['descr'])."|".$_POST['comments']."||\n");
			else
				fwrite($fp,$newscat[$count][0]."|".$newscat[$count][1]."|".$newscat[$count][2]."|".$newscat[$count][3]."||\n");
			$count++;
		}
	}
	fclose($fp);
	unset($_GET['action']);
}



function adminposts() {
	global $langmessage, $message, $out;
	$row_cat=readdata("categories");
	$row_db=readdata("posts");
	$post_id = $_GET['id'];
	switch($_GET['action']) {
	case "deletec":
		if(!$fp=fopen("data/categories.dat","w")) die ($langmessage[127]);
		$i=0;
		while($row_cat[$i][0]!="") {
			if(strval($row_cat[$i][0])!=$post_id)
				fwrite($fp,$row_cat[$i][0]."|".$row_cat[$i][1]."|".$row_cat[$i][2]."|".$row_cat[$i][3]."||");
			$i++;
		}
		fclose($fp);
		unset($row_cat);
		$row_cat=readdata("categories");
		$message=$langmessage[126];
		break;
	case "delete":
		if(!$fp=fopen("data/posts.dat","w")) die ($langmessage[76]);
		$i=0;
		while($row_db[$i][0] != "") {
			if(strval($row_db[$i][0])!=$post_id)
				fwrite($fp,$row_db[$i][0]."|".$row_db[$i][1]."|".$row_db[$i][2]."|".$row_db[$i][3]."|".$row_db[$i][4]."|".$row_db[$i][5]."|".$row_db[$i][6]."|".$row_db[$i][7]."||");
			$i++;
		}
		fclose($fp);
		unset($row_db);
		$row_db=readdata("posts");
		$message=$langmessage[128];
		break;
	case "edit":
		$i=0;
		while($row_db[$i][0] != "") {
			if(strval($row_db[$i][0])==$post_id) break;
			$i++;
		}
		break;
	case "editc":
		$i=0;
		while($row_cat[$i][0]!="") {
			if(strval($row_cat[$i][0])==$post_id) break;
			$i++;
		}
	}
	$out.="<h2 class=\"LNE_title\">$langmessage[72]</h2>\n";
	if($message!="")
		$out.="<h3 class=\"LNE_message\">$message</h3>\n";
	$out.="<div>";
	$out.="<form name=\"adicionar\" method=\"post\" action=\"\">\n
	<fieldset style=\"border: 0;\">\n<table style=\"border: 0;\">
	<tr><td>$langmessage[16]:</td><td><input type='text' name='autor' value=\"";
	if($_GET['action']=="edit") $out.=decode($row_db[$i][1]);
	$out.="\" /></td></tr>\n
	<tr><td>$langmessage[73]:</td><td><input type='text' name='email' value=\"";
	if($_GET['action']=="edit") $out.=decode($row_db[$i][2]);
	$out.="\" /></td></tr>\n
	<tr><td>$langmessage[12]:</td><td><input type='text' name='titulo' value=\"".decode($row_db[$i][3])."\" /></td></tr>\n";
	$out.="<tr><td>$langmessage[52]:</td><td><select name=\"cat\" >\n";
	$count=0;
	while($row_cat[$count][0]!="") {
		$out.='<option value="'.$row_cat[$count][0].'"';
		if($_GET['action']=="edit" && $row_db[$i][7]==$row_cat[$count][0]) $out.=' SELECTED';
		$out.='>'.decode($row_cat[$count][1])."&nbsp;</option>\n";
		$count++;
	}
	$out.="</select></td></tr>\n</table>\n";
	print $out;
	$out="";
	if($_GET['action']=="edit")
		editor(decode($row_db[$i][4]));
	else
		editor("");
	if($_GET['action']=="edit") {
		$out.="<input type='hidden' name='reg' value='".$row_db[$i][0]."' />";
		$out.="<input type='hidden' name='submit' value='Edit News' />";
		$out.="<input type=\"submit\" onClick=\"rtoStore()\" name=\"aa\" value='$langmessage[77]' />\n";
	} else {
		$out.="<input type='hidden' name='submit' value='Add News' />";
		$out.="<input type=\"submit\" onClick=\"rtoStore()\" name=\"aa\" value='$langmessage[74]' />\n";
	}
	$out.="</fieldset></form>";
	$out.="<h3>$langmessage[80]</h3>\n<table>\n";
	$i_edit=0;
	while($row_db[$i_edit][0] != "") {
		$out.="<tr><td><a href='".$_SERVER["SCRIPT_NAME"]."?do=adminposts&amp;action=edit&amp;id=".$row_db[$i_edit][0]."'><img src=\"images/edit.png\" alt=\"edit\" style=\"align: left; border: 0;\" /></a></td><td><a href='".$_SERVER["SCRIPT_NAME"]."?do=adminposts&amp;action=delete&amp;id=".$row_db[$i_edit][0]."'><img src=\"images/editdelete.png\" alt=\"delete\" style=\"align: left; border: 0;\" /></a></td><td><b>".decode($row_db[$i_edit][3])."</b></td><td>".strftime("%d/%m/%y - %I:%M %p", $row_db[$i_edit][5] + $fuso_s)."</td><td>$langmessage[79]: ".$row_db[$i_edit][7]."</td></tr>\n";
		$i_edit++;
	}
	$out.="</table></div>\n";
	$out.="<br /><h2>$langmessage[78]</h2>\n";
	$out.="<div><form name=\"form1\" method=\"post\" action=\"\"><fieldset style=\"border: 0;\"><table>\n";
	$out.="<tr><td>$langmessage[50]</td><td><input type=\"text\" name=\"name\"";
	if($_GET['action']=="editc") $out.=" value=\"".decode($row_cat[$i][1])."\"";
	$out.=" /></td></tr>\n<tr><td>$langmessage[67]</td><td><input type=\"text\" name=\"descr\"";
	if($_GET['action']=="editc") $out.=" value=\"".decode($row_cat[$i][2])."\"";
	$out.=" /></td></tr>\n";
	if($_GET['action']=="editc") $out.="<tr><td>$langmessage[79]</td><td><input type=\"text\" name=\"newid\" value=\"".$row_cat[$i][0]."\" /></td></tr>";
	$out.="<tr><td>$langmessage[143]</td><td><select name=\"comments\">";
	$out.="<option value=\"0\"";
	if($_GET['action']=="editc" && $row_cat[$i][3]=="0")
		$out.=" SELECTED";
	$out.=">$langmessage[60]</option>\n";
	$out.="<option value=\"1\"";
	if($_GET['action']=="editc" && $row_cat[$i][3]=="1")
		$out.=" SELECTED";
	$out.=">$langmessage[61]</option>\n";
	$out.="<option value=\"2\"";
	if($_GET['action']=="editc" && $row_cat[$i][3]=="2")
		$out.=" SELECTED";
	$out.=">$langmessage[62]</option>\n";
	$out.="</select></td></tr>\n";
	$out.="<tr><td></td><td>";
	$out.="<input type=\"hidden\" name=\"id\" value=\"".$_GET['id']."\" />\n";
	if($_GET['action']=="editc") {
		$out.="<input type=\"hidden\" name=\"categories\" value=\"Edit Category\" />\n";
		$out.="<input type=\"submit\" name=\"aa\" value=\"$langmessage[54]\" />\n";
	} else {
		$out.="<input type=\"hidden\" name=\"categories\" value=\"Add Category\" />\n";
		$out.="<input type=\"submit\" name=\"aa\" value=\"$langmessage[53]\" />\n";
	}
	$out.="</td></tr>\n</table></fieldset></form>\n";
	$out.="<h3>$langmessage[78]</h3>\n";
	$out.="<table>\n";
	$i=0;
	while($row_cat[$i][0]!="") {
		$out.="<tr><td><a href='".$_SERVER["SCRIPT_NAME"]."?do=adminposts&amp;action=editc&amp;id=".$row_cat[$i][0]."'><img src=\"images/edit.png\" alt=\"edit\" style=\"align: left; border: 0;\" /></a></td><td><a href='".$_SERVER["SCRIPT_NAME"]."?do=adminposts&amp;action=deletec&amp;id=".$row_cat[$i][0]."'><img src=\"images/editdelete.png\" alt=\"delete\" style=\"align: left; border: 0;\" /></a></td><td><b>".decode($row_cat[$i][1])."</b></td><td>".decode($row_cat[$i][2])."</td><td>&nbsp;Id: ".$row_cat[$i][0]."&nbsp;</td><td>";
		switch($row_cat[$i][3]) {
			case 0:
				$out.=$langmessage[60];
				break;
			case 1:
				$out.=$langmessage[61];
				break;
			case 2:
				$out.=$langmessage[62];
				break;
		}
		$out.="</td></tr>\n";
		$i++;
	}
	$out.="</table>\n</div><br />";
}

function treat_posts() {
	global $message, $edit, $editextra, $langmessage, $set, $pagenum, $menu, $admintemplate;

	if(isset($_POST['return'])) {
		unset($_GET['do']);
		unset($_POST['submit']);
		$edit=0;
		$editextra=0;
	}

	switch($_POST['submit']) {
		case "deletecomment":
			$newsid=sanitize($_POST['newsid']);
			$id=sanitize($_POST['id']);
			$row_cmt=readdata("comments");
			if(!$fp=fopen("./data/comments.dat","w")) die ($langmessage[142]);
			foreach($row_cmt as $row) {
				if($row[0]!=$newsid || $row[3]!=$id) {
					if($row[0]!="")
						fwrite($fp,$row[0]."|".$row[1]."|".$row[2]."|".$row[3]."|".$row[4]."||\n");
				}
			}
			fclose($fp);
			$message=$langmessage[175];
			break;
		case "Add News":
		case "Edit News":
			$autor = encode($_POST["autor"]);
			$email= encode($_POST["email"]);
			$titulo = encode($_POST["titulo"]);
			$texto = encode(stripslashes(stripslashes($_POST['texto'])));
			if($email=="") $email="-";
			if($titulo=="") $titulo="-";
			if($autor=="") $autor="-";
			if($texto=="") $texto="-";
			$cat=$_POST['cat'];
			$data = time();
			$array=readdata("posts");
			if($_POST['submit'] == "Add News") {
				$i=0;
				$maxid=0;
				while($array[$i][0] != "") {
					if(strval($array[$i][0])>$maxid) $maxid=strval($array[$i][0]);
					$i++;
				}
				$maxid++;
				if(!$fp=fopen("data/posts.dat","a")) die ($langmessage[76]);
				fwrite($fp,"$maxid|$autor|$email|$titulo|$texto|$data|1|$cat||");
				$message=$langmessage[75];
			} else {
				if(!$fp=fopen("data/posts.dat","w")) die ($langmessage[76]);
				$i=0;
				while($array[$i][0] != "") {
					if($_POST['reg']==$array[$i][0])
						fwrite($fp,$array[$i][0]."|$autor|$email|$titulo|$texto|$data|1|$cat||");
					else
						fwrite($fp,$array[$i][0]."|".$array[$i][1]."|".$array[$i][2]."|".$array[$i][3]."|".$array[$i][4]."|".$array[$i][5]."|".$array[$i][6]."|".$array[$i][7]."||");
					$i++;
				}
				$message=$langmessage[71];
			}
			fclose($fp);
			unset($_GET['action']);
			unset($_GET['do']);
			break;
		case "Save Extra":
			$fp=fopen("data/extra.htm","w");
			fwrite($fp,encode(stripslashes($_POST['texto'])));
			fclose($fp);
			unset($_GET['do']);
			$message=$langmessage[102];
			break;
		case "Save Menu":
			$fp=fopen("data/menu.dat","w");
			fwrite($fp,encode($_POST['content']));
			fclose($fp);
			unset($_GET['do']);
			$message=$langmessage[134];
			readmenu();
			break;
		case "Save Setup":
			if(!$fp=fopen("data/config.php","w")) die ($langmessage[55]);
			fwrite($fp,"<?php\n");
			if($_POST['password']!="")
				fwrite($fp,'$set[\'password\']="'.sha1($_POST['password'])."\";\n");
			else
				fwrite($fp,'$set[\'password\']="'.$set['password']."\";\n");
			fwrite($fp,'$set[\'homepath\']="'.$_POST['homepath']."\";\n");
			fwrite($fp,'$set[\'template\']="'.$_POST['template']."\";\n");
			fwrite($fp,'$set[\'title\']="'.encode($_POST['title'])."\";\n");
			fwrite($fp,'$set[\'subtitle\']="'.encode($_POST['subtitle'])."\";\n");
			fwrite($fp,'$set[\'keywords\']="'.encode($_POST['keywords'])."\";\n");
			fwrite($fp,'$set[\'description\']="'.encode($_POST['description'])."\";\n");
			fwrite($fp,'$set[\'author\']="'.encode($_POST['author'])."\";\n");
			fwrite($fp,'$set[\'footer\']="'.encode($_POST['footer'])."\";\n");
			fwrite($fp,'$set[\'openfield\']="'.$_POST['openfield']."\";\n");
			fwrite($fp,'$set[\'closefield\']="'.$_POST['closefield']."\";\n");
			fwrite($fp,'$set[\'timeoffset\']="'.$_POST['timeoffset']."\";\n");
			fwrite($fp,'$set[\'extension\']="'.$_POST['extension']."\";\n");
			fwrite($fp,'$set[\'indexfile\']="'.encode($_POST['indexfile'])."\";\n");
			fwrite($fp,'$set[\'fromname\']="'.encode($_POST['fromname'])."\";\n");
			fwrite($fp,'$set[\'fromemail\']="'.$_POST['fromemail']."\";\n");
			fwrite($fp,'$set[\'toemail\']="'.$_POST['toemail']."\";\n");
			fwrite($fp,'$set[\'language\']="'.$_POST['language']."\";\n");
			fwrite($fp,'$set[\'catchpa\']="'.$_POST['catchpa']."\";\n");
			fwrite($fp,'$set[\'editorpath\']="'.$set['editorpath']."\";\n");
			fwrite($fp,'$set[\'dateformat\']="'.$_POST['dateformat']."\";\n");
			fwrite($fp,"?>\n");
			fclose($fp);
			unset($_GET['do']);
			readsetup();
			break;
	}

	switch($_GET['do']) {
		case "adminposts":
			if($_SESSION[$set['password']]!="1")
				unset($_GET['do']);
			break;
		case "edit":
			$edit=0;
			if($_SESSION[$set['password']]=="1") $edit=1;
			else unset($_GET['do']);
			break;
		case "editextra":
			$editextra=0;
			if($_SESSION[$set['password']]=="1") $editextra=1;
			else unset($_GET['do']);
			break;
	}
}

function addons() {
	global $out, $prefix, $langmessage, $message, $addons;
	$out.="<h2>".$langmessage[178]."</h2>\n";
	if($_GET['action']=="edit" && $_GET['name']!="") {
		if(!isset($_POST['submit'])) {
			foreach($addons as $addon) {
				if($addon[0]==$_GET['name']) {
					$out.="<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">\n<table>\n";
					$out.="<tr><td align=\"right\">Name:</td><td><input type=\"text\" name=\"name\" value=\"".$addon[0]."\" /></td></tr>\n";
					$out.="<tr><td align=\"right\">Function name:</td><td><input type=\"text\" name=\"fname\" value=\"".$addon[1]."\" /></td></tr>\n";
					$out.="<tr><td align=\"right\">Admin name:</td><td><input type=\"text\" name=\"aname\" value=\"".$addon[2]."\" /></td></tr>\n";
					$out.="<tr><td align=\"right\">Active:</td><td><input type=\"text\" name=\"active\" value=\"".$addon[3]."\" /></td></tr>\n";
					$out.="<tr><td align=\"right\">Admin Level:</td><td><input type=\"text\" name=\"adminlevel\" value=\"".$addon[4]."\" /></td></tr>\n";
					$out.="<tr><td align=\"right\">Header:</td><td><input type=\"text\" name=\"header\" value=\"".$addon[5]."\" /></td></tr>\n";
					$out.="<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\"Submit\" /></td></tr>\n";
					$out.="</table>\n</form>\n";
				}
			}
		} else {
			dbquery("UPDATE ".$prefix."addons SET name=\"".$_POST['name']."\", fname=\"".$_POST['fname']."\", aname=\"".$_POST['aname']."\", active=\"".$_POST['active']."\", adminlevel=\"".$_POST['adminlevel']."\", header=\"".$_POST['header']."\" WHERE id=\"".$_POST['id']."\"");
			$out.="<h3>Addon ".$_POST['name']." updated</h3>\n";
		}
	} else {
		if(!isset($_POST['submit'])) {
			$out.="<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">\n<table>\n";
			$out.="<tr><td align=\"right\">Name:</td><td><input type=\"text\" name=\"name\" value=\"\" /></td></tr>\n";
			$out.="<tr><td align=\"right\">Function name:</td><td><input type=\"text\" name=\"fname\" value=\"\" /></td></tr>\n";
			$out.="<tr><td align=\"right\">Admin name:</td><td><input type=\"text\" name=\"aname\" value=\"\" /></td></tr>\n";
			$out.="<tr><td align=\"right\">Active:</td><td><input type=\"text\" name=\"active\" value=\"\" /></td></tr>\n";
			$out.="<tr><td align=\"right\">Admin Level:</td><td><input type=\"text\" name=\"adminlevel\" value=\"\" /></td></tr>\n";
			$out.="<tr><td align=\"right\">Header:</td><td><input type=\"text\" name=\"header\" value=\"\" /></td></tr>\n";
			$out.="<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\"Add Addon\" /></td></tr>\n";
			$out.="</table>\n</form>\n";
		} else {
			$query="INSERT INTO ".$prefix."addons VALUES ( null, \"".clean($_POST['name'])."\", \"".clean($_POST['fname'])."\", \"".clean($_POST['aname'])."\", ".$_POST['active'].", ".$_POST['adminlevel'].", ".$_POST['header']." )";
			if(dbquery($query))
				$out.="<h3>Addon ".clean($_POST['name'])." added</h3>\n";
			else
				$out.="<h3>Error adding addon</h3>\n";
		}
	}
	$found=false;
	foreach($addons as $addon) {
		if($addon[0]!="") {
		if(!$found) {
			$found=true;
			$out.="<div id=\"LNE_admininput\">\n<table>\n";
		}
		$out.="<tr><td>".$addon[0]."</td><td align=\"middle\"><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=addons&amp;action=edit&amp;name=".$addon[0]."\">\n";
		$out.="<img src=\"images/edit.png\" alt=\"edit\" title=\""."Edit"."\"align=\"left\" border=\"0\" /></a></td><td>";
		if(intval($addon[3]))
			$out.="<img src=\"images/accept.png\" alt=\"active\" title=\"Active\" border=\"0\" align=\"center\" />";
		$out.="</td></tr>\n";
		}
	}
	if($found)
		$out.="</table>\n</div>\n";
}

function adminmenu() {
	global $set,$pagenum;
	$aa="";
	if($_SESSION[$set['password']]=="1") {
		$aa.="\n<div id=\"LNE_admin\">\n<table>\n<tr>\n";
/*		$aa.="<td><a href=\"".$set['homepath'].$set['indexfile']."?do=adminposts\">\n";
		$aa.="<img src=\"images/edit.png\" alt=\"edit\" align=\"left\" border=\"0\" /></a></td>\n";
		$aa.="<td><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=delete\">";
		$aa.="<img src=\"images/editdelete.png\" alt=\"delete\" align=\"left\" border=\"0\" /></a></td>\n"; */
		$aa.="<td><a href=\"".$set['homepath'].$set['indexfile']."?do=settings\">";
		$aa.="<img src=\"images/tools.png\" alt=\"Settings\" align=\"left\" border=\"0\" /></a></td>\n";
		$aa.="</tr>\n</table>\n</div>\n";
	}
	return $aa;
}

function plugins () {
$out="<h2>Plugin administration</h2><br />\n";
if(isset($_GET['src'])) {
	include $_GET['src'];
} else {
	$folders=filelist ( "/./", "plugins", 1);
	$achou=false;
	foreach($folders as $folder) {
		if($achou==false) {
			$out.="<ul>\n";
			$achou=true;
		}
		$out.="<li>";
		if(file_exists("plugins/$folder/setup.mod"))
			$out.="<a href=\"?do=plugins&src=plugins/$folder/setup.mod\"><img src=\"images/toolss.png\" alt=\"setup\" title=\"Setup plugin\" /></a>&nbsp;".$folder;
		else
			$out.=$folder;
		$out.="</li>\n";
	}
	if($achou) $out.="</ul>\n";
}
return $out;
}

function deleteform() {
	global $langmessage, $selected, $pagenum, $out;
	$out.="<div align=\"center\"><form method=\"post\" action=\"\"><h2>".$langmessage[131].$selected['name']."?</h2>\n";
	$out.="<fieldset><input type=\"hidden\" name=\"submit\" value=\"Delete Page\" />\n";
	$out.="<input type=\"submit\" name=\"aa\" value=\"$langmessage[136]\" />";
	$out.="</fieldset></form></div>\n";
	$out.=showcontent($pagenum);
}

function editmenu() {
	global $langmessage;
	$out="<br /><br /><div align=\"center\">\n";
	$out.="<form method=\"post\" action=\"\">\n<h2 class=\"LNE_title\">$langmessage[91]</h2>\n";
	$out.="<textarea id=\"content\" name=\"content\" rows=\"15\" cols=\"50\">\n";
	$out.=decode(file_get_contents("data/menu.dat"))."</textarea>\n";
	$out.="<input type=\"hidden\" name=\"submit\" value=\"Save Menu\" />\n";
	$out.="<input type=\"submit\" name=\"aa\" value=\"$langmessage[133]\" />\n";
	$out.="</form></div>\n";
	return $out;
}

function settings() {
	global $set, $langmessage, $pagenum, $addons;
	$out.="<a href=\"index.php\"><img src=\"images/back.png\" alt=\"$langmessage[111]\" title=\"$langmessage[111]\" style=\"border: 0; float: left;\" /></a><h2>$langmessage[34]</h2><br /><div id=\"LNE_admininput\">\n";
//	$out.="<div class=\"LNE_settings\"><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=create\"><img src=\"images/addpage.png\" alt=\"$langmessage[35]\" title=\"$langmessage[35]\" style=\"border: 0;\" /></a><br />".$langmessage[35]."</div>\n";
	$out.="<div class=\"LNE_settings\">\n<a href=\"".$set['homepath'].$set['indexfile']."?do=editextra\"><img src=\"images/extra.png\" alt=\"$langmessage[36]\" title=\"$langmessage[36]\" style=\"border: 0;\" /></a><br />$langmessage[36]</div>\n";
//	$out.="<div class=\"LNE_settings\"><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=editmenu\"><img src=\"images/menu.png\" alt=\"$langmessage[41]\" title=\"$langmessage[41]\" style=\"border: 0;\" /></a><br />$langmessage[41]</div>\n";
	$out.="<div class=\"LNE_settings\"><a href=\"".$set['homepath'].$set['indexfile']."?do=adminposts\"><img src=\"images/news.png\" alt=\"$langmessage[72]\" title=\"$langmessage[72]\" style=\"border: 0;\" /></a><br />$langmessage[72]</div>\n";
//	$out.="<div class=\"LNE_settings\"><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=addons\"><img src=\"images/add.png\" alt=\"$langmessage[178]\" title=\"$langmessage[178]\" style=\"border: 0;\" /></a><br />$langmessage[178]</div>\n";
	$out.="<div class=\"LNE_settings\"><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=setup\"><img src=\"images/setup.png\" alt=\"$langmessage[44]\" title=\"$langmessage[44]\" style=\"border: 0;\" /></a><br />$langmessage[44]</div>\n";
/*	require_once "addons/lang_en_US.php";
	foreach($addons as $addon) {
		if($addon[2]!="-" && $addon[0]!="")
			$out.="<div class=\"LNE_settings\"><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=".$addon[0]."\"><img src=\"addons/".$addon[0]."/icon.png\" alt=\"".$addon[0]."\" title=\"".$$addon[0]."\" style=\"border: 0;\" /></a><br />".$$addon[0]."</div>\n";
	}
	$out.="<div class=\"LNE_settings\"><a href=\"".$set['homepath'].$set['indexfile']."?page=".$pagenum."&amp;do=generate\"><img src=\"images/generate.png\" alt=\"$langmessage[42]\" title=\"$langmessage[42]\" style=\"border: 0;\" /></a><br />$langmessage[42]</div>\n"; */
	$out.="</div>\n<div class=\"clear\"></div>\n";
	return $out;
}

function editextra() {
	global $langmessage;
	print "<h2 class=\"LNE_title\">$langmessage[89]</h2>\n<form method=\"post\" action=\"\">\n";
	if(!file_exists("data/extra.htm")) {
	    $fp=fopen("data/extra.htm","w");
	    fclose($fp);
	}
	editor(stripslashes(file_get_contents("data/extra.htm")));
	print savereturn("Save Extra");
}

function editpage($pagenum) {
	global $langmessage,$selected, $set;
	print "<form name=\"f1\" method=\"post\" action=\"\">\n";
	editor(decode(file_get_contents("data/".$pagenum.".html")));
	print "<input  type=\"hidden\" name=\"pagenum\" value=\"$pagenum\" />\n";
	print "<b>".$langmessage[67]."</b>: <input style=\"width: 100%; height: 40px;\" type=\"text\" name=\"description\" value=\"";
	if($selected['descr'] !="-")
		print $selected['descr'];
	print "\" />\n";
	print "<table><tr><td align=\"right\"><b>$langmessage[11]:</b></td><td><select name=\"template\">\n";
	$folder="templates";
	print "<OPTION VALUE=\"\">Default</OPTION>\n";
	$dir=opendir($folder);
	while($file=readdir($dir)) {
		if($file != ".." && $file != "." && is_dir($folder."/".$file)) {
			print '<OPTION VALUE="'.$file.'"';
			if($set['template']==$file) print " SELECTED";
			print '>'.$file."&nbsp;</OPTION>\n";
		}
	}
	closedir($dir);
	print "</select></td></tr></table>\n";
	print savereturn("Save");
}

/* outputs the icons for save/return */
function savereturn($value) {
	$out.="<input type=\"hidden\" name=\"submit\" value=\"$value\" />\n";
	$out.="<table><tr><td valign=\"top\">";
	$out.="<input type=\"image\" name=\"aa\" value=\"\" src=\"images/accept.png\" onClick=\"rtoStore()\" style=\"width: 32px; height: 32px;\" /></form>";
	$out.="<form method=\"post\" action=\"\">\n<fieldset style=\"border: none; background: transparent;\">\n</td>";
	$out.="<td valign=\"top\"><input type=\"hidden\" name=\"return\" value=\"Return\" />\n";
	$out.="<input type=\"image\" name=\"aa\" value=\"Return\" src=\"images/back.png\" value=\"\" style=\"width: 32px; height: 32px;\" />\n</fieldset></form>\n</td>";
	$out.="</tr></table>";
	return $out;
}

function setup() {
	global $set, $langmessage;
	$out="<h2 class=\"LNE_title\">$langmessage[130]</h2>\n";
	$out.="<form method=\"post\" action=\"\" id=\"setupform\">\n<div align=\"center\"><fieldset>\n<table>\n";
	$out.="<tr><td align=\"right\">$langmessage[6]:</td>\n";
	$out.="<td><input type=\"text\" name=\"password\" value=\"\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[10]:</td>\n";
	$out.="<td><input type=\"text\" name=\"homepath\" value=\"".$set['homepath']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[11]:</td>\n<td><select name=\"template\">\n";
	$folder="templates";
	$files=filelist('/./',$folder,1);
	foreach( $files as $file) {
//		$file=substr($file,10);
		if($file != ".." && $file != ".") {
		    $out.='<OPTION VALUE="'.$file.'"';
		    if($file == $set['template']) $out.=' SELECTED';
		    $out.='>'.$file."&nbsp;</OPTION>\n";
		}
	}
	$out.="</select>\n</td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[12]:</td><td><input type=\"text\" name=\"title\" value=\"".$set['title']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[13]:</td><td><input type=\"text\" name=\"subtitle\" value=\"".$set['subtitle']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[14]:</td><td><textarea name=\"keywords\" rows=\"4\">".$set['keywords']."</textarea></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[15]:</td><td><textarea name=\"description\" rows=\"4\">".$set['description']."</textarea></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[16]:</td><td><input type=\"text\" name=\"author\" value=\"".$set['author']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[17]:</td><td><input type=\"text\" name=\"footer\" value=\"".$set['footer']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[145]:</td><td><input type=\"text\" name=\"timeoffset\" value=\"".$set['timeoffset']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[151]:</td><td><input type=\"text\" name=\"dateformat\" value=\"";
		if($set['dateformat']!="")
			$out.=$set['dateformat'];
		else
			$out.="%m/%d/%y - %I:%M %p";
	$out.="\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[19]:</td><td><input type=\"text\" name=\"indexfile\" value=\"".$set['indexfile']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">From Name:</td><td><input type=\"text\" name=\"fromname\" value=\"".$set['fromname']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">From Email:</td><td><input type=\"text\" name=\"fromemail\" value=\"".$set['fromemail']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">To email:</td><td><input type=\"text\" name=\"toemail\" value=\"".$set['toemail']."\" /></td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[20]:</td>\n<td><select name=\"language\">\n";
	$folder="languages";
	$files=filelist('/./',$folder);
	foreach( $files as $file) {
		if(!is_dir($file) && strpos($file,".php")) {
			$out.='<OPTION VALUE="'.substr($file,5,5).'"';
			if(substr($file,5,5) == $set['language']) $out.=' SELECTED';
			$out.='>'.$file."&nbsp;</OPTION>\n";
		}
	}
	$out.="</select>\n</td></tr>\n";
	$out.="<tr><td align=\"right\">$langmessage[32]:</td>\n<td><select name=\"catchpa\">\n";
	$out.="<OPTION VALUE=\"1\">image&nbsp;</OPTION>\n";
	$out.="<OPTION VALUE=\"0\"";
	if($set['catchpa']==0) $out.=" SELECTED";
	$out.=">text&nbsp;</OPTION>\n";
	$out.="</select>\n</td></tr>\n";
	$out.="<tr><td><input type=\"hidden\" name=\"submit\" value=\"Save Setup\" />\n";
	$out.="<input type=\"hidden\" name=\"gzip\" value=\"0\" />";
	$out.="<input type=\"hidden\" name=\"oldpassword\" value=\"".$set['password']."\" /></td>";
	$out.="<td><input type=\"submit\" name=\"aa\" value=\"$langmessage[25]\" /></td></tr>\n</table>\n</div>\n</fieldset></form>\n";
	return $out;
}
?>
Return current item: BlogNEasy