home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / blocks / block-modules.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  5.0 KB  |  128 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("block-Modules.php", $PHP_SELF)) {
  16.     Header("Location: index.php");
  17.     die();
  18. }
  19.  
  20. global $prefix, $dbi, $admin;
  21.  
  22.     $ThemeSel = get_theme();
  23.     if (file_exists("themes/$ThemeSel/module.php")) {
  24.     include("themes/$ThemeSel/module.php");
  25.     if (is_active("$default_module") AND file_exists("modules/$default_module/index.php")) {
  26.         $def_module = $default_module;
  27.     } else {
  28.         $def_module = "";
  29.     }
  30.     }
  31.  
  32.     $result = sql_query("select main_module from ".$prefix."_main", $dbi);
  33.     list($main_module) = sql_fetch_row($result, $dbi);
  34.     
  35.     /* If the module doesn't exist, it will be removed from the database automaticaly */
  36.  
  37.     $result = sql_query("select title from ".$prefix."_modules", $dbi);
  38.     while (list($title) = sql_fetch_row($result, $dbi)) {
  39.     $a = 0;
  40.     $handle=opendir('modules');
  41.     while ($file = readdir($handle)) {
  42.             if ($file == $title) {
  43.         $a = 1;
  44.         }
  45.     }
  46.     closedir($handle);
  47.     if ($a == 0) {
  48.             sql_query("delete from ".$prefix."_modules where title='$title'", $dbi);
  49.     }
  50.     }
  51.  
  52.     /* Now we make the Modules block with the correspondent links */
  53.  
  54.     $content .= "<strong><big>·</big></strong> <a href=\"index.php\">"._HOME."</a><br>\n";
  55.     $result = sql_query("SELECT title, custom_title, view FROM ".$prefix."_modules WHERE active='1' AND title!='$def_module' AND inmenu='1' ORDER BY custom_title ASC", $dbi);
  56.     while(list($m_title, $custom_title, $view) = sql_fetch_row($result, $dbi)) {
  57.     $m_title2 = ereg_replace("_", " ", $m_title);
  58.     if ($custom_title != "") {
  59.         $m_title2 = $custom_title;
  60.     }
  61.     if ($m_title != $main_module) {
  62.         if ((is_admin($admin) AND $view == 2) OR $view != 2) {
  63.         $content .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$m_title\">$m_title2</a><br>\n";
  64.         }
  65.     }
  66.     }
  67.  
  68.     /* If you're Admin you and only you can see Inactive modules and test it */
  69.     /* If you copied a new module is the /modules/ directory, it will be added to the database */
  70.     
  71.     if (is_admin($admin)) {
  72.     $handle=opendir('modules');
  73.     while ($file = readdir($handle)) {
  74.         if ( (!ereg("[.]",$file)) ) {
  75.         $modlist .= "$file ";
  76.         }
  77.     }
  78.     closedir($handle);
  79.     $modlist = explode(" ", $modlist);
  80.     sort($modlist);
  81.     for ($i=0; $i < sizeof($modlist); $i++) {
  82.         if($modlist[$i] != "") {
  83.         $result = sql_query("select mid from ".$prefix."_modules where title='$modlist[$i]'", $dbi);
  84.         list ($mid) = sql_fetch_row($result, $dbi);
  85.         if ($mid == "") {
  86.             sql_query("insert into ".$prefix."_modules values (NULL, '$modlist[$i]', '$modlist[$i]', '0', '0', '1')", $dbi);
  87.         }
  88.         }
  89.     }
  90.     $content .= "<br><center><b>"._INVISIBLEMODULES."</b><br>";
  91.     $content .= "<font class=\"tiny\">"._ACTIVEBUTNOTSEE."</font></center><br>";
  92.     $result = sql_query("select title, custom_title from ".$prefix."_modules where active='1' AND inmenu='0' ORDER BY title ASC", $dbi);
  93.     while(list($mn_title, $custom_title) = sql_fetch_row($result, $dbi)) {
  94.         $mn_title2 = ereg_replace("_", " ", $mn_title);
  95.         if ($custom_title != "") {
  96.         $mn_title2 = $custom_title;
  97.         }
  98.         if ($mn_title2 != "") {
  99.         $content .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$mn_title\">$mn_title2</a><br>\n";
  100.         $dummy = 1;
  101.         } else {
  102.         $a = 1;
  103.         }
  104.     }
  105.     if ($a == 1 AND $dummy != 1) {
  106.             $content .= "<strong><big>·</big></strong> <i>"._NONE."</i><br>\n";
  107.     }
  108.     $content .= "<br><center><b>"._NOACTIVEMODULES."</b><br>";
  109.     $content .= "<font class=\"tiny\">"._FORADMINTESTS."</font></center><br>";
  110.     $result = sql_query("select title, custom_title from ".$prefix."_modules where active='0' ORDER BY title ASC", $dbi);
  111.     while(list($mn_title, $custom_title) = sql_fetch_row($result, $dbi)) {
  112.         $mn_title2 = ereg_replace("_", " ", $mn_title);
  113.         if ($custom_title != "") {
  114.         $mn_title2 = $custom_title;
  115.         }
  116.         if ($mn_title2 != "") {
  117.         $content .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$mn_title\">$mn_title2</a><br>\n";
  118.         $dummy = 1;
  119.         } else {
  120.         $a = 1;
  121.         }
  122.     }
  123.     if ($a == 1 AND $dummy != 1) {
  124.             $content .= "<strong><big>·</big></strong> <i>"._NONE."</i><br>\n";
  125.     }
  126.     }
  127.  
  128. ?>