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());
 }
Exemplo n.º 2
0
		public function open(){
			//auth to prevent theft
			$auth = 'not authorized';
			$lib = new adminFuncs();
			if($lib->config_exists()){
				include($lib->config_fp);
				if(isset($secret)){
					$auth = md5($secret);
				} else {
					@unlink($lib->config_fp);
					if($lib->config_exists()){
						if(isset($secret)){
							$auth = md5($secret);
						}
					}
				}
			}
			
			if($auth==$_COOKIE['sl_scanner']){
				//open the file, put line numbers, and go to the current line if there is one
				if(is_file($this->file)){
					$lines = file($this->file);
					$text = '';
					$currentLine = 0;
					foreach($lines as $line){
						$currentLine++;
						
						//figure out spaces
						$totalLen = strlen(''.count($lines));
						$thisLen = strlen("$currentLine");
						$add = $totalLen-$thisLen+1;
						$spaces = '';
						for($i=0;$i<$add;$i++){
							$spaces .= '&nbsp;';
						}
						
						if($this->line && $this->line==$currentLine){
							$text .= "<b style=\"color:red;\">"."$currentLine.$spaces".str_replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;",htmlentities($line))."</b>";
						} else {
							$text .= "$currentLine.$spaces".str_replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;",htmlentities($line));
						}
					}
					return '<div class="textarea">File last modified: '.date("m/d/Y H:i:s",filectime($this->file)).'<br/><br/>'.str_replace("\n",'<br/>',$text).'</div>';
				} else {
					return 'The requested file could not be found.';
				}
			} else {
				return 'Your session could not be authenticated.';
			}
		}
Exemplo n.º 3
0
		public function Verify(){
			$this->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : getenv('HTTP_HOST');
			$this->account = new Account();
			$lib = new adminFuncs();
			$this->filepath = $lib->sl_get_path();
			$this->uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
			$this->ip = isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : (isset($_SERVER["HTTP_CLIENT_IP"]) ? $_SERVER["HTTP_CLIENT_IP"] : $_SERVER["REMOTE_ADDR"]);
		}
Exemplo n.º 4
0
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
}