/** * Print comments. * @param $moduleId Module identifier. * @param $moduleContentTypeId Type identifier. * @param $moduleContentId Module content identifier. * @param $replySubject Subject to put in form. * @param $formURL URL of post form. * @param $navPath Navigation path. */ function printComments($moduleId, $moduleContentTypeId, $moduleContentId, $replySubject, $formURL, $navPath) { global $dbi, $login, $module, $settings; // Include language include scriptPath . "/include/language/" . $this->language . "/admin.php"; include scriptPath . "/include/language/" . $this->language . "/general.php"; // Get page number $page = !empty($_GET["page"]) ? $_GET["page"] - 1 : 0; // Include comments header template if (file_exists(layoutPath . "/template/commentsHeader.template.php")) { include layoutPath . "/template/commentsHeader.template.php"; } else { include scriptPath . "/include/template/commentsHeader.template.php"; } // TODO: Add pages: LIMIT ".($page*15).",".($page*15+15) $result = $dbi->query("SELECT id FROM " . commentTableName . " WHERE moduleId=" . $dbi->quote($moduleId) . " AND moduleContentTypeId=" . $dbi->quote($moduleContentTypeId) . " AND moduleContentId=" . $dbi->quote($moduleContentId) . " AND spam=0 AND trash=0 ORDER BY posted ASC"); if ($result->rows()) { $comment = new Comment(); for ($i = 0; list($id) = $result->fetchrow_array(); $i++) { $comment->init($id); $commentAdmin = $comment->hasEditPermission(); $user = null; if (!empty($comment->userId)) { $user = new User($comment->userId); $name = $user->username; } else { $name = $comment->name; } $lastComment = $i - 1 == $result->rows(); // Include template if (file_exists(layoutPath . "/template/comment.template.php")) { include layoutPath . "/template/comment.template.php"; } else { include scriptPath . "/include/template/comment.template.php"; } } } else { echo "<i>" . $lComment["NoComments"] . "</i><br />"; } // Fetch user data if (!empty($login->id)) { $user = new User($login->id); $name = $user->name; $mail = $user->email; $link = $user->linkurl; $remember = 0; } else { if (!empty($_COOKIE["commentPoster"])) { $poster = unserialize(stripslashes(stripslashes($_COOKIE["commentPoster"]))); $name = $poster["name"]; $mail = $poster["mail"]; $link = $poster["link"]; $remember = $poster["remember"]; } else { // Reset values $name = ""; $mail = ""; $link = ""; $remember = 0; } } if (!empty($_POST["name"])) { $name = $_POST["name"]; } if (!empty($_POST["mail"])) { $mail = $_POST["mail"]; } if (!empty($_POST["subject"])) { $subject = $_POST["subject"]; } if (!empty($_POST["message"])) { $message = $_POST["message"]; } if (!empty($_POST["remember"])) { $remember = $_POST["remember"]; } // Disable comments for this user $disableForm = $this->disableComments || !$login->hasCommentPermission($moduleContentTypeId, $moduleContentId); // Include comment form if (file_exists(layoutPath . "/template/commentForm.php")) { include layoutPath . "/template/commentForm.php"; } else { include scriptPath . "/include/form/commentForm.php"; } // Create page indexing $pages = printPageIndex($navPath . "&showComments=1&", $page, $this->getNumberOfComments($moduleId, $moduleContentId), 15, "", "comments"); // Print page navigation if (!empty($pages)) { echo "<p align=\"center\">{$pages}</p>"; } // Free result $result->finish(); }
/** * Print blog body. * @param $categoryId Identifier of category to display. */ function printBlogBody($categoryId = "") { global $dbi, $login; // Include language include scriptPath . "/" . folderBlog . "/include/language/" . $this->language . "/general.php"; // Get category if (isset($_GET["categoryId"])) { $categoryId = $_GET["categoryId"]; } // Get parameters $searchString = !empty($_POST["searchString"]) ? $_POST["searchString"] : (!empty($_GET["searchString"]) ? $_GET["searchString"] : ""); $day = !empty($_GET["day"]) ? $_GET["day"] : 0; $month = !empty($_GET["month"]) ? $_GET["month"] : 0; $year = !empty($_GET["year"]) ? $_GET["year"] : 0; // Get page number $page = !empty($_GET["page"]) ? $_GET["page"] : 0; // Print blog header $post = new Post(); $post->blog = $this; echo "<p>" . $this->description; if ($post->hasEditPermission()) { printf(" " . $lBlog["NewPost"], $this->id); } echo "</p>"; // Validate page $page = !empty($page) ? $page - 1 : 0; // Create search query $search_query = !empty($searchString) ? " AND (subject LIKE " . $dbi->quote("%{$searchString}%") . " OR subject LIKE " . $dbi->quote("% {$searchString}%") . " OR summary LIKE " . $dbi->quote("%{$searchString}%") . " OR summary LIKE " . $dbi->quote("{$searchString}%") . ")" : ""; // Create datestamps $time_query = ""; $time_query2 = ""; if (!empty($month) && !empty($year)) { $tmp_date = ""; $tmp_date2 = ""; if (!empty($day)) { $tmp_date = mktime(0, 0, 0, $month, $day, $year); $tmp_date2 = mktime(0, 0, 0, $month, $day + 1, $year); $time_query2 = "day={$day}&month={$month}&year={$year}&"; } else { $tmp_date = mktime(0, 0, 0, $month, 1, $year); $tmp_date2 = mktime(0, 0, 0, $month + 1, 1, $year); $time_query2 = "month={$month}&year={$year}&"; } $time_query = " AND (posted>=FROM_UNIXTIME({$tmp_date}) AND posted<FROM_UNIXTIME({$tmp_date2}))"; } if (!empty($searchString)) { $time_query2 = $time_query2 . (!empty($time_query2) ? "&" : "") . "search_string={$searchString}"; } // Get post from a specific category if ($categoryId != -1) { $result = $dbi->query("SELECT id FROM " . blogPostTableName . " WHERE blogId=" . $dbi->quote($this->id) . (!$this->hasEditPermission() ? " AND draft=0" : "") . " AND id " . ($categoryId == 0 ? "NOT " : "") . "IN(SELECT moduleContentId FROM " . categoryContentRefTableName . " WHERE moduleId=" . $dbi->quote(blogModuleId) . " AND moduleContentTypeId=" . $dbi->quote(blogPostContentId) . ($categoryId != 0 ? " AND categoryId=" . $dbi->quote($categoryId) : "") . "){$time_query}{$search_query} ORDER BY posted DESC LIMIT " . $page * $this->postLimit . "," . $this->postLimit); } else { $result = $dbi->query("SELECT id FROM " . blogPostTableName . " WHERE blogId=" . $dbi->quote($this->id) . (!$this->hasEditPermission() ? " AND draft=0" : "") . "{$time_query}{$search_query} ORDER BY posted DESC LIMIT " . $page * $this->postLimit . "," . $this->postLimit); } if ($result->rows()) { // Print posts for ($i = 0; list($postId) = $result->fetchrow_array(); $i++) { $post = new Post($postId); $post->printPostSummary(); } // Get number of posts in blog if ($categoryId != -1) { $result = $dbi->query("SELECT COUNT(*) FROM " . blogPostTableName . " WHERE blogId=" . $dbi->quote($this->id) . " AND id " . ($categoryId == 0 ? "NOT " : "") . "IN(SELECT moduleContentId FROM " . categoryContentRefTableName . " WHERE moduleId=" . $dbi->quote(blogModuleId) . " AND moduleContentTypeId=" . $dbi->quote(blogPostContentId) . ($categoryId != 0 ? " AND categoryId=" . $dbi->quote($categoryId) : "") . "){$time_query}{$search_query}"); } else { $result = $dbi->query("SELECT COUNT(*) FROM " . blogPostTableName . " WHERE blogId=" . $dbi->quote($this->id) . "{$time_query}{$search_query}"); } if ($result->rows()) { list($count) = $result->fetchrow_array(); echo "<p align=\"center\">"; echo printPageIndex(folderBlog . "/" . fileBlog . "?blogId=" . $this->id . "&" . (!empty($searchString) ? "searchString={$searchString}&" : "") . (isset($categoryId) ? "categoryId={$categoryId}&" : "") . (!empty($time_query2) ? "{$time_query2}&" : ""), $page, $count, $this->postLimit); echo "</p>"; } } else { echo "<p><i>" . $lBlog["NoPosts"] . "</i></p>"; } }