home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / content / index.php < prev   
Encoding:
PHP Script  |  2002-09-16  |  9.7 KB  |  210 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. if (!eregi("modules.php", $PHP_SELF)) {
  16.     die ("You can't access this file directly...");
  17. }
  18.  
  19. require_once("mainfile.php");
  20. $module_name = basename(dirname(__FILE__));
  21. get_lang($module_name);
  22.  
  23. $pagetitle = "- $module_name";
  24.  
  25. function showpage($pid, $page=0) {
  26.     global $prefix, $dbi, $sitename, $admin, $module_name;
  27.     include("header.php");
  28.     OpenTable();
  29.     $result = sql_query("SELECT * from ".$prefix."_pages where pid='$pid'", $dbi);
  30.     $mypage = sql_fetch_array($result, $dbi);
  31.     if (($mypage[active] == 0) AND (!is_admin($admin))) {
  32.     echo "Sorry... This page doesn't exist.";
  33.     } else {
  34.     sql_query("update ".$prefix."_pages set counter=counter+1 where pid='$pid'", $dbi);
  35.     $date = explode(" ", $mypage[date]);
  36.     echo "<font class=\"title\">$mypage[title]</font><br>"
  37.         ."<font class=\"content\">$mypage[subtitle]<br><br><br><br>";
  38.     $contentpages = explode( "<!--pagebreak-->", $mypage[text] );
  39.     $pageno = count($contentpages);
  40.     if ( $page=="" || $page < 1 )
  41.         $page = 1;
  42.     if ( $page > $pageno )
  43.         $page = $pageno;
  44.     $arrayelement = (int)$page;
  45.     $arrayelement --;
  46.     if ($pageno > 1) {
  47.         echo ""._PAGE.": $page/$pageno<br>";
  48.     }
  49.     if ($page == 1) {
  50.         echo "<p align=\"justify\">".nl2br($mypage[page_header])."</p><br>";
  51.     }
  52.     echo "<p align=\"justify\">$contentpages[$arrayelement]</p>";
  53.     if($page >= $pageno) {
  54.         $next_page = "";
  55.     } else {
  56.         $next_pagenumber = $page + 1;
  57.         if ($page != 1) {
  58.         $next_page .= "- ";
  59.         }
  60.         $next_page .= "<a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$next_pagenumber\"><img src=\"images/download/right.gif\" border=\"0\" alt=\""._NEXT."\" title=\""._NEXT."\"></a>";
  61.     }
  62.     if ($page == $pageno) {
  63.         echo "<br><p align=\"justify\">".nl2br($mypage[page_footer])."</p><br><br>";
  64.     }
  65.     if($page <= 1) {
  66.         $previous_page = "";
  67.     } else {
  68.         $previous_pagenumber = $page - 1;
  69.         $previous_page = "<a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$previous_pagenumber\"><img src=\"images/download/left.gif\" border=\"0\" alt=\""._PREVIOUS."\" title=\""._PREVIOUS."\"></a> <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
  70.     }
  71.     echo "<br><br><br><center>$previous_page $next_page</center><br><br>";
  72.     if ($page == $pageno) {
  73.         echo "<p align=\"right\">".nl2br($mypage[signature])."</p>"
  74.         ."<p align=\"right\">"._COPYRIGHT." $sitename "._COPYRIGHT2."</p>"
  75.         ."<p align=\"right\"><font class=\"tiny\">"._PUBLISHEDON.": $date[0] ($mypage[counter] "._READS.")</font></p>"
  76.         ."<center>"._GOBACK."</center>";
  77.     }
  78.     }
  79.     CloseTable();
  80.     include("footer.php");
  81. }
  82.  
  83. function list_pages() {
  84.     global $prefix, $dbi, $sitename, $admin, $multilingual, $module_name;
  85.     include("header.php");
  86.     title("$sitename: "._PAGESLIST."");
  87.     OpenTable();
  88.     echo "<center><font class=\"content\">"._LISTOFCONTENT." $sitename:</center><br><br>";
  89.     $result = sql_query("select * from ".$prefix."_pages_categories", $dbi);
  90.     if (sql_num_rows($result, $dbi) > 0 AND sql_num_rows(sql_query("select * from ".$prefix."_pages WHERE cid!='0'", $dbi),$dbi) > 0) {
  91.     echo "<center>"._CONTENTCATEGORIES."</center><br><br>"
  92.             ."<table border=\"1\" align=\"center\" width=\"95%\">";
  93.     while(list($cid, $title, $description) = sql_fetch_row($result, $dbi)) {
  94.         if (sql_num_rows(sql_query("select * from ".$prefix."_pages WHERE cid='$cid'", $dbi),$dbi) > 0) {
  95.         echo "<tr><td valign=\"top\"> <a href=\"modules.php?name=$module_name&pa=list_pages_categories&cid=$cid\">$title</a> </td><td align=\"left\">$description</td></tr>";
  96.         }
  97.     }
  98.     echo "</td></tr></table><br><br>"
  99.         ."<center>"._NONCLASSCONT."</center><br><br>";
  100.     }
  101.     $result = sql_query("SELECT pid, title, subtitle, clanguage from ".$prefix."_pages WHERE active='1' AND cid='0' order by date", $dbi);
  102.     echo "<blockquote>";
  103.     while(list($pid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
  104.     if ($multilingual == 1) {
  105.         $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  106.     } else {
  107.         $the_lang = "";
  108.     }
  109.         if ($subtitle != "") {
  110.         $subtitle = " ($subtitle)";
  111.     } else {
  112.             $subtitle = "";
  113.     }
  114.     if (is_admin($admin)) {
  115.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=1\">"._DEACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
  116.     } else {
  117.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle<br>";
  118.     }
  119.     }
  120.     echo "</blockquote>";
  121.     if (is_admin($admin)) {
  122.     $result = sql_query("SELECT pid, cid, title, subtitle, clanguage from ".$prefix."_pages WHERE active='0' order by date", $dbi);
  123.     echo "<br><br><center><b>"._YOURADMINLIST."</b></center><br><br>";
  124.     echo "<blockquote>";
  125.     while(list($pid, $cid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
  126.         if ($multilingual == 1) {
  127.         $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  128.         } else {
  129.         $the_lang = "";
  130.         }
  131.             if ($subtitle != "") {
  132.             $subtitle = " ($subtitle) ";
  133.         } else {
  134.                 $subtitle = " ";
  135.         }
  136.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=0\">"._ACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
  137.     }
  138.     echo "</blockquote>";
  139.     }
  140.     CloseTable();
  141.     include("footer.php");
  142. }
  143.  
  144. function list_pages_categories($cid) {
  145.     global $prefix, $dbi, $sitename, $admin, $multilingual, $module_name;
  146.     include("header.php");
  147.     title("$sitename: "._PAGESLIST."");
  148.     OpenTable();
  149.     echo "<center><font class=\"content\">"._LISTOFCONTENT." $sitename:</center><br><br>";
  150.     $result = sql_query("SELECT pid, title, subtitle, clanguage from ".$prefix."_pages WHERE active='1' AND cid='$cid' order by date", $dbi);
  151.     echo "<blockquote>";
  152.     while(list($pid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
  153.     if ($multilingual == 1) {
  154.         $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  155.     } else {
  156.         $the_lang = "";
  157.     }
  158.         if ($subtitle != "") {
  159.         $subtitle = " ($subtitle)";
  160.     } else {
  161.             $subtitle = "";
  162.     }
  163.     if (is_admin($admin)) {
  164.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=1\">"._DEACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
  165.     } else {
  166.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle<br>";
  167.     }
  168.     }
  169.     echo "</blockquote>";
  170.     if (is_admin($admin)) {
  171.     $result = sql_query("SELECT pid, title, subtitle, clanguage from ".$prefix."_pages WHERE active='0' and cid='$cid' order by date", $dbi);
  172.     echo "<br><br><center><b>"._YOURADMINLIST."</b></center><br><br>";
  173.     echo "<blockquote>";
  174.     while(list($pid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
  175.         if ($multilingual == 1) {
  176.         $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  177.         } else {
  178.         $the_lang = "";
  179.         }
  180.             if ($subtitle != "") {
  181.             $subtitle = " ($subtitle) ";
  182.         } else {
  183.                 $subtitle = " ";
  184.         }
  185.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=0\">"._ACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
  186.     }
  187.     echo "</blockquote>";
  188.     }
  189.     echo "<center>"._GOBACK."</center>";
  190.     CloseTable();
  191.     include("footer.php");
  192. }
  193.  
  194. switch($pa) {
  195.  
  196.     case "showpage":
  197.     showpage($pid, $page);
  198.     break;
  199.     
  200.     case "list_pages_categories":
  201.     list_pages_categories($cid);
  202.     break;
  203.     
  204.     default:
  205.     list_pages();
  206.     break;
  207.  
  208. }
  209.  
  210. ?>