SHARE
TWEET

caleb2003

a guest Feb 20th, 2010 137 Never
  1. <?php
  2. session_start();
  3. error_reporting(E_ALL ^ E_NOTICE);
  4. @set_magic_quotes_runtime(0);
  5.  
  6. define('PMDROOT',str_replace('/install/','',dirname(str_replace('\\','/',__FILE__)).'/'));
  7. define('BASE_URL','http://'.str_replace(array('/install/install.php','/install/'),'',$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']));
  8.  
  9. include('./includes/functions.php');
  10.  
  11. if(isset($_POST['complete'])) {
  12.     include('../includes/class_database.php');
  13.     $db = new Database(null);
  14.  
  15.     $db_host = $_POST['hostname'];
  16.     $db_user = $_POST['db_user'];
  17.     $db_pass = $_POST['db_pass'];
  18.     $db_name = $_POST['db_name'];
  19.    
  20.     if(!(@$db->Connect($db_host, $db_user, $db_pass, $db_name)) OR $db_host == "" OR $db_user == "" OR $db_pass == "" OR $db_name == "" ) {
  21.         $errors['database_connect'] = "Database connection details are incorrect.<br>";
  22.     } else {
  23.         if($_POST['prefix'] == '') {
  24.             $errors['prefix_exists'] = 'Please enter a table prefix. (Ex: pmd_)';
  25.         } else {    
  26.             if(count($existing_tables = $db->GetCol("SHOW TABLES LIKE '".$db->Clean($_POST['prefix'])."%'")) > 0 AND !isset($_POST['prefix_overwrite'])) {
  27.                 $errors['prefix_exists'] = 'Table prefix in use.  Change prefix or choose to overwrite tables.';    
  28.             }
  29.         }
  30.     }
  31.    
  32.     if(!validLicense($_POST['license'])) {
  33.         $errors['license_format'] = 'The license number entered is not in the correct format. (ex: PMDGL-xxxxxxxxxxxx)';
  34.     }
  35.    
  36.     if($_POST['admin_email'] == '' OR $_POST['admin_pass'] == '') {
  37.         $errors['admin_details'] = 'Please fill in all administrator details.<br>';
  38.     }
  39.    
  40.     if($_POST['admin_pass'] != $_POST['admin_pass2']) {
  41.         $errors['password_mismatch'] = 'The passwords entered do not match.<br>';
  42.     }
  43.    
  44.     if(!isset($_POST['terms_agree'])) {
  45.         $errors['terms'] = 'You must agree to the terms before installing.';
  46.     }
  47.  
  48.     //if(file_exists(PMDROOT.'/defaults.php.dist') AND !file_exists(PMDROOT.'/defaults.php')) {
  49.     //     $errors['defaults'] = 'Failed - defaults.php.dist must be renamed to defaults.php';
  50.     //}
  51.    
  52.     $variables = array(
  53.         'license'=>$_POST['license'],
  54.         'URL'=>BASE_URL,
  55.         'hostname'=>$_POST['hostname'],
  56.         'db_user'=>$_POST['db_user'],
  57.         'db_pass'=>$_POST['db_pass'],
  58.         'db_name'=>$_POST['db_name'],
  59.         'prefix'=>$_POST['prefix'],
  60.         'admin_email'=>$_POST['admin_email'],
  61.         'admin_pass'=>$_POST['admin_pass']
  62.     );
  63.    
  64.     if(sizeof($errors) < 1) {
  65.         if(isset($_POST['prefix_overwrite'])) {
  66.             foreach((array) $existing_tables as $table) {
  67.                 $db->Execute("DROP TABLE ".$table);
  68.             }  
  69.         }
  70.        
  71.         importSQL('./database_structure.sql',$variables);
  72.         importSQL('./database_data.sql',$variables);    
  73.         $defaults_content = buildDefaults($variables);
  74.         if(!writeDefaults($defaults_content)) {
  75.             $_SESSION['defaults_content'] = $defaults_content;
  76.             $install_instructions = "<span class=\"Failed\">There was a problem saving your configuration file (defaults.php).</span><br /><br />";
  77.             $install_instructions .= "Please download this file by pressing the button below and upload it to your installation folder.<br /><br />";    
  78.             $install_instructions .= '<form name="downloadfile" action="download_defaults.php" method="post">';
  79.             $install_instructions .= '<input class="button" type="submit" name="download" value="Download Configuration File (defaults.php)"><br /><br />';
  80.             $install_instructions .= "</form><span class=\"Failed\">Make sure to delete the /install/ folder for security reasons.</span><br /><br />Once defaults.php is uploaded the installation is complete.  ";
  81.         } else {
  82.             $install_instructions = "<span class=\"Failed\">Make sure to delete the /install/ folder for security reasons.<br />Secondly, set permissions on the defaults.php to 644.</span><br /><br /><br /><b>The installation is now complete.</b>";
  83.         }
  84.         $install_instructions .= '
  85.         <br /><br /><br />
  86.         <a href="../index.php">View Directory Home Page</a><br /><br />
  87.         <a href="../cp/index.php">View Administrator Control Panel</a><br /><br />
  88.         <a href="./import/index.php">Import from Old Versions / Other Scripts</a>';
  89.     }
  90. }
  91.    
  92. if(!isset($_POST['complete']) OR sizeof($errors) > 0) {
  93.     $javascript = '<script type="text/javascript" src="'.BASE_URL.'/includes/jquery/jquery.js"></script>';
  94.     $javascript .= '<script type="text/javascript" src="'.BASE_URL.'/includes/jquery/jquery_custom.js"></script>';
  95.     $javascript .= '<script type="text/javascript" src="'.BASE_URL.'/includes/jquery/qTip/jquery_qtip.js"></script>';
  96.    
  97.     $error = 0;
  98.     $folders = validPermissions();
  99.     if($folders != -1) {
  100.         $error = 1;
  101.         $results['folder']['result'] = 'Failed - defaults.php and all folders in /files/ must be writable.';
  102.     } else {
  103.         $results['folder']['result'] = 'OK';
  104.     }
  105.      
  106.     if(validPHPVersion('5.2.1')) {
  107.         $results['php']['result'] = 'OK';
  108.     } else {
  109.         $error = 1;
  110.         $results['php']['result'] = 'Failed (Version: '.phpversion().') - Must be version 5.2.1 or above.';
  111.     }
  112.     if(validGD()) {
  113.         $results['gd']['result'] = 'OK';
  114.     } else {
  115.         $error = 1;
  116.         $results['gd']['result'] = 'Warning - The GD2 or Image Magick must be installed to process images.';
  117.     }
  118.     if(validCURL()) {
  119.         $results['curl']['result'] = 'OK';
  120.     } else {
  121.         $error = 1;
  122.         $results['curl']['result'] = 'Warning - CURL is required for many payment gateways and link checking.';
  123.     }
  124.    
  125.     if(validionCube()) {
  126.         $results['ioncube']['result'] = 'OK';
  127.     } else {
  128.         $error = 1;
  129.         $results['ioncube']['result'] = 'Failed - ionCube must be installed.';
  130.     }
  131.  
  132.     $phpversion = phpversion();
  133. }
  134. include('./template/header.tpl');
  135. include('./template/install.tpl');
  136. include('./template/footer.tpl');
  137. ?>
RAW Paste Data
Top