├── img ├── welcome.jpg ├── user-default.png └── index.php ├── upload ├── blog │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── default.jpg │ ├── COVER-64b2da11965537.89753786.png │ ├── COVER-64b2dd04e49ce8.82252886.png │ ├── COVER-64b2dd26a7deb9.39821149.png │ ├── COVER-64b2e1f6123915.02720682.jpg │ ├── COVER-64b2f7073f4496.93787747.jpg │ ├── COVER-64b2fceaee4918.12573439.jpg │ ├── COVER-64ba9e879b0c83.79174008.jpg │ ├── COVER-64baa114e66609.40375739.jpg │ ├── COVER-64baa557c0aba9.11287748.png │ ├── COVER-64baa5c24d8949.62444141.jpg │ ├── COVER-64baa64818c1c1.96344816.jpg │ ├── COVER-64baa69b661be3.43596849.jpg │ ├── COVER-64bab16c6cb184.30984126.png │ └── index.php └── index.php ├── logout.php ├── db_conn.php ├── admin ├── data │ ├── Admin.php │ ├── User.php │ ├── Category.php │ ├── Comment.php │ └── Post.php ├── category-delete.php ├── index.php ├── user-delete.php ├── inc │ ├── index.php │ └── side-nav.php ├── comment-delete.php ├── post-delete.php ├── post-publish.php ├── req │ ├── Category-create.php │ ├── Category-edit.php │ ├── admin-edit.php │ ├── admin-edit-pass.php │ ├── post-create.php │ └── post-edit.php ├── admin-login.php ├── single_post.php ├── category-add.php ├── users.php ├── category-edit.php ├── Category.php ├── Comment.php ├── post-add.php ├── profile.php ├── Post.php └── post-edit.php ├── README.md ├── css ├── index.php ├── style.css ├── side-bar.css └── richtext.min.css ├── php ├── index.php ├── comment.php ├── signup.php └── login.php ├── index.php ├── ajax └── like-unlike.php ├── admin-login.php ├── login.php ├── signup.php ├── inc └── NavBar.php ├── Category.php ├── blog-view.php ├── blog.php ├── js └── jquery.richtext.min.js └── _db └── blog_db.sql /img/welcome.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingWithElias/php-blog-website/HEAD/img/welcome.jpg -------------------------------------------------------------------------------- /upload/blog/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingWithElias/php-blog-website/HEAD/upload/blog/1.jpg -------------------------------------------------------------------------------- /upload/blog/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingWithElias/php-blog-website/HEAD/upload/blog/2.jpg -------------------------------------------------------------------------------- /upload/blog/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingWithElias/php-blog-website/HEAD/upload/blog/3.jpg -------------------------------------------------------------------------------- /img/user-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingWithElias/php-blog-website/HEAD/img/user-default.png -------------------------------------------------------------------------------- /upload/blog/default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingWithElias/php-blog-website/HEAD/upload/blog/default.jpg -------------------------------------------------------------------------------- /logout.php: -------------------------------------------------------------------------------- 1 | setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 12 | }catch(PDOException $e){ 13 | echo "Connection failed : ". $e->getMessage(); 14 | } -------------------------------------------------------------------------------- /admin/data/Admin.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 7 | $stmt->execute([$id]); 8 | 9 | if($stmt->rowCount() >= 1){ 10 | $data = $stmt->fetch(); 11 | return $data; 12 | }else { 13 | return 0; 14 | } 15 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to Create a Blog PHP & MySQL database 2 | 3 | ## PHP Blogging Website 4 | 5 | 6 | version: 1.0.0 7 | 8 | ## TECHNOLOGIES 9 | 10 | 1. PHP 11 | 1. HTML & CSS 12 | 1. JQuery AJAX 13 | 1. Javascript 14 | 1. Bootstrap 5 15 | 16 | 17 | 18 | ## Full Tutorial 19 | 20 | [On Youtube](https://www.youtube.com/playlist?list=PL2WFgdVk-usFBEBfk6TVrlHyyaFg0Z1Kg) 21 | 22 | ## Authors 23 | 24 | [Elias Abdurrahman](https://github.com/codingWithElias) -------------------------------------------------------------------------------- /admin/data/User.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 7 | $stmt->execute(); 8 | 9 | if($stmt->rowCount() >= 1){ 10 | $data = $stmt->fetchAll(); 11 | return $data; 12 | }else { 13 | return 0; 14 | } 15 | } 16 | 17 | 18 | 19 | // Delete By ID 20 | function deleteById($conn, $id){ 21 | $sql = "DELETE FROM users WHERE id=?"; 22 | $stmt = $conn->prepare($sql); 23 | $res = $stmt->execute([$id]); 24 | 25 | if($res){ 26 | return 1; 27 | }else { 28 | return 0; 29 | } 30 | } -------------------------------------------------------------------------------- /admin/category-delete.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 404 not found 7 | 8 | 9 | 10 |
11 |

12 | 404 - not found 13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /img/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 404 not found 7 | 8 | 9 | 10 |
11 |

12 | 404 - not found 13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /php/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 404 not found 7 | 8 | 9 | 10 |
11 |

12 | 404 - not found 13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /admin/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 404 not found 7 | 8 | 9 | 10 |
11 |

12 | 404 - not found 13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /admin/user-delete.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 404 not found 7 | 8 | 9 | 10 |
11 |

12 | 404 - not found 13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /admin/inc/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 404 not found 7 | 8 | 9 | 10 |
11 |

12 | 404 - not found 13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /upload/blog/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 404 not found 7 | 8 | 9 | 10 |
11 |

12 | 404 - not found 13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /admin/comment-delete.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 16 | $stmt->execute([$post_id]); 17 | $sm = "Successfully publish!"; 18 | header("Location: post.php?success=$sm"); 19 | exit; 20 | }else { 21 | $sql = "UPDATE post SET publish=0"; 22 | $stmt = $conn->prepare($sql); 23 | $stmt->execute(); 24 | $sm = "Successfully unpublish!"; 25 | header("Location: post.php?success=$sm"); 26 | exit; 27 | } 28 | 29 | }else { 30 | header("Location: ../admin-login.php"); 31 | exit; 32 | } -------------------------------------------------------------------------------- /admin/data/Category.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 7 | $stmt->execute(); 8 | 9 | if($stmt->rowCount() >= 1){ 10 | $data = $stmt->fetchAll(); 11 | return $data; 12 | }else { 13 | return 0; 14 | } 15 | } 16 | 17 | // getById 18 | function getById($conn, $id){ 19 | $sql = "SELECT * FROM category WHERE id=?"; 20 | $stmt = $conn->prepare($sql); 21 | $stmt->execute([$id]); 22 | 23 | if($stmt->rowCount() >= 1){ 24 | $data = $stmt->fetch(); 25 | return $data; 26 | }else { 27 | return 0; 28 | } 29 | } 30 | 31 | // Delete By ID 32 | function deleteById($conn, $id){ 33 | $sql = "DELETE FROM category WHERE id=?"; 34 | $stmt = $conn->prepare($sql); 35 | $res = $stmt->execute([$id]); 36 | 37 | if($res){ 38 | return 1; 39 | }else { 40 | return 0; 41 | } 42 | } -------------------------------------------------------------------------------- /php/comment.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 21 | $stmt->execute([$comment, $user_id, $post_id]); 22 | 23 | header("Location: ../blog-view.php?success=successfully commented ;) &post_id=$post_id#comments"); 24 | exit; 25 | } 26 | 27 | }else { 28 | header("Location: ../blog.php"); 29 | exit; 30 | } 31 | 32 | }else { 33 | header("Location: ../blog.php"); 34 | exit; 35 | } -------------------------------------------------------------------------------- /admin/req/Category-create.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 18 | $res = $stmt->execute([$category]); 19 | 20 | 21 | if ($res) { 22 | $sm = "Successfully Created!"; 23 | header("Location: ../category-add.php?success=$sm"); 24 | exit; 25 | }else { 26 | $em = "Unknown error occurred"; 27 | header("Location: ../category-add.php?error=$em"); 28 | exit; 29 | } 30 | 31 | 32 | }else { 33 | header("Location: ../category-add.php"); 34 | exit; 35 | } 36 | 37 | 38 | }else { 39 | header("Location: ../admin-login.php"); 40 | exit; 41 | } -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | Home Page 17 | 18 | 19 | 20 | 21 | 22 | 25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /admin/req/Category-edit.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 19 | $res = $stmt->execute([$category, $id]); 20 | 21 | 22 | if ($res) { 23 | $sm = "Successfully edited!"; 24 | header("Location: ../category-edit.php?success=$sm&category=$category&id=$id"); 25 | exit; 26 | }else { 27 | $em = "Unknown error occurred"; 28 | header("Location: ../category-edit.php?error=$em&id=$id"); 29 | exit; 30 | } 31 | 32 | 33 | }else { 34 | header("Location: ../category-edit.php"); 35 | exit; 36 | } 37 | 38 | 39 | }else { 40 | header("Location: ../admin-login.php"); 41 | exit; 42 | } -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | img { 2 | max-width: 100%; 3 | } 4 | .main-banner { 5 | width: 100%; 6 | height: 50vh; 7 | background: url("../img/welcome.jpg") center; 8 | background-size: 100%; 9 | } 10 | .main-blog-card { 11 | width: 90%; 12 | } 13 | .category-aside { 14 | width: 100%; 15 | } 16 | .main-blog { 17 | width: 70%; 18 | } 19 | .aside-main { 20 | width: 30%; 21 | } 22 | 23 | .w-450 { 24 | width: 450px; 25 | } 26 | .vh-100 { 27 | min-height: 100vh; 28 | } 29 | /*admin*/ 30 | .section-1 { 31 | width: 100%; 32 | padding: 15px; 33 | } 34 | .main-table { 35 | width: 90%; 36 | max-width: 700px; 37 | } 38 | .react-btns i { 39 | font-size: 24px; 40 | color: #222; 41 | cursor: pointer; 42 | } 43 | .react-btns a { 44 | text-decoration: none; 45 | color: #222; 46 | cursor: pointer; 47 | } 48 | .react-btns a:hover { 49 | opacity: .8; 50 | } 51 | .react-btns .like:hover { 52 | color: #0088FF; 53 | } 54 | .react-btns .liked { 55 | color: #0088FF; 56 | } 57 | .comments .comment span { 58 | color: #0088FF; 59 | } 60 | @media only screen and (max-width: 768px) { 61 | /* For mobile phones: */ 62 | .aside-main { 63 | display: none; 64 | } 65 | .main-blog { 66 | width: 100%; 67 | } 68 | .main-blog-card { 69 | width: 100%; 70 | } 71 | } -------------------------------------------------------------------------------- /php/signup.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 35 | $stmt->execute([$fname, $uname, $pass]); 36 | 37 | header("Location: ../signup.php?success=Your account has been created successfully"); 38 | exit; 39 | } 40 | 41 | 42 | }else { 43 | header("Location: ../signup.php?error=error"); 44 | exit; 45 | } 46 | -------------------------------------------------------------------------------- /ajax/like-unlike.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 18 | $res = $stmt->execute([$post_id, $user_id]); 19 | if($stmt->rowCount() > 0){ 20 | // unlike 21 | $sql = "DELETE FROM post_like 22 | WHERE post_id=? AND liked_by=?"; 23 | $stmt = $conn->prepare($sql); 24 | $res = $stmt->execute([$post_id, $user_id]); 25 | }else { 26 | $sql = "INSERT INTO post_like(liked_by, post_id) VALUES(?,?)"; 27 | $stmt = $conn->prepare($sql); 28 | $res = $stmt->execute([$user_id, $post_id]); 29 | } 30 | 31 | $sql = "SELECT * FROM post_like 32 | WHERE post_id=?"; 33 | $stmt = $conn->prepare($sql); 34 | $stmt->execute([$post_id]); 35 | if($stmt->rowCount() >= 0) echo $stmt->rowCount(); 36 | else echo "..."; 37 | } 38 | 39 | 40 | 41 | 42 | }else { 43 | echo "..."; 44 | } -------------------------------------------------------------------------------- /admin-login.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Admin Login 7 | 8 | 9 | 10 | 11 |
12 | 13 |
16 | 17 |

ADMIN LOGIN


18 |

Only for Administrator

19 | 20 | 23 | 24 | 25 |
26 | 27 | "> 31 |
32 | 33 |
34 | 35 | 38 |
39 | 40 | 41 | User Login 42 |
43 |
44 | 45 | -------------------------------------------------------------------------------- /admin/req/admin-edit.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 32 | $res = $stmt->execute([$fname,$lname,$username, $id]); 33 | 34 | 35 | if ($res) { 36 | $_SESSION['username'] = $username; 37 | $sm = "Successfully edited!"; 38 | header("Location: ../profile.php?success=$sm"); 39 | exit; 40 | }else { 41 | $em = "Unknown error occurred"; 42 | header("Location: ../profile.php?error=$em"); 43 | exit; 44 | } 45 | 46 | 47 | }else { 48 | header("Location: ../profile.php"); 49 | exit; 50 | } 51 | 52 | 53 | }else { 54 | header("Location: ../admin-login.php"); 55 | exit; 56 | } -------------------------------------------------------------------------------- /admin/inc/side-nav.php: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |

My Blog 8 | 11 |

12 | 18 |
19 |
20 | 63 |
64 | 65 | -------------------------------------------------------------------------------- /login.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Login 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 |
17 | 18 |

LOGIN


19 | 20 | 23 | 24 | 25 |
26 | 27 | "> 31 |
32 | 33 |
34 | 35 | 38 |
39 | 40 | 41 | Admin Login 42 |     43 | Blog 44 |     45 | Sign Up 46 |
47 |
48 | 49 | -------------------------------------------------------------------------------- /admin/admin-login.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 26 | $stmt->execute([$uname]); 27 | 28 | if($stmt->rowCount() == 1){ 29 | $user = $stmt->fetch(); 30 | 31 | $username = $user['username']; 32 | $password = $user['password']; 33 | $id = $user['id']; 34 | if($username === $uname){ 35 | if(password_verify($pass, $password)){ 36 | $_SESSION['admin_id'] = $id; 37 | $_SESSION['username'] = $username; 38 | 39 | header("Location: users.php"); 40 | exit; 41 | }else { 42 | $em = "Incorect User name or password"; 43 | header("Location: ../admin-login.php?error=$em&$data"); 44 | exit; 45 | } 46 | 47 | }else { 48 | $em = "Incorect User name or password"; 49 | header("Location: ../admin-login.php?error=$em&$data"); 50 | exit; 51 | } 52 | 53 | }else { 54 | $em = "Incorect User name or password"; 55 | header("Location: ../admin-login.php?error=$em&$data"); 56 | exit; 57 | } 58 | } 59 | 60 | 61 | }else { 62 | header("Location: ../login.php?error=error"); 63 | exit; 64 | } 65 | -------------------------------------------------------------------------------- /php/login.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 26 | $stmt->execute([$uname]); 27 | 28 | if($stmt->rowCount() == 1){ 29 | $user = $stmt->fetch(); 30 | 31 | $username = $user['username']; 32 | $password = $user['password']; 33 | $fname = $user['fname']; 34 | $id = $user['id']; 35 | if($username === $uname){ 36 | if(password_verify($pass, $password)){ 37 | $_SESSION['user_id'] = $id; 38 | $_SESSION['username'] = $username; 39 | 40 | header("Location: ../blog.php"); 41 | exit; 42 | }else { 43 | $em = "Incorect User name or password"; 44 | header("Location: ../login.php?error=$em&$data"); 45 | exit; 46 | } 47 | 48 | }else { 49 | $em = "Incorect User name or password"; 50 | header("Location: ../login.php?error=$em&$data"); 51 | exit; 52 | } 53 | 54 | }else { 55 | $em = "Incorect User name or password"; 56 | header("Location: ../login.php?error=$em&$data"); 57 | exit; 58 | } 59 | } 60 | 61 | 62 | }else { 63 | header("Location: ../login.php?error=error"); 64 | exit; 65 | } 66 | -------------------------------------------------------------------------------- /css/side-bar.css: -------------------------------------------------------------------------------- 1 | * { 2 | padding: 0; 3 | margin: 0; 4 | box-sizing: border-box; 5 | font-family: arial, sans-serif; 6 | } 7 | 8 | .main-profile-link a{ 9 | text-decoration: none; 10 | color: #eee; 11 | } 12 | .main-profile-link i:hover { 13 | color: #127b8e; 14 | } 15 | .main-profile-link a:hover { 16 | color: #127b8e; 17 | } 18 | .header { 19 | display: flex; 20 | justify-content: space-between; 21 | align-items: center; 22 | padding: 15px 30px; 23 | background: #23242b; 24 | color: #fff; 25 | } 26 | 27 | .u-name { 28 | font-size: 20px; 29 | } 30 | .u-name b { 31 | color: #127b8e; 32 | } 33 | .header i { 34 | font-size: 30px; 35 | cursor: pointer; 36 | color: #fff; 37 | } 38 | 39 | .user-p h4 { 40 | color: #ccc; 41 | font-size: 1.2em; 42 | padding-left: 20px; 43 | 44 | } 45 | .side-bar { 46 | width: 250px; 47 | background: #262931; 48 | min-height: 100vh; 49 | transition: 500ms width; 50 | } 51 | .body { 52 | display: flex; 53 | } 54 | 55 | .side-bar ul { 56 | margin-top: 20px; 57 | list-style: none; 58 | padding-left: 0; 59 | } 60 | .side-bar ul li { 61 | font-size: 16px; 62 | padding: 15px 0px; 63 | padding-left: 20px; 64 | transition: 500ms background; 65 | white-space: nowrap; 66 | overflow: hidden; 67 | text-overflow: ellipsis; 68 | } 69 | .side-bar ul li:hover { 70 | background: #127b8e; 71 | } 72 | .side-bar ul .active { 73 | background: #127b8e; 74 | } 75 | .side-bar ul li a { 76 | text-decoration: none; 77 | color: #eee; 78 | cursor: pointer; 79 | letter-spacing: 1px; 80 | } 81 | .side-bar ul li a i { 82 | display: inline-block; 83 | padding-right: 10px; 84 | font-size: 23px; 85 | } 86 | #navbtn { 87 | display: inline-block; 88 | margin-left: 70px; 89 | font-size: 20px; 90 | transition: 500ms color; 91 | } 92 | #checkbox { 93 | display: none; 94 | } 95 | #checkbox:checked ~ .body .side-bar { 96 | width: 60px; 97 | } 98 | #checkbox:checked ~ .body .side-bar .user-p{ 99 | visibility: hidden; 100 | } 101 | #checkbox:checked ~ .body .side-bar a span{ 102 | display: none; 103 | } -------------------------------------------------------------------------------- /signup.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Sign Up 7 | 8 | 9 | 10 | 11 |
12 | 13 |
16 | 17 |

Create Account


18 | 19 | 22 | 23 | 24 | 25 | 28 | 29 |
30 | 31 | "> 35 |
36 | 37 |
38 | 39 | "> 43 |
44 | 45 |
46 | 47 | 50 |
51 | 52 | 53 | Login 54 |
55 |
56 | 57 | -------------------------------------------------------------------------------- /admin/single_post.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | Dashboard - <?=$post['post_title'] ?> 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 |
30 | 31 |
32 | ... 33 |
34 |
35 | 36 |
37 |

38 | Category: 39 | Date: 40 |

41 |
42 |
43 | 44 |
45 |
46 |
47 | 48 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /admin/category-add.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Category 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 |
23 |

Create New Category 24 | Category

25 | 26 |
27 | 28 |
29 | 30 | 31 | 32 |
33 | 34 |
35 | 36 |
39 | 40 |
41 | 42 | 45 |
46 | 47 | 48 |
49 | 50 |
51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /admin/req/admin-edit-pass.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 36 | $stmt->execute([$id]); 37 | 38 | $data = $stmt->fetch(); 39 | 40 | if(!password_verify($cpass, $data['password'])){ 41 | $em = "Incorect password"; 42 | header("Location: ../profile.php?perror=$em#cpassword"); 43 | exit; 44 | }else { 45 | // hashing the password 46 | $new_pass = password_hash($new_pass, PASSWORD_DEFAULT); 47 | 48 | $sql = "UPDATE admin SET password=?"; 49 | $stmt = $conn->prepare($sql); 50 | $res = $stmt->execute([$new_pass]); 51 | if ($res) { 52 | $sm = "The Password Successfully changed!"; 53 | header("Location: ../profile.php?psuccess=$sm#cpassword"); 54 | exit; 55 | }else { 56 | $em = "Unknown error occurred"; 57 | header("Location: ../profile.php?perror=$em#cpassword"); 58 | exit; 59 | } 60 | 61 | } 62 | 63 | 64 | 65 | 66 | }else { 67 | header("Location: ../profile.php"); 68 | exit; 69 | } 70 | 71 | 72 | }else { 73 | header("Location: ../admin-login.php"); 74 | exit; 75 | } -------------------------------------------------------------------------------- /inc/NavBar.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin/data/Comment.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 7 | $stmt->execute(); 8 | 9 | if($stmt->rowCount() >= 1){ 10 | $data = $stmt->fetchAll(); 11 | return $data; 12 | }else { 13 | return 0; 14 | } 15 | } 16 | 17 | // getById 18 | function getCommentById($conn, $id){ 19 | $sql = "SELECT * FROM comment WHERE comment_id=?"; 20 | $stmt = $conn->prepare($sql); 21 | $stmt->execute([$id]); 22 | 23 | if($stmt->rowCount() >= 1){ 24 | $data = $stmt->fetch(); 25 | return $data; 26 | }else { 27 | return 0; 28 | } 29 | } 30 | 31 | function CountByPostID($conn, $id){ 32 | $sql = "SELECT * FROM comment WHERE post_id=?"; 33 | $stmt = $conn->prepare($sql); 34 | $stmt->execute([$id]); 35 | 36 | return $stmt->rowCount(); 37 | } 38 | // LIKE count 39 | function likeCountByPostID($conn, $id){ 40 | $sql = "SELECT * FROM post_like WHERE post_id=?"; 41 | $stmt = $conn->prepare($sql); 42 | $stmt->execute([$id]); 43 | 44 | return $stmt->rowCount(); 45 | } 46 | //isliked 47 | function isLikedByUserID($conn, $post_id, $user_id){ 48 | $sql = "SELECT * FROM post_like WHERE post_id=? AND liked_by=?"; 49 | $stmt = $conn->prepare($sql); 50 | $stmt->execute([$post_id, $user_id]); 51 | 52 | if ($stmt->rowCount() > 0) { 53 | return 1; 54 | }else return 0; 55 | } 56 | function getCommentsByPostID($conn, $id){ 57 | $sql = "SELECT * FROM comment WHERE post_id=? ORDER BY comment_id desc"; 58 | $stmt = $conn->prepare($sql); 59 | $stmt->execute([$id]); 60 | 61 | if($stmt->rowCount() >= 1){ 62 | $data = $stmt->fetchAll(); 63 | return $data; 64 | }else { 65 | return 0; 66 | } 67 | } 68 | 69 | // Delete By ID 70 | function deleteCommentById($conn, $id){ 71 | $sql = "DELETE FROM comment WHERE comment_id=?"; 72 | $stmt = $conn->prepare($sql); 73 | $res = $stmt->execute([$id]); 74 | 75 | if($res){ 76 | return 1; 77 | }else { 78 | return 0; 79 | } 80 | } 81 | function deleteCommentByPostId($conn, $id){ 82 | $sql = "DELETE FROM comment WHERE post_id=?"; 83 | $stmt = $conn->prepare($sql); 84 | $res = $stmt->execute([$id]); 85 | 86 | if($res){ 87 | return 1; 88 | }else { 89 | return 0; 90 | } 91 | } 92 | 93 | function deleteLikeByPostId($conn, $id){ 94 | $sql = "DELETE FROM post_like WHERE post_id=?"; 95 | $stmt = $conn->prepare($sql); 96 | $res = $stmt->execute([$id]); 97 | 98 | if($res){ 99 | return 1; 100 | }else { 101 | return 0; 102 | } 103 | } -------------------------------------------------------------------------------- /admin/users.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Users 10 | 11 | 12 | 13 | 14 | 15 | 16 | 24 | 25 |
26 |

All Users 27 | Add New

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 | 59 | 60 | 61 | 62 | 63 |
#Full NameusernameAction
57 | Delete 58 |
64 | 65 |
66 | Empty! 67 |
68 | 69 |
70 | 71 | 72 | 73 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /admin/category-edit.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Category Edit 10 | 11 | 12 | 13 | 14 | 15 | 16 | 32 | 33 |
34 |

Edit 35 | Category

36 | 37 |
38 | 39 |
40 | 41 | 42 | 43 |
44 | 45 |
46 | 47 |
50 | 51 |
52 | 53 | 57 | 62 |
63 | 64 | 65 |
66 | 67 |
68 | 69 | 70 | 71 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /admin/Category.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Category 10 | 11 | 12 | 13 | 14 | 15 | 16 | 24 | 25 |
26 |

All Categories 27 | Add New

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 | 58 | 59 | 60 | 61 | 62 |
#CategoryAction
55 | Delete 56 | Edit 57 |
63 | 64 |
65 | Empty! 66 |
67 | 68 |
69 | 70 | 71 | 72 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /admin/req/post-create.php: -------------------------------------------------------------------------------- 1 | 130000) { 34 | $em = "Sorry, your file is too large."; 35 | header("Location: ../post-add.php?error=$em"); 36 | exit; 37 | }else { 38 | $image_ex = pathinfo($image_name, PATHINFO_EXTENSION); 39 | $image_ex = strtolower($image_ex); 40 | 41 | $allowed_exs = array('jpg', 'jpeg', 'png'); 42 | 43 | 44 | if (in_array($image_ex, $allowed_exs )) { 45 | $new_image_name = uniqid("COVER-", true).'.'.$image_ex; 46 | $image_path = '../../upload/blog/'.$new_image_name; 47 | move_uploaded_file($image_temp, $image_path); 48 | 49 | $sql = "INSERT INTO post(post_title, post_text,category, cover_url) VALUES (?,?,?,?)"; 50 | $stmt = $conn->prepare($sql); 51 | $res = $stmt->execute([$title, $text, $category, $new_image_name]); 52 | }else { 53 | $em = "You can't upload files of this type"; 54 | header("Location: ../post-add.php?error=$em"); 55 | exit; 56 | } 57 | 58 | } 59 | } 60 | 61 | }else { 62 | $sql = "INSERT INTO post(post_title, post_text, category) VALUES (?,?,?)"; 63 | $stmt = $conn->prepare($sql); 64 | $res = $stmt->execute([$title, $text, $category]); 65 | } 66 | 67 | if ($res) { 68 | $sm = "Successfully Created!"; 69 | header("Location: ../post-add.php?success=$sm"); 70 | exit; 71 | }else { 72 | $em = "Unknown error occurred"; 73 | header("Location: ../post-add.php?error=$em"); 74 | exit; 75 | } 76 | 77 | 78 | }else { 79 | header("Location: ../post-add.php"); 80 | exit; 81 | } 82 | 83 | 84 | }else { 85 | header("Location: ../admin-login.php"); 86 | exit; 87 | } -------------------------------------------------------------------------------- /admin/Comment.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Comments 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 |
28 |

All Comments

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 | 55 | 56 | 57 | 63 | 66 | 71 | 74 | 75 | 76 | 77 | 78 |
#Post TitleCommentUserAction
58 | 59 | 62 | 64 | 65 | 67 | 70 | 72 | Delete 73 |
79 | 80 |
81 | Empty! 82 |
83 | 84 |
85 | 86 | 87 | 88 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /admin/req/post-edit.php: -------------------------------------------------------------------------------- 1 | 130000) { 44 | $em = "Sorry, your file is too large."; 45 | header("Location: ../post-edit.php?error=$em&post_id=$post_id"); 46 | exit; 47 | }else { 48 | $image_ex = pathinfo($image_name, PATHINFO_EXTENSION); 49 | $image_ex = strtolower($image_ex); 50 | 51 | $allowed_exs = array('jpg', 'jpeg', 'png'); 52 | 53 | 54 | if (in_array($image_ex, $allowed_exs )) { 55 | $new_image_name = uniqid("COVER-", true).'.'.$image_ex; 56 | $image_path = '../../upload/blog/'.$new_image_name; 57 | move_uploaded_file($image_temp, $image_path); 58 | 59 | $sql = "UPDATE post SET post_title=?, post_text=?,cover_url=? WHERE post_id=?"; 60 | $stmt = $conn->prepare($sql); 61 | $res = $stmt->execute([$title, $text, $new_image_name, $post_id]); 62 | }else { 63 | $em = "You can't upload files of this type"; 64 | header("Location: ../post-add.php?error=$em&post_id=$post_id"); 65 | exit; 66 | } 67 | 68 | } 69 | } 70 | 71 | }else { 72 | $sql = "UPDATE post SET post_title=?, post_text=? WHERE post_id=?"; 73 | $stmt = $conn->prepare($sql); 74 | $res = $stmt->execute([$title, $text, $post_id]); 75 | } 76 | 77 | if ($res) { 78 | $sm = "Successfully Created!"; 79 | header("Location: ../post-edit.php?success=$sm&post_id=$post_id"); 80 | exit; 81 | }else { 82 | $em = "Unknown error occurred"; 83 | header("Location: ../post-edit.php?error=$em&post_id=$post_id"); 84 | exit; 85 | } 86 | 87 | 88 | }else { 89 | header("Location: ../post-edit.php&post_id=$post_id"); 90 | exit; 91 | } 92 | 93 | 94 | }else { 95 | header("Location: ../admin-login.php"); 96 | exit; 97 | } -------------------------------------------------------------------------------- /admin/post-add.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Create Post 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 29 | 30 |
31 |

Create New Post 32 | Posts

33 | 34 |
35 | 36 |
37 | 38 | 39 | 40 |
41 | 42 |
43 | 44 | 45 |
49 | 50 |
51 | 52 | 55 | 56 |
57 | 58 |
59 | 60 | 63 |
64 |
65 | 66 | 69 |
70 |
71 | 72 | 78 | 79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /admin/profile.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Users 10 | 11 | 12 | 13 | 14 | 15 | 16 | 24 | 25 |
26 |

Admin Profile

27 | 28 |
29 | 30 |
31 | 32 | 33 | 34 |
35 | 36 |
37 | 38 |
41 |

Change Profile Info

42 |
43 | 44 | 48 |
49 |
50 | 51 | 55 |
56 |
57 | 58 | 62 |
63 | 64 |
65 | 66 |
69 |

Change password

70 | 71 |
72 | 73 |
74 | 75 | 76 | 77 |
78 | 79 |
80 | 81 |
82 | 83 | 86 |
87 |
88 | 89 | 92 |
93 |
94 | 95 | 98 |
99 | 100 |
101 | 102 |
103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /admin/data/Post.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 8 | $stmt->execute(); 9 | 10 | if($stmt->rowCount() >= 1){ 11 | $data = $stmt->fetchAll(); 12 | return $data; 13 | }else { 14 | return 0; 15 | } 16 | } 17 | // getAllDeep admin 18 | function getAllDeep($conn){ 19 | $sql = "SELECT * FROM post"; 20 | $stmt = $conn->prepare($sql); 21 | $stmt->execute(); 22 | 23 | if($stmt->rowCount() >= 1){ 24 | $data = $stmt->fetchAll(); 25 | return $data; 26 | }else { 27 | return 0; 28 | } 29 | } 30 | // getAllPostsByCategory 31 | function getAllPostsByCategory($conn, $category_id){ 32 | $sql = "SELECT * FROM post WHERE category=? AND publish=1"; 33 | $stmt = $conn->prepare($sql); 34 | $stmt->execute([$category_id]); 35 | 36 | if($stmt->rowCount() >= 1){ 37 | $data = $stmt->fetchAll(); 38 | return $data; 39 | }else { 40 | return 0; 41 | } 42 | } 43 | // getById 44 | function getById($conn, $id){ 45 | $sql = "SELECT * FROM post 46 | WHERE post_id=? AND publish=1"; 47 | $stmt = $conn->prepare($sql); 48 | $stmt->execute([$id]); 49 | 50 | if($stmt->rowCount() >= 1){ 51 | $data = $stmt->fetch(); 52 | return $data; 53 | }else { 54 | return 0; 55 | } 56 | } 57 | // getById Deep - Admin 58 | function getByIdDeep($conn, $id){ 59 | $sql = "SELECT * FROM post WHERE post_id=?"; 60 | $stmt = $conn->prepare($sql); 61 | $stmt->execute([$id]); 62 | 63 | if($stmt->rowCount() >= 1){ 64 | $data = $stmt->fetch(); 65 | return $data; 66 | }else { 67 | return 0; 68 | } 69 | } 70 | 71 | // serach 72 | function serach($conn, $key){ 73 | # creating simple search temple :) 74 | $key = "%{$key}%"; 75 | 76 | $sql = "SELECT * FROM post 77 | WHERE publish=1 AND (post_title LIKE ? 78 | OR post_text LIKE ?)"; 79 | $stmt = $conn->prepare($sql); 80 | $stmt->execute([$key, $key]); 81 | 82 | if($stmt->rowCount() >= 1){ 83 | $data = $stmt->fetchAll(); 84 | return $data; 85 | }else { 86 | return 0; 87 | } 88 | } 89 | // getCategoryById 90 | function getCategoryById($conn, $id){ 91 | $sql = "SELECT * FROM category WHERE id=?"; 92 | $stmt = $conn->prepare($sql); 93 | $stmt->execute([$id]); 94 | 95 | if($stmt->rowCount() >= 1){ 96 | $data = $stmt->fetch(); 97 | return $data; 98 | }else { 99 | return 0; 100 | } 101 | } 102 | 103 | //get 5 Categoies 104 | 105 | function get5Categoies($conn){ 106 | $sql = "SELECT * FROM category LIMIT 5"; 107 | $stmt = $conn->prepare($sql); 108 | $stmt->execute(); 109 | 110 | if($stmt->rowCount() >= 1){ 111 | $data = $stmt->fetchAll(); 112 | return $data; 113 | }else { 114 | return 0; 115 | } 116 | } 117 | 118 | 119 | 120 | function getUserByID($conn, $id){ 121 | $sql = "SELECT id, fname, username FROM users WHERE id=?"; 122 | $stmt = $conn->prepare($sql); 123 | $stmt->execute([$id]); 124 | 125 | if($stmt->rowCount() >= 1){ 126 | $data = $stmt->fetch(); 127 | return $data; 128 | }else { 129 | return 0; 130 | } 131 | } 132 | 133 | // getAllCategories 134 | function getAllCategories($conn){ 135 | $sql = "SELECT * FROM category ORDER BY category"; 136 | $stmt = $conn->prepare($sql); 137 | $stmt->execute(); 138 | 139 | if($stmt->rowCount() >= 1){ 140 | $data = $stmt->fetchAll(); 141 | return $data; 142 | }else { 143 | return 0; 144 | } 145 | } 146 | 147 | // Delete By ID 148 | function deleteById($conn, $id){ 149 | $sql = "DELETE FROM post WHERE post_id=?"; 150 | $stmt = $conn->prepare($sql); 151 | $res = $stmt->execute([$id]); 152 | 153 | if($res){ 154 | return 1; 155 | }else { 156 | return 0; 157 | } 158 | } -------------------------------------------------------------------------------- /admin/Post.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Posts 10 | 11 | 12 | 13 | 14 | 15 | 16 | 24 | 25 |
26 |

All Posts 27 | Add New

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 | 56 | 57 | 58 | 59 | 62 | 69 | 75 | 88 | 89 | 90 | 91 | 92 |
#TitleCategoryCommentsLikesAction
60 | 61 | 63 | 64 | 65 | 68 | 70 | 71 | 74 | 76 | Delete 77 | Edit 78 | 81 | Public 82 | Privet 83 | 84 | Public 85 | Privet 86 | 87 |
93 | 94 |
95 | Empty! 96 |
97 | 98 |
99 | 100 | 101 | 102 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /admin/post-edit.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Dashboard - Create Edit 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 31 | 32 |
33 |

Create New Post 34 | Posts

35 | 36 |
37 | 38 |
39 | 40 | 41 | 42 |
43 | 44 |
45 | 46 | 47 |
51 | 52 |
53 | 54 | 58 | 63 | 68 |
69 |
70 | 71 | 74 | 75 |
76 |
77 | 78 | 81 |
82 |
83 | 84 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /Category.php: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | <?php 24 | if (isset($_GET['category_id'])){ 25 | $c_id =$_GET['category_id']; 26 | $category = getCategoryById($conn, $c_id); 27 | if ($category == 0) { 28 | echo "Blog Category Page"; 29 | }else { 30 | echo "Blog | ".$category['category']; 31 | } 32 | }else { 33 | echo "Blog Category Page"; 34 | } 35 | ?> 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 |
46 |

47 | 50 | 51 |

52 | 53 |
54 | 55 |
56 |
57 | 58 | 60 | 61 | 62 | 63 |
64 |
65 | 69 | 70 |
71 | 72 |
73 | ... 74 |
75 |
76 | 80 |

...

81 | Read more 82 |
83 |
84 |
85 | 93 | 97 | 98 | 102 | 103 | 104 | 105 | Likes ( 106 | ) 109 | 110 | Comments ( 111 | 114 | ) 115 | 116 |
117 | 118 |
119 | 120 |
121 |
122 | 123 |
124 | 125 |
126 |
127 | No posts yet. 128 |
129 |
130 | 131 | 146 |
147 | 148 |
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /blog-view.php: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | Blog - <?=$post['post_title']?> 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 |
40 |
41 | 42 |
43 | 44 |
45 | ... 46 |
47 |
48 |

49 |
50 |
51 |
52 | 60 | 64 | 65 | 69 | 70 | 71 | 72 | Likes ( 73 | ) 76 | comments ( 77 | 80 | ) 81 | 82 |
83 | 84 |
85 | 86 |
89 | 90 |
Add comment
91 | 92 | 95 | 96 | 97 | 98 | 101 | 102 |
103 | 106 | 111 |
112 | 113 |

114 |
115 |
116 | 120 |
121 |
122 | 123 |
124 |
125 | @ 126 |

127 | 128 |
129 |

130 | 131 |
132 |
133 |
134 |
135 | 136 |
137 | 138 | 151 |
152 |
153 | 154 | 155 | 175 | 176 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /blog.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | <?php 17 | if(isset($_GET['search'])){ 18 | echo "search '".htmlspecialchars($_GET['search'])."'"; 19 | }else{ 20 | echo "Blog Page"; 21 | } ?> 22 | 23 | 24 | 25 | 26 | 27 | 28 | 44 | 45 |
46 |
47 | 48 | 49 |
50 |

51 | '".htmlspecialchars($_GET['search'])."'"; 54 | }?>

55 | 56 |
57 | ... 58 |
59 |
60 | 64 |

...

65 | Read more 66 |
67 |
68 |
69 | 77 | 81 | 82 | 86 | 87 | 88 | 89 | Likes ( 90 | ) 93 | 94 | Comments ( 95 | 98 | ) 99 | 100 |
101 | 102 |
103 | 104 |
105 |
106 | 107 |
108 | 109 |
110 | 111 |
112 | No search results found 113 | key = '".htmlspecialchars($_GET['search'])."'" ?> 114 |
115 | 116 |
117 | No posts yet. 118 |
119 | 120 |
121 | 122 | 137 |
138 |
139 | 140 | 141 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /css/richtext.min.css: -------------------------------------------------------------------------------- 1 | /* 2 | RichText: WYSIWYG editor developed as jQuery plugin 3 | 4 | @name RichText 5 | @author https://github.com/webfashionist - Bob Schockweiler - richtext@webfashion.eu 6 | 7 | Copyright (C) 2020 Bob Schockweiler ( richtext@webfashion.eu ) 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU Affero General Public License as published 11 | by the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Affero General Public License for more details. 18 | 19 | You should have received a copy of the GNU Affero General Public License 20 | along with this program. If not, see . 21 | */ 22 | 23 | .richText{position:relative;background-color:#fafafa;border:#efefef solid 1px;color:#333;width:100%}.richText .richText-form{font-family:Calibri,Verdana,Helvetica,sans-serif}.richText .richText-form label{display:block;padding:10px 15px}.richText .richText-form input[type=file],.richText .richText-form input[type=number],.richText .richText-form input[type=text],.richText .richText-form select{padding:10px 15px;border:#999 solid 1px;min-width:200px;width:100%}.richText .richText-form select{cursor:pointer}.richText .richText-form button{margin:10px 0;padding:10px 15px;background-color:#3498db;border:none;color:#fafafa;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.richText .richText-toolbar{position:sticky;top:0;min-height:20px;background-color:inherit;border-bottom:#efefef solid 1px}.richText .richText-toolbar .richText-length{font-family:Verdana,Helvetica,sans-serif;font-size:13px;vertical-align:middle;line-height:34px}.richText .richText-toolbar .richText-length .black{color:#000}.richText .richText-toolbar .richText-length .orange{color:orange}.richText .richText-toolbar .richText-length .red{color:red}.richText .richText-toolbar ul{padding-left:0;padding-right:0;margin-top:0;margin-bottom:0}.richText .richText-toolbar ul li{float:left;display:block;list-style:none}.richText .richText-toolbar ul li a{display:block;padding:10px 13px;border-right:#efefef solid 1px;cursor:pointer;-webkit-transition:background-color .4s;-moz-transition:background-color .4s;transition:background-color .4s}.richText .richText-toolbar ul li a .fa,.richText .richText-toolbar ul li a .far,.richText .richText-toolbar ul li a .fas,.richText .richText-toolbar ul li a svg{pointer-events:none}.richText .richText-toolbar ul li a .richText-dropdown-outer{display:none;position:absolute;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,.3);cursor:default}.richText .richText-toolbar ul li a .richText-dropdown-outer .richText-dropdown{position:relative;display:block;margin:3% auto 0 auto;background-color:#fafafa;border:#efefef solid 1px;min-width:100px;width:300px;max-width:90%;-webkit-box-shadow:0 0 5px 0 #333;-moz-box-shadow:0 0 5px 0 #333;box-shadow:0 0 5px 0 #333}.richText .richText-toolbar ul li a .richText-dropdown-outer .richText-dropdown .richText-dropdown-close{position:absolute;top:0;right:-23px;background:#fff;color:#333;cursor:pointer;font-size:20px;text-align:center;width:20px}.richText .richText-toolbar ul li a .richText-dropdown-outer ul.richText-dropdown{list-style:none}.richText .richText-toolbar ul li a .richText-dropdown-outer ul.richText-dropdown li{display:block;float:none;font-family:Calibri,Verdana,Helvetica,sans-serif}.richText .richText-toolbar ul li a .richText-dropdown-outer ul.richText-dropdown li a{display:block;padding:10px 15px;border-bottom:#efefef solid 1px}.richText .richText-toolbar ul li a .richText-dropdown-outer ul.richText-dropdown li a:hover{background-color:#fff}.richText .richText-toolbar ul li a .richText-dropdown-outer ul.richText-dropdown li.inline{margin:10px 6px;float:left}.richText .richText-toolbar ul li a .richText-dropdown-outer ul.richText-dropdown li.inline a{display:block;padding:0;margin:0;border:none;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;-webkit-box-shadow:0 0 10px 0 #999;-moz-box-shadow:0 0 10px 0 #999;box-shadow:0 0 10px 0 #999}.richText .richText-toolbar ul li a .richText-dropdown-outer ul.richText-dropdown li.inline a span{display:block;height:30px;width:30px;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}.richText .richText-toolbar ul li a .richText-dropdown-outer div.richText-dropdown{padding:10px 15px}.richText .richText-toolbar ul li a:hover{background-color:#fff}.richText .richText-toolbar ul li[data-disable=true]{opacity:.1}.richText .richText-toolbar ul li[data-disable=true] a{cursor:default}.richText .richText-toolbar ul li:not([data-disable=true]).is-selected .richText-dropdown-outer{display:block}.richText .richText-toolbar ul:after{display:block;content:"";clear:both}.richText .richText-toolbar:last-child{font-size:12px}.richText .richText-toolbar:after{display:block;clear:both;content:""}.richText .richText-editor{padding:20px;background-color:#fff;border-left:#fff solid 2px;font-family:Calibri,Verdana,Helvetica,sans-serif;height:300px;outline:0;overflow-y:scroll;overflow-x:auto}.richText .richText-editor[placeholder]:before{content:attr(placeholder);color:#555}.richText .richText-editor ol,.richText .richText-editor ul{margin:10px 25px}.richText .richText-editor table{margin:10px 0;border-spacing:0;width:100%}.richText .richText-editor table td,.richText .richText-editor table th{padding:10px;border:#efefef solid 1px}.richText .richText-editor:focus{border-left:#3498db solid 2px}.richText .richText-initial{margin-bottom:-4px;padding:10px;background-color:#282828;border:none;color:#3f3;font-family:Monospace,Calibri,Verdana,Helvetica,sans-serif;max-width:100%;min-width:100%;width:100%;min-height:400px;height:400px}.richText .richText-help{float:right;display:block;padding:10px 15px;cursor:pointer}.richText .richText-redo,.richText .richText-undo{float:left;display:block;padding:10px 15px;border-right:#efefef solid 1px;cursor:pointer}.richText .richText-redo.is-disabled,.richText .richText-undo.is-disabled{opacity:.4}.richText .richText-help-popup a{color:#3498db;text-decoration:underline}.richText .richText-help-popup hr{margin:10px auto 5px auto;border:none;border-top:#efefef solid 1px}.richText .richText-list.list-rightclick{position:absolute;background-color:#fafafa;border-right:#efefef solid 1px;border-bottom:#efefef solid 1px}.richText .richText-list.list-rightclick li{padding:5px 7px;cursor:pointer;list-style:none} 24 | -------------------------------------------------------------------------------- /js/jquery.richtext.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | RichText: WYSIWYG editor developed as jQuery plugin 3 | 4 | @name RichText 5 | @author https://github.com/webfashionist - Bob Schockweiler - richtext@webfashion.eu 6 | @license GNU AFFERO GENERAL PUBLIC LICENSE Version 3 7 | @preserve 8 | 9 | Copyright (C) 2020 Bob Schockweiler ( richtext@webfashion.eu ) 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU Affero General Public License as published 13 | by the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Affero General Public License for more details. 20 | 21 | You should have received a copy of the GNU Affero General Public License 22 | along with this program. If not, see . 23 | */ 24 | (function($){$.fn.richText=function(options){var settings=$.extend({bold:true,italic:true,underline:true,leftAlign:true,centerAlign:true,rightAlign:true,justify:true,ol:true,ul:true,heading:true,fonts:true,fontList:["Arial","Arial Black","Comic Sans MS","Courier New","Geneva","Georgia","Helvetica","Impact","Lucida Console","Tahoma","Times New Roman","Verdana"],fontColor:true,backgroundColor:true,fontSize:true,imageUpload:true,fileUpload:true,videoEmbed:true,urls:true,table:true,removeStyles:true,code:true,colors:[],fileHTML:"",imageHTML:"",translations:{title:"Title",white:"White",black:"Black",brown:"Brown",beige:"Beige",darkBlue:"Dark Blue",blue:"Blue",lightBlue:"Light Blue",darkRed:"Dark Red",red:"Red",darkGreen:"Dark Green",green:"Green",purple:"Purple",darkTurquois:"Dark Turquois",turquois:"Turquois",darkOrange:"Dark Orange",orange:"Orange",yellow:"Yellow",imageURL:"Image URL",fileURL:"File URL",linkText:"Link text",url:"URL",size:"Size",responsive:"Responsive",text:"Text",openIn:"Open in",sameTab:"Same tab",newTab:"New tab",align:"Align",left:"Left",justify:"Justify",center:"Center",right:"Right",rows:"Rows",columns:"Columns",add:"Add",pleaseEnterURL:"Please enter an URL",videoURLnotSupported:"Video URL not supported",pleaseSelectImage:"Please select an image",pleaseSelectFile:"Please select a file",bold:"Bold",italic:"Italic",underline:"Underline",alignLeft:"Align left",alignCenter:"Align centered",alignRight:"Align right",addOrderedList:"Ordered list",addUnorderedList:"Unordered list",addHeading:"Heading/title",addFont:"Font",addFontColor:"Font color",addBackgroundColor:"Background color",addFontSize:"Font size",addImage:"Add image",addVideo:"Add video",addFile:"Add file",addURL:"Add URL",addTable:"Add table",removeStyles:"Remove styles",code:"Show HTML code",undo:"Undo",redo:"Redo",save:"Save",close:"Close"},youtubeCookies:false,preview:false,placeholder:"",useSingleQuotes:false,height:0,heightPercentage:0,adaptiveHeight:false,id:"",class:"",useParagraph:false,maxlength:0,maxlengthIncludeHTML:false,callback:undefined,useTabForNext:false,save:false,saveCallback:undefined,saveOnBlur:0,undoRedo:true},options);var $inputElement=$(this);$inputElement.addClass("richText-initial");var $editor,$toolbarList=$("