'Deutsch','en'=>'English'); var $lang; var string $lf = ""; function __construct(){ global $lf; $language=$_COOKIE['astat_install_lang']; if(!$language || $language==''){ $lang=$this->getbrowserlang(); if(!$lang){ $this->lang='en'; }else{ $this->lang=$lang; } }else{ $this->lang=$language; } include dirname(__FILE__).'/languages/'.$this->lang.'.lang.php'; $this->lf=$lf; } function getbrowserlang(): string { $langs=$_SERVER['HTTP_ACCEPT_LANGUAGE']; if(empty($langs)){ return ""; } $alangs=$this->getlanguages(); foreach($alangs as $alang){ $allowed_languages[]=$alang['short']; } $accepted_languages = preg_split('/,\s*/', $langs); $current_q = 0; $current_lang = ""; foreach ($accepted_languages as $accepted_language) { $res = preg_match ('/^([a-z]{1,8}(?:-[a-z]{1,8})*)'.'(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i', $accepted_language, $matches); if (!$res) { continue; } $lang_code = explode ('-', $matches[1]); if (isset($matches[2])) { $lang_quality = (float)$matches[2]; } else { $lang_quality = 1.0; } while (count ($lang_code)) { if (in_array (strtolower (join ('-', $lang_code)), $allowed_languages)) { if ($lang_quality > $current_q) { $current_lang = strtolower (join ('-', $lang_code)); $current_q = $lang_quality; break; } } array_pop ($lang_code); } } return $current_lang; } function setlang($lang): void { setcookie('bcwe_install_lang',$lang); } function getlanguages(): array { $langdir = dirname(__FILE__).'/languages'; $langs = opendir($langdir); $langfile = array(); $i=0; while ($lang = readdir($langs)) { if (preg_match('/^.*?\.lang.php$/', $lang)) { $langfile[$i]['short']=substr($lang,0,2); $langfile[$i]['name']=$this->langname[$langfile[$i]['short']]; unset($lf); $i++; } } @closedir($langdir); return($langfile); } function _($string){ if(isset($this->lf[$string])){ return($this->lf[$string]); }else{ return($string); } } } class dump{ var $db; var $file; var $commands = ''; var $errors = ''; function __construct(& $db){ $this->db = & $db; } function read($dumpfile){ $datei = fopen($dumpfile,'r'); while (!feof($datei)){ $this->file .= fgets($datei,filesize($dumpfile)); } fclose($datei); } function prepare($prefix){ if($prefix!='as_'){ $this->file= preg_replace('/as_/',$prefix,$this->file); } $i=0; $statements=array(); //HACK: We have ; in our Statements. This is to prevent String splitting there. $this->file=str_replace(";\n",";~;\n",$this->file); //Hack end $lines=explode("\n",$this->file); $this->file=''; $linecount= count($lines); for ($i = 0; $i < count($lines); $i++){ if ( $lines[$i][0] != '#' && substr($lines[$i],0,2) != '--'){ $this->file.=stripslashes($lines[$i]); } } $this->commands=explode(';~;',$this->file); } function execute(){ foreach($this->commands as $c){ $c=trim($c); if($c!=''){ $result=$this->db->query($c); if(!$result){ $this->errors[]=$this->db->error(); } } } } } class install{ var $t; var $stepvalue=array('start'=>0,'license'=>1,'check'=>2,'database'=>3,'user'=>4,'finish'=>5); var $chmod_list=array('../'=>'write','../inc'=>'notwrite','../inc/config.inc.php'=>'write','../modules'=>'write','../logs'=>'write'); var $checkdir=array(); var $dbas=array(); var $version; function __construct(& $lang){ $this->version = 'unknown'; $this->t = & $lang; include dirname(__FILE__).'/assets/becastwebengine.ver'; if (isset($ver)) { $this->version=$ver; } } function checkchmod(){ $status=true; foreach ($this->chmod_list as $dir=>$status) { if($status=='write'){ @chmod($dir,0777); }else{ @chmod($dir,0555); } if (!is_writeable($dir)) { if (!is_dir($dir) && !is_file($dir)){ $dir_status=$this->t->_('na'); $color='yellow'; }else{ $dir_status=$this->t->_('nichtbeschreibbar'); if($status=='write'){ $status=false; $color='red'; }else{ $color='green'; } } }else{ $dir_status=$this->t->_('beschreibbar'); if($status=='write'){ $color='green'; }else{ $status=false; $color='red'; } } $this->checkdir[]=array('dir'=>$dir,'status'=>$dir_status,'color'=>$color); } return $status; } function checkphp(){ $status=true; $version=version_compare(PHP_VERSION, '5.0.5', '>='); $color='green'; if(!$version){ $status=false; $color='red'; } $this->checkphp[]=array('name'=>'PHP','success'=>$color,'status'=>PHP_VERSION,'needed'=>'5.0.5'); $gd = @gd_info(); $color='green'; if(!$gd){ $success=FALSE; $status=false; $color='red'; } if($gd['GD Version']==''){ $success=FALSE; $status=$this->t->_('nichtinstalliert'); $color='red'; } $success=version_compare($gd['GD Version'], '2', '>='); if(!$success){ $success=FALSE; $color='red'; } $this->checkphp[]=array('name'=>'GD','success'=>$color,'status'=>$gd['GD Version'],'needed'=>'2.0.0'); return $status; } function getsupportetdbs(){ $status=false; if (class_exists('mysqli')) { $status=true; $dbas[]=array('short'=>'mysqli','name'=>'MySQLi'); } if (function_exists('mysql_connect')){ $status=true; $dbas[]=array('short'=>'mysql','name'=>'MySQL'); } $this->dbas=$dbas; return $status; } function generate_Key($length=8){ $dummy = array_merge(range('0', '9'), range('a', 'z'), range('A', 'Z')); mt_srand((double)microtime()*1000000); for ($i = 1; $i <= (count($dummy)*2); $i++){ $swap = mt_rand(0,count($dummy)-1); $tmp = $dummy[$swap]; $dummy[$swap] = $dummy[0]; $dummy[0] = $tmp; } return substr(implode('',$dummy),0,$length); } function header($step='start'){ $header=' astat Installer
'; $header.=$this->navigation($step); $header.='
'; echo $header; } function navigation($active='start'){ $nav['head']= ''; return implode('', $nav); } function step($step='start'){ global $config; switch($step){ case 'start': if(isset($_POST['send'])){ $this->t->setlang($_POST['language']); header("Location: install.php?step=license"); } $options=''; $languages=$this->t->getlanguages(); foreach($languages as $lang){ $options.=''; } $data='

'.$this->t->_('Wilkommen').'

'.$this->t->_('WilkommenText1').'

'.$this->t->_('Waehledeinesprache').'



'; break; case 'license': if(isset($_POST['back'])){ header("Location: install.php?step=start"); } if(isset($_POST['send'])){ if($_POST['accept']!=1){ $err= '

'.$this->t->_('FehlerAkzeptieren').'

'; }else{ header("Location: install.php?step=check"); } } $datei = fopen(dirname(__FILE__).'/license/gpl2.txt','r'); $license=''; while (!feof($datei)){ $license .= fgets($datei,1024); } fclose($datei); $data='

'.$this->t->_('Lizenz').'

'.$this->t->_('LizenzText').'

'.$err.'
'.$license.'

'.$this->t->_('Akzeptieren').'



'; break; case 'check': $globcheck=true; $dircheck=$this->checkchmod(); if($dircheck){ $dirs='
'.$this->t->_('dateiok'); }else{ $globcheck=false; $dirs='
'.$this->t->_('dateinichtok'); } $dirs.=''; foreach($this->checkdir as $dir){ $dirs.=''; } $dirs.='
'.$this->t->_('Verzeichnis').''.$this->t->_('Ergebnis').'
'.$dir['dir'].'................'.$dir['status'].'
'; $phpcheck=$this->checkphp(); if($phpcheck){ $php='
'.$this->t->_('phpok'); }else{ $globcheck=false; $php='
'.$this->t->_('phpnichtok'); } $php.=''; foreach($this->checkphp as $p){ $php.=''; } $php.='
'.$this->t->_('Komponente').''.$this->t->_('benVersion').''.$this->t->_('instVersion').'
'.$p['name'].''.$p['needed'].''.$p['status'].'
'; $dbcheck=$this->getsupportetdbs(); if($dbcheck){ $dbs='
'.$this->t->_('dbsok'); }else{ $globcheck=false; $dbs='
'.$this->t->_('dbsnichtok'); } foreach($this->dbas as $d){ if(!$dbas) $dbas=$d['name']; else $dbas.=' ,'.$d['name']; } if($dbas==''){ $dbas=$this->t->_('keine'); } $dbs.='
'.$this->t->_('installiertedbs').': '.$dbas.'
'; if(isset($_POST['back'])){ header("Location: install.php?step=license"); } if(isset($_POST['send'])){ if(!$globcheck){ $err= '
'.$this->t->_('Fehlererstloesen').'
'; }else{ header("Location: install.php?step=database"); } } $data='

'.$this->t->_('Pruefung').'

'.$this->t->_('PruefungText').'

'.$err.'

'; if($globcheck){ $data.='

'.$this->t->_('CheckOK').'

'; }else{ $data.='

'.$this->t->_('ChecknichtOK').'

'; $locked='disabled="disabled"'; } $data.='

'.$dirs.'

'.$php.'

'.$dbs.'



'; break; case 'database': $locked='disabled="disabled"'; if(isset($_POST['back'])){ @unlink(dirname(dirname(__FILE__)).'/config.tmp.php'); header("Location: install.php?step=check"); } if(isset($_POST['test'])){ $error=false; $user=$_POST['dbuser']; $pass=$_POST['dbpass']; $db=$_POST['db']; $server=$_POST['dbserv']; $prefix=$_POST['dbprefix']; $driver=$_POST['dbdriver']; $pdata=$_POST; $configdata=''; include dirname(dirname(__FILE__)).'/inc/logger.class.php'; include dirname(dirname(__FILE__)).'/core/database/'.$driver.'.class.php'; try{ $db = new db($server, $user, $pass, $db,'utf8', FALSE,TRUE); $result=$db->query("SHOW TABLES"); }catch(Exception $e){ $error=true; } if(!$error){ $datei = fopen(dirname(dirname(__FILE__)).'/config.tmp.php','w'); fputs($datei,$configdata); fclose($datei); $locked=''; $err='

'.$this->t->_('Installationwarten').'

'; }else{ $err='

'.$this->t->_('FalscheDaten').'

'; } } if(isset($_POST['send'])){ include dirname(dirname(__FILE__)).'/inc/logger.class.php'; include dirname(dirname(__FILE__)).'/config.tmp.php'; include dirname(dirname(__FILE__)).'/core/database/'.$config['db_class'].'.class.php'; $configdata=' * @package BcWe core * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ /* This file was created by the Installer. Don\'t touch it unless you have a very good reason to do so. */ if(!defined("in_astat")){ die(); } // your Database Server (most likely localhost) $config[\'host\'] = \''.$config['host'].'\'; // your Database Username $config[\'user\'] = \''.$config['user'].'\'; // your Database Password $config[\'pass\'] = \''.$config['pass'].'\'; // your Database $config[\'db\'] = \''.$config['db'].'\'; // your Database Prefix $config[\'prefix\']=\''.$config['prefix'].'\'; // your Database Sytem $config[\'db_class\']= \''.$config['db_class'].'\'; define(\'INSTALLED\', TRUE); define(\'CHARSET\', \'UTF-8\'); define(\'DEBUG\', FALSE); ?>'; $datei = fopen(dirname(dirname(__FILE__)).'/inc/config.inc.php','w+'); fputs($datei,$configdata); fclose($datei); $db = new db($config['host'], $config['user'], $config['pass'], $config['db'],'utf8', FALSE,TRUE); $dump = new dump($db); $dump->read(dirname(__FILE__).'/sql/dump.sql'); $dump->prepare($config['prefix']); $dump->execute(); $pdata=$_POST; @unlink(dirname(dirname(__FILE__)).'/config.tmp.php'); header("Location: install.php?step=user"); } if($pdata['dbprefix']==''){ $pdata['dbprefix']='as_'; } if($pdata['dbserv']==''){ $pdata['dbserv']='localhost'; } $this->getsupportetdbs(); foreach($this->dbas as $driver){ if($pdata['dbdriver']==$driver['short']){ $select='selected="selected"'; } $drv.=''; } $data='

'.$this->t->_('Datenbank').'

'.$this->t->_('DatenbankText').'

'.$err.'


'; break; case 'user': if(isset($_POST['back'])){ header("Location: install.php?step=database"); } if(isset($_POST['send'])){ $err=false; if($_POST['pass']!=$_POST['passrepeat']){ $err.='

'.$this->t->_('Passwoerterfalsch').'

'; } if(!preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])){ $err.='

'.$this->t->_('Emailinkorrekt').'

'; } if(!$err){ define('in_astat',TRUE); include dirname(dirname(__FILE__)).'/inc/logger.class.php'; include dirname(dirname(__FILE__)).'/inc/config.inc.php'; include dirname(dirname(__FILE__)).'/core/database/'.$config['db_class'].'.class.php'; $db = new db($config['host'], $config['user'], $config['pass'], $config['db'],'utf8', FALSE,TRUE); $pass=hash('sha256',$db->escape($_POST['pass'])); $key=$this->generate_Key(50); $active=1; $username=$db->escape($_POST['user']); $email=$db->escape($_POST['email']); $db->query("INSERT INTO `" . $config['prefix'] . "users` (`username`,`password`,`loginkey`,`email`,`active`,`since`,`role`) VALUES ('".$username."','".$pass."', '".$key."', '".$email."', '".$active."','".time()."','2')"); header("Location: install.php?step=finish"); }else{ $pdata=$_POST; } } $data='

'.$this->t->_('Benutzer').'

'.$this->t->_('BenutzerText').'

'.$err.'


'; break; case 'finish': $fopen=true; $test=fopen('http://astat.org/install.php?test', 'r'); $testecho= fgets($test,1024); fclose($test); if($testecho!="Success"){ $fopen=false; } $server='Server: '.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; $astat_version='astat version: '.$this->version; $timestamp='Timestamp: '.time(); $sendkey=base64_encode($_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].'|'.$this->version.'|'.time()); if(isset($_POST['back'])){ header("Location: install.php?step=user"); } if(isset($_POST['send'])){ if($_POST['accept']!=1){ $key=fopen('http://astat.org/install.php?install='.$sendkey, 'r'); $ikey= fgets($key,1024); fclose($key); define('in_astat',TRUE); include dirname(dirname(__FILE__)).'/inc/logger.class.php'; include dirname(dirname(__FILE__)).'/inc/config.inc.php'; include dirname(dirname(__FILE__)).'/core/database/'.$config['db_class'].'.class.php'; $db = new db($config['host'], $config['user'], $config['pass'], $config['db'],'utf8', FALSE,TRUE); $db->query("INSERT INTO `" . $config['prefix'] . "datacache` (`cache`,`content`,`expire`) VALUES ('installkey','".$ikey."','0')'"); } header("Location: ../index.php"); } if($fopen){ $fp='

'.$this->t->_('Installationsbenachrichtigung').'
'.$this->t->_('DieseDaten').'
  • '.$server.'
  • '.$astat_version.'
  • '.$timestamp.'
'.$this->t->_('Danke').'

'; $cb='

'.$this->t->_('Datensenden').'

'; } $data='

'.$this->t->_('Abschluss').'

'.$this->t->_('AbschlussText').'

'.$fp.'
'.$cb.'

'; break; } echo $this->header($step); echo $data; } function footer(){ echo '
Original Theme: v2.0.0 © HN MMVII
'; } } $lang = new lang(); $install = new install($lang); $step = $_GET['step']; if(!$step || $step==''){ $step='start'; } $install->step($step); $install->footer(); ?>