Exemplo n.º 1
0
 public static function mainPage()
 {
     $allCount = self::$db->query("SELECT COUNT(*) as cnt, c.`contentID`, cc.`contentID` FROM `content` as c, " . "`content_category` as cc WHERE cc.`contentID`=c.`contentID` AND c.`showOnSite`='Y'")->fetch();
     $sqlData = blog::getPosts(core::pagination($allCount["cnt"]))->fetchAll();
     //if ($sqlData)
     //{
     //blog::highlightCode ($sqlData, "short");
     //}
     return $sqlData;
 }
Exemplo n.º 2
0
 function date()
 {
     system::setParam("page", "blogByDate");
     $offset = 1;
     if (isset($this->get["offset"])) {
         $offset = intval($this->get["offset"]);
     }
     $cacheID = "DTSELECT|ARTICLE|dateoffset_{$offset}";
     if (isset($this->args[1])) {
         $date = preg_replace("/[^0-9.]/uims", '', $this->args[1]);
         $cacheID = $date . "|" . $cacheID;
     }
     $this->smarty->setCacheID($cacheID);
     if (!$this->smarty->isCached()) {
         $allCount = $this->db->query("SELECT COUNT(*) as cnt FROM `content` as c, `content_category` as cc, `categories` as cts WHERE \n            cc.`contentID`=c.`contentID` AND c.`type`='article' AND cts.`categoryID`=cc.`catID` AND c.`showOnSite`='Y' AND c.`dt` >= \n            STR_TO_DATE ('?', '%d.%m.%Y')", $date)->fetch();
         $posts = news::getPostsByDate($date, core::pagination($allCount["cnt"], $offset), "article")->fetchAll();
         $this->smarty->assign("posts", $posts);
         $this->smarty->assign("date", $date);
     }
 }
Exemplo n.º 3
0
 public static function buildList($target, $type = "", array $clause = array())
 {
     if ($type) {
         if ($target == "categories") {
             // временный костыль
             $clause[] = "`catType`='{$type}'";
         } else {
             $clause[] = "`type`='{$type}'";
         }
     }
     $clauseSTR = "";
     if ($clause) {
         $clauseSTR = implode(" AND ", $clause);
     }
     if ($clauseSTR) {
         $clauseSTR = "WHERE {$clauseSTR}";
     }
     $columns = self::$db->query("SHOW COLUMNS FROM `{$target}`")->fetchAll();
     if (isset($_GET["action"])) {
         switch ($_GET["action"]) {
             case "delete":
                 $id = array_keys($_GET);
                 $keyName = $id[count($_GET) - 1];
                 $id = intval($_GET[$keyName]);
                 self::$db->query("DELETE FROM `{$target}` WHERE `?`=?", $keyName, $id);
                 if ($target == "content") {
                     self::$db->query("DELETE FROM `content_category` WHERE `id`=?", $id);
                     self::$smarty->clearCache(null, "MAINPAGE|SEARCH_RES|BLOG|CATSELECT|RSS");
                 }
                 break;
         }
     }
     if (isset($_POST["groupDelete"]) && !empty($_POST["rows"])) {
         self::$db->query("DELETE FROM `{$target}` WHERE `" . $columns[0]["Field"] . "` IN (" . implode(",", $_POST["rows"]) . ")");
     }
     $mysqlLimits = array();
     $offset = 0;
     $allCount = self::$db->query("SELECT COUNT(*) as cnt FROM `{$target}` {$clauseSTR}")->fetch();
     $mysqlLimits = core::pagination($allCount["cnt"]);
     $sort = $columns[0]["Field"];
     $direction = "DESC";
     if (isset($_GET["direction"]) && $_GET["direction"]) {
         if ($_GET["direction"] == "DESC") {
             $direction = "ASC";
         } else {
             if ($_GET["direction"] == "ASC") {
                 $direction = "DESC";
             }
         }
     }
     if (isset($_GET["sort"]) && $_GET["sort"]) {
         $sort = $_GET["sort"];
     }
     self::$smarty->assign("direction", $direction);
     self::$smarty->assign("sort", $sort);
     $res = self::$db->query("SELECT * FROM `{$target}` {$clauseSTR} ORDER BY `{$sort}` {$direction} LIMIT \n\t\t\t{$mysqlLimits["start"]},{$mysqlLimits["end"]}");
     if ($target != "categories") {
         $res->runAfterFetchAll[] = array("blog", "makeSlug");
     }
     $data = $res->fetchAll();
     self::$smarty->assign("list", $data);
     return $data;
 }
Exemplo n.º 4
0
 public static function mailOutbox($offset = 1)
 {
     $userID = intval($_SESSION["user"]["userID"]);
     $_SESSION["user"]["mail"]["box"] = "outbox";
     $cntOut = self::$db->query("SELECT COUNT(*) as cnt FROM `messages`,`users` WHERE `userID`=`senderID` AND `userID`=?", $userID)->fetch();
     $cntIn = self::$db->query("SELECT COUNT(*) as cnt FROM `messages` WHERE `receiverID`=?", $userID)->fetch();
     self::$smarty->assign("cntOut", $cntOut["cnt"]);
     self::$smarty->assign("cntIn", $cntIn["cnt"]);
     $limits = core::pagination($cntIn["cnt"], $offset);
     return self::$db->query("SELECT * FROM `messages` as m LEFT JOIN " . "`users` as u ON u.`userID`=m.`receiverID` WHERE m.`senderID`=? ORDER BY m.`dt` DESC LIMIT " . implode(",", $limits), $userID);
 }