Location: PHPKode > projects > Personal AJAX Content Management System > src/update.php
<?php

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

session_start();

if (isset ($_POST['alive'])) {
	$_SESSION['pw']['lastSeen']=time();
	echo time();
	//session_destroy();
	session_write_close();
	exit();
} else {

	include_once ("./class/SettingsManager.php");
	include_once ("./class/UsersManager.php");
	include_once ("./class/Util.php");

	$GLOBALS['settings'] = new SettingsManager("./settings/settings.xml");
	$GLOBALS['settings']->parse();
	$GLOBALS['settings']->processAll($_SESSION['pw']['section']);

	$GLOBALS['users'] = new UsersManager("./settings/users.xml");
	$GLOBALS['users']->parse();
	Util :: setlocale($GLOBALS['settings']->getValueOf("lang"));

	$class = $_SESSION['pw']['widgetData'][$_POST['wid']]['classType'];
	$inc = "./class/widget/".$class.".php";
	if (is_readable($inc)) {
		include_once ($inc);
		if (class_exists($class)) {
			$wgt = new $class ($_POST['wid']);

			if (method_exists($wgt, $_POST['fct'])) {
				if ($GLOBALS['users']->getUserClass($_SESSION['pw']['loggedUser']) == "admin") {

					$code = $wgt-> $_POST['fct'] ();
				} else {
					if (in_array($_POST['fct'], $wgt->nonAdminFunction)) {
						$code = $wgt-> $_POST['fct'] ();
					} else {
						if ($_SESSION['pw']['widgetData'][$_POST['wid']]['editFlag']) {
							$code = $wgt-> $_POST['fct'] ();
						} else {
							$code = sprintf(gettext("ERROR: unoutorized user: you can't execute this function %s"), $_POST['fct']);
						}
					}
				}

			} else {
				$code = sprintf(gettext("ERROR: function %s not found"), $_POST['fct']);
			}
		} else {
			$code = sprintf(gettext("ERROR: widget %s not found"), $class);
		}
	} else {
		$code = sprintf(gettext("ERROR: file %s not found (try to refresh the page)"), $inc);
	}
	echo $code;
}
?>
Return current item: Personal AJAX Content Management System