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