home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / install / index.php next >
Encoding:
PHP Script  |  2008-01-29  |  64.0 KB  |  1,309 lines

  1. <?php
  2. // $Id: index.php 1283 2008-01-29 04:38:14Z phppp $
  3. //  ------------------------------------------------------------------------ //
  4. //                XOOPS - PHP Content Management System                      //
  5. //                    Copyright (c) 2000 XOOPS.org                           //
  6. //                       <http://www.xoops.org/>                             //
  7. //  ------------------------------------------------------------------------ //
  8. //  This program is free software; you can redistribute it and/or modify     //
  9. //  it under the terms of the GNU General Public License as published by     //
  10. //  the Free Software Foundation; either version 2 of the License, or        //
  11. //  (at your option) any later version.                                      //
  12. //                                                                           //
  13. //  You may not change or alter any portion of this comment or credits       //
  14. //  of supporting developers from this source code or any supporting         //
  15. //  source code which is considered copyrighted (c) material of the          //
  16. //  original comment or credit authors.                                      //
  17. //                                                                           //
  18. //  This program is distributed in the hope that it will be useful,          //
  19. //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
  20. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
  21. //  GNU General Public License for more details.                             //
  22. //                                                                           //
  23. //  You should have received a copy of the GNU General Public License        //
  24. //  along with this program; if not, write to the Free Software              //
  25. //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
  26. //  ------------------------------------------------------------------------ //
  27.  
  28. error_reporting (0);
  29.  
  30. include_once './passwd.php';
  31. if(INSTALL_USER != '' || INSTALL_PASSWD != ''){
  32.     if (!isset($_SERVER['PHP_AUTH_USER'])) {
  33.         header('WWW-Authenticate: Basic realm="XOOPS Installer"');
  34.         header('HTTP/1.0 401 Unauthorized');
  35.         echo 'You can not access this XOOPS installer.';
  36.         exit;
  37.     } else {
  38.         if(INSTALL_USER != '' && $_SERVER['PHP_AUTH_USER'] != INSTALL_USER){
  39.             header('HTTP/1.0 401 Unauthorized');
  40.             echo 'You can not access this XOOPS installer.';
  41.             exit;
  42.         }
  43.         if(INSTALL_PASSWD != $_SERVER['PHP_AUTH_PW']){
  44.             header('HTTP/1.0 401 Unauthorized');
  45.             echo 'You can not access this XOOPS installer.';
  46.             exit;
  47.         }
  48.     }
  49. }
  50.  
  51. include_once './class/textsanitizer.php';
  52. $myts =& TextSanitizer::getInstance();
  53.  
  54. if ( isset($_POST) ) {
  55.     foreach ($_POST as $k=>$v) {
  56.         if (!is_array($v)) {
  57.             $$k = $myts->stripSlashesGPC($v);
  58.         }
  59.     }
  60. }
  61.  
  62. $language = 'english';
  63. if ( !empty($_POST['lang']) ) {
  64.     $language = preg_replace("/[^a-z0-9_\-]/i", "", $_POST['lang']);
  65. } else {
  66.     if (isset($_COOKIE['install_lang'])) {
  67.         $language = preg_replace("/[^a-z0-9_\-]/i", "", $_COOKIE['install_lang']);
  68.     } else {
  69.         //$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'ja,en-us;q=0.7,zh-TW;q=0.6';
  70.         if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
  71.             $accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
  72.             $language_array = array('en' => 'english', 'ja' => 'japanese', 'fr' => 'french', 'de' => 'german', 'nl' => 'dutch', 'es' => 'spanish', 'tw' => 'tchinese', 'cn' => 'schinese', 'ro' => 'romanian');
  73.             foreach ($accept_langs as $al) {
  74.                 $al = strtolower($al);
  75.                 $al_len = strlen($al);
  76.                 if ($al_len > 2) {
  77.                     if (preg_match("/([a-z]{2});q=[0-9.]+$/", $al, $al_match)) {
  78.                         $al = $al_match[1];
  79.                     } else {
  80.                         continue;
  81.                     }
  82.                 }
  83.                 if (isset($language_array[$al])) {
  84.                     $language = $language_array[$al];
  85.                     break;
  86.                 }
  87.             }
  88.         }
  89.     }
  90. }
  91.  
  92. if ( file_exists("./language/".$language."/install.php") ) {
  93.     include_once "./language/".$language."/install.php";
  94. } elseif ( file_exists("./language/english/install.php") ) {
  95.     include_once "./language/english/install.php";
  96.     $language = 'english';
  97. } else {
  98.     echo 'no language file.';
  99.     exit();
  100. }
  101. setcookie("install_lang", $language);
  102.  
  103. //include './include/viewerrors.php';
  104. //include './include/functions.php';
  105.  
  106. define('_OKIMG',"<img src='img/yes.gif' width='6' height='12' border='0' alt='' /> ");
  107. define('_NGIMG',"<img src='img/no.gif' width='6' height='12' border='0' alt='' /> ");
  108.  
  109. $b_back = '';
  110. $b_reload = '';
  111. $b_next = '';
  112.  
  113. // options for mainfile.php
  114. $xoopsOption['nocommon'] = true;
  115. define('XOOPS_INSTALL', 1);
  116.  
  117. if(!empty($_POST['op']))
  118.     $op = $_POST['op'];
  119. elseif(!empty($_GET['op']))
  120.     $op = $_GET['op'];
  121. else
  122.     $op = '';
  123.  
  124. ///// main
  125. switch ($op) {
  126.  
  127. default:
  128. case "langselect":
  129.     $title = _INSTALL_L0;
  130.     if (!defined('_INSTALL_L128')) {
  131.         define('_INSTALL_L128', 'Choose language to be used for the installation process');
  132.     }
  133.     $content = "<p>"._INSTALL_L128."</p>"
  134.               ."<select name='lang'>";
  135.  
  136.     $langarr = getDirList("./language/");
  137.     foreach ($langarr as $lang) {
  138.         $content .= "<option value='".$lang."'";
  139.         if (strtolower($lang) == $language) {
  140.             $content .= ' selected="selected"';
  141.         }
  142.         $content .= ">".$lang."</option>";
  143.     }
  144.     $content .= "</select>";
  145.  
  146.     $b_next = array('start', _INSTALL_L80 );
  147.     include 'install_tpl.php';
  148.     break;
  149.  
  150. case "start":
  151.     $title = _INSTALL_L0;
  152.     $content = "<table width='80%' align='center'><tr><td align='left'>\n";
  153.     include './language/'.$language.'/welcome.php';
  154.     $content .= "</td></tr></table>\n";
  155.     $b_next = array('modcheck', _INSTALL_L81 );
  156.     include 'install_tpl.php';
  157.     break;
  158.  
  159. case "modcheck":
  160.     $writeok = array("uploads/", "cache/", "templates_c/", "mainfile.php");
  161.     $title = _INSTALL_L82;
  162.     $content = "<table align='center'><tr><td align='left'>\n";
  163.     $error = false;
  164.     foreach ($writeok as $wok) {
  165.         if (!is_dir("../".$wok)) {
  166.             if ( file_exists("../".$wok) ) {
  167.                 @chmod("../".$wok, 0666);
  168.                 if (! is_writeable("../".$wok)) {
  169.                     $content .= _NGIMG.sprintf(_INSTALL_L83, $wok)."<br />";
  170.                     $error = true;
  171.                 }else{
  172.                     $content .= _OKIMG.sprintf(_INSTALL_L84, $wok)."<br />";
  173.                 }
  174.             }
  175.         } else {
  176.             @chmod("../".$wok, 0777);
  177.             if (! is_writeable("../".$wok)) {
  178.                 $content .= _NGIMG.sprintf(_INSTALL_L85, $wok)."<br />";
  179.                 $error = true;
  180.             }else{
  181.                 $content .= _OKIMG.sprintf(_INSTALL_L86, $wok)."<br />";
  182.             }
  183.         }
  184.     }
  185.     $content .= "</td></tr></table>\n";
  186.  
  187.     if(! $error) {
  188.         $content .= "<p>"._INSTALL_L87."</p>";
  189.         $b_next = array('dbform', _INSTALL_L89 );
  190.     }else{
  191.         $content .= "<p>"._INSTALL_L46."</p>";
  192.         $b_reload = true;
  193.     }
  194.  
  195.     include 'install_tpl.php';
  196.     break;
  197.  
  198. case "dbform":
  199.     include_once '../mainfile.php';
  200.     include_once 'class/settingmanager.php';
  201.     $sm = new setting_manager();
  202.     $sm->readConstant();
  203.     $content = $sm->editform();
  204.     $title = _INSTALL_L90;
  205.     $b_next = array('dbconfirm',_INSTALL_L91);
  206.     include 'install_tpl.php';
  207.     break;
  208.  
  209. case "dbconfirm":
  210.     include_once 'class/settingmanager.php';
  211.     $sm = new setting_manager(true);
  212.  
  213.     $content = $sm->checkData();
  214.     if (!empty($content)) {
  215.         $content .= $sm->editform();
  216.         $b_next = array('dbconfirm',_INSTALL_L91);
  217.         include 'install_tpl.php';
  218.         break;
  219.     }
  220.  
  221.     $title = _INSTALL_L53;
  222.     $content = $sm->confirmForm();
  223.     $b_next = array('dbsave',_INSTALL_L92 );
  224.     $b_back = array('', _INSTALL_L93 );
  225.     include 'install_tpl.php';
  226.     break;
  227.  
  228. case "dbsave":
  229.     include_once "./class/mainfilemanager.php";
  230.     $title = _INSTALL_L88;
  231.     $mm = new mainfile_manager("../mainfile.php");
  232.  
  233.     $ret = $mm->copyDistFile();
  234.     if(! $ret){
  235.         $content = _INSTALL_L60;
  236.         include 'install_tpl.php';
  237.         exit();
  238.     }
  239.  
  240.     $mm->setRewrite('XOOPS_ROOT_PATH', trim($myts->stripSlashesGPC($_POST['root_path'])));
  241.     $mm->setRewrite('XOOPS_URL', trim($myts->stripSlashesGPC($_POST['xoops_url'])));
  242.     $mm->setRewrite('XOOPS_DB_TYPE', trim($myts->stripSlashesGPC($_POST['database'])));
  243.     $mm->setRewrite('XOOPS_DB_PREFIX', trim($myts->stripSlashesGPC($_POST['prefix'])));
  244.     $mm->setRewrite('XOOPS_DB_HOST', trim($myts->stripSlashesGPC($_POST['dbhost'])));
  245.     $mm->setRewrite('XOOPS_DB_USER', trim($myts->stripSlashesGPC($_POST['dbuname'])));
  246.     $mm->setRewrite('XOOPS_DB_PASS', trim($myts->stripSlashesGPC($_POST['dbpass'])));
  247.     $mm->setRewrite('XOOPS_DB_NAME', trim($myts->stripSlashesGPC($_POST['dbname'])));
  248.     $mm->setRewrite('XOOPS_DB_PCONNECT', intval($_POST['db_pconnect']));
  249.     $mm->setRewrite('XOOPS_GROUP_ADMIN', 1);
  250.     $mm->setRewrite('XOOPS_GROUP_USERS', 2);
  251.     $mm->setRewrite('XOOPS_GROUP_ANONYMOUS', 3);
  252.  
  253.     // Check if XOOPS_CHECK_PATH should be initially set or not
  254.     $xoopsPathTrans = isset($_SERVER['PATH_TRANSLATED']) ? $_SERVER['PATH_TRANSLATED'] :  $_SERVER['SCRIPT_FILENAME'];
  255.     if ( DIRECTORY_SEPARATOR != '/' ) {
  256.          // IIS6 doubles the \ chars
  257.         $xoopsPathTrans = str_replace( strpos( $xoopsPathTrans, '\\\\', 2 ) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $xoopsPathTrans);
  258.     }
  259.     $mm->setRewrite('XOOPS_CHECK_PATH', strcasecmp( substr($xoopsPathTrans, 0, strlen($myts->stripSlashesGPC($_POST['root_path']))), $_POST['root_path']) ? 0 : 1 );
  260.  
  261.     $ret = $mm->doRewrite();
  262.     if(! $ret){
  263.         $content = _INSTALL_L60;
  264.         include 'install_tpl.php';
  265.         exit();
  266.     }
  267.  
  268.     $content = $mm->report();
  269.     $content .= "<p>"._INSTALL_L62."</p>\n";
  270.     $b_next = array('mainfile', _INSTALL_L94 );
  271.     include 'install_tpl.php';
  272.     break;
  273.  
  274. case "mainfile":
  275.     // checking XOOPS_ROOT_PATH and XOOPS_URL
  276.     include_once "../mainfile.php";
  277.     $title = _INSTALL_L94;
  278.     $content = "<table align='center'><tr><td align='left'>\n";
  279.  
  280.     $detected = str_replace("\\", "/", getcwd()); // "
  281.     $detected = str_replace("/install", "", $detected);
  282.     if ( substr($detected, -1) == "/" ) {
  283.         $detected = substr($detected, 0, -1);
  284.     }
  285.  
  286.     if (empty($detected)){
  287.         $content .= _NGIMG._INSTALL_L95.'<br />';
  288.     }
  289.     elseif ( XOOPS_ROOT_PATH != $detected ) {
  290.         $content .= _NGIMG.sprintf(_INSTALL_L96,$detected). '<br />';
  291.     }else {
  292.         $content .= _OKIMG._INSTALL_L97.'<br />';
  293.     }
  294.  
  295.     if(!is_dir(XOOPS_ROOT_PATH)){
  296.         $content .= _NGIMG._INSTALL_L99.'<br />';
  297.     }
  298.  
  299.     if(preg_match('/^http[s]?:\/\/(.*)[^\/]+$/i',XOOPS_URL)){
  300.         $content .= _OKIMG._INSTALL_L100.'<br />';
  301.     }else{
  302.         $content .= _NGIMG._INSTALL_L101.'<br />';
  303.     }
  304.  
  305.     $content .= "<br /></td></tr></table>\n";
  306.  
  307.     $content .= "<table align='center'><tr><td align='left'>\n";
  308.     $content .= _INSTALL_L11."<b>".XOOPS_ROOT_PATH."</b><br />";
  309.     $content .= _INSTALL_L12."<b>".XOOPS_URL."</b><br />";
  310.     $content .= "</td></tr></table>\n";
  311.     $content .= "<p align='center'>"._INSTALL_L13."</p>\n";
  312.  
  313.     $b_next = array('initial', _INSTALL_L102 );
  314.     $b_back = array('start', _INSTALL_L103 );
  315.     $b_reload = true;
  316.  
  317.     include 'install_tpl.php';
  318.     //mainfile_settings();
  319.     break;
  320.  
  321. case "initial":
  322.     // confirm database setting
  323.     include_once "../mainfile.php";
  324.     $content = "<table align=\"center\">\n";
  325.     $content .= "<tr><td align='center'>";
  326.     $content .= "<table align=\"center\">\n";
  327.     $content .= "<tr><td>"._INSTALL_L27."  </td><td><b>".XOOPS_DB_HOST."</b></td></tr>\n";
  328.     $content .= "<tr><td>"._INSTALL_L28."  </td><td><b>".XOOPS_DB_USER."</b></td></tr>\n";
  329.     $content .= "<tr><td>"._INSTALL_L29."  </td><td><b>".XOOPS_DB_NAME."</b></td></tr>\n";
  330.     $content .= "<tr><td>"._INSTALL_L30."  </td><td><b>".XOOPS_DB_PREFIX."</b></td></tr>\n";
  331.     $content .= "</table><br />\n";
  332.     $content .= "</td></tr><tr><td align=\"center\">";
  333.     $content .= _INSTALL_L13."<br /><br />\n";
  334.     $content .= "</td></tr></table>\n";
  335.     $b_next = array('checkDB', _INSTALL_L104);
  336.     $b_back = array('start', _INSTALL_L103);
  337.     $b_reload = true;
  338.     $title = _INSTALL_L102;
  339.     include 'install_tpl.php';
  340.     break;
  341.  
  342. case "checkDB":
  343.     include_once "../mainfile.php";
  344.     include_once './class/dbmanager.php';
  345.     $dbm = new db_manager;
  346.     $title = _INSTALL_L104;
  347.     $content = "<table align='center'><tr><td align='left'>\n";
  348.  
  349.     if (! $dbm->isConnectable()) {
  350.         $content .= _NGIMG._INSTALL_L106."<br />";
  351.         $content .= "<div style='text-align:center'><br />"._INSTALL_L107;
  352.         $content .= "</div></td></tr></table>\n";
  353.         $b_back = array('start', _INSTALL_L103);
  354.         $b_reload = true;
  355.     }else{
  356.         $content .= _OKIMG._INSTALL_L108."<br />";
  357.         if (! $dbm->dbExists()) {
  358.             $content .= _NGIMG.sprintf(_INSTALL_L109, XOOPS_DB_NAME)."<br />";
  359.             $content .= "</td></tr></table>\n";
  360.  
  361.             $content .= "<p>"._INSTALL_L21."<br />"
  362.                         ."<b>".XOOPS_DB_NAME."</b></p>"
  363.                         ."<p>"._INSTALL_L22."</p>";
  364.  
  365.             $b_next = array('createDB', _INSTALL_L105);
  366.             $b_back = array('start', _INSTALL_L103);
  367.             $b_reload = true;
  368.         }else{
  369.             if (!$dbm->tableExists('users')) {
  370.                 $content .= _OKIMG.sprintf(_INSTALL_L110, XOOPS_DB_NAME)."<br />";
  371.                 $content .= "</td></tr></table>\n";
  372.                 $content .= "<p>"._INSTALL_L111."</p>";
  373.                 $b_next = array('createTables', _INSTALL_L40);
  374.             } else {
  375.                 $content .= _OKIMG.sprintf(_INSTALL_L110, XOOPS_DB_NAME)."<br />";
  376.                 if (!$dbm->tableExists('config')) {
  377.                     $content .= "</td></tr></table>\n";
  378.                     $content .= "<p>"._INSTALL_L130."</p>";
  379.                     $b_next = array('updateTables', _INSTALL_L14);
  380.                 } else {
  381.                     $content .= _NGIMG._INSTALL_L131."<br />";
  382.                     $content .= "</td></tr></table>\n";
  383.                 }
  384.             }
  385.         }
  386.     }
  387.  
  388.     include 'install_tpl.php';
  389.     break;
  390.  
  391. case "createDB":
  392.     include_once "../mainfile.php";
  393.     include_once './class/dbmanager.php';
  394.     $dbm = new db_manager;
  395.  
  396.     if(! $dbm->createDB()){
  397.         $content = "<p>"._INSTALL_L31."</p>";
  398.         $b_next = array('checkDB', _INSTALL_L104);
  399.         $b_back = array('start', _INSTALL_L103);
  400.     }else{
  401.         $content = "<p>".sprintf(_INSTALL_L43, XOOPS_DB_NAME)."</p>";
  402.         $b_next = array('checkDB', _INSTALL_L104);
  403.     }
  404.     include 'install_tpl.php';
  405.     break;
  406.  
  407. case "createTables":
  408.     include_once "../mainfile.php";
  409.     include_once './class/dbmanager.php';
  410.     $dbm = new db_manager;
  411.  
  412.     //$content = "<table align='center'><tr><td align='left'>\n";
  413.     $tables = array();
  414.     $result = $dbm->queryFromFile('./sql/'.XOOPS_DB_TYPE.'.structure.sql');
  415.     $content = $dbm->report();
  416.     if(! $result ){
  417.         //$deleted = $dbm->deleteTables($tables);
  418.         $content .= "<p>"._INSTALL_L114."</p>\n";
  419.         $b_back = array('start', _INSTALL_L103);
  420.     }else{
  421.         $content .= "<p>"._INSTALL_L115."</p>\n";
  422.         $b_next = array('siteInit', _INSTALL_L112);
  423.     }
  424.  
  425.     include 'install_tpl.php';
  426.     break;
  427.  
  428. case 'updateTables':
  429.     include_once "../mainfile.php";
  430.     include_once './class/dbmanager.php';
  431.     $db = new db_manager;
  432.     $sql = 'SELECT * FROM '.$db->prefix('groups');
  433.     $result = $db->query($sql);
  434.     $content = '<h5>'._INSTALL_L157.'</h5>';
  435.     $content .= '<table align="center" cellspacing="0" border="1"><tr><td>'._INSTALL_L158.'</td><td>'._INSTALL_L159.'</td><td>'._INSTALL_L160.'</td><td>'._INSTALL_L161.'</td></tr>';
  436.     while ($myrow = $db->fetchArray($result)) {
  437.         if ($myrow['type'] == 'Admin') {
  438.             $content .= '<tr><td>'.$myrow['name'].'</td><td><input type="radio" name="g_webmasters" value="'.$myrow['groupid'].'" /></td><td> </td><td> </td></tr>';
  439.         } elseif ($myrow['type'] == 'User') {
  440.             $content .= '<tr><td>'.$myrow['name'].'</td><td> </td><td><input type="radio" name="g_users" value="'.$myrow['groupid'].'" /></td><td> </td></tr>';
  441.         } else {
  442.             $content .= '<tr><td>'.$myrow['name'].'</td><td> </td><td> </td><td><input type="radio" name="g_anonymous" value="'.$myrow['groupid'].'" /></td></tr>';
  443.         }
  444.     }
  445.     $content .= '</table>';
  446.     $b_back = array();
  447.     $b_next = array('updateTables_go', _INSTALL_L132);
  448.     include 'install_tpl.php';
  449.     break;
  450.  
  451. case 'updateTables_go':
  452.     include_once "../mainfile.php";
  453.     $error = false;
  454.     $g_webmasters = isset($g_webmasters) ? intval($g_webmasters) : 0;
  455.     $g_users = isset($g_users) ? intval($g_users) : 0;
  456.     $g_anonymous = isset($g_anonymous) ? intval($g_anonymous) : 0;
  457.     if (empty($g_webmasters) || empty($g_users) || empty($g_anonymous)) {
  458.         $error = true;
  459.     } else {
  460.         include_once "./class/mainfilemanager.php";
  461.         $title = _INSTALL_L88;
  462.         $mm = new mainfile_manager("../mainfile.php");
  463.         $mm->setRewrite('XOOPS_GROUP_ADMIN', $g_webmasters);
  464.         $mm->setRewrite('XOOPS_GROUP_USERS', $g_users);
  465.         $mm->setRewrite('XOOPS_GROUP_ANONYMOUS', $g_anonymous);
  466.  
  467.         $ret = $mm->doRewrite();
  468.         if(!$ret){
  469.             $content = _INSTALL_L60;
  470.             include 'install_tpl.php';
  471.             exit();
  472.         }
  473.     }
  474.     if (false != $error) {
  475.         $b_back = array();
  476.         $content = _INSTALL_L162;
  477.         include 'install_tpl.php';
  478.         break;
  479.     }
  480.     include_once './class/dbmanager.php';
  481.     $dbm = new db_manager;
  482.     if (!$dbm->query("ALTER TABLE ".$dbm->prefix("newblocks")." ADD dirname VARCHAR(50) NOT NULL, ADD func_file VARCHAR(50) NOT NULL, ADD show_func VARCHAR(50) NOT NULL, ADD edit_func VARCHAR(50) NOT NULL")) {
  483.     }
  484.     $result = $dbm->queryFromFile('./sql/upgrade/'.XOOPS_DB_TYPE.'.structure.sql');
  485.     $content = $dbm->report();
  486.     if (!$result) {
  487.         $content .= "<p>"._INSTALL_L135."</p>\n";
  488.         $b_back = array();
  489.     } else {
  490.         $content .= "<p>"._INSTALL_L136."</p>\n";
  491.         $b_next = array('updateConfig', _INSTALL_L14);
  492.     }
  493.     include 'install_tpl.php';
  494.     break;
  495.  
  496. case 'updateConfig':
  497.     $b_next = array('updateConfig_go', _INSTALL_L144);
  498.     $content = "<p>"._INSTALL_L143."</p>\n";
  499.     include 'install_tpl.php';
  500.     break;
  501.  
  502. case 'updateConfig_go':
  503.     include_once "../mainfile.php";
  504.  
  505.     $language = check_language($language);
  506.     if ( file_exists("./language/".$language."/install2.php") ) {
  507.         include_once "./language/".$language."/install2.php";
  508.     } elseif ( file_exists("./language/english/install2.php") ) {
  509.         include_once "./language/english/install2.php";
  510.         $language = 'english';
  511.     } else {
  512.         echo 'no language file (install2.php).';
  513.         exit();
  514.     }
  515.     include_once './class/dbmanager.php';
  516.     $dbm = new db_manager;
  517.  
  518.     // default settings
  519.     $xoopsConfig['sitename'] = 'XOOPS Site';
  520.     $xoopsConfig['slogan'] = 'Just use it!';
  521.     $xoopsConfig['adminmail'] = '';
  522.     $xoopsConfig['language'] = 'english';
  523.     $xoopsConfig['anonymous'] = 'Anonymous';
  524.     $xoopsConfig['minpass'] = 5;
  525.     $xoopsConfig['anonpost'] = 0;
  526.     $xoopsConfig['new_user_notify'] = 0;
  527.     $xoopsConfig['new_user_notify_group'] = 1;
  528.     $xoopsConfig['self_delete'] = 0;
  529.     $xoopsConfig['gzip_compression'] = 0;
  530.     $xoopsConfig['uname_test_level'] = 0;
  531.     $xoopsConfig['usercookie'] = "xoops_user";
  532.     $xoopsConfig['sessioncookie'] = "xoops_session";
  533.     $xoopsConfig['sessionexpire'] = 4500;
  534.     $xoopsConfig['server_TZ'] = 0;
  535.     $xoopsConfig['default_TZ'] = 0;
  536.     $xoopsConfig['banners'] = 1;
  537.     $xoopsConfig['com_mode'] = "nest";
  538.     $xoopsConfig['com_order'] = 1;
  539.     $xoopsConfig['my_ip'] = "127.0.0.1";
  540.     $xoopsConfig['avatar_allow_upload'] = 0;
  541.     $xoopsConfig['avatar_width'] = 120;
  542.     $xoopsConfig['avatar_height'] = 120;
  543.     $xoopsConfig['avatar_maxsize'] = 15000;
  544.  
  545.     // override deafault with 1.3.x settings if any
  546.     if (file_exists('../modules/system/cache/config.php')) {
  547.         include_once('../modules/system/cache/config.php');
  548.     }
  549.  
  550.     $dbm->insert('config', " VALUES (1, 0, 1, 'sitename', '_MD_AM_SITENAME', '".addslashes($xoopsConfig['sitename'])."', '_MD_AM_SITENAMEDSC', 'textbox', 'text', 0)");
  551.     $dbm->insert('config', " VALUES (2, 0, 1, 'slogan', '_MD_AM_SLOGAN', '".addslashes($xoopsConfig['slogan'])."', '_MD_AM_SLOGANDSC', 'textbox', 'text', 2)");
  552.     $dbm->insert('config', " VALUES (3, 0, 1, 'language', '_MD_AM_LANGUAGE', '".$xoopsConfig['language']."', '_MD_AM_LANGUAGEDSC', 'language', 'other', 4)");
  553.     $dbm->insert('config', " VALUES (4, 0, 1, 'startpage', '_MD_AM_STARTPAGE', '--', '_MD_AM_STARTPAGEDSC', 'startpage', 'other', 6)");
  554.     $dbm->insert('config', " VALUES (5, 0, 1, 'server_TZ', '_MD_AM_SERVERTZ', '".addslashes($xoopsConfig['server_TZ'])."', '_MD_AM_SERVERTZDSC', 'timezone', 'float', 8)");
  555.     $dbm->insert('config', " VALUES (6, 0, 1, 'default_TZ', '_MD_AM_DEFAULTTZ', '".addslashes($xoopsConfig['default_TZ'])."', '_MD_AM_DEFAULTTZDSC', 'timezone', 'float', 10)");
  556.     $dbm->insert('config', " VALUES (7, 0, 1, 'theme_set', '_MD_AM_DTHEME', 'default', '_MD_AM_DTHEMEDSC', 'theme', 'other', 12)");
  557.     $dbm->insert('config', " VALUES (8, 0, 1, 'anonymous', '_MD_AM_ANONNAME', '".addslashes($xoopsConfig['anonymous'])."', '_MD_AM_ANONNAMEDSC', 'textbox', 'text', 15)");
  558.     $dbm->insert('config', " VALUES (9, 0, 1, 'gzip_compression', '_MD_AM_USEGZIP', '".intval($xoopsConfig['gzip_compression'])."', '_MD_AM_USEGZIPDSC', 'yesno', 'int', 16)");
  559.     $dbm->insert('config', " VALUES (10, 0, 1, 'usercookie', '_MD_AM_USERCOOKIE', '".addslashes($xoopsConfig['usercookie'])."', '_MD_AM_USERCOOKIEDSC', 'textbox', 'text', 18)");
  560.     $dbm->insert('config', " VALUES (11, 0, 1, 'session_expire', '_MD_AM_SESSEXPIRE', '15', '_MD_AM_SESSEXPIREDSC', 'textbox', 'int', 22)");
  561.     $dbm->insert('config', " VALUES (12, 0, 1, 'banners', '_MD_AM_BANNERS', '".intval($xoopsConfig['banners'])."', '_MD_AM_BANNERSDSC', 'yesno', 'int', 26)");
  562.     $dbm->insert('config', " VALUES (13, 0, 1, 'debug_mode', '_MD_AM_DEBUGMODE', '0', '_MD_AM_DEBUGMODEDSC', 'select', 'int', 24)");
  563.     $dbm->insert('config', " VALUES (14, 0, 1, 'my_ip', '_MD_AM_MYIP', '".addslashes($xoopsConfig['my_ip'])."', '_MD_AM_MYIPDSC', 'textbox', 'text', 29)");
  564.     $dbm->insert('config', " VALUES (15, 0, 1, 'use_ssl', '_MD_AM_USESSL', '0', '_MD_AM_USESSLDSC', 'yesno', 'int', 30)");
  565.     $dbm->insert('config', " VALUES (16, 0, 1, 'session_name', '_MD_AM_SESSNAME', 'xoops_session', '_MD_AM_SESSNAMEDSC', 'textbox', 'text', 20)");
  566.     $dbm->insert('config', " VALUES (17, 0, 2, 'minpass', '_MD_AM_MINPASS', '".intval($xoopsConfig['minpass'])."', '_MD_AM_MINPASSDSC', 'textbox', 'int', 1)");
  567.     $dbm->insert('config', " VALUES (18, 0, 2, 'minuname', '_MD_AM_MINUNAME', '5', '_MD_AM_MINUNAMEDSC', 'textbox', 'int', 2)");
  568.     $dbm->insert('config', " VALUES (19, 0, 2, 'new_user_notify', '_MD_AM_NEWUNOTIFY', '".intval($xoopsConfig['new_user_notify'])."', '_MD_AM_NEWUNOTIFYDSC', 'yesno', 'int', 4)");
  569.     $dbm->insert('config', " VALUES (20, 0, 2, 'new_user_notify_group', '_MD_AM_NOTIFYTO', ".intval($xoopsConfig['new_user_notify_group']).", '_MD_AM_NOTIFYTODSC', 'group', 'int', 6)");
  570.     $dbm->insert('config', " VALUES (21, 0, 2, 'activation_type', '_MD_AM_ACTVTYPE', '0', '_MD_AM_ACTVTYPEDSC', 'select', 'int', 8)");
  571.     $dbm->insert('config', " VALUES (22, 0, 2, 'activation_group', '_MD_AM_ACTVGROUP', ".XOOPS_GROUP_ADMIN.", '_MD_AM_ACTVGROUPDSC', 'group', 'int', 10)");
  572.     $dbm->insert('config', " VALUES (23, 0, 2, 'uname_test_level', '_MD_AM_UNAMELVL', '".intval($xoopsConfig['uname_test_level'])."', '_MD_AM_UNAMELVLDSC', 'select', 'int', 12)");
  573.     $dbm->insert('config', " VALUES (24, 0, 2, 'avatar_allow_upload', '_MD_AM_AVATARALLOW', '".intval($xoopsConfig['avatar_allow_upload'])."', '_MD_AM_AVATARALWDSC', 'yesno', 'int', 14)");
  574.     $dbm->insert('config', " VALUES (27, 0, 2, 'avatar_width', '_MD_AM_AVATARW', '".intval($xoopsConfig['avatar_width'])."', '_MD_AM_AVATARWDSC', 'textbox', 'int', 16)");
  575.     $dbm->insert('config', " VALUES (28, 0, 2, 'avatar_height', '_MD_AM_AVATARH', '".intval($xoopsConfig['avatar_height'])."', '_MD_AM_AVATARHDSC', 'textbox', 'int', 18)");
  576.     $dbm->insert('config', " VALUES (29, 0, 2, 'avatar_maxsize', '_MD_AM_AVATARMAX', '".intval($xoopsConfig['avatar_maxsize'])."', '_MD_AM_AVATARMAXDSC', 'textbox', 'int', 20)");
  577.     $dbm->insert('config', " VALUES (30, 0, 1, 'adminmail', '_MD_AM_ADMINML', '".addslashes($xoopsConfig['adminmail'])."', '_MD_AM_ADMINMLDSC', 'textbox', 'text', 3)");
  578.     $dbm->insert('config', " VALUES (31, 0, 2, 'self_delete', '_MD_AM_SELFDELETE', '".intval($xoopsConfig['self_delete'])."', '_MD_AM_SELFDELETEDSC', 'yesno', 'int', 22)");
  579.     $dbm->insert('config', " VALUES (32, 0, 1, 'com_mode', '_MD_AM_COMMODE', '".addslashes($xoopsConfig['com_mode'])."', '_MD_AM_COMMODEDSC', 'select', 'text', 34)");
  580.     $dbm->insert('config', " VALUES (33, 0, 1, 'com_order', '_MD_AM_COMORDER', '".intval($xoopsConfig['com_order'])."', '_MD_AM_COMORDERDSC', 'select', 'int', 36)");
  581.     $dbm->insert('config', " VALUES (34, 0, 2, 'bad_unames', '_MD_AM_BADUNAMES', '".addslashes(serialize(array('webmaster', '^xoops', '^admin')))."', '_MD_AM_BADUNAMESDSC', 'textarea', 'array', 24)");
  582.     $dbm->insert('config', " VALUES (35, 0, 2, 'bad_emails', '_MD_AM_BADEMAILS', '".addslashes(serialize(array('xoops.org$')))."', '_MD_AM_BADEMAILSDSC', 'textarea', 'array', 26)");
  583.     $dbm->insert('config', " VALUES (36, 0, 2, 'maxuname', '_MD_AM_MAXUNAME', '10', '_MD_AM_MAXUNAMEDSC', 'textbox', 'int', 3)");
  584.     $dbm->insert('config', " VALUES (37, 0, 1, 'bad_ips', '_MD_AM_BADIPS', '".addslashes(serialize(array('127.0.0.1')))."', '_MD_AM_BADIPSDSC', 'textarea', 'array', 42)");
  585.     $dbm->insert('config', " VALUES (38, 0, 3, 'meta_keywords', '_MD_AM_METAKEY', 'news, technology, headlines, xoops, xoop, nuke, myphpnuke, myphp-nuke, phpnuke, SE, geek, geeks, hacker, hackers, linux, software, download, downloads, free, community, mp3, forum, forums, bulletin, board, boards, bbs, php, survey, poll, polls, kernel, comment, comments, portal, odp, open, source, opensource, FreeSoftware, gnu, gpl, license, Unix, *nix, mysql, sql, database, databases, web site, weblog, guru, module, modules, theme, themes, cms, content management', '_MD_AM_METAKEYDSC', 'textarea', 'text', 0)");
  586.     $dbm->insert('config', " VALUES (39, 0, 3, 'footer', '_MD_AM_FOOTER', 'Powered by XOOPS 2.0 © 2001-" . date('Y', time()) . " <a href=\"http://xoops.sourceforge.net/\" target=\"_blank\">The XOOPS Project</a>', '_MD_AM_FOOTERDSC', 'textarea', 'text', 20)");
  587.     $dbm->insert('config', " VALUES (40, 0, 4, 'censor_enable', '_MD_AM_DOCENSOR', '0', '_MD_AM_DOCENSORDSC', 'yesno', 'int', 0)");
  588.     $dbm->insert('config', " VALUES (41, 0, 4, 'censor_words', '_MD_AM_CENSORWRD', '".addslashes(serialize(array('fuck', 'shit')))."', '_MD_AM_CENSORWRDDSC', 'textarea', 'array', 1)");
  589.     $dbm->insert('config', " VALUES (42, 0, 4, 'censor_replace', '_MD_AM_CENSORRPLC', '#OOPS#', '_MD_AM_CENSORRPLCDSC', 'textbox', 'text', 2)");
  590.     $dbm->insert('config', " VALUES (43, 0, 3, 'meta_robots', '_MD_AM_METAROBOTS', 'index,follow', '_MD_AM_METAROBOTSDSC', 'select', 'text', 2)");
  591.     $dbm->insert('config', " VALUES (44, 0, 5, 'enable_search', '_MD_AM_DOSEARCH', '1', '_MD_AM_DOSEARCHDSC', 'yesno', 'int', 0)");
  592.     $dbm->insert('config', " VALUES (45, 0, 5, 'keyword_min', '_MD_AM_MINSEARCH', '5', '_MD_AM_MINSEARCHDSC', 'textbox', 'int', 1)");
  593.     $dbm->insert('config', " VALUES (46, 0, 2, 'avatar_minposts', '_MD_AM_AVATARMP', '0', '_MD_AM_AVATARMPDSC', 'textbox', 'int', 15)");
  594.     $dbm->insert('config', " VALUES (47, 0, 1, 'enable_badips', '_MD_AM_DOBADIPS', '0', '_MD_AM_DOBADIPSDSC', 'yesno', 'int', 40)");
  595.     $dbm->insert('config', " VALUES (48, 0, 3, 'meta_rating', '_MD_AM_METARATING', 'general', '_MD_AM_METARATINGDSC', 'select', 'text', 4)");
  596.     $dbm->insert('config', " VALUES (49, 0, 3, 'meta_author', '_MD_AM_METAAUTHOR', 'XOOPS', '_MD_AM_METAAUTHORDSC', 'textbox', 'text', 6)");
  597.     $dbm->insert('config', " VALUES (50, 0, 3, 'meta_copyright', '_MD_AM_METACOPYR', 'Copyright © 2001-2003', '_MD_AM_METACOPYRDSC', 'textbox', 'text', 8)");
  598.     $dbm->insert('config', " VALUES (51, 0, 3, 'meta_description', '_MD_AM_METADESC', 'XOOPS is a dynamic Object Oriented based open source portal script written in PHP.', '_MD_AM_METADESCDSC', 'textarea', 'text', 1)");
  599.     $dbm->insert('config', " VALUES (52, 0, 2, 'allow_chgmail', '_MD_AM_ALLWCHGMAIL', '0', '_MD_AM_ALLWCHGMAILDSC', 'yesno', 'int', 3)");
  600.     $dbm->insert('config', " VALUES (53, 0, 1, 'use_mysession', '_MD_AM_USEMYSESS', '0', '_MD_AM_USEMYSESSDSC', 'yesno', 'int', 19)");
  601.     $dbm->insert('config', " VALUES (54, 0, 2, 'reg_dispdsclmr', '_MD_AM_DSPDSCLMR', 1, '_MD_AM_DSPDSCLMRDSC', 'yesno', 'int', 30)");
  602.     $dbm->insert('config', " VALUES (55, 0, 2, 'reg_disclaimer', '_MD_AM_REGDSCLMR', '".addslashes(_INSTALL_DISCLMR)."', '_MD_AM_REGDSCLMRDSC', 'textarea', 'text', 32)");
  603.     $dbm->insert('config', " VALUES (56, 0, 2, 'allow_register', '_MD_AM_ALLOWREG', 1, '_MD_AM_ALLOWREGDSC', 'yesno', 'int', 0)");
  604.     $dbm->insert('config', " VALUES (57, 0, 1, 'theme_fromfile', '_MD_AM_THEMEFILE', '0', '_MD_AM_THEMEFILEDSC', 'yesno', 'int', 13)");
  605.     $dbm->insert('config', " VALUES (58, 0, 1, 'closesite', '_MD_AM_CLOSESITE', '0', '_MD_AM_CLOSESITEDSC', 'yesno', 'int', 26)");
  606.     $dbm->insert('config', " VALUES (59, 0, 1, 'closesite_okgrp', '_MD_AM_CLOSESITEOK', '".addslashes(serialize(array('1')))."', '_MD_AM_CLOSESITEOKDSC', 'group_multi', 'array', 27)");
  607.     $dbm->insert('config', " VALUES (60, 0, 1, 'closesite_text', '_MD_AM_CLOSESITETXT', '"._INSTALL_L165."', '_MD_AM_CLOSESITETXTDSC', 'textarea', 'text', 28)");
  608.     $dbm->insert('config', " VALUES (61, 0, 1, 'sslpost_name', '_MD_AM_SSLPOST', 'xoops_ssl', '_MD_AM_SSLPOSTDSC', 'textbox', 'text', 31)");
  609.     $dbm->insert('config', " VALUES (62, 0, 1, 'module_cache', '_MD_AM_MODCACHE', '', '_MD_AM_MODCACHEDSC', 'module_cache', 'array', 50)");
  610.     $dbm->insert('config', " VALUES (63, 0, 1, 'template_set', '_MD_AM_DTPLSET', 'default', '_MD_AM_DTPLSETDSC', 'tplset', 'other', 14)");
  611.     $dbm->insert('config', " VALUES (64,0,6,'mailmethod','_MD_AM_MAILERMETHOD','mail','_MD_AM_MAILERMETHODDESC','select','text',4)");
  612.     $dbm->insert('config', " VALUES (65,0,6,'smtphost','_MD_AM_SMTPHOST','a:1:{i:0;s:0:\"\";}', '_MD_AM_SMTPHOSTDESC','textarea','array',6)");
  613.     $dbm->insert('config', " VALUES (66,0,6,'smtpuser','_MD_AM_SMTPUSER','','_MD_AM_SMTPUSERDESC','textbox','text',7)");
  614.     $dbm->insert('config', " VALUES (67,0,6,'smtppass','_MD_AM_SMTPPASS','','_MD_AM_SMTPPASSDESC','password','text',8)");
  615.     $dbm->insert('config', " VALUES (68,0,6,'sendmailpath','_MD_AM_SENDMAILPATH','/usr/sbin/sendmail','_MD_AM_SENDMAILPATHDESC','textbox','text',5)");
  616.     $dbm->insert('config', " VALUES (69,0,6,'from','_MD_AM_MAILFROM','','_MD_AM_MAILFROMDESC','textbox','text',1)");
  617.     $dbm->insert('config', " VALUES (70,0,6,'fromname','_MD_AM_MAILFROMNAME','','_MD_AM_MAILFROMNAMEDESC','textbox','text',2)");
  618.     $dbm->insert('config', " VALUES (71, 0, 1, 'sslloginlink', '_MD_AM_SSLLINK', 'https://', '_MD_AM_SSLLINKDSC', 'textbox', 'text', 33)");
  619.     $dbm->insert('config', " VALUES (72, 0, 1, 'theme_set_allowed', '_MD_AM_THEMEOK', '".serialize(array('default'))."', '_MD_AM_THEMEOKDSC', 'theme_multi', 'array', 13)");
  620.     $dbm->insert('config', " VALUES (73,0,6,'fromuid','_MD_AM_MAILFROMUID','1','_MD_AM_MAILFROMUIDDESC','user','int',3)");
  621.  
  622.     $dbm->insert('config', " VALUES (74,0,7,'auth_method','_MD_AM_AUTHMETHOD','xoops','_MD_AM_AUTHMETHODDESC','select','text',1)");
  623.     $dbm->insert('config', " VALUES (75,0,7,'ldap_port','_MD_AM_LDAP_PORT','389','_MD_AM_LDAP_PORT','textbox','int',2)");
  624.     $dbm->insert('config', " VALUES (76,0,7,'ldap_server','_MD_AM_LDAP_SERVER','your directory server','_MD_AM_LDAP_SERVER_DESC','textbox','text',3)");
  625.     $dbm->insert('config', " VALUES (77,0,7,'ldap_base_dn','_MD_AM_LDAP_BASE_DN','dc=xoops,dc=org','_MD_AM_LDAP_BASE_DN_DESC','textbox','text',4)");
  626.     $dbm->insert('config', " VALUES (78,0,7,'ldap_manager_dn','_MD_AM_LDAP_MANAGER_DN','manager_dn','_MD_AM_LDAP_MANAGER_DN_DESC','textbox','text',5)");
  627.     $dbm->insert('config', " VALUES (79,0,7,'ldap_manager_pass','_MD_AM_LDAP_MANAGER_PASS','manager_pass','_MD_AM_LDAP_MANAGER_PASS_DESC','password','text',6)");
  628.     $dbm->insert('config', " VALUES (80,0,7,'ldap_version','_MD_AM_LDAP_VERSION','3','_MD_AM_LDAP_VERSION_DESC','textbox','text', 7)");
  629.     $dbm->insert('config', " VALUES (81,0,7,'ldap_users_bypass','_MD_AM_LDAP_USERS_BYPASS','".serialize(array('admin'))."','_MD_AM_LDAP_USERS_BYPASS_DESC','textarea','array',8)");
  630.     $dbm->insert('config', " VALUES (82,0,7,'ldap_loginname_asdn','_MD_AM_LDAP_LOGINNAME_ASDN','uid_asdn','_MD_AM_LDAP_LOGINNAME_ASDN_D','yesno','int',9)");
  631.     $dbm->insert('config', " VALUES (83,0,7,'ldap_loginldap_attr', '_MD_AM_LDAP_LOGINLDAP_ATTR', 'uid', '_MD_AM_LDAP_LOGINLDAP_ATTR_D', 'textbox', 'text', 10)");
  632.     $dbm->insert('config', " VALUES (84,0,7,'ldap_filter_person','_MD_AM_LDAP_FILTER_PERSON','','_MD_AM_LDAP_FILTER_PERSON_DESC','textbox','text',11)");
  633.     $dbm->insert('config', " VALUES (85,0,7,'ldap_domain_name','_MD_AM_LDAP_DOMAIN_NAME','mydomain','_MD_AM_LDAP_DOMAIN_NAME_DESC','textbox','text',12)");
  634.     $dbm->insert('config', " VALUES (86,0,7,'ldap_provisionning','_MD_AM_LDAP_PROVIS','0','_MD_AM_LDAP_PROVIS_DESC','yesno','int',13)");                
  635.     $dbm->insert('config', " VALUES (87,0,7,'ldap_provisionning_group','_MD_AM_LDAP_PROVIS_GROUP','a:1:{i:0;s:1:\"2\";}','_MD_AM_LDAP_PROVIS_GROUP_DSC','group_multi','array',14)");
  636.     $dbm->insert('config', " VALUES (88,0,7,'ldap_use_TLS','_MD_AM_LDAP_USETLS','0','_MD_AM_LDAP_USETLS_DESC','yesno','int',15)");                    
  637.  
  638.  
  639.     // default the default theme
  640.  
  641.     $time = time();
  642.     $dbm->insert('tplset', " VALUES (1, 'default', 'XOOPS Default Theme', '', ".$time.")");
  643.  
  644. //    include_once './class/cachemanager.php';
  645. //    $cm = new cache_manager;
  646. //    $skinfiles = array('1' => 'skin.html', '2' => 'style.css'
  647. //                        , '3' => 'styleNN.css','4' =>  'styleMAC.css'
  648. //                        , '5' => 'skin_blockleft.html', '6' => 'skin_blockright.html'
  649. //                        , '7' => 'skin_blockcenter_l.html', '8' => 'skin_blockcenter_c.html'
  650. //                        , '9' => 'skin_blockcenter_r.html');
  651. //    foreach ($skinfiles as $key => $skinfile) {
  652. //        if(preg_match('/\.css$/', $skinfile)) {
  653. //            $type = 'css';
  654. //        }else{
  655. //            $type = 'skin';
  656. //        }
  657. //        $dbm->insert('tplfile', " VALUES ($key, 0, '', 'default', '$skinfile', '', $time, $time, '$type')");
  658.  
  659. //        $fp = fopen('./templates/default_skin/'.$skinfile, 'r');
  660. //        $skinsource = fread($fp, filesize('./templates/default_skin/'.$skinfile));
  661. //        fclose($fp);
  662. //        $dbm->insert('tplsource', " (tpl_id, tpl_source) VALUES ($key, '".addslashes($skinsource)."')");
  663. //        if(preg_match('/\.css$/',$skinfile)) {
  664. //            $cm->write($skinfile, $skinsource);
  665. //        }
  666. //    }
  667.  
  668.         $dbm->query("INSERT INTO ".$dbm->prefix('group_permission')." (gperm_groupid, gperm_itemid) SELECT groupid, block_id FROM ".$dbm->prefix('groups_blocks_link'));
  669.         $dbm->query("UPDATE ".$dbm->prefix('group_permission')." SET gperm_name = 'block_read'");
  670.         $dbm->query("INSERT INTO ".$dbm->prefix('group_permission')." (gperm_groupid, gperm_itemid) SELECT groupid, mid FROM ".$dbm->prefix('groups_modules_link') ." WHERE type='A'");
  671.         $dbm->query("UPDATE ".$dbm->prefix('group_permission')." SET gperm_name = 'module_admin' WHERE gperm_name = ''");
  672.         $dbm->query("INSERT INTO ".$dbm->prefix('group_permission')." (gperm_groupid, gperm_itemid) SELECT groupid, mid FROM ".$dbm->prefix('groups_modules_link')." WHERE type='R'");
  673.         $dbm->query("UPDATE ".$dbm->prefix('group_permission')." SET gperm_name = 'module_read' WHERE gperm_name = ''");
  674.         $dbm->query("UPDATE ".$dbm->prefix('group_permission')." SET gperm_modid = 1");
  675.         $dbm->query('DROP TABLE '.$dbm->prefix('groups_blocks_link'));
  676.         $dbm->query('DROP TABLE '.$dbm->prefix('groups_modules_link'));
  677.  
  678.     // insert some more data
  679.     $result = $dbm->queryFromFile('./sql/'.XOOPS_DB_TYPE.'.data.sql');
  680.  
  681.     $content = $dbm->report();
  682.     //$content .= $cm->report();
  683.     $b_next = array('updateModules', _INSTALL_L14);
  684.     include 'install_tpl.php';
  685.     break;
  686.  
  687. case 'updateModules':
  688.     $b_next = array('updateModules_go', _INSTALL_L137);
  689.     $content = "<p>"._INSTALL_L141."</p>\n";
  690.     include 'install_tpl.php';
  691.     break;
  692.  
  693. case 'updateModules_go':
  694.     unset($xoopsOption['nocommon']);
  695.     include_once "../mainfile.php";
  696. ?>
  697. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  698. <html>
  699. <head>
  700.   <title>XOOPS Custom Installation</title>
  701.   <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _INSTALL_CHARSET ?>" />
  702.   <style type="text/css" media="all"><!-- @import url(../xoops.css); --></style>
  703.   <link rel="stylesheet" type="text/css" media="all" href="style.css" />
  704. </head>
  705. <body style="margin: 0; padding: 0;">
  706. <form action='index.php' method='post'>
  707. <table width="778" align="center" cellpadding="0" cellspacing="0" background="img/bg_table.gif">
  708.   <tr>
  709.     <td width="150"><img src="img/hbar_left.gif" width="100%" height="23" alt="" /></td>
  710.     <td width="478" background="img/hbar_middle.gif"> </td>
  711.     <td width="150"><img src="img/hbar_right.gif" width="100%" height="23" alt="" /></td>
  712.   </tr>
  713.   <tr>
  714.     <td width="150"><a href="index.php"><img src="img/logo.gif" width="150" height="80" alt="" /></a></td>
  715.     <td width="478" background="img/bg_darkblue.gif"> </td>
  716.     <td width="150"><img src="img/xoops2.gif" width="100%" height="80"></td>
  717.   </tr>
  718.   <tr>
  719.     <td width="150"><img src="img/hbar_left.gif" width="100%" height="23" alt="" /></td>
  720.     <td width="478" background="img/hbar_middle.gif"> </td>
  721.     <td width="150"><img src="img/hbar_right.gif" width="100%" height="23" alt="" /></td>
  722.   </tr>
  723. </table>
  724.  
  725. <table width="778" align="center" cellspacing="0" cellpadding="0" background="img/bg_table.gif"
  726.   <tr>
  727.     <td width='5%'> </td>
  728.     <td colspan="3"><h4 style="margin-top: 10px; margin-bottom: 5px; padding: 10px;"><?php echo _INSTALL_L142;?></h4><div style="padding: 10px; text-align:left;">
  729. <?php
  730.     $module_handler =& xoops_gethandler('module');
  731.     $modules =& $module_handler->getObjects(null, true);
  732.     foreach (array_keys($modules) as $mid) {
  733.         echo '<h5>'.$modules[$mid]->getVar('name').'</h5>';
  734.         $dirname = $modules[$mid]->getVar('dirname');
  735.         if (is_dir(XOOPS_ROOT_PATH.'/modules/'.$dirname)) {
  736.             $modules[$mid]->loadInfoAsVar($dirname, false);
  737.             if (!$module_handler->insert($modules[$mid])) {
  738.                 echo '<p>Could not update '.$modules[$mid]->getVar('name').'</p>';
  739.             } else {
  740.                 $newmid = $modules[$mid]->getVar('mid');
  741.                 $msgs = array();
  742.                 $msgs[] = 'Module data updated.';
  743.                 $tplfile_handler =& xoops_gethandler('tplfile');
  744.                 $templates = $modules[$mid]->getInfo('templates');
  745.                 if ($templates != false) {
  746.                     $msgs[] = 'Generating templates...';
  747.                     foreach ($templates as $tpl) {
  748.                         $tpl['file'] = trim($tpl['file']);
  749.                         $tpldata =& xoops_module_gettemplate($dirname, $tpl['file']);
  750.                         $tplfile =& $tplfile_handler->create();
  751.                         $tplfile->setVar('tpl_refid', $newmid);
  752.                         $tplfile->setVar('tpl_lastimported', 0);
  753.                         $tplfile->setVar('tpl_lastmodified', time());
  754.                         if (preg_match("/\.css$/i", $tpl['file'])) {
  755.                             $tplfile->setVar('tpl_type', 'css');
  756.                         } else {
  757.                             $tplfile->setVar('tpl_type', 'module');
  758.                             //if ($xoopsConfig['default_theme'] == 'default') {
  759.                             //    include_once XOOPS_ROOT_PATH.'/class/template.php';
  760.                             //    xoops_template_touch($tplfile->getVar('tpl_id'));
  761.                             //}
  762.                         }
  763.                         $tplfile->setVar('tpl_source', $tpldata, true);
  764.                         $tplfile->setVar('tpl_module', $dirname);
  765.                         $tplfile->setVar('tpl_tplset', 'default');
  766.                         $tplfile->setVar('tpl_file', $tpl['file'], true);
  767.                         $tplfile->setVar('tpl_desc', $tpl['description'], true);
  768.                         if (!$tplfile_handler->insert($tplfile)) {
  769.                             $msgs[] = '  <span style="color:#ff0000;">ERROR: Could not insert template <b>'.$tpl['file'].'</b> to the database.</span>';
  770.                         } else {
  771.                             $msgs[] = '  Template <b>'.$tpl['file'].'</b> inserted to the database.';
  772.                         }
  773.                         unset($tpldata);
  774.                     }
  775.                 }
  776.                 $blocks = $modules[$mid]->getInfo('blocks');
  777.                 $msgs[] = 'Rebuilding blocks...';
  778.                 $showfuncs = array();
  779.                 $funcfiles = array();
  780.                 if ($blocks != false) {
  781.                     $count = count($blocks);
  782.                     include_once(XOOPS_ROOT_PATH.'/class/xoopsblock.php');
  783.                     for ( $i = 1; $i <= $count; $i++ ) {
  784.                         if (isset($blocks[$i]['show_func']) && $blocks[$i]['show_func'] != '' && isset($blocks[$i]['file']) && $blocks[$i]['file'] != '') {
  785.                             $editfunc = isset($blocks[$i]['edit_func']) ? $blocks[$i]['edit_func'] : '';
  786.                             $showfuncs[] = $blocks[$i]['show_func'];
  787.                             $funcfiles[] = $blocks[$i]['file'];
  788.                             $template = '';
  789.                             if ((isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '')) {
  790.                                 $content =& xoops_module_gettemplate($dirname, $blocks[$i]['template'], true);
  791.                                 $template = $blocks[$i]['template'];
  792.                             }
  793.                             if (!$content) {
  794.                                 $content = '';
  795.                             }
  796.                             $options = '';
  797.                             if (isset($blocks[$i]['options']) && $blocks[$i]['options'] != '') {
  798.                                 $options = $blocks[$i]['options'];
  799.                             }
  800.                             $sql = "SELECT bid, name FROM ".$xoopsDB->prefix('newblocks')." WHERE mid=".$mid." AND func_num=".$i;
  801.                             $fresult = $xoopsDB->query($sql);
  802.                             $fcount = 0;
  803.                             while ($fblock = $xoopsDB->fetchArray($fresult)) {
  804.                                 $fcount++;
  805.                                 $sql = "UPDATE ".$xoopsDB->prefix("newblocks")." SET name='".addslashes($blocks[$i]['name'])."', title='".addslashes($blocks[$i]['name'])."', dirname='".addslashes($dirname)."',  func_file='".addslashes($blocks[$i]['file'])."', show_func='".addslashes($blocks[$i]['show_func'])."', template='".addslashes($template)."', edit_func='".addslashes($editfunc)."', options='".addslashes($options)."', content='', template='".$template."', last_modified=".time()." WHERE bid=".$fblock['bid'];
  806.                                 $result = $xoopsDB->query($sql);
  807.                                 if (!$result) {
  808.                                     $msgs[] = '  ERROR: Could not update '.$fblock['name'];
  809.                                 } else {
  810.                                     $msgs[] = '  Block <b>'.$fblock['name'].'</b> updated. Block ID: <b>'.$fblock['bid'].'</b>';
  811.                                     if ($template != '') {
  812.                                         $tplfile =& $tplfile_handler->create();
  813.                                         $tplfile->setVar('tpl_refid', $fblock['bid']);
  814.                                         $tplfile->setVar('tpl_source', $content, true);
  815.                                         $tplfile->setVar('tpl_tplset', 'default');
  816.                                         $tplfile->setVar('tpl_file', $blocks[$i]['template']);
  817.                                         $tplfile->setVar('tpl_module', $dirname);
  818.                                         $tplfile->setVar('tpl_type', 'block');
  819.                                         $tplfile->setVar('tpl_desc', $blocks[$i]['description'], true);
  820.                                         $tplfile->setVar('tpl_lastimported', 0);
  821.                                         $tplfile->setVar('tpl_lastmodified', time());
  822.                                         if (!$tplfile_handler->insert($tplfile)) {
  823.                                             $msgs[] = '  <span style="color:#ff0000;">ERROR: Could not insert template <b>'.$blocks[$i]['template'].'</b> to the database.</span>';
  824.                                         } else {
  825.                                             $msgs[] = '  Template <b>'.$blocks[$i]['template'].'</b> inserted to the database.';
  826.                                             //if ($xoopsConfig['default_theme'] == 'default') {
  827.                                             //    if (!xoops_template_touch($tplfile[0]->getVar('tpl_id'))) {
  828.                                             //        $msgs[] = '  <span style="color:#ff0000;">ERROR: Could not recompile template <b>'.$blocks[$i]['template'].'</b>.</span>';
  829.                                             //    } else {
  830.                                             //        $msgs[] = '  Template <b>'.$blocks[$i]['template'].'</b> recompiled.';
  831.                                             //    }
  832.                                             //}
  833.                                         }
  834.                                     }
  835.                                 }
  836.                             }
  837.                             if ($fcount == 0) {
  838.                                 $newbid = $xoopsDB->genId($xoopsDB->prefix('newblocks').'_bid_seq');
  839.                                 $block_name = addslashes($blocks[$i]['name']);
  840.                                 $sql = "INSERT INTO ".$xoopsDB->prefix("newblocks")." (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, isactive, dirname, func_file, show_func, edit_func, template, last_modified) VALUES (".$newbid.", ".$mid.", ".$i.",'".addslashes($options)."','".$block_name."', '".$block_name."', '', 0, 0, 0, 'M', 1, '".addslashes($dirname)."', '".addslashes($blocks[$i]['file'])."', '".addslashes($blocks[$i]['show_func'])."', '".addslashes($editfunc)."', '".$template."', ".time().")";
  841.                                 $result = $xoopsDB->query($sql);
  842.                                 if (!$result) {
  843.                                     $msgs[] = '  ERROR: Could not create '.$blocks[$i]['name'];
  844.                                 } else {
  845.                                     if (empty($newbid)) {
  846.                                         $newbid = $xoopsDB->getInsertId();
  847.                                     }
  848.                                     if ($template != '') {
  849.                                         $tplfile =& $tplfile_handler->create();
  850.                                         $tplfile->setVar('tpl_module', $dirname);
  851.                                         $tplfile->setVar('tpl_refid', $newbid);
  852.                                         $tplfile->setVar('tpl_source', $content, true);
  853.                                         $tplfile->setVar('tpl_tplset', 'default');
  854.                                         $tplfile->setVar('tpl_file', $blocks[$i]['template'], true);
  855.                                         $tplfile->setVar('tpl_type', 'block');
  856.                                         $tplfile->setVar('tpl_lastimported', 0);
  857.                                         $tplfile->setVar('tpl_lastmodified', time());
  858.                                         $tplfile->setVar('tpl_desc', $blocks[$i]['description'], true);
  859.                                         if (!$tplfile_handler->insert($tplfile)) {
  860.                                             $msgs[] = '  <span style="color:#ff0000;">ERROR: Could not insert template <b>'.$blocks[$i]['template'].'</b> to the database.</span>';
  861.                                         } else {
  862.                                             $msgs[] = '  Template <b>'.$blocks[$i]['template'].'</b> inserted to the database.';
  863.                                         }
  864.                                     }
  865.                                     $msgs[] = '  Block <b>'.$blocks[$i]['name'].'</b> created. Block ID: <b>'.$newbid.'</b>';
  866.                                 }
  867.                             }
  868.                         }
  869.                     }
  870.                 }
  871.                 $block_arr = XoopsBlock::getByModule($mid);
  872.                 foreach ($block_arr as $block) {
  873.                     if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
  874.                         $sql = sprintf("DELETE FROM %s WHERE bid = %u", $xoopsDB->prefix('newblocks'), $block->getVar('bid'));
  875.                         if(!$xoopsDB->query($sql)) {
  876.                             $msgs[] = '  <span style="color:#ff0000;">ERROR: Could not delete block <b>'.$block->getVar('name').'</b>. Block ID: <b>'.$block->getVar('bid').'</b></span>';
  877.                         } else {
  878.                             $msgs[] = '  Block <b>'.$block->getVar('name').' deleted. Block ID: <b>'.$block->getVar('bid').'</b>';
  879.                         }
  880.                     }
  881.                 }
  882.  
  883.                 $configs = $modules[$mid]->getInfo('config');
  884.                 if ($configs != false) {
  885.                     if ($modules[$mid]->getVar('hascomments') != 0) {
  886.                         include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');
  887.                         array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));
  888.                         array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));
  889.                     }
  890.                 } else {
  891.                     if ($modules[$mid]->getVar('hascomments') != 0) {
  892.                         $configs = array();
  893.                         include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');
  894.                         $configs[] = array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
  895.                         array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));
  896.                     }
  897.                 }
  898.                 // RMV-NOTIFY
  899.                 if ($modules[$mid]->getVar('hasnotification') != 0) {
  900.                     if (empty($configs)) {
  901.                         $configs = array();
  902.                     }
  903.                     include_once(XOOPS_ROOT_PATH.'/include/notification_constants.php');
  904.                     $configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options' => $options);
  905.                 }
  906.  
  907.                 if ($configs != false) {
  908.                     $msgs[] = 'Adding module config data...';
  909.                     $config_handler =& xoops_gethandler('config');
  910.                     $order = 0;
  911.                     foreach ($configs as $config) {
  912.                         $confobj =& $config_handler->createConfig();
  913.                         $confobj->setVar('conf_modid', $newmid);
  914.                         $confobj->setVar('conf_catid', 0);
  915.                         $confobj->setVar('conf_name', $config['name']);
  916.                         $confobj->setVar('conf_title', $config['title'], true);
  917.                         $confobj->setVar('conf_desc', $config['description'], true);
  918.                         $confobj->setVar('conf_formtype', $config['formtype']);
  919.                         $confobj->setVar('conf_valuetype', $config['valuetype']);
  920.                         $confobj->setVar('conf_value', $config['default'], true);
  921.                         $confobj->setVar('conf_order', $order);
  922.                         $confop_msgs = '';
  923.                         if (isset($config['options']) && is_array($config['options'])) {
  924.                             foreach ($config['options'] as $key => $value) {
  925.                                 $confop =& $config_handler->createConfigOption();
  926.                                 $confop->setVar('confop_name', $key, true);
  927.                                 $confop->setVar('confop_value', $value, true);
  928.                                 $confobj->setConfOptions($confop);
  929.                                 $confop_msgs .= '<br />    Config option added. Name: <b>'.$key.'</b> Value: <b>'.$value.'</b>';
  930.                                 unset($confop);
  931.                             }
  932.                         }
  933.                         $order++;
  934.                         if ($config_handler->insertConfig($confobj) != false) {
  935.                             $msgs[] = '  Config <b>'.$config['name'].'</b> added to the database.'.$confop_msgs;
  936.                         } else {
  937.                             $msgs[] = '  <span style="color:#ff0000;">ERROR: Could not insert config <b>'.$config['name'].'</b> to the database.</span>';
  938.                         }
  939.                         unset($confobj);
  940.                     }
  941.                     unset($configs);
  942.                 }
  943.                 foreach ($msgs as $msg) {
  944.                     echo '<code>'.$msg.'</code><br />';
  945.                 }
  946.             }
  947.             // data for table 'block_module_link'
  948.             include_once './class/dbmanager.php';
  949.             $dbm = new db_manager;
  950.             $sql = 'SELECT bid, side FROM '.$dbm->prefix('newblocks');
  951.             $result = $dbm->query($sql);
  952.  
  953.             while ($myrow = $dbm->fetchArray($result)) {
  954.                 if ($myrow['side'] == 0) {
  955.                     $dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", 0)");
  956.                 } else {
  957.                     $dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", -1)");
  958.                 }
  959.             }
  960.         }
  961.         echo '<br />';
  962.         flush();
  963.         sleep(1);
  964.     }
  965. ?>
  966.     </div></td>
  967.     <td width='5%'> </td>
  968.   </tr>
  969.   <tr>
  970.     <td width='5%'> </td>
  971.     <td width='35%' align='left'> </td>
  972.     <td width='20%' align='center'> </td>
  973.     <td width='35%' align='right'><span style='font-size:85%;'><?php echo _INSTALL_L14;?> >></span> <input type='hidden' name='op' value='updateComments' /><input type='submit' name='submit' value='<?php echo _INSTALL_L47;?>' /></td>
  974.     <td width='5%'> </td>
  975.   </tr>
  976.   <tr>
  977.     <td colspan="5"> </td>
  978.   </tr>
  979. </table>
  980.  
  981. <table width="778" cellspacing="0" cellpadding="0" align="center" background="img/bg_table.gif">
  982.   <tr>
  983.     <td width="150"><img src="img/hbar_left.gif" width="100%" height="23" alt="" /></td>
  984.     <td width="478" background="img/hbar_middle.gif"> </td>
  985.     <td width="150"><img src="img/hbar_installer_right.gif" width="100%" height="23" alt="" /></td>
  986.   </tr>
  987. </table>
  988. </form>
  989. </body>
  990. </html>
  991. <?php
  992.     break;
  993.  
  994. case 'updateComments':
  995.     $content = "<p>"._INSTALL_L149."</p>\n";
  996.     $b_next = array('updateComments_go', _INSTALL_L138);
  997.     include 'install_tpl.php';
  998.     break;
  999.  
  1000. case 'updateComments_go':
  1001.     unset($xoopsOption['nocommon']);
  1002.     include '../mainfile.php';
  1003.     include '../class/xoopscomments.php';
  1004.     include '../include/comment_constants.php';
  1005.     $module_handler =& xoops_gethandler('module');
  1006.     $old_commentd_mods = array('news' => 'comments', 'xoopspoll' => 'xoopspollcomments');
  1007.     $title = _INSTALL_L147;
  1008.     $content = '';
  1009.     foreach ($old_commentd_mods as $module => $com_table) {
  1010.         $moduleobj =& $module_handler->getByDirname($module);
  1011.         if (is_object($moduleobj)) {
  1012.             $content .= '<h5>'.$moduleobj->getVar('name').'</h5>';
  1013.             $comment_handler =& xoops_gethandler('comment');
  1014.             $criteria = new CriteriaCompo();
  1015.             $criteria->setOrder('DESC');
  1016.             $criteria->setSort('com_id');
  1017.             $criteria->setLimit(1);
  1018.             $last_comment =& $comment_handler->getObjects($criteria);
  1019.             $offset = (is_array($last_comment) && count($last_comment) > 0) ? $last_comment[0]->getVar('com_id') : 0;
  1020.             $xc = new XoopsComments($xoopsDB->prefix($com_table));
  1021.             $top_comments =& $xc->getAllComments(array('pid=0'));
  1022.  
  1023.             foreach ($top_comments as $tc) {
  1024.                 $sql = sprintf("INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, '%s', '%s', '%s', %u, %u, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix('xoopscomments'), $tc->getVar('comment_id') + $offset, 0, $moduleobj->getVar('mid'), '', addslashes($tc->getVar('subject', 'n')), addslashes($tc->getVar('comment', 'n')), $tc->getVar('date'), $tc->getVar('date'), $tc->getVar('user_id'), $tc->getVar('ip'), 0, $tc->getVar('item_id'), $tc->getVar('comment_id') + $offset, XOOPS_COMMENT_ACTIVE, 0, 1, 1, 1, 1);
  1025.  
  1026.                 if (!$xoopsDB->query($sql)) {
  1027.                     $content .= _NGIMG.sprintf(_INSTALL_L146, $tc->getVar('comment_id') + $offset).'<br />';
  1028.                 } else {
  1029.                     $content .= _OKIMG.sprintf(_INSTALL_L145, $tc->getVar('comment_id') + $offset).'<br />';
  1030.                     $child_comments = $tc->getCommentTree();
  1031.                     foreach ($child_comments as $cc) {
  1032.                         $sql = sprintf("INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, '%s', '%s', '%s', %u, %u, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix('xoopscomments'), $cc->getVar('comment_id') + $offset, $cc->getVar('pid') + $offset, $moduleobj->getVar('mid'), '', addslashes($cc->getVar('subject', 'n')), addslashes($cc->getVar('comment', 'n')), $cc->getVar('date'), $cc->getVar('date'), $cc->getVar('user_id'), $cc->getVar('ip'), 0, $cc->getVar('item_id'), $tc->getVar('comment_id') + $offset, XOOPS_COMMENT_ACTIVE, 0, 1, 1, 1, 1);
  1033.                         if (!$xoopsDB->query($sql)) {
  1034.                             $content .= _NGIMG.sprintf(_INSTALL_L146, $cc->getVar('comment_id') + $offset).'<br />';
  1035.                         } else {
  1036.                             $content .= _OKIMG.sprintf(_INSTALL_L145, $cc->getVar('comment_id') + $offset).'<br />';
  1037.                         }
  1038.                     }
  1039.                 }
  1040.             }
  1041.         }
  1042.     }
  1043.     $xoopsDB->query('ALTER TABLE '.$xoopsDB->prefix('xoopscomments').' CHANGE com_id com_id mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY');
  1044.     $b_next = array('updateSmilies', _INSTALL_L14);
  1045.     include 'install_tpl.php';
  1046.     break;
  1047.  
  1048. case 'updateSmilies':
  1049.     $content = '<p>'._INSTALL_L150.'</p>';
  1050.     $b_next = array('updateSmilies_go', _INSTALL_L140);
  1051.     include 'install_tpl.php';
  1052.     break;
  1053.  
  1054.  
  1055. case 'updateSmilies_go':
  1056.     unset($xoopsOption['nocommon']);
  1057.     include('../mainfile.php');
  1058.     $result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix('smiles'));
  1059.     $content = '';
  1060.     $title = _INSTALL_L155;
  1061.     if (!defined('XOOPS_UPLOAD_PATH')) {
  1062.         define('XOOPS_UPLOAD_PATH', '../uploads');
  1063.     }
  1064.     while ($smiley = $xoopsDB->fetchArray($result)) {
  1065.         if (file_exists('../images/smilies/'.$smiley['smile_url']) && false != $fp = fopen('../images/smilies/'.$smiley['smile_url'], 'rb')) {
  1066.             $binary = fread($fp, filesize('../images/smilies/'.$smiley['smile_url']));
  1067.             fclose($fp);
  1068.             if (!preg_match("/\.([a-zA-Z0-9]+)$/", $smiley['smile_url'], $matched)) {
  1069.                 continue;
  1070.             }
  1071.             $newsmiley = uniqid('smil').'.'.strtolower($matched[1]);
  1072.             if (false != $fp = fopen(XOOPS_UPLOAD_PATH.'/'.$newsmiley, 'wb')) {
  1073.                 if (-1 != fwrite($fp, $binary)) {
  1074.                     $xoopsDB->query("UPDATE ".$xoopsDB->prefix('smiles')." SET smile_url='".$newsmiley."' WHERE id=".$smiley['id']);
  1075.                     $content .= _OKIMG.sprintf(_INSTALL_L154, $smiley['smile_url']).'<br />';
  1076.                 } else {
  1077.                     $content .= _NGIMG.sprintf(_INSTALL_L153, $smiley['smile_url']).'<br />';
  1078.                 }
  1079.                 fclose($fp);
  1080.             }
  1081.         } else {
  1082.             $content .= _OKIMG.sprintf(_INSTALL_L152, $smiley['smile_url']).'<br />';
  1083.         }
  1084.     }
  1085.     $result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix('ranks'));
  1086.     while ($rank = $xoopsDB->fetchArray($result)) {
  1087.         if (file_exists('../images/ranks/'.$rank['rank_image']) && false != $fp = fopen('../images/ranks/'.$rank['rank_image'], 'rb')) {
  1088.             $binary = fread($fp, filesize('../images/ranks/'.$rank['rank_image']));
  1089.             fclose($fp);
  1090.             if (!preg_match("/\.([a-zA-Z0-9]+)$/", $rank['rank_image'], $matched)) {
  1091.                 continue;
  1092.             }
  1093.             $newrank = uniqid('rank').'.'.strtolower($matched[1]);
  1094.             if (false != $fp = fopen(XOOPS_UPLOAD_PATH.'/'.$newrank, 'wb')) {
  1095.                 if (-1 != fwrite($fp, $binary)) {
  1096.                     $content .= _OKIMG.sprintf(_INSTALL_L154, $rank['rank_image']).'<br />';
  1097.                     $xoopsDB->query("UPDATE ".$xoopsDB->prefix('ranks')." SET rank_image='".$newrank."' WHERE rank_id=".$rank['rank_id']);
  1098.                 } else {
  1099.                     $content .= _NGIMG.sprintf(_INSTALL_L153, $rank['rank_image']).'<br />';
  1100.                 }
  1101.                 fclose($fp);
  1102.             }
  1103.         } else {
  1104.             $content .= _OKIMG.sprintf(_INSTALL_L152, $rank['rank_image']).'<br />';
  1105.         }
  1106.     }
  1107.     $b_next = array('updateAvatars', _INSTALL_L14);
  1108.     include 'install_tpl.php';
  1109.     break;
  1110.  
  1111. case 'updateAvatars':
  1112.     $content = '<p>'._INSTALL_L151.'</p>';
  1113.     $b_next = array('updateAvatars_go', _INSTALL_L139);
  1114.     include 'install_tpl.php';
  1115.     break;
  1116.  
  1117. case 'updateAvatars_go':
  1118.     unset($xoopsOption['nocommon']);
  1119.     include('../mainfile.php');
  1120.     $content = '';
  1121.     $title = _INSTALL_L156;
  1122.     $avatars = getImageFileList(XOOPS_ROOT_PATH.'/images/avatar/users/');
  1123.     $xoopsDB->query("UPDATE ".$xoopsDB->prefix('users')." SET user_avatar='blank.gif'");
  1124.     $avt_handler =& xoops_gethandler('avatar');
  1125.     if (!defined('XOOPS_UPLOAD_PATH')) {
  1126.         define('XOOPS_UPLOAD_PATH', '../uploads');
  1127.     }
  1128.     foreach ($avatars as $avatar_file) {
  1129.         if (preg_match("/^([0-9]+)\.([a-zA-Z]+)$/", $avatar_file, $matched)) {
  1130.             $user_id = intval($matched[1]);
  1131.             if ($user_id > 0 && false != $fp = fopen('../images/avatar/users/'.$avatar_file, 'rb')) {
  1132.                 $binary = fread($fp, filesize('../images/avatar/users/'.$avatar_file));
  1133.                 fclose($fp);
  1134.                 $newavatar = uniqid('cavt').'.'.strtolower($matched[2]);
  1135.                 if (false != $fp = fopen(XOOPS_UPLOAD_PATH.'/'.$newavatar, 'wb')) {
  1136.                     if (-1 != fwrite($fp, $binary)) {
  1137.                         $error = false;
  1138.                         if (!$xoopsDB->query("UPDATE ".$xoopsDB->prefix('users')." SET user_avatar='".$newavatar."' WHERE uid=".$user_id)) {
  1139.                             $error = true;
  1140.                         } else {
  1141.                             $avatar =& $avt_handler->create();
  1142.                             $avatar->setVar('avatar_file', $newavatar);
  1143.                             $avatar->setVar('avatar_name', 'custom');
  1144.                             $avatar->setVar('avatar_mimetype', '');
  1145.                             $avatar->setVar('avatar_display', 1);
  1146.                             $avatar->setVar('avatar_type', 'C');
  1147.                             if(!$avt_handler->insert($avatar)) {
  1148.                                 $error = true;
  1149.                             } else {
  1150.                                 $avt_handler->addUser($avatar->getVar('avatar_id'), $user['uid']);
  1151.                             }
  1152.                         }
  1153.                         if (false != $error) {
  1154.                             $content .= _NGIMG.sprintf(_INSTALL_L153, $avatar_file).'<br />';
  1155.                             @unlink(XOOPS_UPLOAD_PATH.'/'.$newavatar);
  1156.                         } else {
  1157.                             $content .= _OKIMG.sprintf(_INSTALL_L154, $avatar_file).'<br />';
  1158.                         }
  1159.                     } else {
  1160.                         $content .= _NGIMG.sprintf(_INSTALL_L153, $avatar_file).'<br />';
  1161.                         $xoopsDB->query("UPDATE ".$xoopsDB->prefix('users')." SET user_avatar='blank.gif' WHERE uid=".$user_id);
  1162.                     }
  1163.                     fclose($fp);
  1164.                 }
  1165.             } else {
  1166.                 $content .= _NGIMG.sprintf(_INSTALL_L152, $avatar_file).'<br />';
  1167.             }
  1168.         }
  1169.     }
  1170.  
  1171.     $b_next = array('finish', _INSTALL_L14);
  1172.     include 'install_tpl.php';
  1173.     break;
  1174.  
  1175.  
  1176. case "siteInit":
  1177.     include_once "../mainfile.php";
  1178.  
  1179.     $content = "<table align='center' width='70%'>\n";
  1180.     $content .= "<tr><td colspan='2' align='center'>"._INSTALL_L36."</td></tr>\n";
  1181.     $content .= "<tr><td align='right'><b>"._INSTALL_L37."</b></td><td><input type=\"text\" name=\"adminname\" /></td></tr>\n";
  1182.     $content .= "<tr><td align='right'><b>"._INSTALL_L38."</b></td><td><input type='text' name='adminmail' value='' maxlength='60' /></td></tr>\n";
  1183.     $content .= "<tr><td align='right'><b>"._INSTALL_L39."</b></td><td><input type='password' name='adminpass' /></td></tr>\n";
  1184.     $content .= "<tr><td align='right'><b>"._INSTALL_L74."</b></td><td><input type='password' name='adminpass2' /></td></tr>\n";
  1185.     $content .= "</table>\n";
  1186.     $b_next = array('insertData', _INSTALL_L116);
  1187.  
  1188.     include 'install_tpl.php';
  1189.     break;
  1190.  
  1191. case "insertData":
  1192.     $adminname = $myts->stripSlashesGPC($_POST['adminname']);
  1193.     $adminpass = $myts->stripSlashesGPC($_POST['adminpass']);
  1194.     $adminpass2 = $myts->stripSlashesGPC($_POST['adminpass2']);
  1195.     $adminmail = $myts->stripSlashesGPC($_POST['adminmail']);
  1196.  
  1197.     if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$adminmail)) {
  1198.         $content = "<p>"._INSTALL_L73."</p>\n";
  1199.         $b_back = array('', _INSTALL_L112 );
  1200.         include 'install_tpl.php';
  1201.         exit();
  1202.     }
  1203.     if ( !isset($adminname) || !isset($adminpass) || !isset($adminmail) || $adminmail == "" || $adminname =="" || $adminpass =="" || $adminpass != $adminpass2) {
  1204.         $content = "<p>"._INSTALL_L41."</p>\n";
  1205.         $b_back = array('', _INSTALL_L112 );
  1206.         include 'install_tpl.php';
  1207.         exit();
  1208.     }
  1209.  
  1210.     include_once "../mainfile.php";
  1211.     //include_once './include/createtables2.php';
  1212.     include_once './makedata.php';
  1213.     include_once './class/dbmanager.php';
  1214.     $dbm = new db_manager;
  1215.     include_once './class/cachemanager.php';
  1216.     $cm = new cache_manager;
  1217.  
  1218.     $language = check_language($language);
  1219.     if ( file_exists("./language/".$language."/install2.php") ) {
  1220.         include_once "./language/".$language."/install2.php";
  1221.     } elseif ( file_exists("./language/english/install2.php") ) {
  1222.         include_once "./language/english/install2.php";
  1223.         $language = 'english';
  1224.     } else {
  1225.         echo 'no language file (install2.php).';
  1226.         exit();
  1227.     }
  1228.  
  1229.     //$tables = array();
  1230.     $result = $dbm->queryFromFile('./sql/'.XOOPS_DB_TYPE.'.data.sql');
  1231.     $result = $dbm->queryFromFile('./language/'.$language.'/'.XOOPS_DB_TYPE.'.lang.data.sql');
  1232.     $group = make_groups($dbm);
  1233.     $result = make_data($dbm, $cm, $adminname, $adminpass, $adminmail, $language, $group);
  1234.     $content = $dbm->report();
  1235.     $content .= $cm->report();
  1236.     include_once "./class/mainfilemanager.php";
  1237.     $mm = new mainfile_manager("../mainfile.php");
  1238.     foreach($group as $key => $val){
  1239.         $mm->setRewrite($key, intval($val));
  1240.     }
  1241.     $result = $mm->doRewrite();
  1242.     $content .= $mm->report();
  1243.  
  1244.     $b_next = array('finish', _INSTALL_L117);
  1245.     $title = _INSTALL_L116;
  1246.     setcookie('xoops_session', '', time() - 3600);
  1247.     include 'install_tpl.php';
  1248.  
  1249.     break;
  1250.  
  1251. case 'finish':
  1252.  
  1253.     $title = _INSTALL_L32;
  1254.     $content = "<table width='60%' align='center'><tr><td align='left'>\n";
  1255.     include './language/'.$language.'/finish.php';
  1256.     $content .= "</td></tr></table>\n";
  1257.     include 'install_tpl.php';
  1258.     break;
  1259. }
  1260.  
  1261. /*
  1262.  * gets list of name of directories inside a directory
  1263.  */
  1264. function getDirList($dirname)
  1265. {
  1266.     require_once dirname(dirname(__FILE__))."/class/xoopslists.php";
  1267.     return XoopsLists::getDirListAsArray($dirname);
  1268. }
  1269.  
  1270. /*
  1271.  * gets list of name of files within a directory
  1272.  */
  1273. function getImageFileList($dirname)
  1274. {
  1275.     require_once dirname(dirname(__FILE__))."/class/xoopslists.php";
  1276.     return XoopsLists::getImgListAsArray($dirname);
  1277. }
  1278.  
  1279. function &xoops_module_gettemplate($dirname, $template, $block=false)
  1280. {
  1281.     if ($block) {
  1282.         $path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/blocks/'.$template;
  1283.     } else {
  1284.         $path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/'.$template;
  1285.     }
  1286.     if (!file_exists($path)) {
  1287.         return false;
  1288.     } else {
  1289.         $lines = file($path);
  1290.     }
  1291.     if (!$lines) {
  1292.         return false;
  1293.     }
  1294.     $ret = '';
  1295.     $count = count($lines);
  1296.     for ($i = 0; $i < $count; $i++) {
  1297.         $ret .= str_replace("\n", "\r\n", str_replace("\r\n", "\n", $lines[$i]));
  1298.     }
  1299.     return $ret;
  1300. }
  1301.  
  1302. function check_language($language){
  1303.      if ( file_exists('../modules/system/language/'.$language.'/modinfo.php') ) {
  1304.         return $language;
  1305.     } else {
  1306.         return 'english';
  1307.     }
  1308. }
  1309. ?>