Guest User

news_cats.php

a guest
Dec 9th, 2010
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.91 KB | None | 0 0
  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) 2002 - 2008 Nick Jones
  5. | http://www.php-fusion.co.uk/
  6. +--------------------------------------------------------+
  7. | Filename: articles.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | This program is released as free software under the
  11. | Affero GPL license. You can redistribute it and/or
  12. | modify it under the terms of this license which you
  13. | can read by viewing the included agpl.txt or online
  14. | at www.gnu.org/licenses/agpl.html. Removal of this
  15. | copyright header is strictly prohibited without
  16. | written permission from the original author(s).
  17. +--------------------------------------------------------*/
  18. require_once "maincore.php";
  19. require_once THEMES."templates/header.php";
  20. include LOCALE.LOCALESET."articles.php";
  21.  
  22. add_to_title($locale['global_200'].$locale['400']);
  23.  
  24. if (isset($_GET['article_id']) && isnum($_GET['article_id'])) {
  25.     $result = dbquery(
  26.         "SELECT ta.*,tac.*, tu.user_id,user_name FROM ".DB_ARTICLES." ta
  27.         INNER JOIN ".DB_ARTICLE_CATS." tac ON ta.article_cat=tac.article_cat_id
  28.         LEFT JOIN ".DB_USERS." tu ON ta.article_name=tu.user_id
  29.         WHERE ".groupaccess('article_cat_access')." AND article_id='".$_GET['article_id']."' AND article_draft='0'"
  30.     );
  31.     if (dbrows($result)) {
  32.         require_once INCLUDES."comments_include.php";
  33.         require_once INCLUDES."ratings_include.php";
  34.         $data = dbarray($result);
  35.         if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
  36.         if ($_GET['rowstart'] == 0) { $result = dbquery("UPDATE ".DB_ARTICLES." SET article_reads=article_reads+1 WHERE article_id='".$_GET['article_id']."'"); }
  37.        
  38.         //modified by ivoht//
  39.         $article = stripslashes($data['article_snippet']);
  40.        
  41.         if (ereg('<--PAGEBREAK-->', $article)) {
  42.             $article = explode("<--PAGEBREAK-->", $article);
  43.         } else {
  44.             $article = explode("<!-- pagebreak -->", $article);
  45.         }
  46.         $pagecount = count($article);
  47.         $article_subject = stripslashes($data['article_subject']);
  48.         $article_info = array(
  49.             "article_id" => $data['article_id'],
  50.             "user_id" => $data['user_id'],
  51.             "user_name" => $data['user_name'],
  52.             "article_date" => $data['article_datestamp'],
  53.             "article_breaks" => $data['article_breaks'],
  54.             "article_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='A' AND comment_item_id='".$data['article_id']."'"),
  55.             "article_reads" => $data['article_reads'],
  56.             "article_allow_comments" => $data['article_allow_comments']
  57.         );
  58.         add_to_title($locale['global_201'].$article_subject);
  59.         echo "<!--pre_article-->";
  60.         render_article($article_subject, $article[$_GET['rowstart']], $article_info);
  61.         echo "<!--sub_article-->";
  62.         if ($pagecount > 1) {
  63.             echo "<div align='center' style='margin-top:5px;'>\n".makepagenav($_GET['rowstart'], 1, $pagecount, 3, FUSION_SELF."?article_id=".$_GET['article_id']."&amp;")."\n</div>\n";
  64.         }
  65.         if ($data['article_allow_comments']) { showcomments("A", DB_ARTICLES, "article_id", $_GET['article_id'], FUSION_SELF."?article_id=".$_GET['article_id']); }
  66.         if ($data['article_allow_ratings']) { showratings("A", $_GET['article_id'], FUSION_SELF."?article_id=".$_GET['article_id']); }
  67.     } else {
  68.         redirect(FUSION_SELF);
  69.     }
  70. } elseif (!isset($_GET['cat_id']) || !isnum($_GET['cat_id'])) {
  71.     opentable($locale['400']);
  72.     echo "<!--pre_article_idx-->\n";
  73.     $result = dbquery("SELECT * FROM ".DB_ARTICLE_CATS." WHERE ".groupaccess('article_cat_access')." ORDER BY article_cat_name");
  74.     $rows = dbrows($result);
  75.     if ($rows) {
  76.         $counter = 0; $columns = 2;
  77.         echo "<table cellpadding='0' cellspacing='0' width='100%'>\n<tr>\n";
  78.         while ($data = dbarray($result)) {
  79.             if ($counter != 0 && ($counter % $columns == 0)) { echo "</tr>\n<tr>\n"; }
  80.             $num = dbcount("(article_cat)", DB_ARTICLES, "article_cat='".$data['article_cat_id']."' AND article_draft='0'");
  81.             echo "<td valign='top' width='50%' class='tbl article_idx_cat_name'><!--article_idx_cat_name-->
  82.             <a href='".FUSION_SELF."?cat_id=".$data['article_cat_id']."'>".$data['article_cat_name']."</a> <span class='small2'>($num)</span>";
  83.             if ($data['article_cat_description'] != "") { echo "<br />\n<span class='small'>".$data['article_cat_description']."</span>"; }
  84.             echo "</td>\n";
  85.             $counter++;
  86.         }
  87.         echo "</tr>\n</table>\n";
  88.     } else {
  89.         echo "<div style='text-align:center'><br />\n".$locale['401']."<br /><br />\n</div>\n";
  90.     }
  91.     echo "<!--sub_article_idx-->\n";
  92.     closetable();
  93. } else {
  94.     $res = 0;
  95.     $result = dbquery("SELECT * FROM ".DB_ARTICLE_CATS." WHERE article_cat_id='".$_GET['cat_id']."'");
  96.     if (dbrows($result) != 0) {
  97.         $cdata = dbarray($result);
  98.         if (checkgroup($cdata['article_cat_access'])) {
  99.             $res = 1;
  100.             add_to_title($locale['global_201'].$cdata['article_cat_name']);
  101.             opentable($locale['400'].": ".$cdata['article_cat_name']);
  102.             echo
  103. "<!--pre_article_cat-->";
  104.             $rows = dbcount("(article_id)", DB_ARTICLES, "article_cat='".$_GET['cat_id']."' AND article_draft='0'");
  105.             if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
  106.             if ($rows != 0) {
  107.                 $result = dbquery(
  108.                     "SELECT ta.article_id, ta.article_subject, ta.article_snippet, ta.article_datestamp FROM ".DB_ARTICLES." ta
  109.                     WHERE article_cat='".$_GET['cat_id']."' AND article_draft='0' ORDER BY ".$cdata['article_cat_sorting']." LIMIT ".$_GET['rowstart'].",15"
  110.                 );
  111.                 $numrows = dbrows($result); $i = 1;
  112.                 while ($data = dbarray($result)) {
  113.                     if ($data['article_datestamp'] + 604800 > time() + ($settings['timeoffset'] * 3600)) {
  114.                         $new = "&nbsp;<span class='small'>[".$locale['402']."]</span>";
  115.                     } else {
  116.                         $new = "";
  117.                     }
  118.                    
  119.  
  120. //added the snippet of code  
  121. echo opentable($data['article_subject']);
  122. echo $data['article_snippet'];
  123. //Bottom Bar Begin
  124.  
  125.          $nfooter_info = array(
  126.  
  127.                     "article_id" => $data['article_id'],
  128.             "user_id" => $data['user_id'],
  129.             "user_name" => $data['user_name'],
  130.             "article_date" => $data['article_datestamp'],
  131.             "article_breaks" => $data['article_breaks'],
  132.             "article_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='A' AND comment_item_id='".$data['article_id']."'"),
  133.             "article_reads" => $data['article_reads'],
  134.             "article_allow_comments" => $data['article_allow_comments']
  135.         );
  136.  
  137.          render_nfooter($nfooter_info);
  138.  
  139. //Bottom Bar End
  140. closetable();
  141.  
  142. echo ($i != $numrows ? "<br /><br />\n" : "\n"); $i++;
  143.                 }
  144.                 echo "<!--sub_article_cat-->";
  145.                 closetable();
  146.                 if ($rows > 15) echo "<div align='center' style=';margin-top:5px;'>\n".makepagenav($_GET['rowstart'], 15, $rows, 3, FUSION_SELF."?cat_id=".$_GET['cat_id']."&amp;")."\n</div>\n";
  147.             } else {
  148.                 echo "<div style='text-align:center'>".$locale['403']."</div>\n";
  149.                 echo "<!--sub_article_cat-->";
  150.                 closetable();
  151.             }
  152.         }
  153.     }
  154.     if ($res == 0) { redirect(FUSION_SELF); }
  155. }
  156.  
  157. require_once THEMES."templates/footer.php";
  158. ?>
Advertisement
Add Comment
Please, Sign In to add comment