BeCastWebEngine/install/install.php
2025-06-22 16:20:34 +02:00

796 lines
No EOL
28 KiB
PHP
Executable file

<?php
/**
* Project: BeCast WebEngine - simple site engine
* File: install.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.becast.at
* @copyright 2012-2025 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package BcWe core
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
*/
class lang{
var array $langname=array('de'=>'Deutsch','en'=>'English');
var string $lang;
var array $lf = array();
function __construct(){
$language = "";
if(isset($_COOKIE['bcwe_install_lang'])) {
$language = $_COOKIE['bcwe_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';
if (isset($lf)) {
$this->lf = $lf;
}
}
function getbrowserlang(): string
{
$allowed_languages=array();
$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($langs);
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);
}
$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='';
for ($i = 0; $i < count($lines); $i++){
if (!str_starts_with($lines[$i], '#') && !str_starts_with($lines[$i], '--')){
$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, '8.1.0', '>=');
$color='green';
if(!$version){
$status=false;
$color='red';
}
$this->checkphp[]=array('name'=>'PHP','success'=>$color,'status'=>PHP_VERSION,'needed'=>'8.1.0');
$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='<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="'.$this->t->_('LANG_CODE').'">
<head>
<title>BeCastWebEngine Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style media="all">
@import "style/install.css";
</style>
<!--[if lte IE 6]>
<style type="text/css" media="all">
@import "style/ie6_diff.css";
</style>
<![endif]-->
<!--[if gt IE 6]>
<style type="text/css" media="all">
@import "style/ie7_diff.css";
</style>
<![endif]-->
</head>
<body>
<div id="window">
<div id="container">';
$header.=$this->navigation($step);
$header.='<div class="main">
<div class="outer-prettification">
<div class="inner-prettification">
<div class="header">
<h1 class="title"><a>BeCastWebEngine - Simple Site Engine Setup</a></h1>
</div>
<div class="contents">';
echo $header;
}
function navigation($active='start'){
$nav['head']= '<div class="navigation">
<ul>';
$nav['start']='<li><a href="install.php?step=start">'.$this->t->_('Start').'</a></li>';
$nav['license']='<li><a>'.$this->t->_('Lizenz').'</a></li>';
$nav['check']='<li><a>'.$this->t->_('Pruefung').'</a></li>';
$nav['database']='<li><a>'.$this->t->_('Datenbank').'</a></li>';
$nav['user']='<li><a>'.$this->t->_('Benutzer').'</a></li>';
$nav['finish']='<li><a>'.$this->t->_('Abschluss').'</a></li>';
switch($this->stepvalue[$active]){
case 5:
$nav['finish']='<li><a href="install.php?step=finish">'.$this->t->_('Abschluss').'</a></li>';
case 4:
$nav['user']='<li><a href="install.php?step=user">'.$this->t->_('Benutzer').'</a></li>';
case 3:
$nav['database']='<li><a href="install.php?step=database">'.$this->t->_('Datenbank').'</a></li>';
case 2:
$nav['check']='<li><a href="install.php?step=check">'.$this->t->_('Pruefung').'</a></li>';
case 1:
$nav['license']='<li><a href="install.php?step=license">'.$this->t->_('Lizenz').'</a></li>';
break;
}
switch($active){
case 'start':
$nav['start']='<li class="active"><a href="install.php?step=start">'.$this->t->_('Start').'</a></li>';
break;
case 'license':
$nav['license']='<li class="active"><a href="install.php?step=license">'.$this->t->_('Lizenz').'</a></li>';
break;
case 'check':
$nav['check']='<li class="active"><a href="install.php?step=check">'.$this->t->_('Pruefung').'</a></li>';
break;
case 'database':
$nav['database']='<li class="active"><a href="install.php?step=database">'.$this->t->_('Datenbank').'</a></li>';
break;
case 'user':
$nav['user']='<li class="active"><a href="install.php?step=user">'.$this->t->_('Benutzer').'</a></li>';
break;
case 'finish':
$nav['finish']='<li class="active"><a href="install.php?step=finish">'.$this->t->_('Abschluss').'</a></li>';
break;
}
$nav['foot']= '</ul>
</div>';
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.='<option value="'.$lang['short'].'">'.$lang['name'].'</option>';
}
$data='<h3>'.$this->t->_('Wilkommen').'</h3>
<p>'.$this->t->_('WilkommenText1').'</p>
<p>'.$this->t->_('Waehledeinesprache').'</p>
<form action="#" method="post">
<select name="language">
'.$options.'
</select>
<br>
<input type="submit" class="nextbutton" name="send" value="'.$this->t->_('Weiter').'" />
</form>
<br style="clear:both;" />';
break;
case 'license':
if(isset($_POST['back'])){
header("Location: install.php?step=start");
}
if(isset($_POST['send'])){
if($_POST['accept']!=1){
$err= '<p><div class="comment"><img src="style/images/error.png" alt="" /><span style="color: red;">'.$this->t->_('FehlerAkzeptieren').'</span></div></p>';
}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='<h3>'.$this->t->_('Lizenz').'</h3>
<p>'.$this->t->_('LizenzText').'</p>
'.$err.'
<div class="console" style="height:300px; overflow : auto;">'.$license.'</div>
<form action="#" method="post">
<p><input type="checkbox" class="checkbox" name="accept" value="1"/>'.$this->t->_('Akzeptieren').'</p>
<br />
<input type="submit" class="prevbutton" name="back" value="'.$this->t->_('Zurueck').'" /><input type="submit" class="nextbutton" name="send" value="'.$this->t->_('Weiter').'" />
</form>
<br style="clear:both;" />';
break;
case 'check':
$globcheck=true;
$dircheck=$this->checkchmod();
if($dircheck){
$dirs='<div class="comment"><img src="style/images/ok.png" alt="" />'.$this->t->_('dateiok');
}else{
$globcheck=false;
$dirs='<div class="comment"><img src="style/images/error.png" alt="" />'.$this->t->_('dateinichtok');
}
$dirs.='<table><tr><th>'.$this->t->_('Verzeichnis').'</th><th></th><th>'.$this->t->_('Ergebnis').'</th></tr>';
foreach($this->checkdir as $dir){
$dirs.='<tr style="color: '.$dir['color'].'"><td>'.$dir['dir'].'</td><td>................</td><td>'.$dir['status'].'</td></tr>';
}
$dirs.='</table></div>';
$phpcheck=$this->checkphp();
if($phpcheck){
$php='<div class="comment"><img src="style/images/ok.png" alt="" />'.$this->t->_('phpok');
}else{
$globcheck=false;
$php='<div class="comment"><img src="style/images/error.png" alt="" />'.$this->t->_('phpnichtok');
}
$php.='<table><tr><th>'.$this->t->_('Komponente').'</th><th>'.$this->t->_('benVersion').'</th><th>'.$this->t->_('instVersion').'</th></tr>';
foreach($this->checkphp as $p){
$php.='<tr style="color: '.$p['success'].'"><td>'.$p['name'].'</td><td>'.$p['needed'].'</td><td>'.$p['status'].'</td></tr>';
}
$php.='</table></div>';
$dbcheck=$this->getsupportetdbs();
if($dbcheck){
$dbs='<div class="comment"><img src="style/images/ok.png" alt="" />'.$this->t->_('dbsok');
}else{
$globcheck=false;
$dbs='<div class="comment"><img src="style/images/error.png" alt="" />'.$this->t->_('dbsnichtok');
}
$dbas = "";
foreach($this->dbas as $d){
if(empty($dbas))
$dbas=$d['name'];
else
$dbas.=' ,'.$d['name'];
}
if($dbas==''){
$dbas=$this->t->_('keine');
}
$dbs.='<br />'.$this->t->_('installiertedbs').': '.$dbas.'</div>';
if(isset($_POST['back'])){
header("Location: install.php?step=license");
}
if(isset($_POST['send'])){
if(!$globcheck){
$err= '<div class="comment"><img src="style/images/error.png" alt="" /><span style="color: red;">'.$this->t->_('Fehlererstloesen').'</span></div>';
}else{
header("Location: install.php?step=database");
}
}
$data='<h3>'.$this->t->_('Pruefung').'</h3>
<p>'.$this->t->_('PruefungText').'</p><p>'.$err.'</p>';
if($globcheck){
$data.='<p>'.$this->t->_('CheckOK').'</p>';
}else{
$data.='<p>'.$this->t->_('ChecknichtOK').'</p>';
$locked='disabled="disabled"';
}
$data.='<p>'.$dirs.'</p>
<p>'.$php.'</p>
<p>'.$dbs.'</p>
<form action="#" method="post">
<br />
<input type="submit" class="prevbutton" name="back" value="'.$this->t->_('Zurueck').'" /><input type="submit" class="refreshbutton" name="refresh" value="'.$this->t->_('Erneut').'" /><input type="submit" '.$locked.' class="nextbutton" name="send" value="'.$this->t->_('Weiter').'" />
</form>
<br style="clear:both;" />';
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='<?php
$config[\'host\'] = \''.$server.'\';
// your Database Username
$config[\'user\'] = \''.$user.'\';
// your Database Password
$config[\'pass\'] = \''.$pass.'\';
// your Database
$config[\'db\'] = \''.$db.'\';
// your Database Prefix
$config[\'prefix\']=\''.$prefix.'\';
// your Database Sytem
$config[\'db_class\']= \''.$driver.'\';
?>';
define('DEBUG', FALSE);
include dirname(__FILE__, 2) .'/inc/logger.class.php';
include dirname(__FILE__, 2) .'/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(__FILE__, 2) .'/config.tmp.php','w');
fputs($datei,$configdata);
fclose($datei);
$locked='';
$err='<p><div class="comment"><img src="style/images/warning.png" alt="" /><span style="color: orange;">'.$this->t->_('Installationwarten').'</span></div></p>';
}else{
$err='<p><div class="comment"><img src="style/images/error.png" alt="" /><span style="color: red;">'.$this->t->_('FalscheDaten').'</span></div></p>';
}
}
if(isset($_POST['send'])){
define('DEBUG', FALSE);
include dirname(__FILE__, 2) .'/inc/logger.class.php';
include dirname(__FILE__, 2) .'/config.tmp.php';
include dirname(__FILE__, 2) .'/core/database/'.$config['db_class'].'.class.php';
$configdata='<?php
/**
* Project: BeCast WebEngine - simple site engine
* File: config.inc.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.becast.at
* @copyright 2010-2025 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @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(__FILE__, 2) .'/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(__FILE__, 2) .'/config.tmp.php');
header("Location: install.php?step=user");
}
if($pdata['dbprefix']==''){
$pdata['dbprefix']='bcwe_';
}
if($pdata['dbserv']==''){
$pdata['dbserv']='localhost';
}
$this->getsupportetdbs();
foreach($this->dbas as $driver){
if($pdata['dbdriver']==$driver['short']){
$select='selected="selected"';
}
$drv.='<option value="'.$driver['short'].'" '.$select.'>'.$driver['name'].'</option>';
}
$data='<h3>'.$this->t->_('Datenbank').'</h3>
<p>'.$this->t->_('DatenbankText').'</p>
'.$err.'
<form action="#" method="post">
<div class="reihe">
<label class="label" for="dbuser">'.$this->t->_('Datenbankbenutzer').'</label>
<input class="feld" autocomplete="off" id="dbuser" name="dbuser" value="'.$pdata['dbuser'].'" type="text" />
</div>
<div class="reihe">
<label class="label" for="dbpass">'.$this->t->_('Datenbankpasswort').'</label>
<input class="feld" autocomplete="off" id="dbpass" name="dbpass" value="'.$pdata['dbpass'].'" type="password" />
</div>
<div class="reihe">
<label class="label" for="db">'.$this->t->_('Datenbank').'</label>
<input class="feld" autocomplete="off" id="db" name="db" value="'.$pdata['db'].'" type="text" />
</div>
<div class="reihe">
<label class="label" for="dbserv">'.$this->t->_('Datenbankserver').'</label>
<input class="feld" autocomplete="off" id="dbserv" name="dbserv" value="'.$pdata['dbserv'].'" type="text" />
</div>
<div class="reihe">
<label class="label" for="dbprefix">'.$this->t->_('Datenbankprefix').'</label>
<input class="feld" autocomplete="off" id="dbprefix" name="dbprefix" value="'.$pdata['dbprefix'].'" type="text" />
</div>
<div class="reihe">
<label class="label" for="dbdriver">'.$this->t->_('Datenbanktreiber').'</label>
<select class="feld" id="dbdriver" name="dbdriver">
'.$drv.'
</select>
</div>
<br />
<input type="submit" class="prevbutton" name="back" value="'.$this->t->_('Zurueck').'" /><input type="submit" class="refreshbutton" name="test" value="'.$this->t->_('Testen').'" /><input type="submit" '.$locked.' class="nextbutton" name="send" value="'.$this->t->_('Weiter').'" />
</form>
<br style="clear:both;" />';
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.='<p><div class="comment"><img src="style/images/error.png" alt="" /><span style="color: red;">'.$this->t->_('Passwoerterfalsch').'</span></div></p>';
}
if(!preg_match('/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/iD',$_POST['email'])){
$err.='<p><div class="comment"><img src="style/images/error.png" alt="" /><span style="color: red;">'.$this->t->_('Emailinkorrekt').'</span></div></p>';
}
if(!$err){
define('in_astat',TRUE);
define('DEBUG', FALSE);
include dirname(__FILE__, 2) .'/inc/logger.class.php';
include dirname(__FILE__, 2) .'/inc/config.inc.php';
include dirname(__FILE__, 2) .'/core/database/'.$config['db_class'].'.class.php';
$db = new db($config['host'], $config['user'], $config['pass'], $config['db'],'utf8', FALSE,TRUE);
$key=$this->generate_Key(50);
$salt=$this->generate_Key(6);
$active=1;
$pass=hash('sha256',$db->escape($salt.$_POST['pass']));
$username=$db->escape($_POST['user']);
$email=$db->escape($_POST['email']);
$db->query("INSERT INTO `" . $config['prefix'] . "users` (`username`,`password`,`loginkey`,`salt`,`email`,`active`,`since`,`role`) VALUES ('".$username."','".$pass."','".$key."', '".$salt."', '".$email."', '".$active."','".time()."','2')");
header("Location: install.php?step=finish");
}else{
$pdata=$_POST;
}
}
$data='<h3>'.$this->t->_('Benutzer').'</h3>
<p>'.$this->t->_('BenutzerText').'</p>
'.$err.'
<form action="#" method="post">
<div class="reihe">
<label class="label" for="user">'.$this->t->_('Benutzername').'</label>
<input class="feld" autocomplete="off" id="user" name="user" value="'.$pdata['user'].'" type="text" />
</div>
<div class="reihe">
<label class="label" for="pass">'.$this->t->_('Passwort').'</label>
<input class="feld" autocomplete="off" id="pass" name="pass" type="password" />
</div>
<div class="reihe">
<label class="label" for="passrepeat">'.$this->t->_('PasswortWiederholen').'</label>
<input class="feld" autocomplete="off" id="passrepeat" name="passrepeat" type="password" />
</div>
<div class="reihe">
<label class="label" for="email">'.$this->t->_('EMail').'</label>
<input class="feld" autocomplete="off" id="email" name="email" value="'.$pdata['email'].'" type="text" />
</div>
<br />
<input type="submit" class="prevbutton" name="back" value="'.$this->t->_('Zurueck').'" /><input type="submit" class="nextbutton" name="send" value="'.$this->t->_('Weiter').'" />
</form>
<br style="clear:both;" />';
break;
case 'finish':
$fopen=true;
$test=fopen('https://webengine.becast.at/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='BcWe 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('https://webengine.becast.at/install.php?install='.$sendkey, 'r');
$ikey= fgets($key,1024);
fclose($key);
define('in_astat',TRUE);
include dirname(__FILE__, 2) .'/inc/logger.class.php';
include dirname(__FILE__, 2) .'/inc/config.inc.php';
include dirname(__FILE__, 2) .'/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='<p><div class="comment"><img src="style/images/love.png" alt="" />'.$this->t->_('Installationsbenachrichtigung').'<br />'.$this->t->_('DieseDaten').'<br />
<ul>
<li>'.$server.'</li>
<li>'.$astat_version.'</li>
<li>'.$timestamp.'</li>
</ul>
'.$this->t->_('Danke').'
</div></p>';
$cb='<p><input type="checkbox" class="checkbox" name="accept" value="1"/>'.$this->t->_('Datensenden').'</p>';
}
$data='<h3>'.$this->t->_('Abschluss').'</h3>
<p>'.$this->t->_('AbschlussText').'</p>
'.$fp.'
<form action="#" method="post">
'.$cb.'
<input type="submit" class="prevbutton" name="back" value="'.$this->t->_('Zurueck').'" /><input type="submit" class="nextbutton" name="send" value="'.$this->t->_('Fertig').'" />
</form>
<br style="clear:both;" />';
break;
}
echo $this->header($step);
echo $data;
}
function footer(): string
{
return '</div><div class="footer">
<p> <a href="http://www.becast.at">BeCastWebEngine Installer v1.2 &copy; 2012-2025 BeCast</a></p>
</div>
</div>
</div>
</div>
<span style="font-size: xx-small; display: block; text-align:center;">Original Theme: <a href="https://github.com/hnarayanan/simplicity-2">v2.0.0 &copy; HN MMVII</a></span>
</div>
</div>
</body>
</html>';
}
}
$lang = new lang();
$install = new install($lang);
$step = $_GET['step'];
if(!$step || $step==''){
$step='start';
}
$install->step($step);
echo $install->footer();