1<?php 2/********************************************************************* 3 install.php 4 5 osTicket Installer. 6 7 Peter Rotich <peter@osticket.com> 8 Copyright (c) 2006-2013 osTicket 9 http://www.osticket.com 10 11 Released under the GNU General Public License WITHOUT ANY WARRANTY. 12 See LICENSE.TXT for details. 13 14 vim: expandtab sw=4 ts=4 sts=4: 15**********************************************************************/ 16require('setup.inc.php'); 17 18require_once INC_DIR.'class.installer.php'; 19 20 21//define('OSTICKET_CONFIGFILE','../include/ost-config.php'); //osTicket config file full path. 22define('OSTICKET_CONFIGFILE','../include/ost-config.php'); //XXX: Make sure the path is corrent b4 releasing. 23 24 25$installer = new Installer(OSTICKET_CONFIGFILE); //Installer instance. 26$wizard=array(); 27$wizard['title']=__('osTicket Installer'); 28$wizard['tagline']=sprintf(__('Installing osTicket %s'),$installer->getVersionVerbose()); 29$wizard['logo']='logo.png'; 30$wizard['menu']=array(__('Installation Guide')=>'https://docs.osticket.com/en/latest/Getting%20Started/Installation.html', 31 __('Get Professional Help')=>'https://osticket.com/support'); 32 33if($_POST && $_POST['s']) { 34 $errors = array(); 35 $_SESSION['ost_installer']['s']=$_POST['s']; 36 switch(strtolower($_POST['s'])) { 37 case 'prereq': 38 if($installer->check_prereq()) 39 $_SESSION['ost_installer']['s']='config'; 40 else 41 $errors['prereq']=__('Minimum requirements not met!'); 42 break; 43 case 'config': 44 if(!$installer->config_exists()) 45 $errors['err']=__('Configuration file does NOT exist. Follow steps below to add one.'); 46 elseif(!$installer->config_writable()) 47 $errors['err']=__('Write access required to continue'); 48 else 49 $_SESSION['ost_installer']['s']='install'; 50 break; 51 case 'install': 52 if($installer->install($_POST)) { 53 $_SESSION['info']=array('name' =>ucfirst($_POST['fname'].' '.$_POST['lname']), 54 'email' =>$_POST['admin_email'], 55 'URL'=>URL); 56 //TODO: Go to subscribe step. 57 $_SESSION['ost_installer']['s']='done'; 58 } elseif(!($errors=$installer->getErrors()) || !$errors['err']) { 59 $errors['err'] = sprintf('%s %s', 60 __('Error installing osTicket.'), 61 __('Correct any errors below and try again.')); 62 } 63 break; 64 case 'subscribe': 65 if(!trim($_POST['name'])) 66 $errors['name'] = __('Required'); 67 68 if(!$_POST['email']) 69 $errors['email'] = __('Required'); 70 elseif(!Validator::is_valid_email($_POST['email'])) 71 $errors['email'] = __('Invalid'); 72 73 if(!$_POST['alerts'] && !$_POST['news']) 74 $errors['notify'] = __('Check one or more'); 75 76 if(!$errors) 77 $_SESSION['ost_installer']['s'] = 'done'; 78 break; 79 } 80 81}elseif($_GET['s'] && $_GET['s']=='ns' && $_SESSION['ost_installer']['s']=='subscribe') { 82 $_SESSION['ost_installer']['s']='done'; 83} 84 85switch(strtolower($_SESSION['ost_installer']['s'])) { 86 case 'config': 87 case 'install': 88 if(!$installer->config_exists()) { 89 $inc='file-missing.inc.php'; 90 } elseif(!($cFile=file_get_contents($installer->getConfigFile())) 91 || preg_match("/define\('OSTINSTALLED',TRUE\)\;/i",$cFile)) { //osTicket already installed or empty config file? 92 $inc='file-unclean.inc.php'; 93 } elseif(!$installer->config_writable()) { //writable config file?? 94 clearstatcache(); 95 $inc='file-perm.inc.php'; 96 } else { //Everything checked out show install form. 97 $inc='install.inc.php'; 98 } 99 break; 100 case 'subscribe': //TODO: Prep for v1.7 RC1 101 $inc='subscribe.inc.php'; 102 break; 103 case 'done': 104 $inc='install-done.inc.php'; 105 if (!$installer->config_exists()) 106 $inc='install-prereq.inc.php'; 107 else // Clear installer session 108 $_SESSION['ost_installer'] = array(); 109 break; 110 default: 111 //Fail IF any of the old config files exists. 112 if(file_exists(INCLUDE_DIR.'settings.php') 113 || file_exists(ROOT_DIR.'ostconfig.php') 114 || (file_exists(OSTICKET_CONFIGFILE) 115 && preg_match("/define\('OSTINSTALLED',TRUE\)\;/i", 116 file_get_contents(OSTICKET_CONFIGFILE))) 117 ) 118 $inc='file-unclean.inc.php'; 119 else 120 $inc='install-prereq.inc.php'; 121} 122 123require(INC_DIR.'header.inc.php'); 124require(INC_DIR.$inc); 125require(INC_DIR.'footer.inc.php'); 126?> 127