-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcreateaccount.php
executable file
·142 lines (138 loc) · 5.3 KB
/
createaccount.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/*
* createaccount.php
*
* Copyright 2018 Krzysztof Hrybacz <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<?php
require_once('config.php');
session_start();
$link = mysqli_connect($sql, $sqluser, $sqlpass, $sqldb);
mysqli_set_charset($link,'utf8');
$result = mysqli_query($link,'SELECT * FROM `' . $_POST['company'] . '_users`;');
if (strlen($_POST['company'])>4 && $_POST['mail']!='' && $_POST['login']!='' && $_POST['pass']!='' && !(mysqli_num_rows($result)>0) && $_FILES['logo']['tmp_name']!='') {
$query = 'CREATE TABLE `' . $_POST['company'] . '_clients` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`fullname` varchar(50) NOT NULL,
`company` varchar(50) NOT NULL,
`address` text NOT NULL,
`mobile` varchar(20) NOT NULL,
`mail` varchar(50) NOT NULL,
`www` varchar(50) NOT NULL,
`info` text NOT NULL,
`folder` varchar(50) NOT NULL,
`category` varchar(20) NOT NULL,
`priority` smallint(6) NOT NULL,
`nip` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
$query = 'CREATE TABLE `' . $_POST['company'] . '_invoices` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`client` int(11) NOT NULL,
`clientinfo` text NOT NULL,
`description` text NOT NULL,
`type` text NOT NULL,
`brutto` text NOT NULL,
`total` float NOT NULL,
`creation` date NOT NULL,
`added` varchar(20) NOT NULL,
`vat` text NOT NULL,
`invoiceid` varchar(255) NOT NULL,
`bank` varchar(255) NOT NULL,
`currency` varchar(3) NOT NULL,
`info` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
$query = 'CREATE TABLE `' . $_POST['company'] . '_jobs` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`client` int(11) NOT NULL,
`description` text NOT NULL,
`creation` date NOT NULL,
`stage` varchar(20) NOT NULL,
`info` text NOT NULL,
`added` varchar(20) NOT NULL,
`finished` date DEFAULT NULL,
`required` date NOT NULL,
`priority` smallint(6) NOT NULL,
`archive` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
$query = 'CREATE TABLE `' . $_POST['company'] . '_quotes` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`client` int(11) NOT NULL,
`clientinfo` text NOT NULL,
`description` text NOT NULL,
`creation` date NOT NULL,
`added` varchar(20) NOT NULL,
`quoteid` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
$query = 'CREATE TABLE `' . $_POST['company'] . '_tasks` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`job` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`added` varchar(20) NOT NULL,
`archive` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
$query = 'CREATE TABLE `' . $_POST['company'] . '_products` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`price` float NOT NULL,
`vat` int(11) NOT NULL,
`category` varchar(50) NOT NULL,
`description` text NOT NULL,
`sku` varchar(50) NOT NULL,
`creation` date NOT NULL,
`added` varchar(20) NOT NULL,
`archive` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
$query = 'CREATE TABLE `' . $_POST['company'] . '_users` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`mail` varchar(50) NOT NULL,
`pass` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
$query = 'INSERT INTO `' . $_POST['company'] . '_users` VALUES (0,"' . $_POST['login'] . '","' . $_POST['mail'] . '","' . md5($_POST['pass']) . '");';
mysqli_query($link,$query);
$query = 'CREATE TABLE `' . $_POST['company'] . '_info` (
`id` int(11) NOT NULL PRIMARY KEY,
`display` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL,
`contact` varchar(255) NOT NULL,
`bank` varchar(255) NOT NULL,
`color` varchar(10) NOT NULL,
`currency` varchar(3) NOT NULL,
`productlist` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
mysqli_query($link,$query);
if ($_POST['products']==1) $products=1; else $products=0;
$query = 'INSERT INTO `' . $_POST['company'] . '_info` VALUES (1,"' . $_POST['display'] . '","' . $_POST['address'] . '","' . $_POST['contact'] . '","' . $_POST['bank'] . '","' . $_POST['color'] . '","' . $_POST['currency'] . '",' . $products . ');';
mysqli_query($link,$query);
move_uploaded_file($_FILES['logo']['tmp_name'], './logo/' . $_POST['company'] . '.png');
};
mysqli_close($link);
?>
<meta http-equiv="refresh" content="0;url=<?php echo $url; ?>/index.php" />