function doBodyJobs()
    {
        global $SYSTEM_INFO;
        $frame_01 = new uiFrame("advancedFrame", "", "mgmtFrame");
        $text_header = new uiText("text01", "<span class=\"cHeading\">:: advanced</span>");
        $text_welcome = new uiText("textWelcome", 'Inside of this category, you can for example backup and restore your database and do other advanced tasks of maintenance. Before using the Update feature of 29o3, please see the <a href="' . mksyslink("?mgmt;Help;chapter=Update29o3") . '">respective chapter of the documentation</a>.
<br/><br/>
<strong>Currently under development. Stay tuned.</strong>
');
        $og_backup = new uiOptionGroup("og_backup", "Database Backup", "background-color: rgb(166, 220, 113);");
        $text_backup = new uiText("", "\n29o3 offers several options to back up the database.<br/>\nHave in mind that in either way, the output is not encrypted.\nNow, please choose the respective option below.");
        $form_backup = new uiForm("dbbackupform", "POST", mksyslink("?mgmt;DatabaseBackup;"));
        $rad_method = array();
        array_push($rad_method, new uiFormElement("method", "radio", "Upload to FTP server", "ftp"));
        array_push($rad_method, new uiFormElement("method", "radio", "Send via eMail", "mail"));
        array_push($rad_method, new uiFormElement("method", "radio", "Save to local file", "localfile"));
        array_push($rad_method, new uiFormElement("method", "radio", "Download", "downloadfile"));
        $og_backup->attach($text_backup);
        $og_backup->attach($form_backup);
        $form_backup->attach($rad_method);
        $frame_01->attach($text_header);
        $frame_01->attach($text_welcome);
        $frame_01->attach($og_backup);
        $this->pdo->insertIntoBodyBuffer($frame_01->__toString());
    }
 function doBodyJobs()
 {
     global $SYSTEM_INFO;
     $frame_01 = new uiFrame("overviewFrame", "", "mgmtFrame");
     $text_header = new uiText("text01", "<span class=\"cHeading\">:: management console overview</span>");
     $text_welcome = new uiText("textWelcome", "<strong>Welcome to the management console of the 29o3 content management system.</strong><br/><br/>\nIf this is your first visit, let me explain shortly how easy it is to publish content with 29o3:<br/><br/>\nWhen you look to the left, you see the categories of the management console. If you click on <strong>Preferences</strong>, you are able to tune different system-wide settings of your system.<br/><br/>\nThe category <strong>Appearance</strong> lets you set up how your pages should look. Finally, through the category <strong>Structure</strong> you are able to give structure to your website and add content.<br/><br/>\nIf you want to give media files (videos, images, etc.) into the management of 29o3, choose <strong>Media</strong>. For adding other files, go to <strong>Files</strong>.<br/><br/>\nFor managing multiple users/groups editing your websites with different permissions, have a look at <strong>Accounts</strong><br/><br/>\nMore advanced topics, like database backup and recovery, can be found under <strong>Advanced</strong>.\n<br/><br/>\nTo find out about the people behind 29o3, please <a href=\"" . mksyslink("?mgmt;Help;chapter=About") . "\">click here</a>.<br/><br/>\n");
     $text_sysinfo = new uiText("sysInfo", "29o3 is currently running on " . php_uname("s") . "/" . php_uname("m") . " " . php_uname("r") . " with " . $_SERVER["SERVER_SOFTWARE"] . " as webserver. You are running 29o3 " . $SYSTEM_INFO["SystemVersion"] . " Codename " . $SYSTEM_INFO["SystemCodename"] . ".");
     $frame_01->attach($text_header);
     $frame_01->attach($text_welcome);
     $frame_01->attach($text_sysinfo);
     $this->pdo->insertIntoBodyBuffer($frame_01->__toString());
 }
 static function getAdminDesignStart($name)
 {
     $string = '<br/><br/><br/>';
     $string .= '<div align="center">';
     $string .= '<div class="enclosure" align="center">';
     if ($name != "") {
         $name = " &middot; " . $name;
     }
     $string .= '<div class="headline">29o3 management console' . $name . '</div>';
     $string .= '<div style="text-align: left; width: 600px; font-size: 12px;">';
     $string .= ':: <a href="' . mksyslink("?mgmt;Overview;") . '">Home</a> :: <a href="' . mksyslink("?mgmt;Help;") . '">Help</a> :: <a href="' . mksyslink("?mgmt;About;") . '">About</a> ::';
     $string .= '</div><br/>';
     return $string;
 }
 function __toString()
 {
     $this->htmlContent .= '<div class="' . $this->styleClass . '" id="' . $this->name . '">';
     if ($this->subject == "user") {
         $this->htmlContent .= "<strong>" . $this->realname . "</strong> (" . $this->username . ")<br/>" . $this->email;
         if ($this->gid == 100) {
             $this->htmlContent .= ", Administrator";
         }
         $this->htmlContent .= "<br/>\n";
         $this->htmlContent .= '<small><a href="' . mksyslink("?mgmt;ModifyUser;uid=" . $this->uid) . '">Modify ' . $this->username . '\'s details and permissions</a> | <a href="' . mksyslink("?mgmt;DeleteUser;uid=" . $this->uid) . '">Delete user</a></small>';
     } else {
         $this->htmlContent .= "<strong>" . $this->groupname . "</strong><br/>" . $this->additionals . "<br/>\n";
         $this->htmlContent .= '<small><a href="' . mksyslink("?mgmt;ModifyGroup;gid=" . $this->gid) . '">Modify group ' . $this->groupname . '</a>';
         if ($this->gid != 100) {
             $this->htmlContent .= ' | <a href="' . mksyslink("?mgmt;DeleteGroup;gid=" . $this->gid) . '">Delete group ' . $this->groupname . '</a>';
         }
         $this->htmlContent .= "</small>";
     }
     $this->htmlContent .= '</div>' . "\n";
     return $this->htmlContent;
 }
 function doBodyJobs()
 {
     global $SYSTEM_INFO;
     $frame_01 = new uiFrame("accountsFrame", "", "mgmtFrame");
     $text_header = new uiText("text01", "<span class=\"cHeading\">:: accounts</span>");
     $text_welcome = new uiText("textAccounts", "With <strong>Accounts</strong> you can setup multiple users and groups and manage their particular permissions. If you want to change the permissions or details of a certain user or group, click the respective &quot;Modify&quot; link.<br/><br/>\n");
     $text_usermenu = new uiText("", '<a href="' . mksyslink("?mgmt;CreateUser;") . '">Create new user</a>');
     /* users option group */
     $og_users = new uiOptionGroup("og_users", "Users", "background-color: rgb(166, 220, 113);");
     $text_users = new uiText("", "Modify or create users.");
     $og_users->attach($text_users);
     $this->db->executeQuery("SELECT * FROM " . mktablename("users") . " ORDER BY uid ASC");
     $i = 0;
     while ($user = $this->db->fetchArray()) {
         $ugo = new uiMgmtUserGroup($i, "", "user", "uiMgmtUser", implode(":::", $user));
         $og_users->attach($ugo);
         $i++;
     }
     $text_usermenu = new uiText("", '<small><a href="' . mksyslink("?mgmt;CreateUser;") . '">Create new user</a></small>');
     $og_users->attach($text_usermenu);
     /* group option group */
     $og_groups = new uiOptionGroup("og_groups", "Groups", "background-color: rgb(229, 136, 46);");
     $text_groups = new uiText("", "Create new groups or modify existing ones.");
     $og_groups->attach($text_groups);
     $this->db->executeQuery("SELECT * FROM " . mktablename("groups") . " ORDER BY gid ASC");
     $i = 0;
     while ($group = $this->db->fetchArray()) {
         $ugo = new uiMgmtUserGroup($i, "", "group", "uiMgmtGroup", implode(":::", $group));
         $og_groups->attach($ugo);
         $i++;
     }
     $text_groupmenu = new uiText("", '<small><a href="' . mksyslink("?mgmt;CreateGroup;") . '">Create new group</a></small>');
     $og_groups->attach($text_groupmenu);
     $frame_01->attach($text_header);
     $frame_01->attach($text_welcome);
     $frame_01->attach($og_users);
     $frame_01->attach($og_groups);
     $this->pdo->insertIntoBodyBuffer($frame_01->__toString());
 }
 function doBodyJobs()
 {
     global $SYSTEM_INFO, $CONFIG;
     $this->pdo->scheduleInsertion_ExternalStylesheet("lib/admin/adminAppearance.css");
     if (strpos($this->pdo->getAdminFuncParam(), "EditLayout") === 0) {
         $CONFIG["Developer_Debug"] = false;
         $paramlist = split("_", $this->pdo->getAdminFuncParam());
         if (!isset($paramlist[1]) || $paramlist[1] == "") {
             $this->pdo->insertIntoBodyBuffer("<em><strong>Please select a layout from the list above or click &quot;Create&quot; to create a new one.</strong></em>");
         } else {
             ob_start();
             echo '<textarea style="width: 400px; height: 200px; border: 1px solid black;">';
             $file = file_get_contents($CONFIG["ContentDir"] . "layouts/" . $paramlist[1] . ".php");
             echo "<![CDATA[" . $file . "]]>";
             echo '</textarea>';
             $string = ob_get_contents();
             ob_end_clean();
             $this->pdo->insertIntoBodyBuffer($string);
         }
         return;
     }
     $this->pdo->insertIntoBodyBuffer(adminFuncs::getAdminDesignStart("appearance"));
     ob_start();
     echo "\n<br/>\n<div align=\"left\">";
     echo "<strong>Existing Layouts:</strong><br/>";
     echo '<div class="embedded">';
     // lets check which layouts we have
     $query = "SELECT " . mktablename("pages") . ".name, " . mktablename("pages") . ".layout, " . mktablename("layouts") . ".lname, " . mktablename("layouts") . ".file FROM " . mktablename("layouts") . " LEFT JOIN " . mktablename("pages") . " ON " . mktablename("layouts") . ".lname=" . mktablename("pages") . ".layout";
     $this->db->executeQuery($query);
     echo "<div class=\"layout_table\">\n";
     echo "<div class=\"layout_tr\" style=\"font-size: 12px; font-weight: bold; background-image: url(lib/images/uiMgmtMenuBgHover.png);\">\n";
     echo '<div class="layout_td" style="background-image: url(lib/images/uiMgmtMenuBgHover.png);">Layout name</div><div class="layout_td" style="background-image: url(lib/images/uiMgmtMenuBgHover.png);">Used on page:</div><div class="layout_td" style="background-image: url(lib/images/uiMgmtMenuBgHover.png);">&nbsp;</div>' . "\n";
     echo "</div>";
     while ($arr = $this->db->fetchArray()) {
         echo "<div class=\"layout_tr\" style=\"";
         if ($arr["name"] == "") {
             echo "background-color: lightgreen; color: black;\">\n";
         } else {
             echo "background-color: white; color: black; background-image: url(lib/images/uiMgmtMenuBgHover.png);\">\n";
         }
         // layout name
         echo "<div class=\"layout_td\" id=\"td_lname\"><strong><a href=\"" . mksyslink("?mgmt;Appearance;EditLayout_" . $arr["file"]) . "\" target=\"editorframe\">" . $arr["lname"] . "</a></strong></div>\n";
         // page name
         if ($arr["name"] != "") {
             echo "<div class=\"layout_td\" id=\"td_pname\">" . $arr["name"] . "</div>\n";
         } else {
             echo "<div class=\"layout_td\" id=\"td_pname\"><em>none</em></div>\n";
         }
         //echo "Layout " . $arr["lname"] . " used on page " . $arr["name"] . "<br/>\n";
         echo "<div class=\"layout_td\" style=\"width: 285px;\">&nbsp;</div>";
         // close row
         echo "</div>\n";
     }
     // close table
     echo "</div>\n";
     // close embedded
     echo "</div>\n";
     echo "<br/>";
     echo '<iframe src="' . mksyslink("?mgmt;Appearance;EditLayout_") . '" name="editorframe" class="editorframe"></iframe>';
     echo "</div>\n";
     $string = ob_get_contents();
     ob_end_clean();
     $this->pdo->insertIntoBodyBuffer($string . "\n" . adminFuncs::getAdminDesignEnd());
 }
function bootstrap()
{
    global $CONFIG, $SYSTEM_INFO, $output_started, $body_started, $console, $profiler, $ALLOWED_MGMT_FUNCS;
    header("Content-type: application/xhtml+xml\r");
    $console = new SystemConsole();
    DEBUG("<strong>This is 29o3 " . $SYSTEM_INFO['SystemVersion'] . " Codename " . $SYSTEM_INFO['SystemCodename'] . "</strong>");
    DEBUG("SYS: Bootstrapping started...");
    $connector = new DatabaseConnector();
    $connector->setupConnection($CONFIG['DatabaseHost'], $CONFIG['DatabaseUser'], $CONFIG['DatabasePassword'], $CONFIG['DatabaseName'], $CONFIG['DatabasePort']);
    DEBUG("DB: Connected to database.");
    $request = new PageRequest($connector);
    $request->parseRequest();
    // instanciate new cache object
    $co = new cacheObject($connector, $request->getRequestedSite(), $request->getRequestedPage());
    // check if we have content for current page cached
    $cacheContent = $co->getCached();
    if ($cacheContent === false) {
        // construct header and body objects
        $header = new XHTMLHeader();
        $body = new XHTMLBody();
        $pdo = new pageDescriptionObject($header, $body, $connector, $request->getWantAdmin(), $request->getAdminFuncParam());
        $connector->executeQuery("SELECT * FROM " . mktablename("pages") . " WHERE name='" . $request->getRequestedPage() . "'");
        /* lets see what the admin wants */
        if ($request->getWantAdmin()) {
            if ($request->getRequestedPage() == "overview") {
            }
        }
        $pageInfo = $connector->fetchArray();
        $pdo->setPageDescriptionA($pageInfo, $request->getRequestedSite());
        $header->setTitle($pdo->getContent("title"));
        if ($pdo->getContent("description") != "") {
            $header->addMetaDCDescription($pdo->getContent('description'));
        }
        if ($pdo->getContent("subject") != "") {
            $header->addMetaDCSubject($pdo->getContent("subject"));
        }
        if ($pdo->getContent("date") != 0) {
            $header->addMetaDCDate(strftime("%Y-%m-%d", $pdo->getContent('date')));
        }
        if ($pdo->getContent("creator") != "") {
            $header->addMetaDCCreator($pdo->getContent("creator"));
        }
        if ($pdo->getContent("contributors") != "") {
            $c_arr = explode(";", $pdo->getContent('contributors'));
            for ($i = 0; $i <= count($c_arr) - 1; $i++) {
                $header->addMetaDCContributor($c_arr[$i]);
            }
        }
        if ($pdo->getContent("type") != "") {
            $header->addMetaDCType($pdo->getContent("type"));
        }
        if ($pdo->getContent("sources") != "") {
            $sources_array = explode(";", $pdo->getContent('sources'));
            for ($i = 0; $i <= count($sources_array) - 1; $i++) {
                $header->addMetaDCSource($sources_array[$i]);
            }
        }
        /*
        !!!	FIXME: 	THE FOLLOWING CODE CAUSES A RACE CONDITION ON BOTH APACHE2/PHP
        !!!		AND PHP-CLI. 
        !!!	SEV:   	(5) - Causes server process to fill RAM and swap -> kill
        !!!	RES:	Currently no resolution, commented out because of this.
        !!!		I'd say it has got something to do with the database for
        !!!		I cannot find an error elsewhere.
        >!<	*** FIXED ***
        >!<	F**K YOU F**K YOU DAMN CODER!!!! F**K YOU!!!
        */
        if ($pdo->getContent("language") != "") {
            $header->addMetaDCLanguage($pdo->getContent('language'));
        }
        if ($pdo->getContent('copyright') != "") {
            $header->addMetaDCRights($pdo->getContent("copyright"));
        }
        // this is the r0x0r1ng stylesheet which controls how system messages (errors, etc.) appear
        $pdo->scheduleInsertion_ExternalStylesheet("n_style.css");
        if ($pdo->getContent('no_cache') == 1) {
            $co->setScheduleCaching(false);
            DEBUG("CACHE: Caching deactivated on request.");
        }
        // now, get the page's stylesheet; it might be empty, but we'll add it if not :)
        if ($request->getWantAdmin() <= 1) {
            if ($request->getWantAdmin() == 1) {
                $co->setScheduleCaching(false);
                DEBUG("CACHE: Admin wanted, caching deactivated.");
            }
            $layoutManager = new LayoutManager($pdo);
            $pdo->getAvailableBoxes();
            $connector->executeQuery("SELECT * FROM " . mktablename("layouts") . " WHERE lname='" . $pageInfo['layout'] . "'");
            if ($connector->getNumRows() != 0) {
                $currentLayout = $connector->fetchArray();
                $layoutManager->setLayoutFile($currentLayout['file']);
                $layoutManager->parseLayout();
            } else {
                throw new GeneralException("No layout found. 29o3 cannot continue.");
            }
            if ($request->getWantAdmin()) {
                require_once $CONFIG['LibDir'] . 'admin/adminFuncs.php';
                $af = new adminFuncs($pdo, $request);
                $pdo->scheduleInsertion_ExternalStylesheet($af->getAdminStylesheet());
            }
            DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
            $connector->closeConnection();
            DEBUG("DB: Connection closed.");
            $profiler->addBreakpoint();
            DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
            DEBUG("SYS: Exiting normally.");
            // print the buffer of the header since we're done with it :)
            $pdo->doInsertions();
            // we have everything at this point... start caching procedure
            $co->doCache($pdo->getBuffers());
            if ($CONFIG['Developer_Debug'] == true) {
                if ($body) {
                    $body->eyecandyConsole($console);
                } else {
                    $console->printBuffer();
                }
            }
            if ($pdo->getBrandingState() == true) {
                $pdo->insertBodyDiv("Powered by <a href=\"http://twonineothree.berlios.de\">29o3</a> " . $SYSTEM_INFO["SystemVersion"] . " Codename " . $SYSTEM_INFO["SystemCodename"], "poweredBy", "poweredBy_Banner", "Powered by 29o3");
            }
            printf('<?xml version="1.0" encoding="UTF-8"?>');
            printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">%s', "\n");
            printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%s', "\n");
            $pdo->printHeaderBuffer();
            $header_started = true;
            // destruct the header object
            $pdo->destroyHeaderObject();
            $body_started = true;
            // print out the body buffer
            $pdo->printBodyBuffer();
            printf('</html>');
            // exit normally.
            exit(0);
        } else {
            $co->setScheduleCaching(false);
            $pdo->setOmitBranding(true);
            DEBUG("CACHE: Admin wanted, caching deactivated.");
            require_once $CONFIG['LibDir'] . 'admin/adminFuncs.php';
            $co->setScheduleCaching(false);
            $af = new adminFuncs($pdo, $request);
            $pdo->scheduleInsertion_ExternalStylesheet($af->getAdminStylesheet());
            //			$pdo->insertBodyDiv("<img src=\"lib/images/adminlogotop.png\" style=\"vertical-align: top; text-align: left; border: 0; padding: 0; margin: 0;\" /><span class=\"adminMenu\" style=\"width: 100%;\">" . $af->getAdminMenu() . "</span>", "adminStripe", "2mc_menu", "29o3 management console");
            // this part is for the admin scripts which require
            // are not fetched from database
            DEBUG("SYS: Skipping normal layout and box fetching procedures");
            $header->setTitle("29o3 management console");
            $ao = NULL;
            $func = $request->getWantedAdminFunc();
            if (!array_search($func, $ALLOWED_MGMT_FUNCS)) {
                $func = "Overview";
            }
            // administration needs admin logged in
            $sm = new sessionManager($connector);
            if ($sm->checkSession() == false) {
                DEBUG("MGMT: Admin not logged in.");
                $func = "Login";
            }
            if ($func == "Logout") {
                $sm->invalidateSession();
                header("Location: " . mksyslink("?"));
            }
            require_once $CONFIG["LibDir"] . 'admin/admin' . $func . '.php';
            $name = "Admin" . $func;
            $ao = new $name($connector, $pdo, $sm);
            $ao->doPreBodyJobs();
            $pdo->insertIntoBodyBuffer($af->getAdminMenu());
            $ao->doBodyJobs();
            DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
            $profiler->addBreakpoint();
            DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
            $connector->closeConnection();
            DEBUG("DB: Connection closed.");
            DEBUG("SYS: Exiting normally.");
            if ($CONFIG['Developer_Debug'] == true) {
                if ($body) {
                    $body->eyecandyConsole($console);
                } else {
                    $console->printBuffer();
                }
            }
            //			$pdo->insertBodyDiv("Powered by <a href=\"http://twonineothree.berlios.de\">29o3</a> " . $SYSTEM_INFO["SystemVersion"] . " Codename " . $SYSTEM_INFO["SystemCodename"], "poweredBy", "poweredBy_Banner", "Powered by 29o3");
            // print the buffer of the header since we're done with it :)
            printf('<?xml version="1.0" encoding="UTF-8"?>');
            printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">%s', "\n");
            printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%s', "\n");
            $pdo->doInsertions();
            $pdo->printHeaderBuffer();
            $header_started = true;
            // destruct the header object
            $pdo->destroyHeaderObject();
            $body_started = true;
            // print out the body buffer
            $pdo->printBodyBuffer();
            printf('</html>');
            // exit normally
            exit(0);
        }
    } else {
        echo $co->getCacheContent();
        DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
        $profiler->addBreakpoint();
        DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
        $connector->closeConnection();
        DEBUG("DB: Connection closed.");
        DEBUG("SYS: Exiting normally.");
        if ($CONFIG['Developer_Debug'] == true) {
            echo '<center><div class="eyecandyConsole">' . $console->getBuffer() . '</div></center>';
        }
        echo "\n</body>\n</html>";
        // exit normally
        exit(0);
    }
    // never reached
}