[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/install/ -> install.php (source)

   1  <?php
   2  #CMS - CMS Made Simple
   3  #(c)2004 by Ted Kulp (wishy@users.sf.net)
   4  #This project's homepage is: http://cmsmadesimple.sf.net
   5  #
   6  #This program is free software; you can redistribute it and/or modify
   7  #it under the terms of the GNU General Public License as published by
   8  #the Free Software Foundation; either version 2 of the License, or
   9  #(at your option) any later version.
  10  #
  11  #This program is distributed in the hope that it will be useful,
  12  #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  #GNU General Public License for more details.
  15  #You should have received a copy of the GNU General Public License
  16  #along with this program; if not, write to the Free Software
  17  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18  
  19  set_magic_quotes_runtime(false);
  20  
  21  function return_bytes($val) {
  22     $val = trim($val);
  23     $last = strtolower($val{strlen($val)-1});
  24     switch($last) 
  25     {
  26         // The 'G' modifier is available since PHP 5.1.0
  27         case 'g':
  28             $val *= 1024;
  29         case 'm':
  30             $val *= 1024;
  31         case 'k':
  32             $val *= 1024;
  33     }
  34     return $val;
  35  }
  36  
  37  
  38  function test_cfg_var_bool( $name, $desc, $success, $row = 'row2', $warning_message = '' )
  39  {
  40    $icon = 'false.gif';
  41    $alt = 'Failure';
  42    $ret = false;
  43    
  44    $str = (bool) ini_get( $name );
  45    $str = ($str) ? 1 : 0;
  46    if( $success == $str )
  47      {
  48        $icon = 'true.gif';
  49        $alt = 'Success';
  50        $ret = true;
  51      }
  52  
  53    echo "<tr class=\"$row\"><td>$desc";
  54    if ($warning_message != '' && $ret == false)
  55    {
  56      echo "<br/><br /><em>$warning_message</em>";
  57    }
  58    echo " </td><td class=\"col2\">";
  59    echo "<img src=\"../images/cms/install/$icon\" alt=\"$alt\" height=\"16\" width=\"16\" border=\"0\" />";
  60    echo "</td></tr>\n";
  61    return $ret;
  62  }
  63  
  64  function test_cfg_var_range( $name, $desc, $yellowlimit, $greenlimit, $row = 'row2', $compare_as_bytes = FALSE, $warning_message = '' )
  65  {
  66    $icon = 'red.gif';
  67    $alt="Failure";
  68    $ret = false;
  69    
  70    if (! is_int( $yellowlimit ) && ! is_int( $greenlimit ) && $compare_as_bytes == TRUE)
  71      {
  72        $yellowlimit_org = $yellowlimit;
  73        $yellowlimit = return_bytes( $yellowlimit );
  74        $greenlimit  = return_bytes( $greenlimit );
  75      }
  76    
  77    if( is_int( $yellowlimit ) && is_int( $greenlimit ) )
  78      {
  79        if ($compare_as_bytes)
  80          {
  81            $str = ini_get( $name );
  82            if ( $str == '' )
  83              {
  84                $warning = "Could not retrieve a value.... passing anyways";
  85                $str = $yellowlimit;
  86                $show_value = $yellowlimit_org;
  87              }
  88            else
  89              {
  90                $show_value = $str;
  91                $str = return_bytes($str);
  92              }
  93          }
  94        else
  95          {
  96            $str = (int) ini_get( $name );
  97          }
  98  
  99      if( $str < 0 )
 100        {
 101          $alt = 'Success (unlimited)';
 102          $icon = 'green.gif';
 103          $ret = true;
 104        }
 105      else if( $str >= $greenlimit )
 106      {
 107        $alt = 'Success';
 108        $icon = 'green.gif';
 109        $ret = true;
 110      }
 111      else if( $str >= $yellowlimit )
 112      {
 113        $alt = 'Caution';
 114        $icon = 'yellow.gif';
 115        $ret = true;
 116      }
 117      if ($compare_as_bytes) 
 118      { 
 119        $str = $show_value; 
 120      }
 121      }
 122    else
 123      {
 124        $warning = "";
 125        $str = strtoupper(ini_get( $name ));
 126        if( $str == "" )
 127      {
 128        $str = $yellowlimit;
 129        $warning = "Could not retrieve a value.... passing anyways";
 130      }
 131        if( strcmp( $str, $yellowlimit ) >= 0 )
 132      {
 133        $alt = 'Caution';
 134        $icon = 'yellow.gif';
 135        $ret = true;
 136      }
 137        if( strcmp( $str, $greenlimit ) >= 0 )
 138      {
 139        $alt = 'Success';
 140        $icon = 'green.gif';
 141        $ret = true;
 142      }
 143      }
 144    echo "<tr class=\"$row\"><td><span class=\"have\">You have \"$str\"</span>$desc";
 145    if ($warning_message != '') {
 146      $warning = '<br /><em>' . $warning_message . '</em>';
 147    }
 148    if( isset( $warning ) && $warning != "" )
 149      {
 150        echo "<br/>$warning";
 151      }
 152    echo "</td><td class=\"col2\">";
 153    echo "<img src=\"../images/cms/install/$icon\" alt=\"$alt\" height=\"16\" width=\"16\" border=\"0\" />";
 154    echo "</td></tr>\n";
 155    return $ret;
 156  }
 157  
 158  $LOAD_ALL_MODULES=1;
 159  require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'fileloc.php');
 160  
 161  $config = CONFIG_FILE_LOCATION;
 162  if (!file_exists($config)) {
 163      $file = @fopen($config, "w");
 164      if ($file != 0) {
 165          $cwd = addslashes(dirname(dirname(__FILE__)));
 166          fwrite($file,"<?php\n".'$config[\'root_path\'] = "'.$cwd.'";'."\n?>\n");
 167          fclose($file);
 168      } else {
 169          echo "Cannot create $config, please change permissions to allow this\n";
 170          exit;
 171      } ## if
 172  } ## if
 173  else if (filesize($config) == 0) {
 174      $file = @fopen($config, "w");
 175      if ($file != 0) {
 176        $cwd = addslashes(dirname(dirname(__FILE__)));
 177        fwrite($file,"<?php\n".'$config[\'root_path\'] = "'.$cwd.'";'."\n?>\n");
 178        fclose($file);
 179      } else {
 180        echo "Cannot modify $config, please change permissions to allow this\n";
 181        exit;
 182      } ## if
 183  }
 184  
 185  $pages = 4;
 186  if (isset($_POST["page"])) {
 187      $currentpage = $_POST["page"];
 188  } elseif (isset($_GET["page"])) {
 189      $currentpage = $_GET["page"];
 190  } else {  
 191      $currentpage = 1;
 192  } ## if
 193  
 194  // Test for sessions if this is the first page of the install
 195  if (1 == $currentpage)
 196    {
 197      @session_start();
 198      if (!isset($_GET['sessiontest']))
 199        {
 200      $_SESSION['test'] = TRUE;
 201      $scheme = ((! isset($_SERVER['HTTPS'])) || strtolower($_SERVER['HTTPS']) != 'on') ? 'http' : 'https';
 202      $redirect = $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?sessiontest=1&' . SID;
 203      header("Location: $redirect");
 204        }
 205    }
 206  
 207  $DONT_LOAD_DB = true;
 208  
 209  if ($currentpage > 1) { require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."include.php"); }
 210  
 211  ?>
 212  
 213  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 214  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 215  <head>
 216          <title>CMS Made Simple Install</title>
 217          <link rel="stylesheet" type="text/css" href="install.css" />
 218          <script src="../admin/themes/default/includes/standard.js" type="text/javascript"></script>
 219  </head>
 220  
 221  <body>
 222  
 223  <div class="body">
 224  
 225  <img src="../images/cms/cmsbanner.jpg" width="800" height="100" alt="CMS Banner Logo" />
 226  
 227  <div class="headerish">
 228  
 229  <h1>Install System</h1>
 230  
 231  </div>
 232  
 233  <div class="main">
 234  <?php
 235  
 236  echo "<h2>Thanks for installing CMS Made Simple</h2>\n";
 237  echo "<table class=\"countdown\" cellspacing=\"2\" cellpadding=\"2\"><tr>";
 238  echo "<td><img src=\"../images/cms/install/".($currentpage==1?"1":"1off").".gif\" alt=\"Step 1\" /></td>";
 239  echo "<td><img src=\"../images/cms/install/".($currentpage==2?"2":"2off").".gif\" alt=\"Step 2\" /></td>";
 240  echo "<td><img src=\"../images/cms/install/".($currentpage==3?"3":"3off").".gif\" alt=\"Step 3\" /></td>";
 241  echo "<td><img src=\"../images/cms/install/".($currentpage==4?"4":"4off").".gif\" alt=\"Step 4\" /></td>";
 242  echo "<td><img src=\"../images/cms/install/".($currentpage==5?"5":"5off").".gif\" alt=\"Step 5\" /></td>";
 243  echo "</tr></table>\n";
 244  echo "<br />";
 245  
 246  
 247  switch ($currentpage) {
 248      case 1:
 249          showPageOne();
 250          break;
 251      case 2:
 252          showPageTwo();
 253          break;
 254      case 3:
 255          showPageThree();
 256          break;
 257      case 4:
 258          showPageFour();
 259          break;
 260      case 5:
 261          showPageFive();
 262          break;
 263      default:
 264          echo "You were supposed to turn <a href=\"install.php\">right</a> at Alberquerque.<p>\n";
 265          break;
 266  } ## switch
 267  
 268  function showPageOne() {
 269    ## test file permissions
 270    ## apache (or other webserver) user needs to have write access to the cache and template_c dirs
 271    ## as well as the cms root for config.php to be created.
 272  
 273    ## find the user running this script
 274    #$userid = posix_getuid();
 275    #$userdata = posix_getpwuid($userid);
 276    #$username = $userdata['name'];
 277  
 278    ## echo "Userid ($userid) is named $username is running this script<p>\n";
 279  
 280    ## check file perms
 281    
 282    $continueon = true;
 283    echo '<p class="important">Please read the <a href="http://wiki.cmsmadesimple.org/index.php/User_Handbook/Installation/Troubleshooting">Installation Troubleshooting</a> page in the CMS Made Simple Documentation Wiki.</p>';
 284    echo "<h3>Checking permissions and PHP settings</h3>\n";
 285    #$files = array(TMP_CACHE_LOCATION, TMP_TEMPLATES_C_LOCATION, dirname(dirname(__FILE__)).'/uploads', CONFIG_FILE_LOCATION);
 286    $files = array(TMP_CACHE_LOCATION, TMP_TEMPLATES_C_LOCATION, CONFIG_FILE_LOCATION);
 287  
 288  
 289  
 290    // body
 291    echo "<table class=\"settings\" border=\"0\">\n";
 292    echo "<caption class=\"tbcaption\">Required settings</caption>\n";
 293    echo "<thead class=\"tbhead\"><tr><th>Test</th><th>Result</th></tr></thead><tbody>\n";
 294  
 295    echo "<tr class=\"row1\"><td>Checking for PHP version 4.2+</td><td class=\"col2\">";
 296    echo (@version_compare(phpversion(),"4.2.0") > -1?'<img src="../images/cms/install/true.gif" alt="Success" height="16" width="16" border="0" />':'<img src="../images/cms/install/false.gif" alt="Failure" height="16" width="16" border="0" />');
 297    (@version_compare(phpversion(),"4.2.0") > -1?null:$continueon=false);
 298    echo "</td></tr>\n";
 299      
 300    echo "<tr class=\"row2\"><td>Checking for Session Functions</td><td class=\"col2\">";
 301    if (function_exists("session_start"))
 302      {
 303        echo '<img src="../images/cms/install/true.gif" alt="Success" height="16" width="16" border="0" />';
 304      }
 305    else
 306      {
 307        echo '<img src="../images/cms/install/false.gif" alt="Failure" height="16" width="16" border="0" />';
 308        $continueon = false;
 309      }
 310    echo "</td></tr>\n";
 311      
 312    echo "<tr class=\"row1\"><td>Checking for md5 Function</td><td class=\"col2\">";
 313    if (function_exists("md5"))
 314      {
 315        echo '<img src="../images/cms/install/true.gif" alt="Success" height="16" width="16" border="0" />';
 316      }
 317    else
 318      {
 319        echo '<img src="../images/cms/install/false.gif" alt="Failure" height="16" width="16" border="0" />';
 320        $continueon = false;
 321      }
 322    echo "</td></tr>\n";
 323      
 324    $currow = 'row2';
 325    foreach ($files as $f) {
 326      #echo "<tr><td>\n";
 327      ## check if we can write to the this file
 328      echo "<tr class=\"$currow\"><td>Checking write permission on $f";
 329  
 330      echo "</td><td class=\"col2\">";
 331        
 332      if (is_writable($f))
 333        {
 334      echo '<img src="../images/cms/install/true.gif" alt="Success" height="16" width="16" border="0" />';
 335        }
 336      else
 337        {
 338      $continueon=false;
 339      echo '<img src="../images/cms/install/false.gif" alt="Failure" height="16" width="16" border="0" />';
 340        } ## if 
 341      echo "</td></tr>\n";
 342      ($currow=="row1"?$currow="row2":$currow="row1");
 343    } ## foreach
 344      
 345    echo "<tr class=\"row1\"><td>Checking for basic XML (expat) support";
 346    if( !function_exists( "xml_parser_create" ) )
 347      {
 348        echo '<br /><br /><em>XML support is not compiled into your php install.  You can still use the system, but will not be able to use any of the remote module installation functions.</em>';
 349        echo '</td><td class="col2"><img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 350        $special_failed=true;
 351      }
 352    else
 353      {
 354        echo '</td><td class="col2"><img src="../images/cms/install/true.gif" alt="Success" height="16" width="16" border="0" />';
 355      }
 356    echo "</td></tr>\n";
 357    echo "</tbody></table>\n";
 358   
 359   echo "<br /><br />\n";
 360   
 361   // Checking for recommended settings
 362    echo "<table class=\"settings\" border=\"0\">\n";
 363    echo "<caption class=\"tbcaption\">Recommended settings</caption>\n";
 364    echo "<thead class=\"tbhead\"><tr><th>Test</th><th>Result</th></tr></thead><tbody>\n";
 365    
 366    ($currow=="row1"?$currow="row2":$currow="row1");
 367    if (!test_cfg_var_bool( "file_uploads", "Checking file uploads", 1, $currow, 'You will not be able to use any of the file uploading facilities included in CMS Made Simple.  If possible, this restriction should be lifted by your system admin to properly use all file management features of the system.  Proceed with caution.' ))
 368    {
 369      $special_failed=true;
 370    }
 371    
 372    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 373    if(!test_cfg_var_range( "memory_limit", "Checking PHP memory limit (min 8M, recommend 16M)", "8M", "16M", $currow, TRUE, 'You may not have enough memory to run CMSMS correctly. If possible, you should try to get your system admin to raise this value to the minimum 8M or great. Proceed with caution.'))
 374    {
 375      $special_failed=true;
 376    }
 377    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 378    if (!test_cfg_var_range( "upload_max_filesize", "Checking max upload file size (min 2M, recommend 10M)", "2M", "10M", $currow, TRUE, 'You probably will not be able to upload any files using any of the included file management functions.  Please be aware of this restriction.' ))
 379    {
 380      $special_failed=true;
 381    }
 382    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 383   
 384    // is uploads dir writable?
 385    $f = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'uploads';
 386    echo "<tr class=\"$currow\"><td>Checking if $f is writable<br/><br/>
 387          <em>If uploads is not writable you can still install the system, but you will not be able to upload files via the Admin Panel.</em>
 388          </td><td class=\"col2\">";
 389    if (is_writable($f))
 390      {
 391        echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 392      }
 393    else
 394      {
 395        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 396      }
 397    echo "</td></tr>\n";
 398    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 399  
 400  
 401    // is modules dir writable?
 402    $f = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'modules';
 403    echo "<tr class=\"$currow\"><td>Checking if $f is writable<br/><br/>
 404          <em>If modules is not writable you can still install the system, but you will not be able to install modules via the Admin Panel.</em>
 405          </td><td class=\"col2\">";
 406    if (is_writable($f))
 407      {
 408        echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 409      }
 410    else
 411      {
 412        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 413      }
 414    echo "</td></tr>\n";
 415    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 416  
 417   
 418      // do we have the file_get_contents function
 419    echo "<tr class=\"$currow\"><td>Checking for file_get_contents<br/><br/>
 420          <em>The file_get_contents function was added in PHP 4.3 and although a workaround has been added that should allow most functionality that uses this function to work properly in PHP 4.2, it may be advisable to upgrade to PHP 4.3 or greater.</em>
 421          </td><td class=\"col2\">";
 422    if (function_exists("file_get_contents"))
 423      {
 424        echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 425      }
 426    else
 427      {
 428        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 429      }
 430    echo "</td></tr>\n";
 431    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 432  
 433     // is session_save_path writable?
 434    echo "<tr class=\"$currow\"><td>Checking if session.save_path is writable<br/><br/>";
 435    echo '<em>Your session.save_path is "'.session_save_path().'". Not having this as writable may make logins to the Admin Panel not work. You may want to look into making this path writable if you have trouble logging into the Admin Panel.</em>
 436         </td><td class="col2">';
 437    if (is_writable(session_save_path()))
 438      {
 439        echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 440      }
 441    else
 442      {
 443        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 444      }
 445    echo "</td></tr>\n";
 446    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 447  
 448    // can we set a php ini variable
 449    echo "<tr class=\"$currow\"><td>Checking if ini_set works<br/><br/>
 450          <em>Although the ability to override php ini settings is not mandatory, some addon (optional) functionality uses ini_set to extend timeouts, and allow uploading of larger files, etc.  You may have difficulty with some addon functionality without this capability.</em>
 451          </td><td class=\"col2\">";
 452    ini_set( 'max_execution_time', '123' );
 453    if( ini_get('max_execution_time') == 123 )
 454      {
 455        echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 456      }
 457    else
 458      {
 459        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 460      }
 461    echo "</td></tr>\n";
 462    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 463  
 464    // are sessions enabled?
 465    echo "<tr class=\"$currow\"><td>Checking if sessions are enabled<br/><br/>
 466          <em>Although the PHP support for sessions is not mandatory, it is highly recommended. Logins and other things may slow down and you may have difficulty with some addon functionality without this capability.</em>
 467          </td><td class=\"col2\">";
 468    if( isset($_GET['sessiontest']) && isset($_SESSION['test']) )
 469      {
 470        echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 471      }
 472    else
 473      {
 474        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 475      }
 476    echo "</td></tr>\n";
 477    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 478    
 479    // Do tokenizer functions exist?
 480    echo "<tr class=\"$currow\"><td>Checking for tokenizer functions<br/><br/>
 481          <em>Not having the tokenizer could cause pages to render as purely white.  We recommend you have this installed, but your website may work fine without it.</em>
 482          </td><td class=\"col2\">";
 483    if (function_exists("token_get_all"))
 484      {
 485       echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 486      }
 487    else
 488      {
 489        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 490      }
 491    echo "</td></tr>\n";
 492    $currow = ($currow == 'row1') ? 'row2' : 'row1';
 493  
 494    // Safe mode?
 495    echo "<tr class=\"$currow\"><td>Checking for Safe mode<br/><br/>
 496          <em>PHP Safe mode could create some problems with uploading files and other functions. It all depends on how strict your server safe mode settings are.</em>
 497          </td><td class=\"col2\">";
 498    if (ini_get('safe_mode'))
 499      {
 500        echo '<img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" />';
 501      }
 502    else
 503      {
 504       echo '<img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" />';
 505  
 506      }
 507    echo "</td></tr>\n";
 508  
 509  
 510    $special_failed=false;
 511      echo "</tbody></table>\n";
 512  
 513    echo "<br /><br />\n";
 514      
 515    // legend
 516    echo "<table class=\"legend\" border=\"0\">\n";
 517    echo "<caption class=\"tbcaption\">Legend</caption>\n";
 518    echo "<thead class=\"tbhead\"><tr><th>Symbol</th><th>Definition</th></tr></thead>\n";
 519    echo "<tbody>\n";
 520    echo '<tr><td><img src="../images/cms/install/true.gif" alt="Success" height="16" width="16" border="0" /></td><td>A required test passed</td></tr>';
 521    echo '<tr><td><img src="../images/cms/install/false.gif" alt="Failure" height="16" width="16" border="0" /></td><td>A required test failed</td></tr>';
 522    echo '<tr><td><img src="../images/cms/install/red.gif" alt="Failure" height="16" width="16" border="0" /></td><td>A setting is below a required minumum value</td></tr>';
 523    echo '<tr><td><img src="../images/cms/install/yellow.gif" alt="Caution" height="16" width="16" border="0" /></td><td>A setting is above the required value, but below the recommended value<br /><br />or... A capability that <em>may</em> be required for some optional functionality is unavailable</td></tr>';
 524    echo '<tr><td><img src="../images/cms/install/green.gif" alt="Success" height="16" width="16" border="0" /></td><td>A setting meets or exceeds the recommended threshhold<br /><br />or... A capability that <em>may</em> be required for some optional functionality is available</td></tr>';
 525    echo "</tbody>\n";
 526    echo "</table><br/>\n";
 527    
 528      
 529    echo '<form method="post" action="install.php">';
 530      
 531    if ($continueon)
 532      {
 533        if($special_failed) {
 534      echo '<p class="failure" align="center">One or more tests have failed. You can still install the system but some functions may not work correctly. Please click the Continue button.</p>';
 535        } else {
 536      echo '<p class="success" align="center">All tests passed (at least at a minimum level). Please click the Continue button.</p>';
 537        }
 538        echo '<p class="continue" align="center"><input type="hidden" name="page" value="2" /><input type="submit" value="Continue" /></p>';
 539      }
 540    else
 541      {
 542        echo '<p class="failure" align="center">One or more tests have failed. Please correct the problem and click the button below to recheck.</p>';
 543        echo '<p class="continue" align="center"><input type="Submit" value="Try Again" /></p>';
 544      }
 545    echo '</form>';
 546  
 547  } ## showPageOne
 548  
 549  function showPageTwo($errorMessage='',$username='',$email='',$email_accountinfo='0')
 550  {
 551  
 552      if ($errorMessage != '')
 553      {
 554          echo "<p class=\"error\">$errorMessage</p>";
 555      }
 556      ?>
 557  
 558  <h3>Admin Account Information</h3>
 559  
 560  <p>
 561  Select the username, password and email address for your admin account.  Please make sure you record this password somewhere, as
 562  there will be no other way to login to your CMS Made Simple admin system without it.
 563  </p>
 564  
 565  <form action="install.php" method="post" name="page2form" id="page2form">
 566  
 567  <table border="0" class="adminaccount">
 568  
 569      <tr class="row1">
 570          <td>Username</td>
 571          <td><input class="defaultfocus" type="text" name="adminusername" value="<?php echo $username?>" size="20" maxlength="50" /></td>
 572      </tr>
 573  
 574      <tr class="row2">
 575          <td>E-mail Address</td>
 576          <td><input type="text" name="adminemail" value="<?php echo $email?>" size="20" maxlength="50" /></td>
 577      </tr>
 578  
 579      <tr class="row1">
 580          <td>Password</td>
 581          <td><input type="password" name="adminpassword" value="" size="20" maxlength="50" /></td>
 582      </tr>
 583  
 584      <tr class="row2">
 585          <td>Password Again</td>
 586          <td><input type="password" name="adminpasswordagain" value="" size="20" maxlength="50" /></td>
 587      </tr>
 588  <?php
 589  if (function_exists('mail'))
 590  {
 591  ?>
 592      <tr class="row1">
 593          <td>E-Mail Account Information</td>
 594          <td><input type="checkbox" name="email_accountinfo" value="1" <?php if ($email_accountinfo == 1) echo ' checked="checked"' ?> /></td>
 595      </tr>
 596  <?php
 597  }
 598  ?>
 599  </table>
 600  
 601  <p align="center" class="continue"><input type="hidden" name="page" value="3" /><input type="submit" value="Continue" /><!--<a onclick="document.page2form.submit()" href="#">Continue</a>--></p>
 602  
 603  </form>
 604  
 605      <?php
 606  
 607  } ## showPageTwo()
 608  
 609  function showPageThree($errorMessage='')
 610  {
 611      $email_accountinfo = isset($_POST['email_accountinfo']) ? true : false;
 612  
 613      if ($errorMessage != '')
 614      {
 615          echo "<p class=\"error\">$errorMessage</p>";
 616      }
 617  # Do check that username and password are filled out.
 618  # Skip back to showPageTwo() if necessary
 619  # Put given variables into hidden fields so they can up UPDATEd later on in step 4 (post schema install)
 620      if ($_POST['adminusername'] == '')
 621      {
 622          showPageTwo('Username not given!', '', $_POST['adminemail'], ($email_accountinfo ? '1' : '0'));
 623          return;
 624      }
 625      else if ($_POST['adminpassword'] == '' || $_POST['adminpasswordagain'] == '')
 626      {
 627          showPageTwo('Both password fields not given!', $_POST['adminusername'], $_POST['adminemail'], ($email_accountinfo ? '1' : '0'));
 628          return;
 629      }
 630      else if ($_POST['adminpassword'] != $_POST['adminpasswordagain'])
 631      {
 632          showPageTwo('Password fields do not match!', $_POST['adminusername'], $_POST['adminemail'], ($email_accountinfo ? '1' : '0'));
 633          return;
 634      }
 635      if ($email_accountinfo && trim($_POST['adminemail'] == ''))
 636      {
 637          showPageTwo('E-mail accountinfo selected, but no E-mail address given!', $_POST['adminusername'], $_POST['adminemail'], '1');
 638          return;
 639      }
 640      
 641      $adminusername = $_POST['adminusername'];
 642      $adminemail = $_POST['adminemail'];
 643      $adminpassword = $_POST['adminpassword'];
 644  ?>
 645  
 646  <form action="install.php" method="post" name="page3form" id="page3form">
 647  
 648  <h3>Site Name</h3>
 649  
 650  <p>This is the name of your site.  It will be used in various places of the default templates and can be used anywhere with the
 651  {sitename} tag.</p>
 652  <p style="text-align: center;"><input class="defaultfocus selectall" type="text" name="sitename" size="40" value="<?php echo isset($_POST['sitename'])? htmlentities($_POST['sitename']):'CMS Made Simple Site' ?>" /></p>
 653  
 654  <h3>Database Information</h3>
 655  
 656  <p>Make sure you have created your database and granted full privileges to a user to use that database.</p>
 657  <p>For MySQL, use the following:</p>
 658  <p>Log in to mysql from a console and run the following commands:</p>
 659  <ol>
 660  <li>create database cms; (use whatever name you want here but make sure to remember it, you&apos;ll need to enter it on this page)</li>
 661  <li>grant all privileges on cms.* to cms_user@localhost identified by 'cms_pass';</li>
 662  </ol>
 663  
 664  <p>Please complete the following fields:</p>
 665  
 666  <table cellpadding="2" border="1" class="regtable">
 667  <tr class="row2">
 668      <td>Database Type:</td>
 669      <td>
 670          <select name="dbms">
 671  <?php
 672  $valid_database = false;
 673  if (extension_loaded('mysql'))
 674      {
 675      echo '<option value="mysql" ';
 676      echo (isset($_POST['dbms']) && $_POST['dbms'] == 'mysql'?'selected="selected"':'');
 677      echo '>MySQL</option>';
 678      $valid_database = true;
 679      }
 680  if (extension_loaded('mysqli'))
 681      {
 682      echo '<option value="mysqli" ';
 683      echo (isset($_POST['dbms']) && $_POST['dbms'] == 'mysqli'?'selected="selected"':'');
 684      echo '>MySQL (4.1+)</option>';
 685      $valid_database = true;
 686      }
 687  if (extension_loaded('pgsql'))
 688      {
 689      echo '<option value="postgres7" ';
 690      echo (isset($_POST['dbms']) && $_POST['dbms'] == 'postgres7'?'selected="selected"':'');
 691      echo '>PostgreSQL 7/8</option>';
 692      $valid_database = true;
 693      }
 694  if (extension_loaded('sqlite'))
 695      {
 696      echo '<option value="sqlite" ';
 697      echo (isset($_POST['dbms']) && $_POST['dbms'] == 'sqlite'?'selected="selected"':'');
 698      echo '>SQLite</option>';
 699      $valid_database = true;
 700      }
 701  ?>
 702          </select>
 703  <?php if (! $valid_database) { ?>
 704  <div class="error">No valid database drivers appear to be compiled into your PHP install. Please confirm that you have mysql, mysqli, and/or postgres7 support installed, and try again.</div>
 705  <?php } ?>
 706      </td>
 707  </tr>
 708  <tr class="row1">
 709  <td>Database host address</td>
 710  <td><input type="text" name="host" value="<?php echo (isset($_POST['host'])?$_POST['host']:'localhost') ?>" size="20" maxlength="50" /></td>
 711  </tr>
 712  <tr class="row2">
 713  <td>Database name</td>
 714  <td><input type="text" name="database" value="<?php echo (isset($_POST['database'])?$_POST['database']:'cms') ?>" size="20" maxlength="50" /></td>
 715  </tr>
 716  <tr class="row1">
 717  <td>Username</td>
 718  <td><input type="text" name="username" value="<?php echo (isset($_POST['username'])?$_POST['username']:'cms_user') ?>" size="20" maxlength="50" /></td>
 719  </tr>
 720  <tr class="row2">
 721  <td>Password</td>
 722  <td><input type="password" name="password" value="<?php echo (isset($_POST['password'])?$_POST['password']:'cms_pass') ?>" size="20" maxlength="50" /></td>
 723  </tr>
 724  <tr class="row1">
 725  <td>Table prefix</td>
 726  <td><input type="text" name="prefix" value="<?php echo (isset($_POST['prefix'])?$_POST['prefix']:'cms_') ?>" size="20" maxlength="50" />
 727  <input type="hidden" name="page" value="4" />
 728  <input type="hidden" name="adminusername" value="<?php echo $adminusername ?>" />
 729  <input type="hidden" name="adminemail" value="<?php echo $adminemail ?>" />
 730  <input type="hidden" name="adminpassword" value="<?php echo $adminpassword ?>" />
 731  <input type="hidden" name="adminpasswordagain" value="<?php echo $adminpassword ?>" />
 732  <?php
 733  if ($email_accountinfo) 
 734  {
 735  ?>
 736  <input type="hidden" name="email_accountinfo" value="<?php echo $_POST['adminemail'] ?>" />
 737  <?php
 738  }
 739  ?>
 740  </td>
 741  </tr>
 742  <tr class="row2">
 743  <td>Create Tables (Warning: Deletes existing data)</td>
 744  <td><input type="checkbox" name="createtables" checked="true" /></td>
 745  </tr>
 746  <?php if (is_file(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'schemas' . DIRECTORY_SEPARATOR . 'extra.sql')) { ?>
 747  <tr class="row1">
 748  <td>Install sample content and templates</td>
 749  <td><input type="checkbox" name="createextra" checked="true" /></td>
 750  </tr>
 751  <?php } ?>
 752  </table>
 753  <p align="center" class="continue"><!--<a onclick="document.page3form.submit()" href="#">Continue</a>-->
 754  <?php if (! $valid_database) { ?>
 755  <input type="submit" value="Retry" /></p>
 756  <?php } else { ?>
 757  <input type="submit" value="Continue" /></p>
 758  <?php } ?>
 759  <!--<p><input type="submit" value="Continue" /></p>-->
 760  </form>
 761  <?php
 762  
 763  } ## showPageThree
 764  
 765  function showPageFour($sqlloaded = 0) {
 766  
 767  # Do check that database information has been entered
 768  # Skip back to showPageThree() if necessary
 769  
 770          if ($_POST['dbms'] == '')
 771          {
 772                  showPageThree('No dbms selected!');
 773                  return;
 774          }
 775  
 776  
 777      ## don't load statements if they've already been loaded
 778      if ($sqlloaded == 0 && isset($_POST["createtables"])) {
 779  
 780          global $config, $CMS_SCHEMA_VERSION, $ADODB_vers;
 781  
 782          $db = ADONewConnection($_POST['dbms'], 'pear:date:extend:transaction');
 783          
 784          if ($_POST['dbms'] == 'sqlite' && strstr($ADODB_vers, 'ADOdb Lite'))
 785          {
 786              showPageThree('Currently Database Type SQLite will not work with ADOdb Lite.<br /> Add $config[\'use_adodb_lite\'] = false; to your config.php and make sure there is a full version of adodb present in the lib/adodb directory within your CMS Made Simple installation.');
 787              return;
 788          }
 789  
 790          $result = $db->Connect($_POST['host'],$_POST['username'],$_POST['password'],$_POST['database']);
 791          $db_prefix = $_POST['prefix'];
 792          #$db->debug = true;
 793  
 794          if (!$result)
 795          {
 796              showPageThree('Could not connect to database.  Verify that username and password are correct, and that the user has access to the given database.');
 797              return;
 798          }
 799  
 800          //Try to create and drop a dummy table (with appropriate prefix)
 801          @$db->Execute('DROP TABLE ' . $db_prefix . 'dummyinstall');
 802          $result = $db->Execute('CREATE TABLE ' . $db_prefix . 'dummyinstall (i int)');
 803          if ($result)
 804          {
 805              $result = $db->Execute('DROP TABLE ' . $db_prefix . 'dummyinstall');
 806              if (!$result)
 807              {
 808                  //could not drop table
 809                  showPageThree('Could not drop a table.  Verify that the user has privileges to drop tables in the given database.');
 810                  return;
 811              }
 812          }
 813          else
 814          {
 815              //could not create table
 816              showPageThree('Could not create a table.  Verify that the user has privileges to create tables in the given database.');
 817              return;
 818          }
 819  
 820          $db->SetFetchMode(ADODB_FETCH_ASSOC);
 821  
 822          $CMS_INSTALL_DROP_TABLES=1;
 823          $CMS_INSTALL_CREATE_TABLES=1;
 824          
 825          include_once(dirname(__FILE__).DIRECTORY_SEPARATOR."schemas".DIRECTORY_SEPARATOR."schema.php");
 826          
 827          echo "<p>Importing sample data...";
 828          
 829          $handle = '';
 830  
 831          if (isset($_POST["createextra"]))
 832          {
 833              $handle = fopen(dirname(__FILE__).DIRECTORY_SEPARATOR."schemas".DIRECTORY_SEPARATOR."extra.sql", 'r');
 834          }
 835          else
 836          {
 837              $handle = fopen(dirname(__FILE__).DIRECTORY_SEPARATOR."schemas".DIRECTORY_SEPARATOR."initial.sql", 'r');
 838          }
 839  
 840          if ($handle) {
 841              while (!feof($handle)) {
 842                  set_magic_quotes_runtime(false);
 843                  $s = fgets($handle, 32768);
 844                  if ($s != "") {
 845                      $s = trim(str_replace("{DB_PREFIX}", $db_prefix, $s));
 846                      $s = str_replace("\\r\\n", "\r\n", $s);
 847                      $s = str_replace("\\'", "''", $s);
 848                      $s = str_replace('\\"', '"', $s);
 849                      $result = $db->Execute($s);
 850                      if (!$result) {
 851                          die("Invalid query: $s");
 852                      } ## if
 853                  }
 854              }
 855          }
 856  
 857          fclose($handle);
 858  
 859          echo "[done]</p>";
 860  
 861          echo "<p>Setting admin account information...";
 862  
 863          $sql = 'UPDATE ' . $db_prefix . 'users SET username = ?, password = ?, email = ? WHERE user_id = 1';
 864          $db->Execute($sql, array($_POST['adminusername'], md5($_POST['adminpassword']), $_POST['adminemail']));
 865  
 866          echo "[done]</p>";
 867          
 868          echo "<p>Setting sitename...";
 869  
 870          $query = "INSERT INTO ". $db_prefix ."siteprefs (sitepref_name, sitepref_value) VALUES (?,?)";
 871          $db->Execute($query, array('sitename', htmlentities($_POST['sitename'])));
 872  
 873          echo "[done]</p>";
 874  
 875          include_once(dirname(__FILE__).DIRECTORY_SEPARATOR."schemas".DIRECTORY_SEPARATOR."createseq.php");
 876  
 877          $db->Close();
 878          echo '<p class="success">Success!</p>';
 879  
 880      } ## if
 881  
 882      $docroot = 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'],0,strlen($_SERVER['PHP_SELF'])-20);
 883      $docpath = dirname(dirname(__FILE__)); 
 884  
 885      ?>
 886  
 887      <p>Now let's continue to setup your configuration file, we already have most of the stuff we need. Chances are you can leave all these values alone, so when you are ready, click Continue.</p>
 888      <form action="install.php" method="post" name="page3form" id="page3form">
 889      <table cellpadding="2" border="1" class="regtable">
 890          <tr class="row1">
 891              <td>CMS Document root (as seen from the webserver)</td>
 892              <td><input type="text" name="docroot" value="<?php echo $docroot?>" size="50" maxlength="100" /></td>
 893          </tr>
 894          <tr class="row2">
 895              <td>Path to the Document root</td>
 896              <td><input type="text" name="docpath" value="<?php echo $docpath?>" size="50" maxlength="100" /></td>
 897          </tr>
 898          <tr class="row1">
 899              <td>Query string (leave this alone unless you have trouble, then edit config.php by hand)</td>
 900              <td>
 901                  <input type="text" name="querystr" value="page" size="20" maxlength="20" />
 902                  <input type="hidden" name="page" value="5" /><input type="hidden" name="host" value="<?php echo $_POST['host']?>" />
 903                 <input type="hidden" name="dbms" value="<?php echo $_POST['dbms']?>" />
 904                 <input type="hidden" name="database" value="<?php echo $_POST['database']?>" />
 905                 <input type="hidden" name="username" value="<?php echo $_POST['username']?>" />
 906                  <input type="hidden" name="password" value="<?php echo $_POST['password']?>" />
 907                 <input type="hidden" name="prefix" value="<?php echo $_POST['prefix']?>" />
 908                  <input type="hidden" name="bbcode" value="false" />
 909                  <?php if (isset($_POST["createtables"])) { ?>
 910                  <input type="hidden" name="createtables" value="true" />
 911                  <?php } ?>
 912                  <?php if (isset($_POST["email_accountinfo"])) { ?>
 913                  <input type="hidden" name="email_accountinfo" value="<?php echo $_POST['email_accountinfo'] ?>" />
 914                  <input type="hidden" name="adminusername" value="<?php echo $_POST['adminusername'] ?>" />
 915                  <input type="hidden" name="adminpassword" value="<?php echo $_POST['adminpassword'] ?>" />
 916                  <?php } ?>
 917              </td>
 918          </tr>
 919          <!--
 920          <tr class="row2">
 921              <td>Use BBCode (must have this installed, see <a href="INSTALL" target="_new">INSTALL</a></td>
 922              <td>
 923                  <input type="text" name="bbcode" value="false" size="5" maxlength="5">
 924              </td>
 925          </tr>
 926          -->
 927      </table>
 928      <p align="center" class="continue"><!--<a onclick="document.page3form.submit()" href="#">Continue</a>--><input type="submit" value="Continue" /></p>
 929      </form>
 930  
 931      <?php
 932      
 933  } ## showPageFour
 934  
 935  function showPageFive() {
 936  
 937      global $gCms;
 938  
 939      /*
 940      if ($_POST['bbcode'] != 'false' and $_POST['bbcode'] != 'true') {
 941          echo "<p>BB Code needs to be either 'true' or 'false'</p>\n";
 942          showPageFour(1);
 943          exit;
 944      } ## if
 945      */
 946      
 947      require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR."config.functions.php");
 948      
 949      // check if db info is correct as it should at this point to prevent an undeleted installation dir
 950      // to be used for sending spam by messing up $_POST variables
 951      $db = ADONewConnection($_POST['dbms'], 'pear:date:extend:transaction');
 952      
 953      if (! $db->Connect($_POST['host'],$_POST['username'],$_POST['password'],$_POST['database']))
 954      {
 955          showPageThree('Could not connect to database.  Verify that username and password are correct, and that the user has access to the given database.');
 956          return;
 957      }
 958  
 959      $newconfig = cms_config_load();
 960  
 961      $newconfig['dbms'] = $_POST['dbms'];
 962      $newconfig['db_hostname'] = $_POST['host'];
 963      $newconfig['db_username'] = $_POST['username'];
 964      $newconfig['db_password'] = $_POST['password'];
 965      $newconfig['db_name'] = $_POST['database'];
 966      $newconfig['db_prefix'] = $_POST['prefix'];
 967      $newconfig['root_url'] = $_POST['docroot'];
 968      $newconfig['root_path'] = str_replace('\\\\', '\\', addslashes($_POST['docpath']));
 969      $newconfig['query_var'] = $_POST['querystr'];
 970      $newconfig['use_bb_code'] = false;
 971      $newconfig['use_smarty_php_tags'] = false;
 972      $newconfig['previews_path'] = TMP_CACHE_LOCATION;
 973      $newconfig["uploads_path"] = $newconfig['root_path'] . DIRECTORY_SEPARATOR . "uploads";
 974          // Note: leave the / slashes for the URLs
 975      $newconfig["uploads_url"] = $newconfig['root_url'] . "/uploads";    
 976      $newconfig["image_uploads_path"] = $newconfig['root_path'] . DIRECTORY_SEPARATOR . "uploads".DIRECTORY_SEPARATOR."images";
 977          // Note: leave the / slashes for the URLs
 978      $newconfig["image_uploads_url"] = $newconfig['root_url'] ."/uploads/images";
 979      $maxFileSize = ini_get('upload_max_filesize');
 980      if (!is_numeric($maxFileSize))
 981      {
 982          $l=strlen($maxFileSize);
 983          $i=0;$ss='';$x=0;
 984          while ($i < $l)
 985          {
 986              if (is_numeric($maxFileSize[$i]))
 987                  {$ss .= $maxFileSize[$i];}
 988              else
 989              {
 990                  if (strtolower($maxFileSize[$i]) == 'm') $x=1000000;
 991                  if (strtolower($maxFileSize[$i]) == 'k') $x=1000;
 992              }
 993              $i ++;
 994          }
 995          $maxFileSize=$ss;
 996          if ($x >0) $maxFileSize = $ss * $x;
 997      }
 998      else
 999      {
1000          $maxFileSize = 1000000;
1001      }
1002      $newconfig["max_upload_size"] = $maxFileSize;
1003      //$newconfig["max_upload_size"] = 1000000;
1004      $newconfig["debug"] = false;
1005      $newconfig["assume_mod_rewrite"] = false;
1006      $newconfig["auto_alias_content"] = true;
1007      $newconfig["image_manipulation_prog"] = "GD";
1008      $newconfig["image_transform_lib_path"] = "/usr/bin/ImageMagick/";
1009      $newconfig["use_Indite"] = false;
1010      $newconfig["image_uploads_path"] = $newconfig['root_path'] . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . "images";
1011      $newconfig["image_uploads_url"] = $newconfig['root_url'] . "/uploads/images";
1012      $newconfig["default_encoding"] = "";
1013      $newconfig["disable_htmlarea_translation"] = false;
1014      $newconfig["admin_dir"] = "admin";
1015      $newconfig["persistent_db_conn"] = false;
1016      $newconfig["default_upload_permission"] = '664';
1017      $newconfig["page_extension"] = "";
1018      $newconfig["locale"] = "";
1019      $newconfig["admin_encoding"] = "utf-8";
1020      $newconfig["use_adodb_lite"] = true;
1021      $newconfig['internal_pretty_urls'] = false;
1022      $newconfig['use_hierarchy'] = false;
1023      $newconfig['old_stylesheet'] = false;
1024      $newconfig['wiki_url'] = "http://wiki.cmsmadesimple.org/index.php/User_Handbook/Admin_Panel";
1025      $newconfig['backwards_compatible'] = false;
1026  
1027      $configfile = CONFIG_FILE_LOCATION;
1028      ## build the content for config file
1029  
1030      if ((file_exists($configfile) && is_writable($configfile)) || !file_exists($configfile)) {
1031          cms_config_save($newconfig);
1032      } else {
1033          echo "Error: Cannot write to $config.<br />\n";
1034          exit;
1035      } ## if
1036  
1037      if (file_exists(TMP_CACHE_LOCATION.'/SITEDOWN'))
1038      {
1039          if (!unlink(TMP_CACHE_LOCATION.'/SITEDOWN'))
1040          {
1041              echo "Error: Could not remove the tmp/cache/SITEDOWN file. Please remove manually.";
1042          }
1043      }
1044  
1045      #Do module installation
1046      if (isset($_POST["createtables"]))
1047      {
1048          echo '<p>Updating hierarchy positions...';
1049  
1050          include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'include.php';
1051          
1052          #Set $gCms->config - somehow it doesn't get set by include.php
1053          $gCms->config = $newconfig;
1054  
1055          $db->SetFetchMode(ADODB_FETCH_ASSOC);
1056          #$db->debug = true;
1057          $gCms->db =& $db;
1058  
1059          $contentops =& $gCms->GetContentOperations();
1060          $contentops->SetAllHierarchyPositions();
1061  
1062          echo "[done]</p>";
1063          
1064          echo '<p>Setting up core events...';
1065          
1066          Events::SetupCoreEvents();
1067          
1068          echo "[done]</p>";
1069  
1070          echo '<p>Installing modules...';
1071  
1072          foreach ($gCms->modules as $modulename=>$value)
1073          {
1074              if ($gCms->modules[$modulename]['object']->AllowAutoInstall() == true)
1075              {
1076                $query = "SELECT * FROM ".cms_db_prefix()."modules WHERE module_name = ?";
1077                $dbresult = $db->Execute($query, array($modulename));
1078                $count = $dbresult->RecordCount();
1079                  if (!isset($count) || $count == 0)
1080                  {
1081                      $modinstance =& $gCms->modules[$modulename]['object'];
1082                      $result = $modinstance->Install();
1083  
1084                      #now insert a record
1085                      if (!isset($result) || $result === FALSE)
1086                      {
1087                          $query = "INSERT INTO ".cms_db_prefix()."modules (module_name, version, status, active, admin_only) VALUES (".$db->qstr($modulename).",".$db->qstr($modinstance->GetVersion()).",'installed',1,".($modinstance->IsAdminOnly()==true?1:0).")";
1088                          $db->Execute($query);
1089                          $gCms->modules[$modulename]['installed'] = true;
1090                          $gCms->modules[$modulename]['active'] = true;
1091                          
1092                          /*
1093                          #and insert any dependancies
1094                          if (count($modinstance->GetDependencies()) > 0) #Check for any deps
1095                          {
1096                              #Now check to see if we can satisfy any deps
1097                              foreach ($modinstance->GetDependencies() as $onedepkey=>$onedepvalue)
1098                              {
1099                                  $time = $db->DBTimeStamp(time());
1100                                  $query = "INSERT INTO ".cms_db_prefix()."module_deps (parent_module, child_module, minimum_version, create_date, modified_date) VALUES (?,?,?,".$time.",".$time.")";
1101                                  $db->Execute($query, array($onedepkey, $module, $onedepvalue));
1102                              }
1103                          }
1104  
1105                          #and show the installpost if necessary...
1106                          if ($modinstance->InstallPostMessage() != FALSE)
1107                          {
1108                              @ob_start();
1109                              echo $modinstance->InstallPostMessage();
1110                              $content = @ob_get_contents();
1111                              @ob_end_clean();
1112                              echo '<div class="pagecontainer">';
1113                              echo '<p class="pageheader">'.lang('moduleinstallmessage', array($module)).'</p>';
1114                              echo $content;
1115                              echo "</div>";
1116                              echo '<p class="pageback"><a class="pageback" href="listmodules.php">&#171; '.lang('back').'</a></p>';
1117                              include_once("footer.php");
1118                              exit;
1119                              
1120                          }
1121                          */
1122                      }
1123                  }
1124              }
1125          }
1126          echo "[done]</p>";
1127          
1128          if (isset($gCms->modules['Search']) && isset($gCms->modules['Search']['object']))
1129          {
1130              echo '<p>Index Search...';
1131              
1132              $modinstance =& $gCms->modules['Search']['object'];
1133              @$modinstance->Reindex();
1134  
1135              echo "[done]</p>";
1136          }
1137          echo '<p>Clearing site cache (if any)...';
1138                  $contentops->ClearCache();
1139          echo "[done]</p>";
1140      }
1141   
1142      $link = str_replace(" ", "%20", $_POST['docroot']);
1143      
1144      if (isset($_POST["email_accountinfo"])) 
1145      {
1146          echo "<p>E-mailing admin account information...";
1147          $to      = $_POST['email_accountinfo'];
1148          $subject = 'CMS Made Simple Admin Account Information';
1149          $message = <<<EOF
1150  Thank you for installing CMS Made Simple.
1151  
1152  This is your new account information:
1153  username: {$_POST['adminusername']}
1154  password: {$_POST['adminpassword']}
1155  
1156  Log into the site admin here: $link/admin/
1157  EOF;
1158          echo (
1159              @mail($to, $subject, $message)
1160              ? '[done]'
1161              : '<strong>[failed]</strong>'
1162          );
1163          echo '</p>';
1164      }
1165      echo "<h4 class=\"success\">Congratulations, you are all setup - here is your <a href=\"".$link."\">CMS site</a>.</h4>";
1166  
1167  } ## showPageFour
1168  ?>
1169  
1170  </div>
1171  </div>
1172  
1173  </body>
1174  </html>
1175  <?php
1176  
1177  # vim:ts=4 sw=4 noet
1178  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7