Location: PHPKode > projects > SAPID > etc/interface/user_functions.inc.php
<?PHP
// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | SAPID: XML Sapiens Engine Demonstrator                               |
// +----------------------------------------------------------------------+
// | Author:  Max Baryshnikov aka Mephius <hide@address.com>	                  |
// | Copyright (c) 2004 Max Baryshnikov                                   |
// | http://sapid.sourceforge.net	                                      |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+
// Release: 28.11.04 (dd/mm/yy)
// $Id: user_functions.inc.php,v 1.3 2006/02/20 08:27:31 sheiko Exp $

if (!defined("SAPID_STARTED")) die("Hacking attempt!");

if($env["user"]["GROUP"]=="wheel")
switch ($_GET["option"]){

	case "list_func":
	$d = dir($root_path . "usr/extensions/");
	$panel="<div style=\"padding-left: 20px; padding-bottom: 10px;\">
			
			".$lang["FunctionsInterfaceDescription"]."
			<div style=\"padding: 10px 0px 5px 0px;\"><input class=\"sapidcms_cont_btn\" type=\"button\" onclick=\"location.href='".$env["http_path"]."?option=create_func';\" value=\"".$lang["CreateFunction"]."\" /></div>
			</div><form method=\"post\"  style=\"margin: 0px 0px 0px 0px;\"><table class=\"tpanel\" cellpadding=0 cellspacing=0><tr><td width=\"60%\" class=\"header\"><b>".$lang["Functions"]."</b></td><td class=\"header\">&nbsp;</td></tr>";
	while (false !== ($entry = $d->read())) {
		if ($entry!="." and $entry!=".." and !is_dir($root_path . "usr/extensions/" . $entry)) {
			$fp=fopen($root_path . "usr/extensions/" . $entry, "r");
			$size=filesize($root_path . "usr/extensions/" . $entry);
			$ddc=fread($fp, $size);
			fclose($fp);
			$panel.="<td><a href=\"".$env["http_path"]."?option=edit_func&name=".$entry."\"><img src=\"".$env["http_path"]."usr/system/images/edit.gif\" alt=\"".$lang["Edit"]."\" width=\"12\" hight=\"14\" border=\"0\" /></a>&nbsp;<a href=\"".$env["http_path"]."?option=delete_func&name=".$entry."\" onClick=\"return confirm('".$lang["confirm_delete"]."')\"><img src=\"".$env["http_path"]."usr/system/images/delete.gif\" alt=\"".$lang["Delete"]."\" width=\"12\" hight=\"14\" border=\"0\" /></a>&nbsp;" . $entry . "</td><td>&nbsp;</td></tr>";
		}
	}
	$d->close();
	$panel='<div style="margin-top: 3px;" class="panel">' . $panel . "</table><br /></div>";
	break;
	case "edit_func":
	if ($_POST["html"] and $_POST["name"] and $DEMO_MODE!="enabled") {
		$fp=fopen($root_path . "usr/extensions/" . $_POST["name"], "w+");
		fwrite($fp, (ini_get("magic_quotes_gpc")?stripslashes($_POST["html"]):$_POST["html"]));
		fclose($fp);
		$_GET["option"]="list_func";
		option_switch();
		break;
	}

	$template=preg_replace("/\//", "", $_GET["name"]);
	$fp=fopen($root_path . "usr/extensions/" . $template, "r");
	$size=filesize($root_path . "usr/extensions/" . $template);
	$data=fread($fp, $size);
	fclose($fp);
	$panel="<div class=\"panel\" style=\"margin-top: 3px; text-align: center;\" ><b>".$lang["Functions"].":</b> ".$_GET["name"]."<br /><form method=\"post\"   style=\"margin: 5px 0px 0px 0px\" onClick=\"id_form_focus='form_1'\" id=\"form_1\"><input type=\"hidden\" name=\"name\" value=\"".$_GET["name"]."\"><textarea name=\"html\" style=\"width: 100%; height: 395px; margin: 5px; ".($SystemTextAreaStyle ? $SystemTextAreaStyle : "background-color: white; font-family: Courier new,Tahoma, Arial; font-size: 12px;")."\">".$data."</textarea><br /><input  style=\"margin: 5px 5px 5px 5px\" type=\"submit\" class=\"sapidcms_cont_btn\" value=\"".$lang["Save"]."\"></form></div>";
	break;
	case "create_func":
	if ($_POST["html"] and stripslashes($_POST["name"]) and $DEMO_MODE!="enabled") {
		$fp=fopen($root_path . "usr/extensions/" . $_POST["name"] . ".inc.php", "w+");
		fwrite($fp, (ini_get("magic_quotes_gpc")?stripslashes($_POST["html"]):$_POST["html"]));
		fclose($fp);
		$_GET["option"]="list_func";
		option_switch();
		break;
	}
	$panel="<div class=\"panel\" style=\"margin-top: 3px; text-align: center;\"><form  style=\"margin: 0px 0px 0px 0px\" method=\"post\"  onClick=\"id_form_focus='form_1'\" id=\"form_1\"><b>".$lang["Functions"].":</b> <input type=\"text\" name=\"name\">.inc.php<br /><textarea name=\"html\" style=\"margin: 5px 5px 0px 5px\" rows=\"24\" cols=\"100\"></textarea><br /><input style=\"margin: 5px 5px 5px 5px\" type=\"submit\" class=\"sapidcms_cont_btn\" value=\"".$lang["Save"]."\"></form></div>";
	break;
	case "delete_func":
	if ($_GET["name"] and $DEMO_MODE!="enabled") {
		@unlink($root_path . "usr/extensions/" . $_GET["name"]);
		$_GET["option"]="list_func";
		option_switch();
		break;
	}
	break;


}

?>
Return current item: SAPID