Open Sencillo  2015.107
Long live the simplicity of PHP
 All Data Structures Namespaces Functions Pages
core_installer.php
1 <?php
11 error_reporting(E_ERROR | E_PARSE);
12 require_once("./core_interface.php");
13 require_once("./core_functions.php");
14 $i=0;
15 $afterBootUp=array();
16 $afterBootUp[$i++]=new coreSencillo;
17 $seo=new headerSeo;
18 $seo->encode();
19 $seo->title($afterBootUp[0]->info['FWK'].' - Installer');
20 $seo->owner('Bc. Peter Horváth');
21 $seo->bootstrapDefs();
22 $seo->save();
23 echo $seo->seo;
24 $PHPversion=explode(".",phpversion());
25 if(($_GET['install']=='true')&&($PHPversion[0]>=5))
26 {
27  chmod("../fw_headers/", 0777);
28  if(($_POST['host']!="")&&($_POST['user']!="")&&($_POST['name']!="")&&($_POST['pass']!=""))
29  {
30  $hash = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_ADDR'].$_POST['host'].$_POST['user'].$_POST['type']);
31  $file = new fileSystem('../fw_headers/mysql-config.php');
32  $file->write('<?php
33 /*~ mysql-config.php
34 .---------------------------------------------------------------------------.
35 | Software: OpenSencillo SQL Config |
36 | Version: '.$afterBootUp[0]->info['VSN'].' |
37 | Contact: mail@phorvath.com |
38 | ------------------------------------------------------------------------- |
39 | Author: Bc. Peter Horváth (original founder) |
40 | Copyright (c) 2015, Bc. Peter Horváth. All Rights Reserved. |
41 | ------------------------------------------------------------------------- |
42 | License: Distributed under the General Public License (GPL) |
43 | http://www.gnu.org/licenses/gpl-3.0.html |
44 | This program is distributed in the hope that it will be useful - WITHOUT |
45 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
46 | FITNESS FOR A PARTICULAR PURPOSE. |
47 ´---------------------------------------------------------------------------´
48 ~*/
49 //changable settings
50 class database
51 {
52  const host = "'.$_POST['host'].'";
53  const name = "'.$_POST['name'].'";
54  const user = "'.$_POST['user'].'";
55  const pass = "'.$_POST['pass'].'";
56  const type = "'.$_POST['type'].'";
57  const hash = "'.$hash.'";
58  const cache= "'.$_POST['cache'].'";
59 }
60 //depecrated variables
61 //DB Server
62 $DBHost = database::host;
63 //SQL access
64 $DBUser = database::name;
65 $DBName = database::user;
66 $DBPass = database::pass;
67 //SQL type
68 $DBType = database::type;
69 //Hash
70 define("SENCILLO_CONFIG",database::hash);
71 //Cache
72 $QUICKCACHE_ON = database::cache;
73 ?>');
74  }
75  chmod("../", 0777);
76  if(!file_exists('../yourcode.php'))
77  {
78  $file = new fileSystem('../yourcode.php');
79 
80  $file->write('<?php
81  $seo = new headerSeo;
82  $seo->encode();
83  $seo->title($core->coreSencillo->info["FWK"]." - Example page");
84  $seo->owner("'.$_POST['user-new-name'].', '.$_POST['user-new-mail'].'");
85  $seo->bootstrapDefs();
86  echo $seo->save();
87 
88  $translate = new translate("translate.json","en");
89  require_once("./fw_templates/welcome.default.screen.php");
90 ?>');
91 
92  $file = new fileSystem('../firststart.json');
93  $json = json_encode(array( 'time'=>date("H:i:s"),
94  'date'=>date("Y-m-d"),
95  'email'=>$_POST['user-new-mail'],
96  'PHP' =>phpversion(),
97  'SYSTEM'=>$afterBootUp[0]->info['FWK'],
98  'hash'=>$hash
99  ));
100  $file->write($json);
101  }
102  $file = new fileSystem('../.htaccess');
103  $file->write('# Create with '.$afterBootUp[0]->info['FWK'].'.
104 # Image cache
105 <IfModule mod_expires.c>
106  ExpiresActive on
107 
108  ExpiresByType image/jpg "access plus 1 month"
109  ExpiresByType image/jpeg "access plus 1 month"
110  ExpiresByType image/gif "access plus 1 month"
111  ExpiresByType image/png "access plus 1 month"
112 </IfModule>
113 
114 RewriteCond %{SERVER_PORT} ^443$
115 RewriteRule ^(.*)$ http://'.$_SERVER['SERVER_NAME'].'/$1 [L,R=301]
116 
117 # Rewrite URLs
118 RewriteEngine on
119 RewriteBase /
120 
121 # Best URLs
122 RewriteCond %{REQUEST_FILENAME} !-f
123 RewriteCond %{REQUEST_FILENAME} !-d
124 RewriteCond %{REQUEST_FILENAME} !-l
125 RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]
126 
127 # opensencillo.com -> www.opensencillo.com
128 RewriteCond %{HTTP_HOST} !^'.$_SERVER['SERVER_NAME'].'$ [NC]
129 RewriteRule ^(.*)$ http://'.$_SERVER['SERVER_NAME'].'/$1 [L,R=301]');
130  chmod("../fw_core/", 0700);
131  chmod("../fw_cache/", 0700);
132  chmod("../fw_headers/", 0700);
133  chmod("../fw_modules/", 0700);
134  chmod("../fw_libraries/", 0700);
135  chmod("../fw_script/", 0700);
136  chmod("../", 0700);
137  require("../fw_headers/mysql-config.php");
138  require("../fw_headers/main-config.php");
139  require("./core_sql.php");
140  require("../fw_libraries/login.management.logman.php");
141  require("../fw_libraries/test.tool.framework.php");
142 
143  $delinsql='
144  SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
145  ';
146  $mysql->write($delinsql);
147  $delinsql='
148  SET time_zone = "+00:00";
149  ';
150  $mysql->write($delinsql);
151 
152  $delinsql='
153  CREATE TABLE IF NOT EXISTS `console` (
154  `id` bigint(20) NOT NULL AUTO_INCREMENT,
155  `time` datetime NOT NULL,
156  `title` varchar(25) NOT NULL,
157  `data` varchar(255) NOT NULL,
158  PRIMARY KEY (`id`)
159  ) ENGINE=MEMORY DEFAULT CHARSET=utf8 MAX_ROWS=10000 AUTO_INCREMENT=0;
160  ';
161  $mysql->write($delinsql);
162 
163  $delinsql='
164  CREATE TABLE IF NOT EXISTS `country` (
165  `id` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
166  `id2` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
167  `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
168  PRIMARY KEY (`id`)
169  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
170  ';
171  $mysql->write($delinsql);
172 
173  $delinsql='
174  CREATE TABLE IF NOT EXISTS `login` (
175  `id` bigint(20) NOT NULL AUTO_INCREMENT,
176  `userid` bigint(20) NOT NULL,
177  `sessionid` longtext NOT NULL,
178  `expiration` int(11) NOT NULL,
179  `perm` int(11) NOT NULL,
180  PRIMARY KEY (`id`)
181  ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;
182  ';
183  $mysql->write($delinsql);
184 
185  $delinsql='
186  CREATE TABLE sencillo_cache (
187  CACHEKEY varchar(255) NOT NULL,
188  CACHEEXPIRATION int(11) NOT NULL,
189  GZDATA blob,
190  DATASIZE int(11),
191  DATACRC int(11),
192  PRIMARY KEY (CACHEKEY)
193  );
194  ';
195  $mysql->write($delinsql);
196 
197  $delinsql='
198  CREATE TABLE IF NOT EXISTS `virtual_system_config` (
199  `id` int(11) NOT NULL AUTO_INCREMENT,
200  `function` varchar(25) NOT NULL,
201  `command` varchar(25) NOT NULL,
202  `commander` int(11) NOT NULL,
203  PRIMARY KEY (`id`)
204  ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
205  ';
206  $mysql->write($delinsql);
207  $mysql->close();
208 
209  $logman=new logMan($DBHost,$DBName,$DBUser,$DBPass);
210  $mysql=new mysqlInterface($DBHost,$DBName,$DBUser,$DBPass);
211  $mysql->config();
212  $mysql->connect();
213 
214  $delinsql=array(
215  'virtual_system_config'=>array(
216  'id'=>"''",
217  'function'=>'superuser',
218  'command'=>$_POST['user-new-name'],
219  'commander'=>0
220  ));
221  $mysql->insert($delinsql);
222 
223 
224  $delinsql=array(
225  'virtual_system_config'=>array(
226  'id'=>"''",
227  'function'=>'superpass',
228  'command'=>md5($_POST['user-new-pass']),
229  'commander'=>0
230  ));
231  $mysql->insert($delinsql);
232 
233  $delinsql=array(
234  'virtual_system_config'=>array(
235  'id'=>"''",
236  'function'=>'supermail',
237  'command'=>$_POST['user-new-mail'],
238  'commander'=>0
239  ));
240  $mysql->insert($delinsql);
241 
242  $delinsql=array(
243  'virtual_system_config'=>array(
244  'id'=>"''",
245  'function'=>'systemhash',
246  'command'=>$hash,
247  'commander'=>0
248  ));
249  $mysql->insert($delinsql);
250 
251  $delinsql=array(
252  'virtual_system_config'=>array(
253  'id'=>"''",
254  'function'=>'servername',
255  'command'=>$_SERVER['SERVER_NAME'],
256  'commander'=>0
257  ));
258  $mysql->insert($delinsql);
259 
260  $delinsql=array(
261  'virtual_system_config'=>array(
262  'id'=>"''",
263  'function'=>'htaccess_config',
264  'command'=>'default',
265  'commander'=>0
266  ));
267  $mysql->insert($delinsql);
268 
269  $delinsql=array(
270  'virtual_system_config'=>array(
271  'id'=>"''",
272  'function'=>'phpversion',
273  'command'=>phpversion(),
274  'commander'=>0
275  ));
276  $mysql->insert($delinsql);
277 
278  $delinsql=array(
279  'users'=>array(
280  'id'=>"''",
281  'sign'=>"'first_use'",
282  'active'=>0,
283  'login'=>"'".$_POST['user-new-name']."'",
284  'pass'=>"'".md5($_POST['user-new-pass'])."'",
285  'email'=>"'".$_POST['user-new-mail']."'",
286  'fname'=>"''",
287  'lname'=>"''",
288  'perm'=>1111,
289  'ip'=>"'".$_SERVER['REMOTE_ADDR']."'",
290  'agent'=>"'".$_SERVER['HTTP_USER_AGENT']."'",
291  'date'=>'DATE(NOW())',
292  'time'=>'TIME(NOW())',
293  ));
294  $mysql->insert($delinsql,false);
295  $mysql->execute();
296 }
297 require_once '../fw_templates/installer.main.screen.php';
298 ?>