Location: PHPKode > projects > Exero CMS > upload/admin/theme.php
<?
/*========================================*\
| Exero CMS                                |
|==========================================|
|          http://ecms.getox.net           |
|https://sourceforge.net/projects/exerocms/|
|==========================================|
|     Exero CMS is released under the      |
|     GNU General Public License (GPL)     |
| opensource.org/licenses/gpl-license.php  |
\*========================================*/

require("global.php");
if(!checkadminsession()) {
	print_login();
	exit;
}

if(!adminpermissions("managethemes")) {
	print_no_permission();
	exit;
}

if($_REQUEST['do'] == "") {
	print_cp_header("Theme Manager");
	
	print_table_header("Themes","2","","1");
	$handle = opendir("../themes");
	print_multicol_row(array("Theme[align:left]"=>"","Options[align:right]"=>"130"),"optiontitle");
	while(false !== ($folder = readdir($handle))) {
		if($folder != "." && $folder != "..") {
			print_multicol_row(array($folder."[align:left]"=>"","<a href=\"theme.php?do=templates&theme=".$folder."\">Templates</a>[align:right]"=>"130"));
		}
	}
	print_table_footer();
		
	print_cp_footer();
} else if($_REQUEST['do'] == "templates") {
	print_cp_header("Templates for ".$_REQUEST['theme']);
	
	if(!isset($_REQUEST['dir'])) { 
		$dir = "Main";
	} else {
		$dir = $_REQUEST['dir']." <a href=\"theme.php?do=templates&theme=".$_REQUEST['theme']."\">(Back to main)</a>";
	}
	
	$templatedir = "/".$_REQUEST['dir'];
	
	print_table_header("Theme Info","2","","1");
	print_multicol_row(array("Name:[align:left]"=>"120",$_REQUEST['theme']."[align:left]"=>""));
	print_multicol_row(array("Directory:[align:left]"=>"120",$dir."[align:left]"=>""));
	print_table_footer();
	
	print_table_header("Templates","2","","1");
	print_multicol_row(array("Template[align:left]"=>"","Options[align:right]"=>"130"),"optiontitle");
	$handle = opendir("../themes/".$_REQUEST['theme'].$templatedir);
	while(false !== ($template = readdir($handle))) {
		if($template != "." && $template != "..") {
			if(!strpos($template,".")) {
				if(isset($_REQUEST['dir'])) {
					print_table_row("<strong><a href=\"theme.php?do=templates&theme=".$_REQUEST['theme']."&dir=".$_REQUEST['dir']."/".$template."\">".$template."</a></strong>","2");
				} else {
					print_table_row("<strong><a href=\"theme.php?do=templates&theme=".$_REQUEST['theme']."&dir=".$template."\">".$template."</a></strong>","2");
				}
			} else {
				if(isset($_REQUEST['dir'])) {
					print_multicol_row(array($template."[align:left]"=>"","<a href=\"theme.php?do=edittemplate&theme=".$_REQUEST['theme']."&dir=".$_REQUEST['dir']."&template=".$template."\">Edit</a>[align:right]"=>"130"));
				} else {
					print_multicol_row(array($template."[align:left]"=>"","<a href=\"theme.php?do=edittemplate&theme=".$_REQUEST['theme']."&template=".$template."\">Edit</a>[align:right]"=>"130"));
				}
			}
		}
	}
	print_table_footer();
		
	print_cp_footer();
} else if($_REQUEST['do'] == "edittemplate") {
	print_cp_header("Edit Template");
	
	print_form_header("theme.php?do=savetemplate","template");
	print_form_hiddenfield("theme",$_REQUEST['theme']);
	print_form_hiddenfield("dir",$_REQUEST['dir']);
	print_form_hiddenfield("template",$_REQUEST['template']);
	print_table_header("Template: ".$_REQUEST['template'],"2","","1");
	print_form_textarearow("templatedata",(file_get_contents("../themes/".$_REQUEST['theme']."/".$_REQUEST['dir']."/".$_REQUEST['template'])),"2","90","25","");
	print_form_submit("Save");
	print_table_footer();
	print_form_footer();
	
	print_cp_footer();
} else if($_REQUEST['do'] == "savetemplate") {
	$fp = fopen("../themes/".$_POST['theme']."/".$_POST['dir']."/".$_POST['template'], "w");
	fwrite($fp, $_POST['templatedata']);
	fclose($fp);
	print_redirect("theme.php?do=templates&theme=".$_POST['theme']."&dir=".$_POST['dir'],"Template Saved","Template Saved.");
}
?>
Return current item: Exero CMS