home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / sections / index.php
Encoding:
PHP Script  |  2002-09-16  |  7.8 KB  |  190 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. function listsections() {
  24.     global $sitename, $prefix, $dbi, $module_name;
  25.     include ('header.php');
  26.     $result = sql_query("select secid, secname, image from ".$prefix."_sections order by secname", $dbi);
  27.     OpenTable();
  28.     echo "
  29.     <center>"._SECWELCOME." $sitename.<br><br>
  30.     "._YOUCANFIND."</center><br><br>
  31.     <table border=\"0\" align=\"center\">";
  32.     $count = 0;
  33.     while (list($secid, $secname, $image) = sql_fetch_row($result, $dbi)) {
  34.         if ($count==2) {
  35.         echo "<tr>";
  36.         $count = 0;
  37.         }
  38.         echo "<td><a href=\"modules.php?name=$module_name&op=listarticles&secid=$secid\"><img src=\"images/sections/$image\" border=\"0\" Alt=\"$secname\"></a>";
  39.         $count++;
  40.         if ($count==2) {
  41.         echo "</tr>";
  42.         }
  43.         echo "</td>";
  44.     }
  45.     echo "</table></center>";
  46.     CloseTable();
  47.     include ('footer.php');
  48. }
  49.  
  50. function listarticles($secid) {
  51.     global $prefix, $multilingual, $currentlang, $dbi, $module_name;
  52.     if ($multilingual == 1) {
  53.     $querylang = "AND slanguage='$currentlang'";
  54.     } else {
  55.     $querylang = "";
  56.     }
  57.     include ('header.php');
  58.     $result = sql_query("select secname from ".$prefix."_sections where secid=$secid", $dbi);
  59.     list($secname) = sql_fetch_row($result, $dbi);
  60.     $result = sql_query("select artid, secid, title, content, counter from ".$prefix."_seccont where secid=$secid $querylang", $dbi);
  61.     OpenTable();
  62.     $result2 = sql_query("select image from ".$prefix."_sections where secid=$secid", $dbi);
  63.     list($image) = sql_fetch_row($result2, $dbi);
  64.     echo "<center><img src=\"images/sections/$image\" border=\"0\" alt=\"\"><br><br>
  65.     <font class=\"option\">
  66.     "._THISISSEC." <b>$secname</b>.<br>"._FOLLOWINGART."</font></center><br><br>
  67.     <table border=\"0\" align=\"center\">";
  68.     while (list($artid, $secid, $title, $content, $counter) = sql_fetch_row($result, $dbi)) {
  69.         echo "
  70.         <tr><td align=\"left\" nowrap><font class=\"content\">
  71.         <li><a href=\"modules.php?name=$module_name&op=viewarticle&artid=$artid\">$title</a> ($counter "._READS.")
  72.         <a href=\"modules.php?name=$module_name&op=printpage&artid=$artid\"><img src=\"images/print.gif\" border=\"0\" Alt=\""._PRINTER."\" width=\"15\" height=\"11\"></a>
  73.         </td></tr>
  74.         ";
  75.     }
  76.     echo "</table>
  77.     <br><br><br><center>
  78.     [ <a href=\"modules.php?name=$module_name\">"._SECRETURN."</a> ]</center>";
  79.     CloseTable();
  80.     include ('footer.php');
  81. }
  82.  
  83. function viewarticle($artid, $page) {
  84.     global $prefix, $dbi, $module_name;
  85.     include("header.php");
  86.     if (($page == 1) OR ($page == "")) {
  87.     sql_query("update ".$prefix."_seccont set counter=counter+1 where artid='$artid'", $dbi);
  88.     }
  89.     $result = sql_query("select artid, secid, title, content, counter from ".$prefix."_seccont where artid=$artid", $dbi);
  90.     list($artid, $secid, $title, $content, $counter) = sql_fetch_row($result, $dbi);
  91.  
  92.     $result2 = sql_query("select secid, secname from ".$prefix."_sections where secid=$secid", $dbi);
  93.     list($secid, $secname) = sql_fetch_row($result2, $dbi);
  94.     $words = sizeof(explode(" ", $content));
  95.     echo "<center>";
  96.     OpenTable();
  97.     $contentpages = explode( "<!--pagebreak-->", $content );
  98.     $pageno = count($contentpages);
  99.     if ( $page=="" || $page < 1 )
  100.     $page = 1;
  101.     if ( $page > $pageno )
  102.     $page = $pageno;
  103.     $arrayelement = (int)$page;
  104.     $arrayelement --;
  105.     echo "<font class=\"option\"><b>$title</b></font><br><br><font class=\"content\">";
  106.     if ($pageno > 1) {
  107.     echo ""._PAGE.": $page/$pageno<br>";
  108.     }
  109.     echo "($words "._TOTALWORDS.")<br>"
  110.     ."($counter "._READS.")   "
  111.     ."<a href=\"modules.php?name=$module_name&op=printpage&artid=$artid\"><img src=\"images/print.gif\" border=\"0\" Alt=\""._PRINTER."\" width=\"15\" height=\"11\"></a>"
  112.     ."</font><br><br><br><br>";
  113.     echo "$contentpages[$arrayelement]";
  114.     if($page >= $pageno) {
  115.       $next_page = "";
  116.     } else {
  117.     $next_pagenumber = $page + 1;
  118.     if ($page != 1) {
  119.         $next_page .= "<img src=\"images/blackpixel.gif\" width=\"10\" height=\"2\" border=\"0\" alt=\"\">    ";
  120.     }
  121.     $next_page .= "<a href=\"modules.php?name=$module_name&op=viewarticle&artid=$artid&page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a href=\"modules.php?name=$module_name&op=viewarticle&artid=$artid&page=$next_pagenumber\"><img src=\"images/download/right.gif\" border=\"0\" alt=\""._NEXT."\"></a>";
  122.     }
  123.  
  124.     if($page <= 1) {
  125.     $previous_page = "";
  126.     } else {
  127.     $previous_pagenumber = $page - 1;
  128.     $previous_page = "<a href=\"modules.php?name=$module_name&op=viewarticle&artid=$artid&page=$previous_pagenumber\"><img src=\"images/download/left.gif\" border=\"0\" alt=\""._PREVIOUS."\"></a> <a href=\"modules.php?name=$module_name&op=viewarticle&artid=$artid&page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
  129.     }
  130.     echo "</td></tr>"
  131.     ."<tr><td align=\"center\">"
  132.     ."$previous_page    $next_page<br><br>"
  133.     ."[ <a href=\"modules.php?name=$module_name&op=listarticles&secid=$secid\">"._BACKTO." $secname</a> | "
  134.     ."<a href=\"modules.php?name=$module_name\">"._SECINDEX."</a> ]";
  135.     CloseTable();
  136.     echo "</center>";
  137.     include ('footer.php');
  138. }
  139.  
  140. function PrintSecPage($artid) {
  141.     global $site_logo, $nukeurl, $sitename, $datetime, $prefix, $dbi, $module_name;
  142.     $result = sql_query("select title, content from ".$prefix."_seccont where artid=$artid", $dbi);
  143.     list($title, $content) = sql_fetch_row($result, $dbi);
  144.     echo "
  145.     <html>
  146.     <head><title>$sitename</title></head>
  147.     <body bgcolor=\"#FFFFFF\" text=\"#000000\">
  148.     <table border=\"0\"><tr><td>
  149.     <table border=\"0\" width=\"640\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#000000\"><tr><td>
  150.     <table border=\"0\" width=\"640\" cellpadding=\"20\" cellspacing=\"1\" bgcolor=\"#FFFFFF\"><tr><td>
  151.     <center>
  152.     <img src=\"images/$site_logo\" border=\"0\" alt=\"\"><br><br>
  153.     <font class=\"content\">
  154.     <b>$title</b></font><br>
  155.     </center><font class=\"content\">
  156.     $content<br><br>";
  157.     echo "</td></tr></table></td></tr></table>
  158.     <br><br><center>
  159.     <font class=\"content\">
  160.     "._COMESFROM." $sitename<br>
  161.     <a href=\"$nukeurl\">$nukeurl</a><br><br>
  162.     "._THEURL."<br>
  163.     <a href=\"$nukeurl/modules.php?name=$module_name&op=viewarticle&artid=$artid\">$nukeurl/modules.php?name=$module_name&op=viewarticle&artid=$artid</a></font></center>
  164.     </td></tr></table>
  165.     </body>
  166.     </html>
  167.     ";
  168. }
  169.  
  170. switch($op) {
  171.  
  172.     case "viewarticle":
  173.     viewarticle($artid, $page);
  174.     break;
  175.  
  176.     case "listarticles":
  177.     listarticles($secid);
  178.     break;
  179.  
  180.     case "printpage":
  181.     PrintSecPage($artid);
  182.     break;
  183.  
  184.     default:
  185.     listsections();
  186.     break;
  187.  
  188. }
  189.  
  190. ?>