/setup/install.php

https://github.com/JoshuaGarrison27/osTicket-1.8 · PHP · 124 lines · 95 code · 12 blank · 17 comment · 22 complexity · b70c0146518183fdb4d9f6c51e1a9cf6 MD5 · raw file

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