11 error_reporting(E_ERROR|E_PARSE);
14 public function __construct($DBHost=null,$DBName=null,$DBUser=null,$DBPass=null)
18 $this->DBHost = $DBHost;
19 $this->DBName = $DBName;
20 $this->DBUser = $DBUser;
21 $this->DBPass = $DBPass;
23 if(($this->DBHost!=
'')&&($this->DBUser!=
'')&&($this->DBPass!=
'')&&($this->DBName!=
''))
25 $this->checksum=md5($this->DBHost.$this->DBUser.$this->DBPass.$this->DBName);
27 $this->con = mysql_connect($this->DBHost, $this->DBUser, $this->DBPass);
30 die(
"<b>core_installer: MySQL connection failed!</b> ".mysql_error());
32 mysql_select_db($this->DBName, $this->con);
37 $ini = parse_ini_file(
'../fw_headers/install.ini',
true);
38 foreach($ini[
'bootstrap_paths'][
'require'] as $val)
44 $inc->install($ini[
'extensions'][
'ignored']);
45 $paths = $inc->installerPath();
47 foreach($paths as $val)
62 $seo->title($afterBootUp[0]->info[
'FWK'].
' - '.$ini[
'installer'][
'name']);
63 $seo->owner($ini[
'installer'][
'author']);
64 $seo->bootstrapDefs();
67 $PHPversion=explode(
".",phpversion());
68 if(($_GET[
'install']==$ini[
'installer'][
'initialize'])&&((floatval($PHPversion[0].
'.'.$PHPversion[1]))>=floatval($ini[
'installer'][
'minimalphp'])))
70 chmod(
"../fw_headers/", 0777);
71 if((($_POST[
'host']!=
"")&&($_POST[
'user']!=
"")&&($_POST[
'name']!=
"")&&($_POST[
'pass']!=
""))||((defined(
'DB_USER'))&&(defined(
'DB_NAME'))&&(defined(
'DB_PASS'))&&(defined(
'DB_HOST'))))
73 $hash = md5($_SERVER[
'SERVER_NAME'].$_SERVER[
'SERVER_ADDR'].$_POST[
'host'].$_POST[
'user'].$_POST[
'type']);
74 $mysqlTest =
new testingMysql((isset($_POST[
'host'])?$_POST[
'host']:DB_HOST),(isset($_POST[
'name'])?$_POST[
'name']:DB_NAME),(isset($_POST[
'user'])?$_POST[
'user']:DB_USER),(isset($_POST[
'pass'])?$_POST[
'pass']:DB_PASS));
75 $file =
new fileSystem($ini[
'new_file_paths'][
'mysqlconfig']);
78 .---------------------------------------------------------------------------.
79 | Software: '.$afterBootUp[0]->info[
'NME'].
' SQL Config |
80 | Version: '.$afterBootUp[0]->info[
'VSN'].
' |
81 | Contact: mail@phorvath.com |
82 | ------------------------------------------------------------------------- |
83 | Author: Bc. Peter Horváth (original founder) |
84 | Copyright (c) 2011-'.date(
"Y").
', Bc. Peter Horváth. All Rights Reserved. |
85 | ------------------------------------------------------------------------- |
86 | License: Distributed under the General Public License (GPL) |
87 | http://www.gnu.org/licenses/gpl-3.0.html |
88 | This program is distributed in the hope that it will be useful - WITHOUT |
89 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
90 | FITNESS FOR A PARTICULAR PURPOSE. |
91 ´---------------------------------------------------------------------------´
96 const host = "'.(isset($_POST[
'host'])?$_POST[
'host']:DB_HOST).
'";
97 const name = "'.(isset($_POST[
'name'])?$_POST[
'name']:DB_NAME).
'";
98 const user = "'.(isset($_POST[
'user'])?$_POST[
'user']:DB_USER).
'";
99 const pass = "'.(isset($_POST[
'pass'])?$_POST[
'pass']:DB_PASS).
'";
100 const type = "'.(isset($_POST[
'type'])?$_POST[
'type']:
"sams").
'";
101 const hash = "'.$hash.
'";
102 const cache= "'.(isset($_POST[
'cache'])?$_POST[
'cache']:
"0").
'";
104 //depecrated variables
106 $DBHost = database::host;
108 $DBUser = database::user;
109 $DBName = database::name;
110 $DBPass = database::pass;
112 $DBType = database::type;
114 define("SENCILLO_CONFIG",database::hash);
116 $QUICKCACHE_ON = database::cache;
120 if(!file_exists($ini[
'new_file_paths'][
'yourcode']))
122 $file =
new fileSystem($ini[
'new_file_paths'][
'yourcode']);
125 $seo = new headerSeo;
127 $seo->title($core->coreSencillo->info["FWK"]." - Example page");
128 $seo->owner("'.$_POST[
'user-new-name'].
', '.$_POST[
'user-new-mail'].
'");
129 $seo->bootstrapDefs();
132 $translate = new translate("translate.json","en");
133 require_once("./fw_templates/system/welcome.default.screen.php");
136 $file =
new fileSystem($ini[
'new_file_paths'][
'firststart']);
137 $json = json_encode(array(
'time'=>date(
"H:i:s"),
138 'date'=>date(
"Y-m-d"),
139 'email'=>$_POST[
'user-new-mail'],
140 'PHP' =>phpversion(),
141 'SYSTEM'=>$afterBootUp[0]->info[
'FWK'],
146 if(!defined(
'DB_USER'))
148 foreach($ini[
'htaccess'][
'cache'] as $key=>$val)
150 $expiresbytype.=
'ExpiresByType '.$val.
' "access plus '.$ini[
'htaccess'][
'cache_size'].
' '.$ini[
'htaccess'][
'cache_unit'].
'"'.PHP_EOL;
152 if($ini[
'htaccess'][
'protocol']==
"http")
154 $protocolinhtaccess=
'# HTTPS to HTTP
155 <IfModule mod_rewrite.c>
156 RewriteCond %{SERVER_PORT} ^443$
157 RewriteCond %{HTTPS} =on
158 RewriteRule ^(.*)$ http://'.$_SERVER[
'SERVER_NAME'].
'/$1 [L,R=301]
163 $protocolinhtaccess=
'# HTTP to HTTPS
164 <IfModule mod_rewrite.c>
165 RewriteCond %{SERVER_PORT} !^443$
166 RewriteCond %{HTTPS} off
167 RewriteRule ^(.*)$ https://'.$_SERVER[
'SERVER_NAME'].
'/$1 [R=301,L]
170 $file =
new fileSystem($ini[
'new_file_paths'][
'htaccess']);
171 $file->write(
'# Create with '.$afterBootUp[0]->info[
'FWK'].
'.
179 <IfModule mod_expires.c>
184 '.$protocolinhtaccess.
'
187 <IfModule mod_rewrite.c>
193 <IfModule mod_rewrite.c>
194 RewriteCond %{REQUEST_FILENAME} !-f
195 RewriteCond %{REQUEST_FILENAME} !-d
196 RewriteCond %{REQUEST_FILENAME} !-l
197 RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]
200 # '.$_SERVER[
'SERVER_NAME'].
' -> www.'.$_SERVER[
'SERVER_NAME'].
'
201 <IfModule mod_rewrite.c>
202 RewriteCond %{HTTP_HOST} !^'.$_SERVER[
'SERVER_NAME'].
'$ [NC]
203 RewriteRule ^(.*)$ http://'.$_SERVER[
'SERVER_NAME'].
'/$1 [L,R=301]
207 chmod(
"../fw_core/", 0700);
208 chmod(
"../fw_cache/", 0700);
209 chmod(
"../fw_headers/", 0700);
210 chmod(
"../fw_modules/", 0700);
211 chmod(
"../fw_libraries/", 0700);
212 chmod(
"../fw_script/", 0700);
215 foreach($ini[
'bootstrap_middle_paths'][
'require'] as $val)
217 require_once(
"$val");
219 }
catch(Exception $e){
220 echo
'ERR: '.$e->getMessage().PHP_EOL;
221 die(
'core_installer: Permission error - FATAL ERROR!');
226 if(!defined(
'DB_USER'))
229 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
231 $mysql->write($delinsql);
233 SET time_zone = "'.$ini[
'sql_driver_config'][
'timezone'].
'";
235 $mysql->write($delinsql);
238 CREATE TABLE IF NOT EXISTS `console` (
239 `id` bigint(20) NOT NULL AUTO_INCREMENT,
240 `time` datetime NOT NULL,
241 `title` varchar(25) NOT NULL,
242 `data` varchar(255) NOT NULL,
244 ) ENGINE=MEMORY DEFAULT CHARSET=utf8 MAX_ROWS='.$ini[
'sql_driver_config'][
'consolesize'].
' AUTO_INCREMENT=0;
246 $mysql->write($delinsql);
249 CREATE TABLE IF NOT EXISTS `country` (
250 `id` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
251 `id2` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
252 `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
254 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
256 $mysql->write($delinsql);
261 CREATE TABLE IF NOT EXISTS `login` (
262 `id` bigint(20) NOT NULL AUTO_INCREMENT,
263 `userid` bigint(20) NOT NULL,
264 `sessionid` longtext NOT NULL,
265 `expiration` int(11) NOT NULL,
266 `perm` int(11) NOT NULL,
268 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;
270 $mysql->write($delinsql);
273 CREATE TABLE sencillo_cache (
274 CACHEKEY varchar(255) NOT NULL,
275 CACHEEXPIRATION int(11) NOT NULL,
279 PRIMARY KEY (CACHEKEY)
282 $mysql->write($delinsql);
285 CREATE TABLE IF NOT EXISTS `virtual_system_config` (
286 `id` int(11) NOT NULL AUTO_INCREMENT,
287 `function` varchar(25) NOT NULL,
288 `command` varchar(25) NOT NULL,
289 `commander` int(11) NOT NULL,
291 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
293 $mysql->write($delinsql);
300 foreach($clist as $key=>$val)
308 $mysql->insert($delinsql);
311 if(!defined(
'DB_USER'))
314 'virtual_system_config'=>array(
316 'function'=>
'superuser',
317 'command'=>$_POST[
'user-new-name'],
320 $mysql->insert($delinsql);
323 'virtual_system_config'=>array(
325 'function'=>
'superpass',
326 'command'=>md5($_POST[
'user-new-pass']),
329 $mysql->insert($delinsql);
332 'virtual_system_config'=>array(
334 'function'=>
'supermail',
335 'command'=>$_POST[
'user-new-mail'],
338 $mysql->insert($delinsql);
341 'virtual_system_config'=>array(
343 'function'=>
'systemhash',
347 $mysql->insert($delinsql);
350 'virtual_system_config'=>array(
352 'function'=>
'servername',
353 'command'=>$_SERVER[
'SERVER_NAME'],
356 $mysql->insert($delinsql);
359 'virtual_system_config'=>array(
361 'function'=>
'htaccess_config',
362 'command'=>
'default',
365 $mysql->insert($delinsql);
370 'virtual_system_config'=>array(
372 'function'=>
'htaccess_config',
376 $mysql->insert($delinsql);
381 'virtual_system_config'=>array(
383 'function'=>
'phpversion',
384 'command'=>phpversion(),
387 $mysql->insert($delinsql);
390 $dir =
'../fw_libraries';
391 $scan = array_diff(scandir($dir),array(
'..',
'.'));
392 $json = json_encode($scan);
394 foreach($scan as $key=>$val)
397 'virtual_system_config'=>array(
399 'function'=>
"lib:$key",
403 $mysql->insert($delinsql);
408 'virtual_system_config'=>array(
410 'function'=>
"lib_count",
411 'command'=>
sizeof($scan),
414 $mysql->insert($delinsql);
420 'sign'=>
"'first_use'",
422 'login'=>
"'".$_POST[
'user-new-name'].
"'",
423 'pass'=>
"'".md5($_POST[
'user-new-pass']).
"'",
424 'email'=>
"'".$_POST[
'user-new-mail'].
"'",
428 'ip'=>
"'".$_SERVER[
'REMOTE_ADDR'].
"'",
429 'agent'=>
"'".$_SERVER[
'HTTP_USER_AGENT'].
"'",
430 'date'=>
'DATE(NOW())',
431 'time'=>
'TIME(NOW())',
433 $mysql->insert($delinsql,
false);
436 foreach($ini[
'bootstrap_end_paths'][
'require'] as $val)
438 require_once(
"$val");