home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / modules / Content / index.php < prev   
PHP Script  |  2004-01-10  |  11KB  |  250 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", $_SERVER['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, $db, $sitename, $admin, $module_name, $locale;
  27.     include("header.php");
  28.     OpenTable();
  29.     $pid = intval($pid);
  30.     $mypage = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_pages WHERE pid='$pid'"));
  31.     $myactive = intval($mypage['active']);
  32.     $mytitle = $mypage['title'];
  33.     $mysubtitle = $mypage['subtitle'];
  34.     $mypage_header = $mypage['page_header'];
  35.     $mytext = $mypage['text'];
  36.     $mypage_footer = $mypage['page_footer'];
  37.     $mysignature = $mypage['signature'];
  38.     $mydate = $mypage['date'];
  39.     $mycounter = $mypage['counter'];
  40.     if (($myactive == 0) AND (!is_admin($admin))) {
  41.     echo "Sorry... This page doesn't exist.";
  42.     } else {
  43.     $db->sql_query("UPDATE ".$prefix."_pages SET counter=counter+1 WHERE pid='$pid'");
  44.     $date = explode(" ", $mydate);
  45.  
  46.     $new_date_by_locale = strtotime($date[0]); //nacteme do timestamp mesic slovne
  47.     setlocale(LC_TIME, $locale); //nastavime locale
  48.     $new_date_by_locale = strftime(translate(linksdatestring), $new_date_by_locale);
  49.     $date[0] = $new_date_by_locale;
  50.     setlocale(LC_TIME, ''); //nastavime zpet locale na vychozi systemovou hodnotu
  51.  
  52.     echo "<font class=\"title\">$mytitle</font><br>"
  53.         ."<font class=\"content\">$mysubtitle<br><br><br><br>";
  54.     $contentpages = explode( "<!--pagebreak-->", $mytext );
  55.     $pageno = count($contentpages);
  56.     if ( $page=="" || $page < 1 )
  57.         $page = 1;
  58.     if ( $page > $pageno )
  59.         $page = $pageno;
  60.     $arrayelement = (int)$page;
  61.     $arrayelement --;
  62.     if ($pageno > 1) {
  63.         echo ""._PAGE.": $page/$pageno<br>";
  64.     }
  65.     if ($page == 1) {
  66.         echo "<p align=\"justify\">".nl2br($mypage_header)."</p><br>";
  67.     }
  68.     echo "<p align=\"justify\">$contentpages[$arrayelement]</p>";
  69.     if($page >= $pageno) {
  70.         $next_page = "";
  71.     } else {
  72.         $next_pagenumber = $page + 1;
  73.         if ($page != 1) {
  74.         $next_page .= "- ";
  75.         }
  76.         $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/right.gif\" border=\"0\" alt=\""._NEXT."\" title=\""._NEXT."\"></a>";
  77.     }
  78.     if ($page == $pageno) {
  79.         echo "<br><p align=\"justify\">".nl2br($mypage_footer)."</p><br><br>";
  80.     }
  81.     if($page <= 1) {
  82.         $previous_page = "";
  83.     } else {
  84.         $previous_pagenumber = $page - 1;
  85.         $previous_page = "<a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$previous_pagenumber\"><img src=\"images/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>";
  86.     }
  87.     echo "<br><br><br><center>$previous_page $next_page</center><br><br>";
  88.     if ($page == $pageno) {
  89.         echo "<p align=\"right\">".nl2br($mysignature)."</p>"
  90.         ."<p align=\"right\">"._COPYRIGHT." $sitename "._COPYRIGHT2."</p>"
  91.         ."<p align=\"right\"><font class=\"tiny\">"._PUBLISHEDON.": $date[0] ($mycounter "._READS.")</font></p>"
  92.         ."<center>"._GOBACK."</center>";
  93.     }
  94.     }
  95.     CloseTable();
  96.     include("footer.php");
  97. }
  98.  
  99. function list_pages() {
  100.     global $prefix, $db, $sitename, $admin, $multilingual, $module_name;
  101.     include("header.php");
  102.     title("$sitename: "._PAGESLIST."");
  103.     OpenTable();
  104.     echo "<center><font class=\"content\">"._LISTOFCONTENT." $sitename:</center><br><br>";
  105.     $result = $db->sql_query("SELECT * FROM ".$prefix."_pages_categories");
  106.     $numrows = $db->sql_numrows($result);
  107.     $numrows2 = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_pages WHERE cid!='0' AND active='1'"));
  108.     if ($numrows > 0 AND $numrows2 > 0) {
  109.     echo "<center>"._CONTENTCATEGORIES."</center><br><br>"
  110.             ."<table border=\"1\" align=\"center\" width=\"95%\">";
  111.     while ($row = $db->sql_fetchrow($result)) {
  112.         $cid = intval($row['cid']);
  113.         $title = $row['title'];
  114.         $description = $row['description'];
  115.         $numrows3 = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_pages WHERE cid='$cid'"));
  116.         if ($numrows3 > 0) {
  117.         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>";
  118.         }
  119.     }
  120.     echo "</td></tr></table><br><br>"
  121.         ."<center>"._NONCLASSCONT."</center><br><br>";
  122.     }
  123.     $result4 = $db->sql_query("SELECT pid, title, subtitle, clanguage FROM ".$prefix."_pages WHERE active='1' AND cid='0' ORDER BY date");
  124.     echo "<blockquote>";
  125.     while ($row4 = $db->sql_fetchrow($result4)) {
  126.     $pid = intval($row4['pid']);
  127.     $title = $row4['title'];
  128.     $subtitle = $row4['subtitle'];
  129.     $clanguage = $row4['clanguage'];
  130.     if ($multilingual == 1) {
  131.         $the_lang = "<img src=\"images/language/flag-".$clanguage.".png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  132.     } else {
  133.         $the_lang = "";
  134.     }
  135.         if ($subtitle != "") {
  136.         $subtitle = " ($subtitle)";
  137.     } else {
  138.             $subtitle = "";
  139.     }
  140.     if (is_admin($admin)) {
  141.         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>";
  142.     } else {
  143.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle<br>";
  144.     }
  145.     }
  146.     echo "</blockquote>";
  147.     if (is_admin($admin)) {
  148.     $result5 = $db->sql_query("SELECT pid, cid, title, subtitle, clanguage FROM ".$prefix."_pages WHERE active='0' ORDER BY date");
  149.     echo "<br><br><center><b>"._YOURADMINLIST."</b></center><br><br>";
  150.     echo "<blockquote>";
  151.     while ($row5 = $db->sql_fetchrow($result5)) {
  152.         $pid = intval($row5['pid']);
  153.         $cid = intval($row5['cid']);
  154.         $title = $row5['title'];
  155.         $subtitle = $row5['subtitle'];
  156.         $clanguage = $row5['clanguage'];
  157.         if ($multilingual == 1) {
  158.         $the_lang = "<img src=\"images/language/flag-".$clanguage.".png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  159.         } else {
  160.         $the_lang = "";
  161.         }
  162.             if ($subtitle != "") {
  163.             $subtitle = " ($subtitle) ";
  164.         } else {
  165.                 $subtitle = " ";
  166.         }
  167.         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>";
  168.     }
  169.     echo "</blockquote>";
  170.     }
  171.     CloseTable();
  172.     include("footer.php");
  173. }
  174.  
  175. function list_pages_categories($cid) {
  176.     global $prefix, $db, $sitename, $admin, $multilingual, $module_name;
  177.     include("header.php");
  178.     title("$sitename: "._PAGESLIST."");
  179.     OpenTable();
  180.     echo "<center><font class=\"content\">"._LISTOFCONTENT." $sitename:</center><br><br>";
  181.     $cid = intval($cid);
  182.     $result = $db->sql_query("SELECT pid, title, subtitle, clanguage FROM ".$prefix."_pages WHERE active='1' AND cid='$cid' ORDER BY date");
  183.     echo "<blockquote>";
  184.     while ($row = $db->sql_fetchrow($result)) {
  185.     $pid = intval($row['pid']);
  186.     $title = $row['title'];
  187.     $subtitle = $row['subtitle'];
  188.     $clanguage = $row['clanguage'];
  189.     if ($multilingual == 1) {
  190.         $the_lang = "<img src=\"images/language/flag-".$clanguage.".png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  191.     } else {
  192.         $the_lang = "";
  193.     }
  194.         if ($subtitle != "") {
  195.         $subtitle = " ($subtitle)";
  196.     } else {
  197.             $subtitle = "";
  198.     }
  199.     if (is_admin($admin)) {
  200.         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>";
  201.     } else {
  202.         echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\">$title</a> $subtitle<br>";
  203.     }
  204.     }
  205.     echo "</blockquote>";
  206.     if (is_admin($admin)) {
  207.     $result2 = $db->sql_query("SELECT pid, title, subtitle, clanguage FROM ".$prefix."_pages WHERE active='0' AND cid='$cid' ORDER BY date");
  208.     echo "<br><br><center><b>"._YOURADMINLIST."</b></center><br><br>";
  209.     echo "<blockquote>";
  210.     while ($row2 = $db->sql_fetchrow($result2)) {
  211.         $pid = intval($row2['pid']);
  212.         $title = $row2['title'];
  213.         $subtitle = $row2['subtitle'];
  214.         $clanguage = $row2['clanguage'];
  215.         if ($multilingual == 1) {
  216.         $the_lang = "<img src=\"images/language/flag-".$clanguage.".png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
  217.         } else {
  218.         $the_lang = "";
  219.         }
  220.             if ($subtitle != "") {
  221.             $subtitle = " ($subtitle) ";
  222.         } else {
  223.                 $subtitle = " ";
  224.         }
  225.         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>";
  226.     }
  227.     echo "</blockquote>";
  228.     }
  229.     echo "<center>"._GOBACK."</center>";
  230.     CloseTable();
  231.     include("footer.php");
  232. }
  233.  
  234. switch($pa) {
  235.  
  236.     case "showpage":
  237.     showpage($pid, $page);
  238.     break;
  239.     
  240.     case "list_pages_categories":
  241.     list_pages_categories($cid);
  242.     break;
  243.     
  244.     default:
  245.     list_pages();
  246.     break;
  247.  
  248. }
  249.  
  250. ?>