Open Sencillo  2014.008
 All Data Structures Files Functions Variables Pages
core_installer.php
Go to the documentation of this file.
1 <?php
2 /*~ core_installer.php
3 .---------------------------------------------------------------------------.
4 | Software: Sencillo SQL Installer |
5 | Version: 2014.008 |
6 | Contact: ph@mastery.sk |
7 | ------------------------------------------------------------------------- |
8 | Author: Bc. Peter Horváth (original founder) |
9 | Copyright (c) 2014, Bc. Peter Horváth. All Rights Reserved. |
10 | ------------------------------------------------------------------------- |
11 | License: Distributed under the General Public License (GPL) |
12 | http://www.gnu.org/copyleft/gpl.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 require_once("./core_functions.php");
28 $i=0;
29 $afterBootUp=array();
32 $seo->encode();
33 $seo->title('LightWeight Sencillo - Install');
34 $seo->owner('Bc. Peter Horváth');
35 $seo->save();
36 echo $seo->seo;
37 echo("<body><form method='post' action='http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."?install=true'><table>");
38 echo("<tr><td><b>System:</b></td><td>".$afterBootUp[0]->info['FWK']."</td></tr>");
39 echo("<tr><td><b>Installation mode:</b></td><td>default</td></tr>");
40 echo("<tr><td><b>By:</b></td><td>".$afterBootUp[0]->info['CPY']."</td></tr>");
41 echo("<tr><td><b>PHP:</b></td><td>".phpversion()."</td></tr>");
42 echo("<tr><td><b>DB charset:</b></td><td>UTF-8</td></tr>");
43 echo("<tr><td><b>System charset:</b></td><td>UTF-8</td></tr>");
44 echo("<tr><td><b>Database</b></td><td></td></tr>");
45 $PHPversion=explode(".",phpversion());
46 if(($_GET['install']!='true')&&($PHPversion[0]>=5))
47 {
48  echo("<tr><td><b>Host:</b></td><td><input type='text' name='host'></td></tr>");
49  echo("<tr><td><b>Name:</b></td><td><input type='text' name='name'></td></tr>");
50  echo("<tr><td><b>User:</b></td><td><input type='text' name='user'></td></tr>");
51  echo("<tr><td><b>Pass:</b></td><td><input type='text' name='pass'></td></tr>");
52  echo("<tr><td><b>SQL type:</b></td><td><select name='type'>
53  <option value='mysql' selected>MySQL</option>
54  <option value='mariasql'>MariaSQL</option>
55  <option value='pgsql'>PgSQL</option>
56  </select></td></tr>");
57  echo("<tr><td></td><td><input type='submit' value='Install'></td></tr>");
58 }
59 else
60 {
61  chmod("../fw_headers/", 0777);
62  if(($_POST['host']!="")&&($_POST['user']!="")&&($_POST['name']!="")&&($_POST['pass']!=""))
63  {
64  $file = new fileSystem('../cms_headers/mysql-config.php');
65  $file->write('<?php
66 /*~ mysql-config.php
67 .---------------------------------------------------------------------------.
68 | Software: Sencillo SQL Config |
69 | Version: 2014.008 |
70 | Contact: ph@mastery.sk |
71 | ------------------------------------------------------------------------- |
72 | Author: Bc. Peter Horváth (original founder) |
73 | Copyright (c) 2014, Bc. Peter Horváth. All Rights Reserved. |
74 | ------------------------------------------------------------------------- |
75 | License: Distributed under the General Public License (GPL) |
76 | http://www.gnu.org/copyleft/gpl.html |
77 | This program is distributed in the hope that it will be useful - WITHOUT |
78 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79 | FITNESS FOR A PARTICULAR PURPOSE. |
80 ´---------------------------------------------------------------------------´
81 ~*/
82 //DB Server
83 $DBHost = "'.$_POST['host'].'";
84 //SQL access
85 $DBUser = "'.$_POST['user'].'";
86 $DBName = "'.$_POST['name'].'";
87 $DBPass = "'.$_POST['pass'].'";
88 //SQL type
89 $DBType = "'.$_POST['type'].'";
90 ?>');
91  }
92  chmod("../", 0777);
93  $file = new fileSystem('../yourcode.php');
94  $file->write('<?php
95  //write your PHP code here
96 ?>');
97  $file = new fileSystem('../.htaccess');
98  $file->write('# Create with '.$afterBootUp[0]->info['FWK'].'.
99 # Image cache
100 <IfModule mod_expires.c>
101  ExpiresActive on
102 
103  ExpiresByType image/jpg "access plus 1 month"
104  ExpiresByType image/jpeg "access plus 1 month"
105  ExpiresByType image/gif "access plus 1 month"
106  ExpiresByType image/png "access plus 1 month"
107 </IfModule>
108 
109 RewriteCond %{SERVER_PORT} ^443$
110 RewriteRule ^(.*)$ http://'.$_SERVER['SERVER_NAME'].'/$1 [L,R=301]
111 
112 # Rewrite URLs
113 RewriteEngine on
114 RewriteBase /
115 
116 # Best URLs
117 RewriteCond %{REQUEST_FILENAME} !-f
118 RewriteCond %{REQUEST_FILENAME} !-d
119 RewriteCond %{REQUEST_FILENAME} !-l
120 RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]
121 
122 # opensencillo.com -> www.opensencillo.com
123 RewriteCond %{HTTP_HOST} !^'.$_SERVER['SERVER_NAME'].'$ [NC]
124 RewriteRule ^(.*)$ http://'.$_SERVER['SERVER_NAME'].'/$1 [L,R=301]');
125  chmod("../fw_core/", 0700);
126  chmod("../fw_cache/", 0700);
127  chmod("../fw_headers/", 0700);
128  chmod("../fw_modules/", 0700);
129  chmod("../fw_libraries/", 0700);
130  chmod("../fw_script/", 0700);
131  chmod("../", 0700);
132  usleep(1000000);
133  require("../cms_headers/mysql-config.php");
134  require("../cms_headers/main-config.php");
135  require("./core_sql.php");
136 
137  echo("<tr><td><b>Host:</b></td><td>".$_POST['host']."</td></tr>");
138  echo("<tr><td><b>Name:</b></td><td>".$_POST['name']."</td></tr>");
139  echo("<tr><td><b>User:</b></td><td>".$_POST['user']."</td></tr>");
140  echo("<tr><td><b>Pass:</b></td><td>****</td></tr>");
141 
143  SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
144  ';
145  $mysql->write($delinsql);
146  $delinsql='
147  SET time_zone = "+00:00";
148  ';
149  $mysql->write($delinsql);
150 
151  $delinsql='
152  CREATE TABLE IF NOT EXISTS `console` (
153  `id` bigint(20) NOT NULL AUTO_INCREMENT,
154  `time` datetime NOT NULL,
155  `title` varchar(25) NOT NULL,
156  `data` varchar(255) NOT NULL,
157  PRIMARY KEY (`id`)
158  ) ENGINE=MEMORY DEFAULT CHARSET=utf8 MAX_ROWS=10000 AUTO_INCREMENT=0;
159  ';
160  $mysql->write($delinsql);
161 
162  $delinsql='
163  CREATE TABLE IF NOT EXISTS `country` (
164  `id` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
165  `id2` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
166  `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
167  PRIMARY KEY (`id`)
168  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
169  ';
170  $mysql->write($delinsql);
171 
172  $delinsql='
173  CREATE TABLE IF NOT EXISTS `login` (
174  `id` bigint(20) NOT NULL AUTO_INCREMENT,
175  `userid` bigint(20) NOT NULL,
176  `sessionid` longtext NOT NULL,
177  `expiration` int(11) NOT NULL,
178  `perm` int(11) NOT NULL,
179  PRIMARY KEY (`id`)
180  ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;
181  ';
182  $mysql->write($delinsql);
183 
184  $delinsql='
185  CREATE TABLE sencillo_cache (
186  CACHEKEY varchar(255) NOT NULL,
187  CACHEEXPIRATION int(11) NOT NULL,
188  GZDATA blob,
189  DATASIZE int(11),
190  DATACRC int(11),
191  PRIMARY KEY (CACHEKEY)
192  );
193  ';
194  $mysql->write($delinsql);
195 
196  $delinsql='
197  CREATE TABLE IF NOT EXISTS `virtual_system_config` (
198  `id` int(11) NOT NULL AUTO_INCREMENT,
199  `function` varchar(25) NOT NULL,
200  `command` varchar(25) NOT NULL,
201  `commander` int(11) NOT NULL,
202  PRIMARY KEY (`id`)
203  ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
204  ';
205  $mysql->write($delinsql);
206  $mysql->close();
207  echo("<tr><td></td><td><b>Success</b></td></tr>");
208 }
209 echo("</table></form></body>");
210 ?>
$delinsql
$PHPversion
$mysql
Definition: core_sql.php:254
$afterBootUp