private function generateCommentsHTML() { $comments = $this->article->getComments(); $this->commentHTML = ""; if (getStyle()->doCommentHTML()) { try { $this->commentHTML = getStyle()->getCommentsHTML($comments); } catch (Exception $e) { $msgbox = new MessageBox("The style didn't generate the HTML code for the comments, therefore the default generator was used. <br /><br />To hide this message open <br />" . getStyle()->getStylePath() . "info.xml<br /> and set <strong>own_comment_html</strong> to <strong>false</strong>."); $msgbox->bindException($e); getDisplay()->addObject($msgbox); foreach ($comments as $comment) { $this->commentHTML .= $comment->toHTML(); } } } else { foreach ($comments as $comment) { $this->commentHTML .= $comment->toHTML(); } } $LCID = 0; if (count($comments) != 0) { $LCID = $comments[0]->getID(); } $ajaxPC = new CommentPoster($this->article->getID()); $ajaxPC->start(); $ajaxLC = new CommentLoader($this->article->getID(), $LCID, count($comments)); $ajaxLC->start(); }
private function generateArticleHTML() { if ($this->articles == null) { return; } if (getStyle()->doArticleHTML()) { try { $this->articleHTML = getStyle()->getArticlesHTML($this->articles); } catch (Exception $e) { $msgbox = new MessageBox("The style didn't generate the HTML code for the articles, therefore the default generator was used. <br /><br />To hide this message open <br />" . $style->getStylePath() . "info.xml<br /> and set <strong>own_article_html</strong> to <strong>false</strong>."); $msgbox->bindException($e); getDisplay()->addObject($msgbox); foreach ($this->articles as $article) { $this->articleHTML .= $article->toShortHTML(); } } } else { foreach ($this->articles as $article) { $this->articleHTML .= $article->toShortHTML(); } } }
private function generateArticlesHTML() { $articles = array(); $q = "action=fetch&object=article&max=5&order=article.id,desc"; try { $articles = orongo_query($q); } catch (Exception $e) { $msgbox = new MessageBox(); $msgbox->bindException($e); getDisplay()->addObject($msgbox); } if (count($articles) < 1) { try { $article = Article::createArticle("Hello World!"); $article->setContent("<p>Thank you for installing OrongoCMS!</p><p>To edit this simply delete it and create a new article or change this article.</p><br /><p>The OrongoCMS team</p>"); $articles[0] = $article; } catch (Exception $e) { } } if (getStyle()->doArticleHTML()) { try { $this->articleHTML = getStyle()->getArticlesHTML($articles); } catch (Exception $e) { $msgbox = new MessageBox("The style didn't generate the HTML code for the articles, therefore the default generator was used. <br /><br />To hide this message open <br />" . $style->getStylePath() . "info.xml<br /> and set <strong>own_article_html</strong> to <strong>false</strong>."); $msgbox->bindException($e); getDisplay()->addObject($msgbox); foreach ($articles as $article) { $this->articleHTML .= $article->toShortHTML(); } } } else { foreach ($articles as $article) { $this->articleHTML .= $article->toShortHTML(); } } }
if (getUser()->getRank() != RANK_ADMIN) { header("Location: " . orongoURL("orongo-admin/index.php?msg=0")); exit; } if (!isset($_POST['website_url']) || !isset($_POST['website_style']) || !isset($_POST['website_name']) || !isset($_POST['website_lang']) || !isset($_POST['show_archive'])) { header("Location: " . orongoURL("orongo-admin/orongo-settings.php")); exit; } if (Settings::getWebsiteURL() != $_POST['website_url'] && !empty($_POST['website_url'])) { Settings::setWebsiteURL($_POST['website_url']); } if (Settings::getWebsiteName() != $_POST['website_name'] && !empty($_POST['website_name'])) { Settings::setWebsiteName($_POST['website_name']); } if (Settings::getLanguageName() != $_POST['website_lang'] && !empty($_POST['website_lang'])) { Settings::setLanguageName($_POST['website_lang']); } if (strval(Settings::showArchive()) != $_POST['show_archive'] && !empty($_POST['show_archive'])) { Settings::setShowArchive($_POST['show_archive']); } if (getStyle()->getStyleFolder() != $_POST['website_style'] && file_exists(ROOT . "/themes/" . $_POST['website_style']) . "/info.xml") { try { Settings::setStyle($_POST['website_style']); } catch (Exception $e) { $msgbox = new MessageBox("Can't install style: " . $_POST['website_style']); $msgbox->bindException($e); die($msgbox->getImports() . $msgbox->toHTML()); } } header("Location: " . orongoURL("orongo-admin/orongo-settings.php?msg=0")); exit;
/** * Runs the style's PHP file if it has one. */ public function run() { if ($this->usePHP) { if ($this->getPHPFile() != null) { try { if ($this->mainClass instanceof IOrongoStyle) { $this->mainClass->run(); } } catch (Exception $e) { $msg = new MessageBox("An error occured while running the style."); $msg->bindException($e); getDisplay()->addObject($msg); } } } }
/** *Starts Orongo! :) * @param String $paramCurrentPage the current page */ function startOrongo($paramCurrentPage = 'anonymous') { session_start(); define("ROOT", dirname(__FILE__)); define("LIB", ROOT . "/lib"); define("ADMIN", ROOT . "/orongo-admin"); define("CONFIG", ROOT . "/config.php"); define('RANK_ADMIN', 3); define('RANK_WRITER', 2); define('RANK_USER', 1); define('ARTICLE_NOT_EXIST', 2100); define('PAGE_NOT_EXIST', 3100); define('USER_NOT_EXIST', 4100); define('COMMENT_NOT_EXIST', 5100); error_reporting(E_ALL); if (file_exists("orongo-install.php")) { die("If you didn't install OrongoCMS yet, proceed to the <a href='orongo-install.php'>installer</a><br/>If you installed it, please delete orongo-install.php"); } if (!file_exists(CONFIG)) { die("config.php (" . CONFIG . ") was missing!"); } require_once CONFIG; require LIB . '/function_load.php'; try { load(LIB); } catch (Exception $e) { die($e->getMessage()); } setDatabase(new Database(CONFIG)); try { setLanguage(new Language(ADMIN . '/lang/' . Settings::getLanguageName())); } catch (Exception $e) { $msgbox = new MessageBox(); $msgbox->bindException($e); die($msgbox->getImports() . $msgbox->toHTML()); } setCurrentPage($paramCurrentPage); $style = null; try { $style = Settings::getStyle(); } catch (Exception $e) { $msgbox = new MessageBox(); $msgbox->bindException($e); die($msgbox->getImports() . $msgbox->toHTML()); } setMenu(new Menu()); setStyle($style); setDisplay(new Display($style->getStylePath())); setUser(handleSessions()); if (defined('HACK_PLUGINS') && HACK_PLUGINS == true) { Plugin::hackKeys(); } try { setPlugins(Plugin::getActivatedPlugins('orongo-admin/')); } catch (Exception $e) { $msgbox = new MessageBox(); $msgbox->bindException($e); getDisplay()->addObject($msgbox); } //getLanguage()->setTempLanguage(ADMIN . '/lang/en_US'); OrongoDefaultEventHandlers::init(); }
/** * Returns activated plugins * @return array containing plugins */ public static function getActivatedPlugins() { $loadedPluginNames = array(); if (self::$requiresDone) { throw new Exception(); } self::$requiresDone = true; self::$authKeys = array(); $rows = getDatabase()->query("SELECT `plugin_xml_path` FROM `activated_plugins`"); $plugins = array(); $count = 0; foreach ($rows as $row) { $infoXML = $row['plugin_xml_path']; if (!file_exists($infoXML)) { if (!file_exists('../' . $infoXML)) { continue; } $infoXML = '../' . $infoXML; } $xml = @simplexml_load_file($infoXML); $json = @json_encode($xml); $info = @json_decode($json, true); if (in_array($info['plugin']['name'], $loadedPluginNames)) { throw new ClassLoadException("There is already a plugin loaded with this name: " . $info['plugin']['name']); } switch (trim(strtoupper($info['plugin']['language']))) { case "PHP": try { $phpFile = self::getPHPFile($infoXML); } catch (Exception $e) { $msgbox = new MessageBox(); $msgbox->bindException($e); die($msgbox->getImports() . $msgbox->toHTML()); } require_once $phpFile; try { $className = $info['plugin']['main_class']; $accessKey = $info['plugin']['access_key']; $authKey = md5(rand() . microtime() . rand()); self::$authKeys[$authKey] = $accessKey; $plugin = new $className(array("time" => time(), "auth_key" => $authKey)); if ($plugin instanceof OrongoPluggableObject == false) { throw new ClassLoadException("Invalid plugin object!"); } $plugin->setXMLFile($infoXML); $plugins[$count] = $plugin; $count++; } catch (IllegalMemoryAccessException $ie) { throw new ClassLoadException("Plugin tried to access illegal memory. Unable to load plugin (php): <br /> " . $phpFile); continue; } catch (Exception $e) { throw new ClassLoadException("Unable to load plugin (php): <br /> " . $phpFile . "<br/><br /><strong>Exception</strong><br />" . $e->getMessage()); continue; } break; case "OSC": try { $oscFile = self::getOSCFile($infoXML); } catch (Exception $e) { $msgbox = new MessageBox(); $msgbox->bindException($e); die($msgbox->getImports() . $msgbox->toHTML()); } try { $accessKey = $info['plugin']['access_key']; $authKey = md5(rand() . microtime() . rand()); self::$authKeys[$authKey] = $accessKey; $pluginBridge = new OrongoScriptPluginBridge(array("osc_file" => $oscFile, "time" => time(), "auth_key" => $authKey)); $pluginBridge->setXMLFile($infoXML); $plugins[$count] = $plugin; $count++; } catch (OrongoScriptParseException $pe) { throw new ClassLoadException("Unable to load plugin (osc): <br /> " . $oscFile . "<br/><br/><strong>OrongoScriptParseException</strong><br />" . $pe->getMessage()); } catch (Exception $e) { throw new ClassLoadException("Unable to load plugin (osc): <br /> " . $oscFile . "<br/><br /><strong>Exception</strong><br />" . $e->getMessage()); continue; } break; default: throw new ClassLoadException("Invalid plugin language: " . $info['plugin']['language'] . "!"); break; } } return $plugins; }