home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / blocks / block-Modules.php < prev    next >
PHP Script  |  2004-01-10  |  5KB  |  136 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", $_SERVER['PHP_SELF'])) {
  16.     Header("Location: index.php");
  17.     die();
  18. }
  19.  
  20. global $prefix, $db, $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.     $row = $db->sql_fetchrow($db->sql_query("SELECT main_module FROM ".$prefix."_main"));
  33.     $main_module = $row['main_module'];
  34.  
  35.     /* If the module doesn't exist, it will be removed from the database automaticaly */
  36.     $result2 = $db->sql_query("SELECT title FROM " . $prefix . "_modules");
  37.     while ($row2 = $db->sql_fetchrow($result2)) {
  38.     $title = stripslashes($row2['title']);
  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.         $db->sql_query("DELETE FROM ".$prefix."_modules WHERE title='$title'");
  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.     $result3 = $db->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");
  56.     while ($row3 = $db->sql_fetchrow($result3)) {
  57.     $m_title = stripslashes($row3['title']);
  58.     $custom_title = $row3['custom_title'];
  59.     $view = intval($row3['view']);
  60.     $m_title2 = ereg_replace("_", " ", $m_title);
  61.     if ($custom_title != "") {
  62.         $m_title2 = $custom_title;
  63.     }
  64.     if ($m_title != $main_module) {
  65.         if ((is_admin($admin) AND $view == 2) OR $view != 2) {
  66.         $content .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$m_title\">$m_title2</a><br>\n";
  67.         }
  68.     }
  69.     }
  70.  
  71.     /* If you're Admin you and only you can see Inactive modules and test it */
  72.     /* If you copied a new module is the /modules/ directory, it will be added to the database */
  73.     
  74.     if (is_admin($admin)) {
  75.     $handle=opendir('modules');
  76.     while ($file = readdir($handle)) {
  77.         if ( (!ereg("[.]",$file)) ) {
  78.         $modlist .= "$file ";
  79.         }
  80.     }
  81.     closedir($handle);
  82.     $modlist = explode(" ", $modlist);
  83.     sort($modlist);
  84.     for ($i=0; $i < sizeof($modlist); $i++) {
  85.         if($modlist[$i] != "") {
  86.         $row4 = $db->sql_fetchrow($db->sql_query("SELECT mid FROM ".$prefix."_modules WHERE title='$modlist[$i]'"));
  87.         $mid = intval($row4['mid']);
  88.         $mod_uname = ereg_replace("_", " ", $modlist[$i]);
  89.         if ($mid == "") {
  90.             $db->sql_query("INSERT INTO ".$prefix."_modules VALUES (NULL, '$modlist[$i]', '$mod_uname', '0', '0', '1')");
  91.         }
  92.         }
  93.     }
  94.     $content .= "<br><center><b>"._INVISIBLEMODULES."</b><br>";
  95.     $content .= "<font class=\"tiny\">"._ACTIVEBUTNOTSEE."</font></center><br>";
  96.     $result5 = $db->sql_query("SELECT title, custom_title FROM ".$prefix."_modules WHERE active='1' AND inmenu='0' ORDER BY title ASC");
  97.     while ($row5 = $db->sql_fetchrow($result5)) {
  98.         $mn_title = stripslashes($row5['title']);
  99.         $custom_title = $row5['custom_title'];
  100.         $mn_title2 = ereg_replace("_", " ", $mn_title);
  101.         if ($custom_title != "") {
  102.         $mn_title2 = $custom_title;
  103.         }
  104.         if ($mn_title2 != "") {
  105.         $content .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$mn_title\">$mn_title2</a><br>\n";
  106.         $dummy = 1;
  107.         } else {
  108.         $a = 1;
  109.         }
  110.     }
  111.     if ($a == 1 AND $dummy != 1) {
  112.             $content .= "<strong><big>·</big></strong> <i>"._NONE."</i><br>\n";
  113.     }
  114.     $content .= "<br><center><b>"._NOACTIVEMODULES."</b><br>";
  115.     $content .= "<font class=\"tiny\">"._FORADMINTESTS."</font></center><br>";
  116.     $result6 = $db->sql_query("SELECT title, custom_title FROM ".$prefix."_modules WHERE active='0' ORDER BY title ASC");
  117.     while ($row6 = $db->sql_fetchrow($result6)) {
  118.         $mn_title = stripslashes($row6['title']);
  119.         $custom_title = $row6['custom_title'];
  120.         $mn_title2 = ereg_replace("_", " ", $mn_title);
  121.         if ($custom_title != "") {
  122.         $mn_title2 = $custom_title;
  123.         }
  124.         if ($mn_title2 != "") {
  125.         $content .= "<strong><big>·</big></strong> <a href=\"modules.php?name=$mn_title\">$mn_title2</a><br>\n";
  126.         $dummy = 1;
  127.         } else {
  128.         $a = 1;
  129.         }
  130.     }
  131.     if ($a == 1 AND $dummy != 1) {
  132.             $content .= "<strong><big>·</big></strong> <i>"._NONE."</i><br>\n";
  133.     }
  134.     }
  135.  
  136. ?>