=$errors['err']?>
}elseif($msg) {?>=$msg?>
}elseif($warn) {?>=$warn?>
}?>Copyright (c) 2006-2010 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
$Id: $
**********************************************************************/
#inits
error_reporting(E_ALL ^ E_NOTICE); //turn on errors
ini_set('magic_quotes_gpc', 0);
ini_set('session.use_trans_sid', 0);
ini_set('session.cache_limiter', 'nocache');
ini_set('display_errors',1); //We want the user to see errors during install process.
ini_set('display_startup_errors',1);
#start session
session_start();
require('setup.inc.php');
$errors=array();
$fp=null;
$_SESSION['abort']=false;
define('VERSION','1.6 ST'); //Current version number
define('VERSION_VERBOSE','1.6 Stable'); //What the user sees during installation process.
define('CONFIGFILE','../include/ost-config.php'); //osTicket config file full path.
define('SCHEMAFILE','./inc/osticket-v1.6.sql'); //osTicket SQL schema.
define('URL',rtrim('http'.(($_SERVER['HTTPS']=='on')?'s':'').'://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']),'setup'));
$install='Benätigen Sie Hilfe? Professionelle Hilfe finden Sie hier!';
$support='Holen Sie sich Unterstützung Hier bekommen sie geschäftlichen Support';
//Basic checks
$inc='install.inc.php';
$info=$install;
if(file_exists('../ostconfig.php') || file_exists('../include/settings.php')) { //old installation? try upgrading it buddy.
header('Location: upgrade.php');
die('Eine alte Installation existiert.... versuchen Sie ein Upgrade stattdessen');
}elseif((double)phpversion()<4.3){ //Old PHP installation
$errors['err']='PHP-Installation sehr veraltet';
$inc='php.inc.php';
}elseif(!ini_get('short_open_tag')) {
$errors['err']='Short open tag deaktiviert! - bitte für osTicket-Installation aktivieren.';
$inc='shortopentag.inc.php';
}elseif(!file_exists(CONFIGFILE)) {
$errors['err']=sprintf('Die Konfigurationsdatei (%s) ist nicht vorhanden!',basename(CONFIGFILE));
$inc='missing.inc.php';
}elseif(($cFile=file_get_contents(CONFIGFILE)) && preg_match("/define\('OSTINSTALLED',TRUE\)\;/i",$cFile)){
$errors['err']='Die Konfigurationsdatei ist bereits modifiziert!';
$inc='unclean.inc.php';
}elseif(!file_exists(CONFIGFILE) || !is_writable(CONFIGFILE)) { //writable config file??
clearstatcache();
$errors['err']='Die Konfigurationsdatei ist nicht beschreibbar!';
$inc='chmod.inc.php';
}else {
$configfile=file_get_contents(CONFIGFILE); //Get the goodies...peek and tell.
//Make SURE this is a new installation.
if(preg_match("/define\('OSTINSTALLED',TRUE\)\;/i",$configfile) || !strpos($configfile,'%CONFIG-DBHOST')){
$errors['err']='Die Konfigurationsdatei ist bereits modifiziert!!';
$inc='unclean.inc.php';
}elseif($_POST){
$f=array();
$f['title'] = array('type'=>'string', 'required'=>1, 'error'=>'Titel erforderlich');
$f['sysemail'] = array('type'=>'email', 'required'=>1, 'error'=>'Gültige Email erforderlich');
$f['username'] = array('type'=>'username', 'required'=>1, 'error'=>'Nutzername erforderlich');
$f['password'] = array('type'=>'password', 'required'=>1, 'error'=>'Passwort erforderlich');
$f['password2'] = array('type'=>'password', 'required'=>1, 'error'=>'Passwort bestätigen');
$f['email'] = array('type'=>'email', 'required'=>1, 'error'=>'Gültige Email erforderlich');
$f['dbhost'] = array('type'=>'string', 'required'=>1, 'error'=>'Hostname erforderlich');
$f['dbname'] = array('type'=>'string', 'required'=>1, 'error'=>'Datenbankname erforderlich');
$f['dbuser'] = array('type'=>'string', 'required'=>1, 'error'=>'Datenbanknutzer erforderlich');
$f['dbpass'] = array('type'=>'string', 'required'=>1, 'error'=>'Datenbankpasswort erforderlich');
$f['prefix'] = array('type'=>'string', 'required'=>1, 'error'=>'Tabellenpräfix erforderlich');
$validate = new Validator($f);
if(!$validate->validate($_POST)){
$errors=array_merge($errors,$validate->errors());
}
if($_POST['sysemail'] && $_POST['email'] && !strcasecmp($_POST['sysemail'],$_POST['email']))
$errors['email']='Konflikte mit genannter Systememail';
if(!$errors && strcasecmp($_POST['password'],$_POST['password2']))
$errors['password2']='Passwörter stimmen nicht überein!';
//Check table prefix underscore required at the end!
if($_POST['prefix'] && substr($_POST['prefix'], -1)!='_')
$errors['prefix']='Ungültiger Präfix. Sie müssen einen Unterstrich (_) am Ende einfügen z.b. \'ost_\'';
//Make sure admin username is not very predictable.
if(!$errors['username'] && in_array(strtolower($_POST['username']),array('admin','admins','username','osticket')))
$errors['username']='Ungültiger Nutzername';
//Connect to the DB
if(!$errors && !db_connect($_POST['dbhost'],$_POST['dbuser'],$_POST['dbpass']))
$errors['mysql']='Verbindung zum MySQL Server nicht möglich. Eventuell fehlerhafte Anmeldedaten.
';
//check mysql version
if(!$errors && (db_version()<'4.1.1'))
$errors['mysql']='osTicket benötigt MySQL 4.1.1 oder besser! Bitte aktualisieren';
//Select the DB
if(!$errors && !db_select_database($_POST['dbname'])) {
//Try creating the missing DB
if(!mysql_query('CREATE DATABASE '.$_POST['dbname'].' DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci')) {
$errors['dbname']='Datenbank existiert nicht.';
$errors['mysql']='Datenbank erstellen nicht erlaubt.';
}elseif(!db_select_database($_POST['dbname'])) {
$errors['dbname']='Auswahl der Datenbank nicht möglich';
}
}
//Get database schema
if(!$errors && !file_exists(SCHEMAFILE)) {
$errors['err']='Interner Fehler. Bitte stellen Sie sicher, dass die aktuellste Version herunter geladen haben.';
$errors['mysql']='SQL-Schema fehlt';
}
//Open the file for writing..
if(!$errors && !($fp = @fopen(CONFIGFILE,'r+'))){
$errors['err']='Die Konfigurationsdatei konnte nicht zum Schreiben geöffnet werden. Erlaubnis verweigert!';
}
//IF no errors..Do the install. Let the fun start...
if(!$errors && $fp) {
define('ADMIN_EMAIL',$_POST['email']); //Needed to report SQL errors during install.
define('PREFIX',$_POST['prefix']); //Table prefix
$debug=false; //Change it to true to show failed query
if(!load_sql_schema(SCHEMAFILE,$errors,$debug) && !$errors['err'])
$errors['err']='Fehler beim parsen des SQL-Schemas! Bitte Hilfe vom Entwickler einholen.';
if(!$errors) {
$info=$support;
//Rewrite the config file.
$configfile= str_replace("define('OSTINSTALLED',FALSE);","define('OSTINSTALLED',TRUE);",$configfile);
$configfile= str_replace('%ADMIN-EMAIL',$_POST['email'],$configfile);
$configfile= str_replace('%CONFIG-DBHOST',$_POST['dbhost'],$configfile);
$configfile= str_replace('%CONFIG-DBNAME',$_POST['dbname'],$configfile);
$configfile= str_replace('%CONFIG-DBUSER',$_POST['dbuser'],$configfile);
$configfile= str_replace('%CONFIG-DBPASS',$_POST['dbpass'],$configfile);
$configfile= str_replace('%CONFIG-PREFIX',$_POST['prefix'],$configfile);
$configfile= str_replace('%CONFIG-SIRI',Misc::randcode(32),$configfile);
if(ftruncate($fp,0) && fwrite($fp,$configfile)){
//Some more configurations.
$tzoffset= date("Z")/3600; //Server's offset.
//Create admin user. Dummy last name.
$sql='INSERT INTO '.PREFIX.'staff SET created=NOW(), isadmin=1,change_passwd=0,group_id=1,dept_id=1 '.
',email='.db_input($_POST['email']).',firstname='.db_input('Hans').',lastname='.db_input('Mustermann').
',username='.db_input($_POST['username']).',passwd='.db_input(MD5($_POST['password'])).
',timezone_offset='.db_input($tzoffset);
mysql_query($sql);
//Add emails - hopefully the domain is actually valid
list($uname,$domain)=explode('@',$_POST['sysemail']);
//1 - main support email
$sql='INSERT INTO '.PREFIX.'email SET created=NOW(),updated=NOW(),priority_id=2,dept_id=1'.
',name='.db_input('Support').',email='.db_input($_POST['sysemail']);
mysql_query($sql);
//2 - alert email
$sql='INSERT INTO '.PREFIX.'email SET created=NOW(),updated=NOW(),priority_id=1,dept_id=1'.
',name='.db_input('osTicket Alarme').',email='.db_input('alerts@'.$domain);
mysql_query($sql);
//3 - noreply email
$sql='INSERT INTO '.PREFIX.'email SET created=NOW(),updated=NOW(),priority_id=1,dept_id=1'.
',name='.db_input('').',email='.db_input('noreply@'.$domain);
mysql_query($sql);
//config info
$sql='INSERT INTO '.PREFIX.'config SET updated=NOW() '.
',isonline=0,default_email_id=1,alert_email_id=2,default_dept_id=1,default_template_id=1'.
',timezone_offset='.db_input($tzoffset).
',ostversion='.db_input(VERSION).
',admin_email='.db_input($_POST['email']).
',helpdesk_url='.db_input(URL).
',helpdesk_title='.db_input($_POST['title']);
mysql_query($sql);
//Create a ticket to make the system warm and happy.
$sql='INSERT INTO '.PREFIX.'ticket SET created=NOW(),ticketID='.db_input(Misc::randNumber(6)).
",priority_id=2,dept_id=1,email='support@osticket.com',name='osTicket Support' ".
",subject='osTicket Installiert!',helptopic='Kommerzieller Support',status='open',source='Web'";
if(db_query($sql) && ($id=db_insert_id())){
db_query('INSERT INTO '.PREFIX."ticket_message VALUES (1,$id,NULL,".db_input(OSTICKET_INSTALLED).",NULL,'Web','',NOW(),NULL)");
}
//Log a message.
$sql='INSERT INTO '.PREFIX.'syslog SET created=NOW(),updated=NOW() '.
',title="osTicket installiert!",log_type="Debug" '.
',log='.db_input("Glückwunsch! osTicket Basis-Installation abgeschlossen!\n\nVielen Dank dass Sie sich für osTicket entschieden haben!").
',ip_address='.db_input($_SERVER['REMOTE_ADDR']);
mysql_query($sql);
$msg='Glückwunsch! osTicket Basis-Installation abgeschlossen!';
$inc='done.inc.php';
}else{
$errors['err']='Schreiben in die Konfigurationsdate nicht möglich!';
}
}
@fclose($fp);
}else{
$errors['err']=$errors['err']?$errors['err']:'Fehler aufgetreten. Bitte beheben und nochmals versuchen';
}
}
}
$title=sprintf('osTicket Version %s - Basis Installation',VERSION_VERBOSE);
?>