├── .gitignore ├── .vs ├── Phpblog │ └── config │ │ └── applicationhost.config ├── ProjectSettings.json └── slnx.sqlite ├── Controller ├── Admin.php └── Blog.php ├── Engine ├── Config.php ├── Db.php ├── Loader.php ├── Pattern │ ├── Base.trait.php │ └── Singleton.trait.php ├── Router.php └── Util.php ├── LICENSE.txt ├── Model ├── Admin.php └── Blog.php ├── README.md ├── View ├── add_post.php ├── edit_post.php ├── inc │ ├── control_buttons.php │ ├── footer.php │ ├── header.php │ └── msg.php ├── index.php ├── login.php ├── not_found.php └── post.php ├── _create_admin_pwd.php ├── db.sql ├── index.php ├── readme_tech.txt └── static └── style.css /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio. 3 | ################################################################################ 4 | 5 | /.vs/VSWorkspaceState.json 6 | -------------------------------------------------------------------------------- /.vs/Phpblog/config/applicationhost.config: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 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 | 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 | 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 | 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 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | -------------------------------------------------------------------------------- /.vs/ProjectSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "CurrentProjectSetting": null 3 | } -------------------------------------------------------------------------------- /.vs/slnx.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/PHP-MVC-Blog-System/a5a5085fe365afe19c547e428d7e4ac7553eec2d/.vs/slnx.sqlite -------------------------------------------------------------------------------- /Controller/Admin.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Controller; 10 | 11 | class Admin extends Blog 12 | { 13 | public function login() 14 | { 15 | if ($this->isLogged()) 16 | header('Location: ' . ROOT_URL . '?p=blog&a=all'); 17 | 18 | if (isset($_POST['email'], $_POST['password'])) 19 | { 20 | $this->oUtil->getModel('Admin'); 21 | $this->oModel = new \TestProject\Model\Admin; 22 | 23 | $sHashPassword = $this->oModel->login($_POST['email']); 24 | if (password_verify($_POST['password'], $sHashPassword)) 25 | { 26 | $_SESSION['is_logged'] = 1; // Admin is logged now 27 | header('Location: ' . ROOT_URL . '?p=blog&a=all'); 28 | exit; 29 | } 30 | else 31 | { 32 | $this->oUtil->sErrMsg = 'Incorrect Login!'; 33 | } 34 | } 35 | 36 | $this->oUtil->getView('login'); 37 | } 38 | 39 | public function logout() 40 | { 41 | if (!$this->isLogged()) 42 | exit; 43 | 44 | // If there is a session, destroy it to disconnect the admin 45 | if (!empty($_SESSION)) 46 | { 47 | $_SESSION = array(); 48 | session_unset(); 49 | session_destroy(); 50 | } 51 | 52 | // Redirect to the homepage 53 | header('Location: ' . ROOT_URL); 54 | exit; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Controller/Blog.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Controller; 10 | 11 | class Blog 12 | { 13 | const MAX_POSTS = 5; 14 | 15 | protected $oUtil, $oModel; 16 | private $_iId; 17 | 18 | public function __construct() 19 | { 20 | // Enable PHP Session 21 | if (empty($_SESSION)) 22 | @session_start(); 23 | 24 | $this->oUtil = new \TestProject\Engine\Util; 25 | 26 | /** Get the Model class in all the controller class **/ 27 | $this->oUtil->getModel('Blog'); 28 | $this->oModel = new \TestProject\Model\Blog; 29 | 30 | /** Get the Post ID in the constructor in order to avoid the duplication of the same code **/ 31 | $this->_iId = (int) (!empty($_GET['id']) ? $_GET['id'] : 0); 32 | } 33 | 34 | 35 | /***** Front end *****/ 36 | // Homepage 37 | public function index() 38 | { 39 | $this->oUtil->oPosts = $this->oModel->get(0, self::MAX_POSTS); // Get only the latest X posts 40 | 41 | $this->oUtil->getView('index'); 42 | } 43 | 44 | public function post() 45 | { 46 | $this->oUtil->oPost = $this->oModel->getById($this->_iId); // Get the data of the post 47 | 48 | $this->oUtil->getView('post'); 49 | } 50 | 51 | public function notFound() 52 | { 53 | $this->oUtil->getView('not_found'); 54 | } 55 | 56 | 57 | /***** For Admin (Back end) *****/ 58 | public function all() 59 | { 60 | if (!$this->isLogged()) exit; 61 | 62 | $this->oUtil->oPosts = $this->oModel->getAll(); 63 | 64 | $this->oUtil->getView('index'); 65 | } 66 | 67 | 68 | public function add() 69 | { 70 | if (!$this->isLogged()) exit; 71 | 72 | if (!empty($_POST['add_submit'])) 73 | { 74 | if (isset($_POST['title'], $_POST['body']) && mb_strlen($_POST['title']) <= 50) // Allow a maximum of 50 characters 75 | { 76 | $aData = array('title' => $_POST['title'], 'body' => $_POST['body'], 'created_date' => date('Y-m-d H:i:s')); 77 | 78 | if ($this->oModel->add($aData)) 79 | $this->oUtil->sSuccMsg = 'Hurray!! The post has been added.'; 80 | else 81 | $this->oUtil->sErrMsg = 'Whoops! An error has occurred! Please try again later.'; 82 | } 83 | else 84 | { 85 | $this->oUtil->sErrMsg = 'All fields are required and the title cannot exceed 50 characters.'; 86 | } 87 | } 88 | 89 | $this->oUtil->getView('add_post'); 90 | } 91 | 92 | public function edit() 93 | { 94 | if (!$this->isLogged()) exit; 95 | 96 | if (!empty($_POST['edit_submit'])) 97 | { 98 | if (isset($_POST['title'], $_POST['body'])) 99 | { 100 | $aData = array('post_id' => $this->_iId, 'title' => $_POST['title'], 'body' => $_POST['body']); 101 | 102 | if ($this->oModel->update($aData)) 103 | $this->oUtil->sSuccMsg = 'Hurray! The post has been updated.'; 104 | else 105 | $this->oUtil->sErrMsg = 'Whoops! An error has occurred! Please try again later'; 106 | } 107 | else 108 | { 109 | $this->oUtil->sErrMsg = 'All fields are required.'; 110 | } 111 | } 112 | 113 | /* Get the data of the post */ 114 | $this->oUtil->oPost = $this->oModel->getById($this->_iId); 115 | 116 | $this->oUtil->getView('edit_post'); 117 | } 118 | 119 | public function delete() 120 | { 121 | if (!$this->isLogged()) exit; 122 | 123 | if (!empty($_POST['delete']) && $this->oModel->delete($this->_iId)) 124 | header('Location: ' . ROOT_URL); 125 | else 126 | exit('Whoops! Post cannot be deleted.'); 127 | } 128 | 129 | protected function isLogged() 130 | { 131 | return !empty($_SESSION['is_logged']); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Engine/Config.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Engine; 10 | 11 | final class Config 12 | { 13 | // Database info (if you want to test the script, please edit the below constants with yours) 14 | const 15 | DB_HOST = 'localhost', 16 | DB_NAME = 'mymvcblog', 17 | DB_USR = 'root', 18 | DB_PWD = '', 19 | 20 | // Title of the site 21 | SITE_NAME = 'My Simple Blog!'; 22 | } 23 | -------------------------------------------------------------------------------- /Engine/Db.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Engine; 10 | 11 | class Db extends \PDO 12 | { 13 | public function __construct() 14 | { 15 | $aDriverOptions[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES UTF8'; 16 | parent::__construct('mysql:host=' . Config::DB_HOST . '; dbname=' . Config::DB_NAME . '; ', Config::DB_USR, Config::DB_PWD, $aDriverOptions); 17 | $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Engine/Loader.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Engine; 10 | 11 | use TestProject\Engine\Pattern\Singleton; 12 | 13 | // First, include necessary Pattern classes 14 | require_once __DIR__ . '/Pattern/Base.trait.php'; 15 | require_once __DIR__ . '/Pattern/Singleton.trait.php'; 16 | 17 | class Loader 18 | { 19 | use Singleton; // Thanks Trait feature of PHP 5.4, I don't duplicate pattern code 20 | 21 | public function init() 22 | { 23 | // Register the loader method 24 | spl_autoload_register(array(__CLASS__, '_loadClasses')); 25 | } 26 | 27 | private function _loadClasses($sClass) 28 | { 29 | // Remove namespace and backslash 30 | $sClass = str_replace(array(__NAMESPACE__, 'TestProject', '\\'), '/', $sClass); 31 | 32 | if (is_file(__DIR__ . '/' . $sClass . '.php')) 33 | require_once __DIR__ . '/' . $sClass . '.php'; 34 | 35 | if (is_file(ROOT_PATH . $sClass . '.php')) 36 | require_once ROOT_PATH . $sClass . '.php'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Engine/Pattern/Base.trait.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Engine\Pattern; 10 | 11 | trait Base 12 | { 13 | final private function __construct() {} 14 | final private function __clone() {} 15 | } 16 | -------------------------------------------------------------------------------- /Engine/Pattern/Singleton.trait.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Engine\Pattern; 10 | 11 | trait Singleton 12 | { 13 | use Base; 14 | 15 | protected static $_oInstance = null; 16 | 17 | /** 18 | * Get instance of class. 19 | * 20 | * @access public 21 | * @static 22 | * @return object Return the instance class or create first instance of the class. 23 | */ 24 | public static function getInstance() 25 | { 26 | return (null === static::$_oInstance) ? static::$_oInstance = new static : static::$_oInstance; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Engine/Router.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Engine; 10 | 11 | class Router 12 | { 13 | public static function run (array $aParams) 14 | { 15 | $sNamespace = 'TestProject\Controller\\'; 16 | $sDefCtrl = $sNamespace . 'Blog'; 17 | $sCtrlPath = ROOT_PATH . 'Controller/'; 18 | $sCtrl = ucfirst($aParams['ctrl']); 19 | 20 | if (is_file($sCtrlPath . $sCtrl . '.php')) 21 | { 22 | $sCtrl = $sNamespace . $sCtrl; 23 | $oCtrl = new $sCtrl; 24 | 25 | if ((new \ReflectionClass($oCtrl))->hasMethod($aParams['act']) && (new \ReflectionMethod($oCtrl, $aParams['act']))->isPublic()) 26 | call_user_func(array($oCtrl, $aParams['act'])); 27 | else 28 | call_user_func(array($oCtrl, 'notFound')); 29 | } 30 | else 31 | { 32 | call_user_func(array(new $sDefCtrl, 'notFound')); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Engine/Util.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Engine; 10 | 11 | class Util 12 | { 13 | public function getView($sViewName) 14 | { 15 | $this->_get($sViewName, 'View'); 16 | } 17 | 18 | public function getModel($sModelName) 19 | { 20 | $this->_get($sModelName, 'Model'); 21 | } 22 | 23 | /** 24 | * This method is useful in order to avoid the duplication of code (create almost the same method for "getView" and "getModel" 25 | */ 26 | private function _get($sFileName, $sType) 27 | { 28 | $sFullPath = ROOT_PATH . $sType . '/' . $sFileName . '.php'; 29 | if (is_file($sFullPath)) 30 | require $sFullPath; 31 | else 32 | exit('The "' . $sFullPath . '" file doesn\'t exist'); 33 | } 34 | 35 | /** 36 | * Set variables for the template views. 37 | * 38 | * @return void 39 | */ 40 | public function __set($sKey, $mVal) 41 | { 42 | $this->$sKey = $mVal; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /Model/Admin.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Model; 10 | 11 | class Admin extends Blog 12 | { 13 | public function login($sEmail) 14 | { 15 | $oStmt = $this->oDb->prepare('SELECT email, password FROM Admins WHERE email = :email LIMIT 1'); 16 | $oStmt->bindValue(':email', $sEmail, \PDO::PARAM_STR); 17 | $oStmt->execute(); 18 | $oRow = $oStmt->fetch(\PDO::FETCH_OBJ); 19 | 20 | return @$oRow->password; // Use the PHP 5.5 password function 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Model/Blog.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | namespace TestProject\Model; 10 | 11 | class Blog 12 | { 13 | protected $oDb; 14 | 15 | public function __construct() 16 | { 17 | $this->oDb = new \TestProject\Engine\Db; 18 | } 19 | 20 | public function get($iOffset, $iLimit) 21 | { 22 | $oStmt = $this->oDb->prepare('SELECT * FROM Posts ORDER BY createdDate DESC LIMIT :offset, :limit'); 23 | $oStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT); 24 | $oStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT); 25 | $oStmt->execute(); 26 | return $oStmt->fetchAll(\PDO::FETCH_OBJ); 27 | } 28 | 29 | public function getAll() 30 | { 31 | $oStmt = $this->oDb->query('SELECT * FROM Posts ORDER BY createdDate DESC'); 32 | return $oStmt->fetchAll(\PDO::FETCH_OBJ); 33 | } 34 | 35 | public function add(array $aData) 36 | { 37 | $oStmt = $this->oDb->prepare('INSERT INTO Posts (title, body, createdDate) VALUES(:title, :body, :created_date)'); 38 | return $oStmt->execute($aData); 39 | } 40 | 41 | public function getById($iId) 42 | { 43 | $oStmt = $this->oDb->prepare('SELECT * FROM Posts WHERE id = :postId LIMIT 1'); 44 | $oStmt->bindParam(':postId', $iId, \PDO::PARAM_INT); 45 | $oStmt->execute(); 46 | return $oStmt->fetch(\PDO::FETCH_OBJ); 47 | } 48 | 49 | public function update(array $aData) 50 | { 51 | $oStmt = $this->oDb->prepare('UPDATE Posts SET title = :title, body = :body WHERE id = :postId LIMIT 1'); 52 | $oStmt->bindValue(':postId', $aData['post_id'], \PDO::PARAM_INT); 53 | $oStmt->bindValue(':title', $aData['title']); 54 | $oStmt->bindValue(':body', $aData['body']); 55 | return $oStmt->execute(); 56 | } 57 | 58 | public function delete($iId) 59 | { 60 | $oStmt = $this->oDb->prepare('DELETE FROM Posts WHERE id = :postId LIMIT 1'); 61 | $oStmt->bindParam(':postId', $iId, \PDO::PARAM_INT); 62 | return $oStmt->execute(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple PHP MVC Blog System 2 | 3 | 4 | ## Description 5 | 6 | This *PHP Blog System* has an MVC pattern, uses Traits (PHP 5.4), Namespace (PHP 5.3), Singleton pattern, PDO (PHP 5.1) and the new PHP Password Hashing feature (PHP 5.5). 7 | 8 | The project was a *PHP Challenge Project* I have done. 9 | 10 | 11 | ## Why this MVC Blog System can be very Useful for You? 12 | 13 | If you need to code a simple website under a Professional and very nice/clean code (as I really enjoy doing), this script will be very useful in order to *start on good basis* and *save time and money*. 14 | 15 | However, if you need to build a blog system, again this project can be used as a *framework* to start your project easily under a *good development pattern* and *good development practice* and organization. 16 | 17 | 18 | ## Requirements that were Requested for the Project 19 | 20 | ### Requirements 21 | 22 | * The project should be written in object-oriented PHP targeting version 5.5 or higher 23 | * It should be all self-written, no existing frameworks or libraries 24 | * It should have good security (e.g., hashed passwords, protect against SQL injection, shouldn't have any error when we try to change URL query strings or to hack it, etc) 25 | * Should use a MySQL database to store admin account and article data 26 | 27 | ### Specification 28 | 29 | *Build a simple blog with the following functionalities* 30 | 31 | #### The Frontend 32 | 33 | * List of blog articles showing the **title**, **body** truncated to 100 characters, and **date**. It should show only the latest 5 articles 34 | * Single blog article showing the **title**, **full body**, and the **date** 35 | 36 | #### The Backend 37 | 38 | * List of all the blog articles 39 | * Possibility to add a new blog article with a title and body. The title should allow a maximum of 50 characters 40 | * Possibility to edit an existing blog article 41 | * Possibility to delete an article 42 | * Logout feature for the admin user 43 | 44 | HTML and CSS code should be kept to the minimum needed to make the website functional – This project is purely to assess how you approach the problem and not how good it looks. 45 | 46 | 47 | ## Server Requirements of the Web App 48 | 49 | * **Application Server** PHP 5.5.0 or higher. 50 | 51 | * **PHP Extension** mbstring 52 | 53 | * **Database MySQL/MariaDB 5** or higher. 54 | 55 | 56 | ## The Author 57 | 58 | [Pierre-Henry Soria](http://ph7.me) 59 | 60 | 61 | ## Contact the Author 62 | 63 | By email at: *phy [AT] hizup [D0T] uk* 64 | 65 | 66 | ## License 67 | 68 | This blog system (PHP script) is under [Lesser General Public License](http://www.gnu.org/copyleft/lesser.html) (LGPL); See the LICENSE.txt file for more information. 69 | -------------------------------------------------------------------------------- /View/add_post.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 10 | 11 | 12 |
13 | 14 |


15 | 16 |

17 | 18 |


19 | 20 |

21 | 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /View/edit_post.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 10 | 11 | 12 | oPost)): ?> 13 |

Post Data Not Found!

14 | 15 | 16 |
17 |


18 | 19 |

20 | 21 |


22 | 23 |

24 | 25 |

26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /View/inc/control_buttons.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 10 | 11 | | 12 |
| 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /View/inc/footer.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /View/inc/header.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 10 | 11 | 12 | 13 | <?=\TestProject\Engine\Config::SITE_NAME?> 14 | 15 | 16 | 17 | 18 |
19 | -------------------------------------------------------------------------------- /View/inc/msg.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | sErrMsg)): ?> 10 |

sErrMsg?>

11 | 12 | 13 | sSuccMsg)): ?> 14 |

sSuccMsg?>

15 | 16 | -------------------------------------------------------------------------------- /View/index.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | 10 | /** 11 | * Since PHP 5.4, the echo short tag " is always available, so I use it to simplify the visibility of the template 12 | */ 13 | ?> 14 | 15 | 16 | oPosts)): ?> 17 |

There is no Blog Post.

18 |

19 | 20 | 21 | oPosts as $oPost): ?> 22 |

title)?>

23 | 24 |

body, 0, 100, '...')))?>

25 |

Want to see more?

26 |

Posted on createdDate?>

27 | 28 | 29 |

30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /View/login.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 10 | 11 | 12 |
13 | 14 |


15 | 16 |

17 | 18 |


19 | 20 |

21 | 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /View/not_found.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 10 | 11 |

Page Not Found

12 | 13 |

Whoops! Sorry but this page doesn't seem to exist.

14 | 15 | 16 | -------------------------------------------------------------------------------- /View/post.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | ?> 9 | 10 | 11 | oPost)): ?> 12 |

The post can't be be found!

13 | 14 | 15 |
16 | 17 | 18 |

oPost->title)?>

19 |

oPost->body))?>

20 |

Posted on oPost->createdDate?>

21 | 22 | oPost; 24 | require 'inc/control_buttons.php'; 25 | ?> 26 |
27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /_create_admin_pwd.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | /** Allows to create an admin password easily **/ 10 | /* I use PHP 5.5 password hashing for this app test. Thanks this new PHP feature, the password gets a salt and it is much more secure than a simple SHA1 algorithm */ 11 | 12 | $sPwd = 'pwd123'; // Admin Password 13 | $sHashedPwd = password_hash($sPwd , PASSWORD_BCRYPT, array('cost' => 14)); 14 | echo 'Password is: ' . $sHashedPwd; 15 | -------------------------------------------------------------------------------- /db.sql: -------------------------------------------------------------------------------- 1 | 2 | SET @sAdminEmail = 'test@test.com'; 3 | SET @sAdminPassword = '$2y$14$kefF6aqkuOEWo7CIFduNf.7O8BuGR4uWrIAFcHWm2u99OcLPDFWOe'; 4 | SET @sPostTitle = 'My First Post'; 5 | SET @sPostBody = 'Hello! Here is my first blog post!!\r\n\r\n\r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.\r\n\r\nDonec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus.\r\n\r\nAenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.\r\n\r\nEtiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante.\r\n\r\nEtiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus.\r\n\r\nNullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui.'; 6 | SET @sPostDate = NOW(); 7 | 8 | 9 | CREATE TABLE IF NOT EXISTS Posts ( 10 | id int(10) unsigned NOT NULL AUTO_INCREMENT, 11 | title varchar(50) DEFAULT NULL, 12 | body longtext NOT NULL, 13 | createdDate datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 14 | PRIMARY KEY (id) 15 | ) DEFAULT CHARSET=utf8; 16 | 17 | INSERT INTO Posts (title, body, createdDate) VALUES 18 | (@sPostTitle, @sPostBody, @sPostDate); 19 | 20 | 21 | CREATE TABLE IF NOT EXISTS Admins ( 22 | id int(10) unsigned NOT NULL AUTO_INCREMENT, 23 | email varchar(120) NOT NULL, 24 | password char(60) NOT NULL, 25 | PRIMARY KEY (id) 26 | ) DEFAULT CHARSET=utf8; 27 | 28 | INSERT INTO Admins (email, password) VALUES 29 | (@sAdminEmail, @sAdminPassword); -- The admin password is: pwd123 30 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 4 | * @copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 5 | * @license Lesser General Public License 6 | * @link http://hizup.uk 7 | */ 8 | 9 | // Note, the script requires PHP 5.5 or higher 10 | namespace TestProject; 11 | 12 | use TestProject\Engine as E; 13 | 14 | if (version_compare(PHP_VERSION, '5.5.0', '<')) 15 | exit('Your PHP version is ' . PHP_VERSION . '. The script requires PHP 5.5 or higher.'); 16 | if (!extension_loaded('mbstring')) 17 | exit('The script requires "mbstring" PHP extension. Please install it.'); 18 | 19 | 20 | // Set constants (root server path + root URL) 21 | define('PROT', (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'); 22 | define('ROOT_URL', PROT . $_SERVER['HTTP_HOST'] . str_replace('\\', '', dirname(htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES))) . '/'); // Remove backslashes for Windows compatibility 23 | define('ROOT_PATH', __DIR__ . '/'); 24 | 25 | try 26 | { 27 | require ROOT_PATH . 'Engine/Loader.php'; 28 | E\Loader::getInstance()->init(); // Load necessary classes 29 | $aParams = ['ctrl' => (!empty($_GET['p']) ? $_GET['p'] : 'blog'), 'act' => (!empty($_GET['a']) ? $_GET['a'] : 'index')]; // I use the new PHP 5.4 short array syntax 30 | E\Router::run($aParams); 31 | } 32 | catch (\Exception $oE) 33 | { 34 | echo $oE->getMessage(); 35 | } 36 | -------------------------------------------------------------------------------- /readme_tech.txt: -------------------------------------------------------------------------------- 1 | - Please note that you need PHP 5.5 or higher to execute the script 2 | - Please create a database name/user and exucute "db.sql" first 3 | - To change the MySQL connection information, please edit /Engine/Config.php 4 | - Admin login (email/password) is: test@test.com / pwd123 5 | - Navigation Tip. On the website, there is no logo or "Homepage" link. To come back to the homepage, please click on the "Simple Blog" link located in the bottom page 6 | -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Author Pierre-Henry Soria 3 | * Copyright (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved. 4 | * License Lesser General Public License 5 | * Link http://hizup.uk 6 | */ 7 | 8 | body{color:#666;font-size:14px;font-family:Arial,Helvetica,sans-serif;background:#efefef} 9 | h1{font-size:2em} 10 | .center{text-align:center;margin-left:auto;margin-right:auto;width:80%} 11 | .right{float:right;margin-right:10px} 12 | .left{float:left;margin-left:10px} 13 | .left,.right{width:200px} 14 | .success{color:green} 15 | .error{color:red} 16 | .success,.error,.bold{font-weight:bold;font-size:16px} 17 | .small{font-size:x-small} 18 | .italic{font-style:italic} 19 | .inline{display:inline} 20 | header{margin-bottom:10px} 21 | footer{font-size:.9em;text-align:center;padding:8px;margin-top:28px;border-top:1px solid #c8c8c8} 22 | input,textarea{width:260px} 23 | .clear{clear:both} 24 | --------------------------------------------------------------------------------