public function get($obj = null, $id = null) { terminalAuth(); if ($id == null || !is_numeric($id)) { throw new Exception("invalid id"); } if ($obj == null || $obj != 'page' && $obj != 'user' && $obj != 'comment' && $obj != 'article') { throw new Exception("invalid object"); } $result = orongo_query("action=fetch&object=" . $obj . "&max=1&where=" . $obj . ".id:" . $id); foreach ($result as $obj) { if ($obj instanceof Article) { $arr = array("article title" => $obj->getTitle(), "article id" => $obj->getID(), "article author name" => $obj->getAuthorName(), "article author id" => $obj->getAuthorID(), "article date" => $obj->getDate(), "article comments count" => $obj->getCommentCount()); return $arr; } elseif ($obj instanceof Comment) { $arr = array("comment id" => $obj->getID(), "comment article id" => $obj->getArticleID(), "comment author name" => $obj->getAuthorName(), "comment author id" => $obj->getAuthorID(), "comment timestamp" => $obj->getTimestamp()); return $arr; } elseif ($obj instanceof Page) { $arr = array("page title" => $obj->getTitle(), "page id" => $obj->getID()); return $arr; } elseif ($obj instanceof User) { $arr = array("user name" => $obj->getName(), "user id" => $obj->getID(), "user rank" => $obj->getRank(), "user email" => $obj->getEmail()); return $arr; } } throw new Exception("wrong id"); }
/** * Init Menu */ public function __construct() { $this->flip = false; $this->URLs = array(); $this->hookURL(orongoURL("index.php"), l("Home"), 0); if (Settings::showArchive()) { $this->hookURL(orongoURL("archive.php"), l("Archive"), 10000); } $pages = @orongo_query('action=fetch&object=page&max=10000&order=page.id'); if ($pages != false) { $c = 1; foreach ($pages as $page) { if ($page instanceof Page == false) { continue; } $this->hookURL(orongoURL("page.php?id=" . $page->getID()), $page->getTitle(), $c); //C++, SOOO HARDCORE :D $c++; } } }
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(); } } }
$manager = new AdminFrontendContentManager(100, "Pages"); $manager->createTab("Pages", array("ID", "Title")); foreach ($objs as $obj) { if ($obj instanceof Page == false) { continue; } $manager->addItem("Pages", array($obj->getID(), '<a href="' . orongoURL("orongo-admin/view.php?page." . $obj->getID()) . '">' . $obj->getTitle() . '</a>'), orongoURL("orongo-admin/delete.php?page." . $obj->getID()), orongoURL("orongo-admin/edit.php?page." . $obj->getID())); } $manage->addObject($manager); $manage->render(); break; case "comments": $objs = null; $manage->setTitle("Manage Comments"); try { $objs = orongo_query("action=fetch&object=comment&max=1000000&order=comment.id,desc"); } catch (Exception $e) { $manage->addMessage($e, "error"); $manage->render(); exit; } $manager = new AdminFrontendContentManager(100, "Comments"); $manager->createTab("Comments", array("ID", "Comment", "Commenter", "Date", "Article ID", "Article Title")); $manager->hideEditButton(); foreach ($objs as $obj) { if ($obj instanceof Comment == false) { continue; } $articleName = "?"; if (Cache::isStored('article_name_' . $obj->getArticleID())) { $articleName = Cache::get('article_name_' . $obj->getArticleID());
exit; } foreach ($lastCommentArr as $comment) { if ($comment instanceof Comment == false) { continue; } if ($comment->getID() <= $_POST['last_comment_id']) { errorDie("No new comments! ", NO_NEW_COMMENTS); exit; } else { $newLCID = $comment->getID(); } } $newComments = null; try { $newComments = orongo_query("action=fetch&object=comment&max=1000000&offset=" . Security::escape($_POST['offset']) . "&order=comment.id,asc&where=article.id:" . Security::escape($_POST['article'])); } catch (Exception $e) { die("500"); } $newComments = array_reverse($newComments); $html = ""; if (getStyle()->doCommentHTML()) { try { $html = getStyle()->getCommentsHTML($newComments); } catch (Exception $e) { foreach ($newComments as $comment) { $html .= $comment->toHTML(); } } } else { foreach ($newComments as $comment) {
if (isset($_GET['user'])) { $username = mysql_escape_string($_GET['user']); } else { if (isset($_GET['userid'])) { $userid = mysql_escape_string($_GET['userid']); } } } $articles = array(); $c = 0; $q = "action=fetch&object=article&max=1000000&order=article.id,desc"; if ($date != false) { $q .= "&where=article.date:" . $date; } if ($username != false && is_string($username)) { $q .= "&where=author.name:" . $username; } if ($userid != false && is_numeric($userid)) { $q .= "&where=author.id:" . $userid; } try { $articles = orongo_query($q); } catch (Exception $e) { $msgbox = new MessageBox(l("FETCH_ERROR", strtolower(l("ARTICLES")))); $msgbox->bindException($e); getDisplay()->addObject($msgbox); $articles = null; } $archive = new ArchiveFrontend(); $archive->main(array("time" => time(), "articles" => $articles)); $archive->render();
/** * Inits all the event handlers */ public static function init() { /** OrongoEventManager::addEventHandlers(array( "article_edit" => "onArticleEdit", "article_created" => "onArticleCreated", "article_deleted" => "onArticleDeleted", "user_edit" => "onUserEdit", "user_created" => "onUserCreated", "user_deleted" => "onUserDeleted", "page_edit" => "onPageEdit", "page_created" => "onPageCreated", "page_deleted" => "onPageDeleted", "comment_created" => "onCommentCreated", "comment_deleted" => "onCommentDeleted", ), new OrongoDefaultEventHandlers());**/ Article::$CreateEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Article created"), l("Article was created by", User::getUserName($args['by']))); } }); Article::$EditEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Article edited"), l("Article was edited by", User::getUserName($args['by']))); } }); Article::$DeleteEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Article deleted"), l("Article was deleted by", User::getUserName($args['by']))); } }); Page::$CreateEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Page created"), l("Page was created by", User::getUserName($args['by']))); } }); Page::$EditEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Page edited"), l("Page was edited by", User::getUserName($args['by']))); } }); Page::$DeleteEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Page deleted"), l("Page was deleted by", User::getUserName($args['by']))); } }); User::$CreateEvent->subscribe(function ($args) { $newUser = new User($args['user_id']); $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("User created"), l("Just registered", $newUser->getName())); } }); User::$EditEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("User edited"), l("User was edited by", User::getUserName($args['by']))); } }); User::$DeleteEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("User deleted"), l("User was deleted by", User::getUserName($args['by']))); } }); Comment::$CreateEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Comment posted"), l("Comment was posted by", User::getUserName($args['by']))); } }); Comment::$DeleteEvent->subscribe(function ($args) { $admins = orongo_query("action=fetch&object=user&max=100000&where=user.rank:admin"); foreach ($admins as $user) { if ($user instanceof User == false) { continue; } $user->notify(l("Comment deleted"), l("Comment was deleted by", User::getUserName($args['by']))); } }); }
/** * @return array comments */ public function getComments() { $comments = array(); try { $comments = orongo_query("action=fetch&object=comment&max=10000000&order=comment.id,desc&where=article.id:" . $this->id); } catch (Exception $e) { } return $comments; }