├── LICENSE ├── README.md ├── classes └── class.user.php ├── config └── db.php ├── css ├── normalize.css └── style.css ├── footer.php ├── header.php ├── index.php ├── login.php ├── menu.php ├── user-edit.php ├── user-register.php └── user.php /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 David López 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PHP User class 2 | ============== 3 | 4 | An object-oriented PHP & MySQL user class to login, register and change the password. -------------------------------------------------------------------------------- /classes/class.user.php: -------------------------------------------------------------------------------- 1 | db = $db; 19 | 20 | $this->update_messages(); 21 | 22 | if (isset($_GET['logout'])) { 23 | 24 | $this->logout(); 25 | 26 | } elseif (isset($_COOKIE['username']) || (!empty($_SESSION['username']) && $_SESSION['is_logged'])) { 27 | 28 | $this->is_logged = true; 29 | $this->username = $_SESSION['username']; 30 | $this->email = $_SESSION['email']; 31 | 32 | if (isset($_POST['update'])) { 33 | 34 | $this->update($this->username); 35 | 36 | } elseif (isset($_POST['register'])) { 37 | 38 | $this->register(); 39 | 40 | } 41 | 42 | } elseif (isset($_POST['login'])) { 43 | 44 | $this->login(); 45 | 46 | } elseif ($this->empty_db() && isset($_POST['register'])) { 47 | 48 | $this->register(); 49 | 50 | } else if (!$this->db_exists()) $this->create_db(); 51 | 52 | return $this; 53 | } 54 | 55 | // Get username 56 | 57 | public function get_username() { return $this->username; } 58 | 59 | // Get email 60 | 61 | public function get_email() { return $this->email; } 62 | 63 | // Check if the user is logged 64 | 65 | public function is_logged() { return $this->is_logged; } 66 | 67 | // Get info messages 68 | 69 | public function get_info() { return $this->msg; } 70 | 71 | // Get errors 72 | 73 | public function get_error() { return $this->error; } 74 | 75 | // Copy error & info messages from $_SESSION to the user object 76 | 77 | private function update_messages() { 78 | if (isset($_SESSION['msg']) && $_SESSION['msg'] != '') { 79 | $this->msg = array_merge($this->msg, $_SESSION['msg']); 80 | $_SESSION['msg'] = ''; 81 | } 82 | if (isset($_SESSION['error']) && $_SESSION['error'] != '') { 83 | $this->error = array_merge($this->error, $_SESSION['error']); 84 | $_SESSION['error'] = ''; 85 | } 86 | } 87 | 88 | // Login 89 | 90 | public function login() { 91 | 92 | if (!empty($_POST['username']) && !empty($_POST['password'])) { 93 | 94 | $this->username = $this->db->real_escape_string($_POST['username']); 95 | $this->password = sha1($this->db->real_escape_string($_POST['password'])); 96 | 97 | if ($row = $this->verify_password()) { 98 | 99 | session_regenerate_id(true); 100 | $_SESSION['id'] = session_id(); 101 | $_SESSION['username'] = $this->username; 102 | $_SESSION['email'] = $row->email; 103 | $_SESSION['is_logged'] = true; 104 | $this->is_logged = true; 105 | // Set a cookie that expires in one week 106 | if (isset($_POST['remember'])) 107 | setcookie('username', $this->username, time() + 604800); 108 | // To avoid resending the form on refreshing 109 | header('Location: ' . $_SERVER['REQUEST_URI']); 110 | exit(); 111 | 112 | } else $this->error[] = 'Wrong user or password.'; 113 | 114 | } elseif (empty($_POST['username'])) { 115 | 116 | $this->error[] = 'Username field was empty.'; 117 | 118 | } elseif (empty($_POST['password'])) { 119 | 120 | $this->error[] = 'Password field was empty.'; 121 | } 122 | 123 | } 124 | 125 | // Check if username and password match 126 | 127 | private function verify_password() { 128 | 129 | $query = 'SELECT * FROM users ' 130 | . 'WHERE user = "' . $this->username . '" ' 131 | . 'AND password = "' . $this->password . '"'; 132 | 133 | return ($this->db->query($query)->fetch_object()); 134 | 135 | } 136 | 137 | // Logout function 138 | 139 | public function logout() { 140 | 141 | session_unset(); 142 | session_destroy(); 143 | $this->is_logged = false; 144 | setcookie('username', '', time()-3600); 145 | header('Location: index.php'); 146 | exit(); 147 | 148 | } 149 | 150 | // Register a new user 151 | 152 | public function register() { 153 | 154 | if (!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['confirm'])) { 155 | 156 | if ($_POST['password'] == $_POST['confirm']) { 157 | 158 | $first_user = $this->empty_db(); 159 | $username = $this->db->real_escape_string($_POST['username']); 160 | $password = sha1($this->db->real_escape_string($_POST['password'])); 161 | $email = $this->db->real_escape_string($_POST['email']); 162 | 163 | $query = 'INSERT INTO users (user, password, email) ' 164 | . 'VALUES ("' . $username . '", "' . $password . '", "' . $email . '")'; 165 | 166 | if ($this->db->query($query)) { 167 | 168 | if ($first_user) { 169 | session_regenerate_id(true); 170 | $_SESSION['id'] = session_id(); 171 | $_SESSION['username'] = $username; 172 | $_SESSION['email'] = $email; 173 | $_SESSION['is_logged'] = true; 174 | $this->is_logged = true; 175 | } else { 176 | $this->msg[] = 'User created.'; 177 | $_SESSION['msg'] = $this->msg; 178 | } 179 | // To avoid resending the form on refreshing 180 | header('Location: ' . $_SERVER['REQUEST_URI']); 181 | exit(); 182 | 183 | } else $this->error[] = 'Username already exists.'; 184 | 185 | } else $this->error[] = 'Passwords don\'t match.'; 186 | 187 | } elseif (empty($_POST['username'])) { 188 | 189 | $this->error[] = 'Username field was empty.'; 190 | 191 | } elseif (empty($_POST['password'])) { 192 | 193 | $this->error[] = 'Password field was empty.'; 194 | 195 | } elseif (empty($_POST['confirm'])) { 196 | 197 | $this->error[] = 'You need to confirm the password.'; 198 | } 199 | 200 | } 201 | 202 | // Update an existing user's password 203 | 204 | public function update($username) { 205 | 206 | if (!empty($_POST['email']) && $_POST['email'] !== $_POST['old_email']) { 207 | 208 | $this->email = $this->db->real_escape_string($_POST['email']); 209 | 210 | $query = 'UPDATE users ' 211 | . 'SET email = "' . $this->email . '" ' 212 | . 'WHERE user = "' . $username . '"'; 213 | 214 | if ($this->db->query($query)) $this->msg[] = 'Your email has been changed successfully.'; 215 | else $this->error[] = 'Something went wrong. Please, try again later.'; 216 | 217 | } elseif (!empty($_POST['email'])) $this->error[] = 'You must enter an email adress.'; 218 | 219 | if (!empty($_POST['password']) && !empty($_POST['newpassword1']) && !empty($_POST['newpassword2'])) { 220 | 221 | if ($_POST['newpassword1'] == $_POST['newpassword2']) { 222 | 223 | $this->password = sha1($this->db->real_escape_string($_POST['password'])); 224 | 225 | if ($this->verify_password()) { 226 | 227 | $this->password = sha1($this->db->real_escape_string($_POST['newpassword1'])); 228 | 229 | $query = 'UPDATE users ' 230 | . 'SET password = "' . $this->password . '" ' 231 | . 'WHERE user = "' . $username . '"'; 232 | 233 | if ($this->db->query($query)) $this->msg[] = 'Your password has been changed successfully.'; 234 | else $this->error[] = 'Something went wrong. Please, try again later.'; 235 | 236 | } else $this->error[] = 'Wrong password.'; 237 | 238 | } else $this->error[] = 'Passwords don\'t match.'; 239 | 240 | } elseif (empty($_POST['password']) && (!empty($_POST['newpassword1']) || !empty($_POST['newpassword2']))) { 241 | 242 | $this->error[] = 'Old password field was empty.'; 243 | 244 | } elseif (!empty($_POST['password']) && empty($_POST['newpassword1'])) { 245 | 246 | $this->error[] = 'New password field was empty.'; 247 | 248 | } elseif (!empty($_POST['password']) && empty($_POST['newpassword2'])) { 249 | 250 | $this->error[] = 'You must enter the new password again.'; 251 | } 252 | 253 | // To avoid resending the form on refreshing 254 | $_SESSION['msg'] = $this->msg; 255 | $_SESSION['error'] = $this->error; 256 | header('Location: ' . $_SERVER['REQUEST_URI']); 257 | exit(); 258 | 259 | } 260 | 261 | // Delete an existing user 262 | 263 | public function delete($user) { 264 | $query = 'DELETE FROM users WHERE user = "' . $user . '"'; 265 | return ($this->db->query($query)); 266 | } 267 | 268 | // Get info about an user 269 | 270 | public function get_user_info($user) { 271 | $query = 'SELECT user, password, email FROM users WHERE user = "' . $user . '"'; 272 | $result = $this->db->query($query); 273 | return $result->fetch_object(); 274 | } 275 | 276 | // Get all the existing users 277 | 278 | public function get_users() { 279 | 280 | $query = 'SELECT user, password, email FROM users'; 281 | 282 | return ($this->db->query($query)); 283 | } 284 | 285 | // Print info messages in screen 286 | 287 | public function display_info() { 288 | foreach ($this->msg as $msg) { 289 | echo '

' . $msg . '

'; 290 | } 291 | } 292 | 293 | // Print errors in screen 294 | 295 | public function display_errors() { 296 | foreach ($this->error as $error) { 297 | echo '

' . $error . '

'; 298 | } 299 | } 300 | 301 | // Check if the users db has been created 302 | 303 | public function db_exists() { 304 | return ($this->db->query('SELECT 1 FROM users')); 305 | } 306 | 307 | // Check if the users db has any users 308 | 309 | public function empty_db() { 310 | $query = 'SELECT * FROM users'; 311 | $result = $this->db->query($query); 312 | return ($result->num_rows === 0); 313 | } 314 | 315 | // Create a new db to start with 316 | 317 | private function create_db() { 318 | 319 | $query = 'CREATE TABLE users (' 320 | . 'user VARCHAR(75) NOT NULL, ' 321 | . 'password VARCHAR(75) NOT NULL, ' 322 | . 'email VARCHAR(150) NULL, ' 323 | . 'PRIMARY KEY (user) ' 324 | . ') ENGINE=MyISAM COLLATE=utf8_general_ci'; 325 | 326 | return ($this->db->query($query)); 327 | 328 | } 329 | 330 | // Drop an existing db 331 | 332 | private function drop_db() { 333 | 334 | $query = 'DROP TABLE IF EXISTS users '; 335 | 336 | } 337 | 338 | } 339 | 340 | ?> -------------------------------------------------------------------------------- /config/db.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v2.1.2 | MIT License | git.io/normalize */ 2 | 3 | /* ========================================================================== 4 | HTML5 display definitions 5 | ========================================================================== */ 6 | 7 | /** 8 | * Correct `block` display not defined in IE 8/9. 9 | */ 10 | 11 | article, 12 | aside, 13 | details, 14 | figcaption, 15 | figure, 16 | footer, 17 | header, 18 | hgroup, 19 | main, 20 | nav, 21 | section, 22 | summary { 23 | display: block; 24 | } 25 | 26 | /** 27 | * Correct `inline-block` display not defined in IE 8/9. 28 | */ 29 | 30 | audio, 31 | canvas, 32 | video { 33 | display: inline-block; 34 | } 35 | 36 | /** 37 | * Prevent modern browsers from displaying `audio` without controls. 38 | * Remove excess height in iOS 5 devices. 39 | */ 40 | 41 | audio:not([controls]) { 42 | display: none; 43 | height: 0; 44 | } 45 | 46 | /** 47 | * Address styling not present in IE 8/9. 48 | */ 49 | 50 | [hidden] { 51 | display: none; 52 | } 53 | 54 | /* ========================================================================== 55 | Base 56 | ========================================================================== */ 57 | 58 | /** 59 | * 1. Set default font family to sans-serif. 60 | * 2. Prevent iOS text size adjust after orientation change, without disabling 61 | * user zoom. 62 | */ 63 | 64 | html { 65 | font-family: sans-serif; /* 1 */ 66 | -ms-text-size-adjust: 100%; /* 2 */ 67 | -webkit-text-size-adjust: 100%; /* 2 */ 68 | } 69 | 70 | /** 71 | * Remove default margin. 72 | */ 73 | 74 | body { 75 | margin: 0; 76 | } 77 | 78 | /* ========================================================================== 79 | Links 80 | ========================================================================== */ 81 | 82 | /** 83 | * Address `outline` inconsistency between Chrome and other browsers. 84 | */ 85 | 86 | a:focus { 87 | outline: thin dotted; 88 | } 89 | 90 | /** 91 | * Improve readability when focused and also mouse hovered in all browsers. 92 | */ 93 | 94 | a:active, 95 | a:hover { 96 | outline: 0; 97 | } 98 | 99 | /* ========================================================================== 100 | Typography 101 | ========================================================================== */ 102 | 103 | /** 104 | * Address variable `h1` font-size and margin within `section` and `article` 105 | * contexts in Firefox 4+, Safari 5, and Chrome. 106 | */ 107 | 108 | h1 { 109 | font-size: 2em; 110 | margin: 0.67em 0; 111 | } 112 | 113 | /** 114 | * Address styling not present in IE 8/9, Safari 5, and Chrome. 115 | */ 116 | 117 | abbr[title] { 118 | border-bottom: 1px dotted; 119 | } 120 | 121 | /** 122 | * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. 123 | */ 124 | 125 | b, 126 | strong { 127 | font-weight: bold; 128 | } 129 | 130 | /** 131 | * Address styling not present in Safari 5 and Chrome. 132 | */ 133 | 134 | dfn { 135 | font-style: italic; 136 | } 137 | 138 | /** 139 | * Address differences between Firefox and other browsers. 140 | */ 141 | 142 | hr { 143 | -moz-box-sizing: content-box; 144 | box-sizing: content-box; 145 | height: 0; 146 | } 147 | 148 | /** 149 | * Address styling not present in IE 8/9. 150 | */ 151 | 152 | mark { 153 | background: #ff0; 154 | color: #000; 155 | } 156 | 157 | /** 158 | * Correct font family set oddly in Safari 5 and Chrome. 159 | */ 160 | 161 | code, 162 | kbd, 163 | pre, 164 | samp { 165 | font-family: monospace, serif; 166 | font-size: 1em; 167 | } 168 | 169 | /** 170 | * Improve readability of pre-formatted text in all browsers. 171 | */ 172 | 173 | pre { 174 | white-space: pre-wrap; 175 | } 176 | 177 | /** 178 | * Set consistent quote types. 179 | */ 180 | 181 | q { 182 | quotes: "\201C" "\201D" "\2018" "\2019"; 183 | } 184 | 185 | /** 186 | * Address inconsistent and variable font size in all browsers. 187 | */ 188 | 189 | small { 190 | font-size: 80%; 191 | } 192 | 193 | /** 194 | * Prevent `sub` and `sup` affecting `line-height` in all browsers. 195 | */ 196 | 197 | sub, 198 | sup { 199 | font-size: 75%; 200 | line-height: 0; 201 | position: relative; 202 | vertical-align: baseline; 203 | } 204 | 205 | sup { 206 | top: -0.5em; 207 | } 208 | 209 | sub { 210 | bottom: -0.25em; 211 | } 212 | 213 | /* ========================================================================== 214 | Embedded content 215 | ========================================================================== */ 216 | 217 | /** 218 | * Remove border when inside `a` element in IE 8/9. 219 | */ 220 | 221 | img { 222 | border: 0; 223 | } 224 | 225 | /** 226 | * Correct overflow displayed oddly in IE 9. 227 | */ 228 | 229 | svg:not(:root) { 230 | overflow: hidden; 231 | } 232 | 233 | /* ========================================================================== 234 | Figures 235 | ========================================================================== */ 236 | 237 | /** 238 | * Address margin not present in IE 8/9 and Safari 5. 239 | */ 240 | 241 | figure { 242 | margin: 0; 243 | } 244 | 245 | /* ========================================================================== 246 | Forms 247 | ========================================================================== */ 248 | 249 | /** 250 | * Define consistent border, margin, and padding. 251 | */ 252 | 253 | fieldset { 254 | border: 1px solid #c0c0c0; 255 | margin: 0 2px; 256 | padding: 0.35em 0.625em 0.75em; 257 | } 258 | 259 | /** 260 | * 1. Correct `color` not being inherited in IE 8/9. 261 | * 2. Remove padding so people aren't caught out if they zero out fieldsets. 262 | */ 263 | 264 | legend { 265 | border: 0; /* 1 */ 266 | padding: 0; /* 2 */ 267 | } 268 | 269 | /** 270 | * 1. Correct font family not being inherited in all browsers. 271 | * 2. Correct font size not being inherited in all browsers. 272 | * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. 273 | */ 274 | 275 | button, 276 | input, 277 | select, 278 | textarea { 279 | font-family: inherit; /* 1 */ 280 | font-size: 100%; /* 2 */ 281 | margin: 0; /* 3 */ 282 | } 283 | 284 | /** 285 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in 286 | * the UA stylesheet. 287 | */ 288 | 289 | button, 290 | input { 291 | line-height: normal; 292 | } 293 | 294 | /** 295 | * Address inconsistent `text-transform` inheritance for `button` and `select`. 296 | * All other form control elements do not inherit `text-transform` values. 297 | * Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+. 298 | * Correct `select` style inheritance in Firefox 4+ and Opera. 299 | */ 300 | 301 | button, 302 | select { 303 | text-transform: none; 304 | } 305 | 306 | /** 307 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` 308 | * and `video` controls. 309 | * 2. Correct inability to style clickable `input` types in iOS. 310 | * 3. Improve usability and consistency of cursor style between image-type 311 | * `input` and others. 312 | */ 313 | 314 | button, 315 | html input[type="button"], /* 1 */ 316 | input[type="reset"], 317 | input[type="submit"] { 318 | -webkit-appearance: button; /* 2 */ 319 | cursor: pointer; /* 3 */ 320 | } 321 | 322 | /** 323 | * Re-set default cursor for disabled elements. 324 | */ 325 | 326 | button[disabled], 327 | html input[disabled] { 328 | cursor: default; 329 | } 330 | 331 | /** 332 | * 1. Address box sizing set to `content-box` in IE 8/9. 333 | * 2. Remove excess padding in IE 8/9. 334 | */ 335 | 336 | input[type="checkbox"], 337 | input[type="radio"] { 338 | box-sizing: border-box; /* 1 */ 339 | padding: 0; /* 2 */ 340 | } 341 | 342 | /** 343 | * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. 344 | * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome 345 | * (include `-moz` to future-proof). 346 | */ 347 | 348 | input[type="search"] { 349 | -webkit-appearance: textfield; /* 1 */ 350 | -moz-box-sizing: content-box; 351 | -webkit-box-sizing: content-box; /* 2 */ 352 | box-sizing: content-box; 353 | } 354 | 355 | /** 356 | * Remove inner padding and search cancel button in Safari 5 and Chrome 357 | * on OS X. 358 | */ 359 | 360 | input[type="search"]::-webkit-search-cancel-button, 361 | input[type="search"]::-webkit-search-decoration { 362 | -webkit-appearance: none; 363 | } 364 | 365 | /** 366 | * Remove inner padding and border in Firefox 4+. 367 | */ 368 | 369 | button::-moz-focus-inner, 370 | input::-moz-focus-inner { 371 | border: 0; 372 | padding: 0; 373 | } 374 | 375 | /** 376 | * 1. Remove default vertical scrollbar in IE 8/9. 377 | * 2. Improve readability and alignment in all browsers. 378 | */ 379 | 380 | textarea { 381 | overflow: auto; /* 1 */ 382 | vertical-align: top; /* 2 */ 383 | } 384 | 385 | /* ========================================================================== 386 | Tables 387 | ========================================================================== */ 388 | 389 | /** 390 | * Remove most spacing between table cells. 391 | */ 392 | 393 | table { 394 | border-collapse: collapse; 395 | border-spacing: 0; 396 | } 397 | -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | * { -moz-box-sizing:border-box; -webkit-box-sizing:border-box; box-sizing:border-box; } 2 | 3 | /* Clearfix 4 | ---------------------------------------------------- */ 5 | 6 | .clearfix:after{ 7 | content:"."; 8 | display:block; 9 | height:0; 10 | clear:both; 11 | visibility:hidden; 12 | } 13 | * html .clearfix{ /* CSS rule for IE6 */ 14 | height:1%; 15 | } 16 | *:first-child+html .clearfix{ /* CSS rule for IE7 */ 17 | min-height:1px; 18 | } 19 | 20 | 21 | /* Main 22 | ---------------------------------------------------- */ 23 | 24 | body{ 25 | font-size:62.5%; 26 | line-height:normal; 27 | color:#444; 28 | background:#f0f0f0; 29 | } 30 | #wrapper{ 31 | width:90%; 32 | margin:0 auto; 33 | } 34 | #post-form{ 35 | float:right; 36 | width:25%; 37 | max-width:220px; 38 | } 39 | #archive-table{ 40 | float:left; 41 | width:73%; 42 | } 43 | .hidden{ 44 | display:none; 45 | } 46 | .msg, .error{ 47 | font-size:1.2em; 48 | padding:10px; 49 | margin-top:-49px; 50 | } 51 | .msg{ 52 | border:1px solid green; 53 | color:green; 54 | } 55 | .error{; 56 | border:1px solid red; 57 | color:red; 58 | } 59 | 60 | /* Menu 61 | ---------------------------------------------------- */ 62 | 63 | nav{ 64 | text-align:center; 65 | border-bottom: 1px solid #dfdfdf; 66 | } 67 | ul{ 68 | padding:0; 69 | margin:0; 70 | } 71 | nav li{ 72 | display:inline-block; 73 | } 74 | nav li a{ 75 | padding:5px 20px; 76 | color:#777; 77 | display:block; 78 | font-size:1.6em; 79 | line-height:1.5em; 80 | text-decoration:none; 81 | white-space:nowrap; 82 | } 83 | nav li a:hover{ 84 | color:#333; 85 | } 86 | 87 | 88 | /* Archive 89 | ---------------------------------------------------- */ 90 | 91 | table{ 92 | font-size:1.4em; 93 | line-height:normal; 94 | width:100%; 95 | } 96 | th{ 97 | font-weight:normal; 98 | background:#CCC; 99 | } 100 | td{ 101 | background:#DDD; 102 | } 103 | th, td{ 104 | padding:10px; 105 | border:1px solid #FFF; 106 | } 107 | .td-rival{ 108 | 109 | } 110 | .td-channel{ 111 | width:20%; 112 | } 113 | .td-home{ 114 | width:60px; 115 | text-align:center; 116 | } 117 | .td-date{ 118 | width:140px; 119 | } 120 | .td-edit{ 121 | width:45px; 122 | } 123 | .td-delete{ 124 | width:45px; 125 | } 126 | 127 | /* Form 128 | ---------------------------------------------------- */ 129 | 130 | #login{ 131 | width:220px; 132 | height:130px; 133 | position:absolute; 134 | left:50%; 135 | top:50%; 136 | margin-left:-110px; 137 | margin-top:-75px; 138 | } 139 | label{ 140 | font-size:1.3em; 141 | display:none; 142 | } 143 | input{ 144 | -webkit-background-clip:padding-box; 145 | -moz-background-clip:padding-box; 146 | background-clip:padding-box; 147 | border-radius:6px; 148 | } 149 | .placeholder{ 150 | color:#444; 151 | } 152 | input[type="text"], 153 | input[type="password"], 154 | input[type="email"], 155 | input[type="date"], 156 | input[type="time"]{ 157 | width:100%; 158 | height:40px; 159 | positon:relative; 160 | margin-bottom:7px; 161 | padding-left:20px; 162 | font-size:1.4em; 163 | color:#444; 164 | outline:none; 165 | border:1px solid rgba(0, 0, 0, .49); 166 | background-image:-webkit-linear-gradient(bottom, #FFFFFF 0%, #F2F2F2 100%); 167 | background-image:-moz-linear-gradient(bottom, #FFFFFF 0%, #F2F2F2 100%); 168 | background-image:-o-linear-gradient(bottom, #FFFFFF 0%, #F2F2F2 100%); 169 | background-image:-ms-linear-gradient(bottom, #FFFFFF 0%, #F2F2F2 100%); 170 | background-image:linear-gradient(bottom, #FFFFFF 0%, #F2F2F2 100%); 171 | -webkit-box-shadow:inset 0px 2px 0px #d9d9d9; 172 | box-shadow:inset 0px 2px 0px #d9d9d9; 173 | } 174 | input[type="time"]{ 175 | width:100px; 176 | margin-bottom:0; 177 | display:inline-block; 178 | } 179 | input[type="checkbox"]{ 180 | font-size:1.3em; 181 | margin-top:13px; 182 | margin-left:2px; 183 | float:left; 184 | } 185 | input[type="checkbox"] + label{ 186 | margin-top:12px; 187 | margin-left:7px; 188 | cursor:pointer; 189 | display:inline; 190 | float:left; 191 | } 192 | input[type="submit"]{ 193 | width:60px; 194 | height:30px; 195 | margin-top:5px; 196 | float:right; 197 | color:#fff; 198 | font-size:1.2em; 199 | text-shadow:0px -1px 0px #5b6ddc; 200 | outline:none; 201 | border:1px solid rgba(0, 0, 0, .49); 202 | background-color:#5466da; 203 | background-image:-webkit-linear-gradient(bottom, #5466da 0%, #768ee4 100%); 204 | background-image:-moz-linear-gradient(bottom, #5466da 0%, #768ee4 100%); 205 | background-image:-o-linear-gradient(bottom, #5466da 0%, #768ee4 100%); 206 | background-image:-ms-linear-gradient(bottom, #5466da 0%, #768ee4 100%); 207 | background-image:linear-gradient(bottom, #5466da 0%, #768ee4 100%); 208 | -webkit-box-shadow:inset 0px 1px 0px #9ab1ec; 209 | box-shadow:inset 0px 1px 0px #9ab1ec; 210 | cursor:pointer; 211 | } 212 | input[type="submit"]:hover{ 213 | background-color:#5f73e9; 214 | background-image:-webkit-linear-gradient(bottom, #5f73e9 0%, #859bef 100%); 215 | background-image:-moz-linear-gradient(bottom, #5f73e9 0%, #859bef 100%); 216 | background-image:-o-linear-gradient(bottom, #5f73e9 0%, #859bef 100%); 217 | background-image:-ms-linear-gradient(bottom, #5f73e9 0%, #859bef 100%); 218 | background-image:linear-gradient(bottom, #5f73e9 0%, #859bef 100%); 219 | } 220 | input[type="submit"]:active{ 221 | background-color:#7588e1; 222 | background-image:-webkit-linear-gradient(bottom, #7588e1 0%, #7184df 100%); 223 | background-image:-moz-linear-gradient(bottom, #7588e1 0%, #7184df 100%); 224 | background-image:-o-linear-gradient(bottom, #7588e1 0%, #7184df 100%); 225 | background-image:-ms-linear-gradient(bottom, #7588e1 0%, #7184df 100%); 226 | background-image:linear-gradient(bottom, #7588e1 0%, #7184df 100%); 227 | } 228 | 229 | 230 | .install{ 231 | margin-top:250px; 232 | } 233 | .user{ 234 | width:25%; 235 | margin:150px auto 0; 236 | } -------------------------------------------------------------------------------- /footer.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /header.php: -------------------------------------------------------------------------------- 1 | connect_errno) { 8 | echo 'Database connection problem: ' . $db->connect_errno; 9 | exit(); 10 | } 11 | 12 | $user = new User($db); 13 | 14 | ?> 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | is_logged()) { 29 | 30 | if ($user->empty_db()) { 31 | 32 | include('user-register.php'); 33 | 34 | } else include('login.php'); 35 | 36 | include('footer.php'); 37 | 38 | exit(); 39 | 40 | } 41 | 42 | include('menu.php'); 43 | 44 | ?> 45 | 46 |
-------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /login.php: -------------------------------------------------------------------------------- 1 |
2 | display_errors(); ?> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-------------------------------------------------------------------------------- /menu.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /user-edit.php: -------------------------------------------------------------------------------- 1 |
2 | display_info(); ?> 3 | display_errors(); ?> 4 | /> 5 | 6 | /> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
-------------------------------------------------------------------------------- /user-register.php: -------------------------------------------------------------------------------- 1 |
2 | display_info(); ?> 3 | display_errors(); ?> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
-------------------------------------------------------------------------------- /user.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | --------------------------------------------------------------------------------