Files
bm/public_html/public/cms/index.php
2025-09-24 13:26:28 +02:00

117 lines
2.8 KiB
PHP

<?php
define('ROOT', "../");
require_once(ROOT."include/config.inc.php");
require_once(ROOT."include/template.inc.php");
require_once(ROOT."include/events.inc.php");
require_once(CMS_DIR."modules/root.class.php");
require_once(CMS_DIR."modules/_flexiconfactory.class.php");
/** session variables:
* login ................ true, if logged in
* user ................. login of the current user
* username ............. full name of the current user
* userlevel ............ level of the current user (admin, group or all)
* path ................. path to the current element
*/
session_start();
if(!isset($_SESSION['login'])){
$_SESSION['path'] = "0";
header("Location: login.php");
exit;
}
if(get_magic_quotes_gpc()){
foreach($_POST as $i=>$j){
if(!is_array($j)){
$_POST[$i] = stripslashes($j);
}
}
}
$path = explode("/", $_SESSION['path']);
$root = new Root();
$root->load($path);
$current =& $root->getCurrent($path);
//process action
if(isset($_POST['action'])){
switch($_POST['action']){
case "load":
$path = explode("/", $_POST['position']);
$current->unlock();
$root->load($path);
$current =& $root->getCurrent($path);
$current->lock();
break;
case "save":
$current->update();
$current->save();
break;
case "insert":
$current->update();
$child =& $current->insertChild($_POST['position'], $_POST['type']);
$current->save();
$path = $child->getPath();
$_SESSION['path'] = implode("/", $path);
session_write_close();
header("Location: index.php");
exit;
break;
case "delete":
$current->update();
$current->deleteChild($_POST['position']);
$current->save();
break;
case "moveup":
$current->update();
$current->moveChild($_POST['position'], "up");
$current->save();
break;
case "movedown":
$current->update();
$current->moveChild($_POST['position'], "down");
$current->save();
break;
case "cut":
$current->update();
$current->cutChild($_POST['position']);
$current->save();
break;
case "paste":
$current->update();
$current->pasteChild($_POST['position']);
$current->save();
break;
case "publish":
$current->update();
$current->save();
$current->publish();
break;
case "cancel":
array_pop($path);
$current->unlock();
$root->load($path);
$current =& $root->getCurrent($path);
$current->lock();
break;
default:
$current->update();
$current->handleAction($_POST['action'], $_POST['position'], $_POST['type']);
break;
}
}
//print output
$t = new Template("flexicon.html");
$t->setVar("TREE", $root->printTreeMenu($path));
$t->setVar("BREADCRUMBS", $root->printBreadcrumbs($path));
$t->setVar("TITLE", $current->toString());
$t->setVar("CONTENT", $current->printContent());
$t->setVar("ACTION", "index.php");
$t->parse();
$_SESSION['path'] = implode("/", $path);
?>