Website Status
First off open phpMyAdmin and run the following:
Code
CREATE TABLE `site_stats` (
`sid` INT( 11 ) NOT NULL auto_increment,
`stats` CHAR( 7 ) NOT NULL default 'Online',
`immunity` CHAR( 3 ) NOT NULL default 'Yes',
`immunelvl` INT( 2 ) NOT NULL default '6',
`forums` INT( 1 ) NOT NULL default '1',
`signups` INT( 1 ) NOT NULL default '1',
PRIMAY KEY(`sid`)
);
INSERT INTO `site_stats` (`sid`,`stats`,`immunity`,`immunelvl`,`forums`,`signups`) VALUES ('1','Online','Yes','6','1','1');
I suggest doing them separate though :S
Next make a new file name it: stats.php
In that file place the following code Be Sure To Read it::
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
<?php
if(!$logged[username] && !$logged[userlevel]){ //check if user is logged in
echo "You Are Not Logged In!"; //echo this if they are not
}elseif($logged[username] && $logged[userlevel] != "6"){ //check if user is an admin
echo "You Are Not An Admin!"; //echo this if they aren't
}else{ //or if everything is ok..
if(!isset($_GET[edit])){ //check if ?edit is in the address bar
$get = mysql_query("SELECT * FROM `site_stats` WHERE sid = '1';"); //select data from the table
if(mysql_error()){ //if there is an error
echo "You have an error in the SQL Query on line: 18"; //echo this
}else{ //or not
$r = mysql_fetch_array($get); //array the info to be echoed.
echo "<p align=\"center\"><a href=\"stats.php?edit\">Edit Site Status</a>
<b>Website Status</b>: $r[stats]<Br />
<b>Admin Immunity</b>: $r[immunity]
<b>Immunity Level</b>: $r[immunelvl]
<b>Forum Status</b>:"; //echo part of the information
if($r[forums] == "1"){ //check if the forums are online
echo " Online"; //if they are
}else{ //if they are something else..
echo " Offline"; //if they are of
} //end forums check
echo "<b>Sign-up Status</b>:"; //signup status
if($r[signups] == "1"){ //if its online
echo " Online"; //say thing
}else{ //or if it is something else
echo " Offline"; //echo this
} //end check
echo "</p>"; //end paragraph
} //end error check
}else{ //or if it is in the address bar
$get = mysql_query("SELECT * FROM `site_stats` WHERE sid = '1';"); //get info
if(mysql_error()){ //check if thers an error
echo "You have an error in the SQL Query on line: 18"; //if there is echo that
}else{ //or not...
$r = mysql_fetch_array($get);
if(!$_POST[edit]){ //check if the form was submitted
echo "<form method=\"post\" action=\"\">
<table width=\"150\" cellpadding=\"0\" cellspacing=\"2\">
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Site Status</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"stats\">"; //Yay tables forms and data inputs =O!!!
if($r[stats] == "Online"){ //if status is online
echo "<option value=\"Online\" selected=\"selected\">Online</option"; //online is selected
}else{ //but if it isn't
echo "<option value=\"Online\">Online</option>"; //its not
} //end online field
if($r[stats] == "Offline"){ //or if its offline
echo "<option value=\"Offline\" selected=\"selected\">Offline</option>"; //offline is selected
}else{ //maybe its not....
echo "<option value=\"Offline\">Offline</option>"; //its not selected
} //end offline check
echo "</select>
</td>
</tr>
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Admin Immunity</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"immunity\">"; //continue data
if($r[immunity] == "Yes"){ //check if admin immunty is on
echo "<option value=\"Yes\" selected=\"selected\">Yes</option>"; //if it is...yes is selected
}else{ //or if its no
echo "<optiong value=\"Yes\">Yes</option>"; //its not selected
} //end yes check
if($r[immunity] == "No"){ //immunity check :P
echo "<option value=\"No\" selected=\"selected\">No</option>"; //it is YAY
}else{ //or if it isint No
echo "<option value=\"No\">No</option>"; //if not
} //end no check
echo "</select>
</td>
</tr>
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Immune Level</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<input type=\"text\" name=\"level\" value=\"$r[immunelvl]\" size=\"15\" maxlength=\"2\">
</td>
</tr>
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Forums Status</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"forums\">"; //continue with some more information...
if($r[forums] == "1"){ //check if forums are online
echo "<option value=\"1\" selected=\"selected\">Online</option>"; //if they are
}else{ //or if they aren't
echo "option value=\"1\">Online</option>"; //echo online field not selcted
} //end check
if($r[forums] == "0"){ //check if forums are offline
echo "<option value=\"0\" selected=\"selected\">Offline</option>"; //if they are
}else{ //or if they aren't
echo "option value=\"0\">Offline</option>"; //echo offline field not selcted
} //end check
echo "</select>
</td>
</tr>
</tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Sign-up Status</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"signups\">"; //more information and some moer table :)
if($r[signups] == "1"){ //if signups is online
echo "<option value=\"1\" selected=\"selected\">Online</option>"; //if it is
}else{ //or not
echo "<option value=\"1\">Online</option>"; //its not checked
} //end check
if($r[signups] == "0"){ //or maybe offine?
echo "<option value=\"0\" selected=\"selected\">Offline</option>"; //checked
}else{ //if it isint 0
echo "<option value=\"0\">Offline</option>"; //its not checked :O
} //end check
echo "</select>
</td>
</tr>
<td>
<td width=\"300\" colspan=\"3\" align=\"center\" valign=\"middle\">
<input type=\"submit\" name=\"edit\" value=\"Update Stats\">
</td>
</tr>
</table>
</form>"; //finish up the form and information
}else{ //or if the form was submitted
$stats = strip_tags(htmlspecialchars($_POST[stats])); //clean stats
$immunity = strip_tags(htmlspecialchars($_POST[immunity])); //clean immunity
$imunelvl = (int) strip_tags(htmlspecialchars($_POST[level])); //clean immune level
$forums = strip_tags(htmlspecialchars($_POST[forums])); //clean forums
$signups = strip_tags(htmlspecialchars($_POST[signups])); //cheak signups
$mysql = mysql_query("UPDATE `site_stats` SET `stats` = '$stats', immunity = '$immunity', `immunelvl` = '$immunelvl', `forums` = '$forums', `signups` = '$signups' WHERE sid = '1';");
if(!mysql_error()){ //if no error encountered
echo "Site Status Updated!"; //success
}else{ //or not?
echo "There is an error in the syntax of line 137! please check it out!"; //error
} //end error
} //end form check
} //end error check
} //end edit check
} //end login check
?>
Next open your config.php and add:
Code
$sets = mysql_query("SELECT * FROM site_stats WHERE `sid` = '1';");
$setting = mysql_fetch_array($sets);
//get the info and let it be used all over the site :)
Thats done, it can be called out in basically all files upon your website :)
Now open up forum.php if you have it from this site and do the follow modifications:
FIND:
Code
if($logged[username])
{
Add After:
Code
if($setting[forums] == "0"){ //check if forums are offline
echo "Forums Offline, please check back later"; //say they are offline
}else{
Next, these lines can be found near the end but
Find:
Add After:
Thats that file!
Now you will want to open up your register.php and do the following modifications:
FIND
Code
echo "<center>";
//checks if there trying to veriy there account
Add After:
Code
if($setting[signups] == "0"){
echo "Signups Are Disabled, Please Check Back Later!";
}else{
FIND:
Code
</form>";
}
echo "<center>";
Replace with:
Code
</form>";
}
echo "</center>";
Then add after:
Now, if you have your template split into 2 files add this to the top of the header file or index.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
session_start(); //allow sessions
include("config.php"); //get config
if(!$logged[username] && $setting[stats] == "Offline"){ //check if not logged in and site stats is offline
exit("$setting[reason]"); //uh ohs it is!
}elseif($logged[username] && $setting[stats] == "Offline" && $setting[immunity] == "Yes"){ //check if logged in and stats is offline but immunity is on
if($logged[userlevel] != $setting[immunelvl]){ //see if levels are same
exit("$setting[reason]"); //die reaosn for offline :S if not
}else{ //or if they are
} //show the site, this is ending the level check :)
}elseif($logged[username] && $setting[stats] == "Offline" && $setting[immunity] == "No"){ //or if they are logged in, stats is offline, and immunity is off
exit("$setting[reason]"); //die with the reason
}elseif($setting[stats] == "Online"){ //or if the site is online
} //show site and finish the script :)
?>
That is all! if you encounter any errors post them here and i'll respond ASAP. i have tested this and it came up clean.
Code
Updated by Daniel error fix, (index.php)
Parse error: syntax error, unexpected ';' in /index.php on line 12
Missing ']' after $setting[immunity