Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 226
0 Users 8 Guests Online

Usersystem installation

This script will show you how to create an installer for your website. Good for if you are creating a CMS Type system and wish to distribute it.
Notice: Read The Comments!

Requirements

  • User System Part 1


Please call this file install.php x]

PHP Code
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
/**
 * This script was made by MOD-Shadow of rmb-scripting.com
 * DO NOT REMOVE
 */
session_start(); //allow sessions.
$step = (int)$_GET['step']; //current step for INT Only.
if (!$step || empty($step) || $step == '1') { //check if $step is nul or the step is 1
    
print "<p>
    Welcome to the User System Installation script tutorial x] To begin, Click the link below.
    <a href=\"install.php?step=2\">Database Information</a>
    </p>"
//simple welcome mesage with link to step 2
    
exit(); //go no further
//end welcome
if ($step == '2') { //database setup x]
    
if (!$_POST['db_setup']) { //form wasn't submitted
        
print "<h2>Database Setup</h2>
        <form method=\"post\" action=\"
$_SERVER[PHP_SELF]?step=2\">
        <p>
        <label>DB Host</label>
        <input type=\"text\" name=\"host\" value=\"localhost\" size=\"15\" />
        <label>DB Username</label>
        <input type=\"text\" name=\"user\" value=\"root\" size=\"15\" />
        <label>DB Password</label>
        <input type=\"password\" name=\"pass\" value=\"\" size=\"15\" />
        <label>DB Name</label>
        <input type=\"text\" name=\"name\" value=\"\" size=\"15\" />
        <input type=\"submit\" name=\"db_setup\" value=\"Submit Details\" />
        </p>
        </form>"
//echo the form x]
        
exit(); //go no further
    
} else { //it was x]
        
$host $_POST['host']; //the DB Host
        
$user $_POST['user']; //DB User
        
$pass $_POST['pass']; //DB Pass
        
$name $_POST['name']; //DB Name
        
$errors = array(); //array for errors x]
        
if (empty($host)) { //if host is empty
            
$errors[] = "You Must Enter A Host."//our error
        
//end host check
        
if (empty($user)) { //user check
            
$errors[] = "You Must Enter A Username"//:O Invalid username!
        
//end user check
        
if (empty($pass)) { //check password.
            
$errors[] = "You Must Enter a Password"//the error
        
//end pass check
        
if (empty($name)) { //database name check
            
$errors[] = "You Must Enter a Database Name"//You Fail. O_o
        
//end db name check
        
if (count($errors) > 0) { //if theres more then 0 errors
            
print "<h2>Errors Found!</h2>
            <p>"
//error header
            
foreach ($errors as $err) { //foreach error
                
print $err ''//print them out
            
//end loop
            
print "</p>"//end paragraph x]
            
exit(); //go no further
        
} else { //YAY No Errors
            
$connect = @mysql_connect($host$user$pass); //test our information
            
if (!$connect) { //didnt work :(
                
$con_test "<span style=\"color:red\">False</span>"//our connect status
                
$cerror true//return a true for error
            
} else { //it worked!!!
                
$con_test "<span style=\"color:green\">Green</span>"//connect stats
                
$cerror false//returns false for error.
            
//end error check
            
$dbtest = @mysql_select_db($name$connect);
            if (!
$dbtest) { //didnt work :(
                
$db_test "<span style=\"color:red\">False</span>"//our db test status
                
$derror true//return a true for error
            
} else { //it worked!!!
                
$db_test "<span style=\"color:green\">Green</span>"//db test stats
                
$derror false//returns false for error.
            
//end error check
            
print "<table>
            <tr>
            <td width=\"150\">
            <strong>Connection Stats</strong>
            </td>
            <td width=\"150\">
            
$con_stats
            </td>
            </tr>
            <tr>
            <td width=\"150\">
            <strong>DB Stats</strong>
            </td>
            <td width=\"150\">
            
$db_stats
            </td>
            </tr>
            </table>"
//our stats in a nice table.
            
if ($cerror) { //if connect error
                
print "<h2>Connection Error</h2>
                <p>
                Connection failed. Please go back and check your details.
                <a href=\"javascript:history.go(-1);\">Go Back</a>
                </p>"
//lets tell them
                
exit(); //go no further
            
//end connect error
            
if ($derror) { //dbtest error obviously going to be true if connect is true.
                
print "<h2>Database Error</h2>
                <p>
                Could not connect to database. Attempting to create.....
                <a href=\"javascript:history.go(-1);\">Go Back</a>
                </p>"
//tell them they made a boo boo
                
$create_db = @mysql_query("CREATE DATABASE `$name`");
                if (!
$create_db) {
                    print 
"<p>
                    Database Creation Failed.
                    </p>"
;
                }
                exit(); 
//go no further
            
//end db test error.
            
if (!$cerror && !$derror) { //No Error found!!!!!!!!!!
                
$conf_handle fopen('config.php''w+');
                
$data "<?php
session_start(); //allows session 

\$connect = @mysql_connect(
$host,$user,$pass);
\$db = @mysql_select_db(\$db,\$connect);

\$logged = @mysql_query(\"SELECT * FROM `members` WHERE `id` = '\$_SESSION[id]' AND `password` = '\$_SESSION[password]'\"); 
\$logged = @mysql_fetch_array(\$logged);

//some server details, don't edit! 
\$host = \$_SERVER['HTTP_HOST'];
\$self = \$_SERVER['PHP_SELF'];

//change this to your site name
\$sitename = \"My Site\";

//Send emails or not (email activation). 1 = true, 0 = false 
\$semail = \"1\"; 
?>"
;
                
$write = @fwrite($conf_handle$data);
                if (
$write) {
                    print 
"<h2>Success</h2>
                        <p>
                        Config File Created! To continue the installation please click the link below.
                        <span style=\"color:red\">NOTICE: PLEASE CHMOD CONFIG FILE TO 0644</span>
                        <a href=\"install.php?step=3\">Setup Tables</a>
                        </p>"
;
                    exit(); 
//go no further.
                
} else {
                    print 
"<h2>Error</h2>
                        <p>
                        Config File Creation Failed. Please check and make sure your CHMOD Perms are 0777 before performing this step again.
                        <a href=\"javascript:history.go(-1);\">Go Back</a>
                        </p>"
;
                    exit(); 
//go no further
                
//end write check
            
//end no error check
        
//end error check
    
//end form submit check
//end step check
if ($step == '3') {
    require(
"config.php"); //require newly found config.php x]
    
$create_members mysql_query("CREATE TABLE `members` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(30) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`email` varchar(55) NOT NULL default '',
`location` varchar(40) NOT NULL default 'N/A',
`userlevel` int(3) NOT NULL default '1',
`age` int(3) NOT NULL,
`sex` varchar(40) NOT NULL default 'N/A',
PRIMARY KEY (`id`)
) TYPE=MyISAM;"
); //create our members table...or...attempt to.....

    
$create_verification mysql_query("CREATE TABLE `verification` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(30) NOT NULL default '',
`code` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE = MYISAM;"
); //attempt to create verification table
    
if(!$create_members){ //members check
        
$mem_stats "<span style=\"color :red;\">False</span>"//our stats
        
$merror true//OH NO
    
}else{ //no error
        
$mem_stats "<span style=\"color:green;\">True</span>"//GREEN!!!
        
$merror false//no error
    
//end check
    
if(!$create_verification){ //error found
        
$pms_stats "<span style=\"color:red;\">False</span>"//red false
        
$verror true//true for error
    
}else{ //or not?
        
$pms_stats "<span style=\"color:green;\">True</span>"//its good to go
        
$verror false//no error
    
}
    print 
"<table width=\"200\">
    <tr>
    <td width=\"150\">
    <strong>Members</strong>
    </td>
    <td width=\"50\">
    
$mem_stats
    </td>
    </tr>
    <tr>
    <td width=\"150\">
    <strong>Verification</strong>
    </td>
    <td width=\"50\">
    
$ver_stats
    </td>
    </tr>
    </table>"
//nice table x]
    
if($merror){ //error in members
        
print "<p>
        members Table Creation Failed!
        Please Use <a href=\"http://
$host:2082/3rdparty/phpMyAdmin/index.php\">phpMyAdmin</a> To Create the table.
        </p>"
//tell them and give link to Cpanel.
        
exit(); //go no further
    
//end members error
    
if($verror){ //verification error
        
print "<p>
        verification Table Creation Failed!
        Please Use <a href=\"http://
$host:2082/3rdparty/phpMyAdmin/index.php\">phpMyAdmin</a> To Create the table.
        </p>"
//give link to cpanel and such
        
exit(); //go no further
    
//end verification error
    
if(!$merror && !$verror){ //no errors
        
print "<h2>Success</h2>
        <p>
        Tables Created!
        <a href=\"install.php?step=4\">Admin Setup</a>
        </p>"
//success!!!!
        
exit(); //go no further
    
}
//end step check
if ($step == '4') { //step 4 YAYZZ
    
require("config.php"); //get config
    
if(!$_POST['admin_setup']){ //form not submitted
         
print "<form method=\"post\" action=\"$_SERVER[PHP_SELF]?step=4\">
         <p>
         <label>Admin Username</label>
         <input type=\"text\" name=\"user\" size=\"15\" />
         <label>Admin Password</label>
         <input type=\"password=\" name=\"pass\" size=\"15\" />
         <label>Admin Email</label>
         <input type=\"text\" name=\"mail\" size=\"15\" />
         <input type=\"submit\" name=\"admin_setup\" value=\"Save Admin\" />
         </p>
         </form>"
//submit form.
    
}else{ //form submitted
        
$username $_POST['user']; //our username 
        
$password sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST['pass'])))))))); //secure pass
        
$email $_POST['mail']; //the admin email
        
if(empty($username) || empty($password) || empty($email)){ //check for empty field
            
print "<h2>Error</h2>
            <p>
            You Must Fill Out All Fields!
            </p>"
//give error
            
exit(); //go no further
        
}else{ //no error
            
$insert mysql_query("INSERT INTO `members` (`username`,`password`,`email`,`userlevel`) VALUES ('$username','$password','$email','6');"); //insert admin data.
            
if($insert){ //check if error
                
print "<h2>Success</h2>
                <p>
                Admin User Setup!
                <a href=\"install.php?step=5\">Finish</a>
                </p>"
//no error found
                
exit(); //go no further
            
}else{ //insert failed.
                
print "<h2>Error</h2>
                <p>
                Error Returned: "
.mysql_error()."
                </p>"
//you have an error!!!
                
exit(); //go no further.
            
//no error.
        
}//end error check  
    
//end form check
//end step check
if ($step == '5') { //FINAL STEP WOOHOO
    
print "<h2>Complete!</h2>
    <p>
    Setup Complete! Please delete this file and CHMOD config.php back to 0644 so hackers can not attack your website.
    </p>"
//give finished message
    
chmod("config.php"'0644'); //chmod the config to 0644 if not done already.
    
unlink("install.php"); //delete install file.
//end step check x]
?>
ShadowMage
Author:
Views:
3249
Rating:
Posted on Sunday 20th July 2008 at 06:07 PM
Paul
Paul
i get the below error

Parse error: syntax error, unexpected ',', expecting ')' in /home/sites/sthelensclubberz.co.uk/public_html/config.php on line 5


any help would be brillant
Posted on Sunday 20th July 2008 at 05:28 PM
Paul
Paul
were it says

$errors[] = "You Must Enter A Host."; //our error
} //end host check
if (empty($user)) { //user check
$errors[] = "You Must Enter A Username"; //:O Invalid username!
} //end user check
if (empty($pass)) { //check password.
$errors[] = "You Must Enter a Password"; //the error
} //end pass check
if (empty($name)) { //database name check
$errors[] = "You Must Enter a Database Name"; //You Fail. O_o
} //end db name check


i put my host in along with username and password and comes up with

Errors Found!
FractixPaulbigandbanginweb176-website

any help would be great
Posted on Thursday 19th June 2008 at 11:41 PM
jambomb
jambomb
thats just lazyness lol then u would prob have to copy the code from the download lol
Posted on Wednesday 18th June 2008 at 09:00 PM
ilyas-shezad
ilyas-shezad
It might be a simple installer but its a long long piece of script.
You should put up on the downloads so that people can download insteada copying n pasting :P
Posted on Thursday 15th May 2008 at 07:17 PM
peza
peza
Im getting the error Parse error: syntax error, unexpected ',', expecting ')' in /home/aftermat/public_html/v2/system/config.php on line 5
Posted on Thursday 15th May 2008 at 07:17 PM
peza
peza
Im getting the error Parse error: syntax error, unexpected ',', expecting ')' in /home/aftermat/public_html/v2/system/config.php on line 5
Posted on Thursday 8th May 2008 at 09:57 PM
DanielXP
DanielXP
I love installers!!!!

Best part of like a few script. thats why plus news one is better than the script itself :p
Posted on Wednesday 7th May 2008 at 02:02 AM
ShadowMage
ShadowMage
Ive updated this code :3 so if you have the $_SESSION[currentstep] type stuff update to the new code and it should execute x]
Posted on Wednesday 7th May 2008 at 01:33 AM
DjMilez
DjMilez
It tells me that it's redirecting the request in a way that will never complete.
Posted on Wednesday 30th April 2008 at 09:14 PM
UrbanTwitch
UrbanTwitch
The requested URL: /install/install.php?step=2 is not available.

:(