bzr branch
http://gegoxaren.bato24.eu/bzr/booka/newlayout
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
1 |
<?php
|
2 |
session_start(); |
|
3 |
/*
|
|
4 |
BooKa.php
|
|
5 |
This is the "main" file or "index" file
|
|
6 |
*/
|
|
7 |
||
8 |
if(file_exists("./cfg/lock.lock") == false){ |
|
9 |
||
10 |
header('Location: ./firstrun.php'); |
|
11 |
||
12 |
}
|
|
13 |
||
14 |
include "./inc/dbConnect.php"; |
|
15 |
include "./inc/head.php"; |
|
16 |
||
17 |
if($_SESSION[logedin]){ |
|
18 |
||
19 |
?>
|
|
20 |
<p><img src="./img/Logo.png" alt="BooKa´s logo" /></p> |
|
21 |
|
|
22 |
<div class="menu"> |
|
23 |
<h1> Logedin <a href="./logout.php">[logout]</a> </h1> |
|
24 |
<hr /> |
|
25 |
<p> |
|
26 |
You are logged in.<br /> |
|
27 |
</p> |
|
28 |
<hr /> |
|
29 |
<?php if($_GET[showadminpage]=="true"){ ?><h2> User registration </h2> <?php }?> |
|
30 |
<p> |
|
31 |
|
|
32 |
<?php |
|
33 |
if($_SESSION[admin]){ //this section prpbobly needs re work? |
|
34 |
if($_GET[showadminpage]=="true"){ |
|
|
13
by Gustav Hartvigsson
Fixed stiff with the url's cousing the admin panel to not show. |
35 |
echo "<a href='BooKa.php?showadminpage=false'>[hide adminpage]</a><br /> \n"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
36 |
}
|
37 |
if($_GET[showadminpage]=="false" || $_GET[showadminpage] == null){ |
|
|
13
by Gustav Hartvigsson
Fixed stiff with the url's cousing the admin panel to not show. |
38 |
echo "<a href='BooKa.php?showadminpage=true'>[Show adminpage]</a><br /> \n"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
39 |
}
|
|
26
by Gustav Hartvigsson
added so that webpage is served as XHTML, and then some coding errors in XHTML code... |
40 |
} ?> |
41 |
</p> |
|
|
29.1.1
by gustav.hartvigsson
Fixed a parsing error, namly replaced all <? with <?php. |
42 |
<?php |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
43 |
if($_SESSION[admin] == true && $_GET[showadminpage]== "true" ){ |
44 |
?>
|
|
45 |
|
|
46 |
<form action="BooKa.php?showadminpage=true" method="post" > |
|
47 |
<p> |
|
48 |
<input type="hidden" name="userreg" value="true" /> |
|
49 |
<label for="username">Name of the new user</label><input type="text" name="username" /><br /> |
|
50 |
<label for="password1">password of the new user</label><input type="password" name="password1" /> |
|
51 |
<label for="password2">password again</label><input type="password" name="password2" /><br /> |
|
52 |
<label for="isadmin">is this user a admin?</label> <input type="checkbox" name="isadmin" /><br /> |
|
53 |
|
|
54 |
|
|
55 |
<?php |
|
56 |
//ifs and buts goes here
|
|
57 |
if($_POST[userreg]){ |
|
58 |
||
59 |
||
60 |
$canreg = true; |
|
61 |
||
62 |
$query = "SELECT * FROM users WHERE username = '{$_POST[username]}';"; |
|
63 |
||
64 |
$userinfo = $db->query($query); |
|
65 |
||
66 |
$newinfo = $userinfo->fetch(); |
|
67 |
||
68 |
if($newinfo[username] == $_POST[username]){ |
|
69 |
||
|
22
by Gustav Hartvigsson
Made the Warnings in the user registration more eye-catching. |
70 |
echo "<span class='warning'> username is already in use </span> <br />"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
71 |
$canreg = false; |
72 |
}
|
|
73 |
||
74 |
if($_POST[username] == null){ |
|
|
22
by Gustav Hartvigsson
Made the Warnings in the user registration more eye-catching. |
75 |
echo "<span class='warning'>you need to enter a new username </span> <br />"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
76 |
$canreg = false; |
77 |
}
|
|
78 |
||
79 |
if($_POST[password1] == null){ |
|
80 |
||
|
22
by Gustav Hartvigsson
Made the Warnings in the user registration more eye-catching. |
81 |
echo "<span class='warning'>you need to have a password <br /> </span>"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
82 |
$canreg = false; |
83 |
}
|
|
84 |
||
85 |
if($_POST[password2] != $_POST[password1]){ |
|
86 |
||
|
22
by Gustav Hartvigsson
Made the Warnings in the user registration more eye-catching. |
87 |
echo "<span class='warning'>passwords deos not match </span> <br />"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
88 |
$canreg = false; |
89 |
}
|
|
90 |
sleep(.5);//to prevent $conreg being true whun it should be false 0_o? |
|
91 |
if($canreg){ |
|
92 |
if($_POST[isadmin]){ |
|
93 |
$group = 1; |
|
94 |
}else { |
|
95 |
||
96 |
$group = 2; |
|
97 |
||
98 |
}
|
|
99 |
$username1 = $_POST[username]; |
|
100 |
$password1 = md5($_POST[password1]); |
|
101 |
||
102 |
$db->queryExec("BEGIN; |
|
103 |
INSERT INTO users (username, password, 'group')
|
|
104 |
VALUES('{$username1}' , '{$password1}', '{$group}'); |
|
105 |
COMMIT;") or die("could not do query"); |
|
106 |
echo $db->error; |
|
107 |
echo "Registration of user {$_POST[username]} complite!"; |
|
108 |
}
|
|
109 |
}
|
|
110 |
?>
|
|
111 |
<input type="submit" /><br /> |
|
112 |
</p> |
|
113 |
</form> |
|
114 |
|
|
115 |
<?php |
|
116 |
if($_SESSION[admin]){ //this section prpbobly needs re work? |
|
117 |
if($_GET[showrmuser]=="true"){ |
|
|
27
by Gustav Hartvigsson
fixxed stupid xhtml parsing error... that I coused yesturday, lol. |
118 |
echo "<a href='BooKa.php?showadminpage=true&showrmuser=false'>[Hide remove user page]</a><br /> \n"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
119 |
}
|
120 |
if($_GET[showrmuser]=="false" || $_GET[showrmuser] == null){ |
|
|
27
by Gustav Hartvigsson
fixxed stupid xhtml parsing error... that I coused yesturday, lol. |
121 |
echo "<a href='BooKa.php?showadminpage=true&showrmuser=true'>[Show remove user page]</a><br /> \n"; |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
122 |
}
|
123 |
}
|
|
124 |
if($_GET[showrmuser]=="true"){ |
|
125 |
||
126 |
//table with user id, user name and a remove button goes here...
|
|
127 |
?>
|
|
128 |
<h2>DO NOT REMOVE THE LAST ADMIN PL0X!</h2> |
|
129 |
<table> <!-- muckup tabell --> |
|
130 |
<tr> <!-- row one --> |
|
131 |
<td> uid </td> |
|
132 |
<td> User Name </td> |
|
133 |
<td> Admin </td> |
|
134 |
<td> remove </td> |
|
135 |
</tr> <!-- end of row one --> |
|
|
29.1.1
by gustav.hartvigsson
Fixed a parsing error, namly replaced all <? with <?php. |
136 |
<?php |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
137 |
|
138 |
$result = $db->query("SELECT * FROM users") or die("could not do query!"); |
|
139 |
foreach($result as $row){ |
|
140 |
?>
|
|
141 |
<tr> <!-- Row two and up --> |
|
142 |
<td> <?php echo $row[id]?> </td> |
|
143 |
<td> <?php echo $row[username]?> </td> |
|
144 |
<td> <?php |
|
|
23
by Gustav Hartvigsson
fixxed osme stupid shit with the user rehistration, now it works. |
145 |
if($row[group] == 1){ |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
146 |
echo "Yes"; |
147 |
} else { |
|
148 |
echo "no"; |
|
149 |
}
|
|
150 |
||
151 |
?> </td> |
|
152 |
<td> |
|
153 |
<form action="removeUser.php" method="post"> |
|
154 |
<p> |
|
155 |
<input type="submit" value="remove" /> |
|
156 |
<input type="hidden" value="<? echo $row[id]?>" name="id"/> |
|
157 |
</p> |
|
158 |
</form> |
|
159 |
</td> |
|
160 |
</tr> <!-- end of row two and up --> |
|
161 |
|
|
|
29.1.1
by gustav.hartvigsson
Fixed a parsing error, namly replaced all <? with <?php. |
162 |
<?php |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
163 |
}
|
164 |
?>
|
|
165 |
</table> |
|
166 |
|
|
167 |
||
168 |
||
|
29.1.1
by gustav.hartvigsson
Fixed a parsing error, namly replaced all <? with <?php. |
169 |
<?php |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
170 |
}
|
171 |
}
|
|
172 |
?>
|
|
|
35
by Gustav Hartvigsson
trying out new layout, initial work |
173 |
</div> |
|
29.1.1
by gustav.hartvigsson
Fixed a parsing error, namly replaced all <? with <?php. |
174 |
<?php
|
|
35
by Gustav Hartvigsson
trying out new layout, initial work |
175 |
include "./dbEditor.php"; |
176 |
||
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
177 |
} else { |
178 |
?>
|
|
179 |
<div class="head"><img src="./img/Logo.png" alt="BooKa´s logo" /></div> |
|
180 |
|
|
181 |
<div class="menu"> |
|
182 |
<h1> Login </h1> |
|
183 |
<hr /> |
|
184 |
<form action="login.php" method="post"> |
|
185 |
<p> |
|
186 |
User name: <input type="text" name="userName" /> <br/> |
|
187 |
Pass word: <input type="password" name="userPassword" /> <br /> |
|
188 |
<input type="hidden" name="login" value="true" /> |
|
|
22
by Gustav Hartvigsson
Made the Warnings in the user registration more eye-catching. |
189 |
<input type="submit" name="null" value="Login" /> |
|
11
by Gustav Hartvigsson
merging Neo to trunk. freezing neo branshs. |
190 |
</p> |
191 |
</form> |
|
192 |
<p> |
|
193 |
All registrations are performed by admin. |
|
194 |
</p> |
|
195 |
</div> |
|
196 |
|
|
197 |
<?php
|
|
198 |
}
|
|
199 |
||
200 |
include "./inc/foot.php"; |
|
201 |
||
202 |
?>
|