- modified by Simon Georget * @link http://www.vadimg.co.il/ * @version $Id$ 1.0.0a * @license GNU Lesser General Public License */ /** Load the template class **/ require_once(INSTALLER_PATH . '/Installer_Template.php'); /** * Class installer * */ class Installer { /** * Options property * * @var array */ protected $_options = array(); /** * View object * * @var object */ protected $view; /** * Language array * * @var array */ protected $lang = array(); protected $default_lang = U_L; /** * Constructor * */ public function __construct() { // get lang from browser $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); if(file_exists('../languages/' .$lang. '/installer.utf-8.php')) { $this->default_lang = $lang; } else { $this->default_lang = 'fr'; } # Do we have a cookie if(isset($_COOKIE['lang']) && $_COOKIE['lang'] != '') { $this->default_lang = $_COOKIE['lang']; } # Change language if(isset($_POST['lang']) && $_POST['lang'] != '' && $this->default_lang != $_POST['lang']) { $path = INSTALLER_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $_POST['lang'] . '.php'; $path = '../languages/' .$_POST['lang']. '/installer.utf-8.php'; if(file_exists($path)) { $this->default_lang = $_POST['lang']; @setCookieLinea21('lang', $this->default_lang, time() + 60 * 60 * 24); $_POST['lang'] = 0; $this->nextStep('index'); } } # Load the language file require_once( '../languages/' .$this->default_lang. '/installer.utf-8.php' ); $this->lang = $lang; # Load the template class $this->view = new Installer_Template($this->lang); # Are config files writable? if(!is_writable('../install/') || !is_writable('../install/installer/data/')) { $this->view->error($this->lang['L-13']); } # Is config folder writable? if(!is_writable('../config/')) { $this->view->error($this->lang['L-12']); } # Did we run it again? if(file_exists(INSTALLER_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'installer.lock')) { $this->view->error($this->lang['L-01']); } $allwed_steps = array('index' => 'indexAction', 'db' => 'dbAction', 'cfg' => 'configAction', 'database' => 'dbTables', 'config' => 'configWrite', 'finish' => 'finishInstaller'); if(!in_array($_POST['step'], array_keys($allwed_steps))) { $this->nextStep('index'); } # Display the right step $this->{$allwed_steps[$_POST['step']]}($_POST); } /** * Show welcome message * */ public function indexAction() { $_SESSION = array(); // unset session $options = CultureSelectBox('lang', $this->default_lang); $this->view->vars = array('options' => $options); $this->view->render('index'); } /** * Show database setup stuff * */ public function dbAction() { $this->view->render('db'); } public function configAction() { $root_path = str_replace('install', '', ROOT_PATH); $root_url =str_replace('install/install.php', '', BASE_URL); // we get current php configuration values $mem = (int) str_replace('M', '', ini_get('memory_limit')); $umf = (int) str_replace('M', '', ini_get('upload_max_filesize')); $pmf = (int) str_replace('M', '', ini_get('post_max_size')); // we write .user.ini file $dmemory = 256; $dupload_max_filesize = 128; $dpost_max_size = 128; // if current values are superior wee keep them if($mem > $dmemory) $dmemory = $mem; if($umf > $dupload_max_filesize) $dupload_max_filesize = $umf; if($pmf > $dpost_max_size) $dpost_max_size = $pmf; // .user.ini file content $user_ini_content ="display_errors=On\nlog_errors=On\nerror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT\nerror_log = \"".$root_path."logs/PHP_errors.log\"\nmemory_limit = ".$dmemory."M\nupload_max_filesize = ".$dupload_max_filesize."M\npost_max_size = ".$dpost_max_size."M"; $htaccess_content = '# Security Headers # instructs user agents to treat all of a sites insecure URLs (those served over HTTP) as though they have been replaced with secure URLs (those served over HTTPS). # Header set Content-Security-Policy "upgrade-insecure-requests" # only accessible through https Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" # Enables XSS filtering. Rather than sanitizing the page, the browser will prevent rendering of the page if an attack is detected. Header set X-Xss-Protection "1; mode=block" # Header set X-Frame-Options "SAMEORIGIN" # prevent iframe from other websites # always use the MIME type that is declared in the Content-Type header rather than trying to determine the MIME type based Header set X-Content-Type-Options "nosniff" # only the origin is sent in the Referer header of cross-origin requests. Header set Referrer-Policy "strict-origin-when-cross-origin" # The feature will be allowed in this document, and in all nested browsing contexts (