├── .gitignore
├── .vscode
└── launch.json
├── Login
├── changepassword.php
├── confirmationcode.php
├── login.php
└── passwordRecover.php
├── README.md
├── api
├── comment
│ ├── delete.php
│ ├── edit.php
│ └── post.php
├── follow
│ ├── add.php
│ ├── delete.php
│ ├── get_followed_users.php
│ └── get_followers.php
├── like
│ └── post.php
├── messages
│ ├── DELETE.php
│ ├── Send.php
│ ├── get_friend_messages.php
│ └── message_writing_notifier
│ │ ├── add.php
│ │ └── delete.php
├── post
│ ├── delete.php
│ ├── edit.php
│ ├── post.php
│ └── shared
│ │ └── add.php
├── user
│ ├── GET.php
│ └── get_by_username.php
└── user_relation
│ ├── accept_request.php
│ ├── cancel_request.php
│ ├── decline_request.php
│ ├── send_request.php
│ └── unfriend_relation.php
├── chat.php
├── classes
├── Common.php
├── Config.php
├── Cookie.php
├── DB.php
├── Hash.php
├── Redirect.php
├── Session.php
├── Token.php
└── Validation.php
├── composer.json
├── composer.lock
├── core
├── init.php
└── rest_init.php
├── database
├── chat-database-24-2-2021.sql
└── chat.sql
├── functions
├── get_extension.php
├── sanitize.php
├── sanitize_id.php
├── sanitize_text.php
└── unique_key_array.php
├── index.php
├── layouts
├── chat
│ ├── ChatComponent.php
│ ├── discussions
│ │ └── get_user_discussions.php
│ ├── generate_chat_container.php
│ └── get_chat_friend_by_username.php
├── general
│ └── CreatePost.php
├── master_right
│ └── Right.php
├── post
│ ├── Post.php
│ ├── generate_last_post.php
│ ├── generate_post.php
│ ├── generate_post_creation_image.php
│ ├── generate_post_creation_video.php
│ └── generate_post_data_item.php
└── search
│ └── Search.php
├── models
├── Comment.php
├── Follow.php
├── Like.php
├── Message.php
├── Post.php
├── User.php
└── UserRelation.php
├── page_parts
├── basic
│ ├── header.php
│ ├── log-header.php
│ ├── master-left.php
│ ├── master-right.php
│ └── post_creator.php
├── errors
│ └── 404.php
├── profile
│ ├── contact-header.php
│ └── owner-profile-header.php
└── settings
│ └── left-panel.php
├── people.php
├── post-viewer.php
├── profile.php
├── public
├── assets
│ ├── audios
│ │ └── tone.mp3
│ └── images
│ │ ├── favicons
│ │ ├── android-chrome-192x192.png
│ │ ├── android-chrome-512x512.png
│ │ ├── apple-touch-icon.png
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ └── favicon.ico
│ │ ├── icons
│ │ ├── add-friend.png
│ │ ├── black-comment.png
│ │ ├── black-live.png
│ │ ├── black-more.png
│ │ ├── black-refresh.png
│ │ ├── black-search.png
│ │ ├── calendar.png
│ │ ├── change-image.png
│ │ ├── close.png
│ │ ├── dotted-more-white.png
│ │ ├── dotted-more.png
│ │ ├── down-arrow.png
│ │ ├── download.png
│ │ ├── explore-green.png
│ │ ├── explore-w.png
│ │ ├── eye.png
│ │ ├── follow-black.png
│ │ ├── follow-user.png
│ │ ├── followed.png
│ │ ├── friends.png
│ │ ├── full-screen-black.png
│ │ ├── full-screen.png
│ │ ├── group-w.png
│ │ ├── group.png
│ │ ├── home-green.png
│ │ ├── home-w.png
│ │ ├── is-friend.png
│ │ ├── left-arrow.png
│ │ ├── like-black-filled.png
│ │ ├── like-black.png
│ │ ├── like-white-filled.png
│ │ ├── like-white.png
│ │ ├── live-red.png
│ │ ├── live-w.png
│ │ ├── lock-white.png
│ │ ├── lock.png
│ │ ├── log.png
│ │ ├── logout.png
│ │ ├── media.png
│ │ ├── messages.png
│ │ ├── more.png
│ │ ├── multimedia.png
│ │ ├── no-result.png
│ │ ├── notification.png
│ │ ├── off-white.png
│ │ ├── off.png
│ │ ├── offline.png
│ │ ├── on.png
│ │ ├── online.png
│ │ ├── page.png
│ │ ├── profile-white.png
│ │ ├── profile.png
│ │ ├── public-white.png
│ │ ├── public.png
│ │ ├── received.png
│ │ ├── reply-black.png
│ │ ├── reply.png
│ │ ├── right-arrow.png
│ │ ├── save.png
│ │ ├── seen.png
│ │ ├── sent.png
│ │ ├── settings-w.png
│ │ ├── settings.png
│ │ ├── timeline.png
│ │ ├── unfollow-black.png
│ │ ├── unfriend-black.png
│ │ ├── unfriend-white.png
│ │ ├── unfriend.png
│ │ ├── user.png
│ │ ├── video.png
│ │ ├── videos.png
│ │ ├── white-close.png
│ │ ├── white-comment-filled.png
│ │ ├── white-comment.png
│ │ ├── white-eye.png
│ │ ├── white-logout.png
│ │ ├── white-refresh.png
│ │ └── white-search.png
│ │ ├── logos
│ │ ├── large.png
│ │ ├── large.xcf
│ │ └── logo512.png
│ │ └── preview.png
├── css
│ ├── chat.css
│ ├── create-post-style.css
│ ├── error.css
│ ├── global.css
│ ├── header.css
│ ├── index.css
│ ├── log-header.css
│ ├── login.css
│ ├── master-left-panel.css
│ ├── master-right-contacts.css
│ ├── post-viewer.css
│ ├── post.css
│ ├── profile.css
│ ├── search.css
│ └── settings.css
└── javascript
│ ├── chat.js
│ ├── config.js
│ ├── global.js
│ ├── index.js
│ ├── master-right.js
│ ├── post-viewer.js
│ ├── post.js
│ ├── profile.js
│ ├── search.js
│ └── settings.js
├── search.php
├── security
├── check_current_user.php
├── check_user_existence.php
├── generate_new_token_post.php
└── get_current_user.php
├── server
├── long-polling.php
├── message_writing_notifier.php
└── update_active_presence.php
├── settings-account.php
├── settings.php
└── z__important_notes.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor/
2 | !data/users
3 | data/users/*
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 |
8 | {
9 | //"debugServer": 4711, // Uncomment for debugging the adapter
10 | "name": "Listen for XDebug",
11 | "type": "php",
12 | "request": "launch",
13 | "port": 9001,
14 | "log": true
15 | },
16 | {
17 | //"debugServer": 4711, // Uncomment for debugging the adapter
18 | "name": "Launch",
19 | "request": "launch",
20 | "type": "php",
21 | "program": "${file}",
22 | "cwd": "${C:\\xampp\\php\\ext\\php_xdebug-3.0.2-7.4-vc15-x86_64.dll}",
23 | "externalConsole": false
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/Login/changepassword.php:
--------------------------------------------------------------------------------
1 | fetchUser("id", Session::get("u_id"));
20 |
21 | if(isset($_POST["save"])) {
22 | if(Token::check(Common::getInput($_POST, "token_password_save"), "reset-pasword")) {
23 | $validate->check($_POST, array(
24 | "password"=>array(
25 | "name"=>"Password",
26 | "required"=>true,
27 | "min"=>6
28 | /* (later)
29 | "strength"=>array(
30 |
31 | )*/
32 | ),
33 | "password_again"=>array(
34 | "name"=>"Repeated password",
35 | "required"=>true,
36 | "matches"=>"password"
37 | )
38 | ));
39 |
40 | if($validate->passed()) {
41 | if(Common::getInput($_POST, "email") != $user->getPropertyValue("email")) {
42 | $validate->addError("It seems that you change the email section which is not allowed !");
43 | } else {
44 | // Now we need to generate a salt hash, and then make a hashed password using that salt
45 | $newSalt = Hash::salt(16);
46 | $newPassword = Hash::make(Common::getInput($_POST, "password"), $newSalt);
47 |
48 | /*
49 | Here we can check if that hashed password already exists in database, and if so we generate other hash
50 | but in sake of simplicity we just update the password and salt anyway !
51 | */
52 | $user->setPropertyValue("password", $newPassword);
53 | $user->setPropertyValue("salt", $newSalt);
54 |
55 | $user->update();
56 |
57 | // At the bottom in html code add a div where you check if this flash is exists, if so print its content
58 | Session::flash("Password_changed", "Your password has been changed successfully.");
59 | }
60 | }
61 |
62 | foreach($validate->errors() as $error) {
63 | echo $error . " ";
64 | }
65 | }
66 | }
67 |
68 | ?>
69 |
70 |
71 |
72 |
73 |
74 |
75 | Password recovery
76 |
77 |
78 |
79 |
85 |
86 |
87 |
88 |
89 |
90 |
93 |
New Password
94 |
Choose a new password
95 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/Login/confirmationcode.php:
--------------------------------------------------------------------------------
1 | check($_POST, array(
19 | "code"=>array(
20 | "name"=>"Confirmation code",
21 | "required"=>true,
22 | "max"=>16
23 | )
24 | ));
25 |
26 | if($validate->passed()) {
27 | if(Session::get("email-confirmation") == Common::getInput($_POST, "code")) {
28 | // Here the confirmation code is good
29 | Session::delete("email-confirmation");
30 | Session::put("password-change-allow", "allowed");
31 | Redirect::to("changepassword.php");
32 | } else {
33 | $validate->addError("Invalide confirmation code");
34 | }
35 | }
36 |
37 | foreach($validate->errors() as $error) {
38 | echo $error . " ";
39 | }
40 | }
41 | }
42 |
43 | ?>
44 |
45 |
46 |
47 |
48 |
49 |
50 | Password recovery
51 |
52 |
53 |
54 |
60 |
61 |
62 |
63 |
64 |
65 |
Email Confirmation
66 |
We sent a confirmation code into your email, copy and past it here
67 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/Login/passwordRecover.php:
--------------------------------------------------------------------------------
1 | check($_POST, array(
15 | "email"=>array(
16 | "name"=>"Email",
17 | "required"=>true,
18 | "max"=>255,
19 | "min"=>6,
20 | "email"=>true
21 | )
22 | ));
23 |
24 | if($validate->passed()) {
25 | $exists = $user->fetchUser("email", Common::getInput($_POST, "email"));
26 | if($exists) {
27 | $conf_code = substr(Hash::unique(), 16, 16);
28 | // Code to send conf code
29 | $mg = new Mailgun("YOUR_KEY");
30 | $domain = "YOUR_DOMAIN";
31 | # Make the call to the client.
32 | try {
33 | $result = $mg->sendMessage($domain, array(
34 | 'from' => '',
35 | 'to' => '<' . $user->getPropertyValue("email") . '>',
36 | 'subject' => "Confirmation code",
37 | 'text' => $conf_code
38 | ));
39 |
40 | /* We'll use email-confirmation sesion variable in the next page to see if the user pass from this process,
41 | If the user try directly to go to the next page, he'll not be able to access it because email-confirmation
42 | session variable will not be set here and we redirect him to login page*/
43 | Session::put("email-confirmation", $conf_code);
44 |
45 | // We'll need this variable to fetch the user data in th next pages of password recovery
46 | Session::put("u_id", $user->getPropertyValue("id"));
47 | $user->fetchUser("email", Common::getInput($_POST, "email"));
48 | Redirect::to("confirmationcode.php");
49 | } catch(Exception $e) {
50 | $validate->addError("There's a problem while sending the confirmation code.");
51 | $validate->addError("If send message throws an error about ssl certificat, read [IMPORTANT#5] in Z_IMPORTANT.txt file in root directory to resolve this problem!");
52 | }
53 |
54 | } else {
55 | // Print error message
56 | echo "There's no user with this email address !";
57 | }
58 | } else {
59 | // Here instead of printing out errors we can put them in an array and use them in proper html labels
60 | foreach($validate->errors() as $error) {
61 | echo $error . " ";
62 | }
63 | }
64 | }
65 | }
66 |
67 | ?>
68 |
69 |
70 |
71 |
72 |
73 |
74 | Password recovery
75 |
76 |
77 |
78 |
84 |
85 |
86 |
87 |
88 |
89 |
Password recovery
90 |
Enter your email and click send button to get a confirmation code on your email box.
91 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | VOID47 Chat Application
2 |
3 | This is a real-time chat application written in pure PHP/MYSQL.
4 |
5 |
--------------------------------------------------------------------------------
/api/comment/delete.php:
--------------------------------------------------------------------------------
1 | "comment id required !",
20 | "success"=>false
21 | ));
22 | }
23 |
24 | $post_id = sanitize_id($_POST["comment_id"]);
25 |
26 | $comment = new Comment();
27 | $comment->set_property("id", $post_id);
28 | if($comment->delete()) {
29 | echo 1;
30 | } else {
31 | echo -1;
32 | }
--------------------------------------------------------------------------------
/api/comment/edit.php:
--------------------------------------------------------------------------------
1 | "comment id required !",
21 | "success"=>false
22 | ));
23 | }
24 |
25 | if(!isset($_POST["new_comment"])) {
26 | echo json_encode(array(
27 | "message"=>"new comment required !",
28 | "success"=>false
29 | ));
30 | }
31 |
32 | $comment_id = sanitize_id($_POST["comment_id"]);
33 | $new_comment = sanitize_text($_POST["new_comment"]);
34 |
35 | $comment = new Comment();
36 | $comment->fetch_comment($comment_id);
37 |
38 | $comment->set_property("comment_text", $new_comment);
39 |
40 | if($comment->update()) {
41 | echo $new_comment;
42 | } else {
43 | echo -1;
44 | }
--------------------------------------------------------------------------------
/api/comment/post.php:
--------------------------------------------------------------------------------
1 | "post id required !",
23 | "success"=>false
24 | ));
25 | }
26 |
27 | if(!isset($_POST["current_user_id"])) {
28 | echo json_encode(array(
29 | "message"=>"Current user id required !",
30 | "success"=>false
31 | ));
32 | }
33 |
34 | if(!isset($_POST["comment_owner"])) {
35 | echo json_encode(array(
36 | "message"=>"comment owner required !",
37 | "success"=>false
38 | ));
39 | }
40 |
41 | if(!isset($_POST["comment_owner"]) || empty($_POST["comment_owner"])) {
42 | echo json_encode(array(
43 | "message"=>"comment should not be empty or unset !",
44 | "success"=>false
45 | ));
46 | }
47 |
48 | $comment_owner = sanitize_id($_POST["comment_owner"]);
49 | $post_id = sanitize_id($_POST["post_id"]);
50 | $comment_text = sanitize_text($_POST["comment_text"]);
51 | $current_user_id = sanitize_id($_POST["current_user_id"]);
52 |
53 | $comment = new Comment();
54 | $comment->setData(array(
55 | "comment_owner"=>$comment_owner,
56 | "post_id"=>$post_id,
57 | "comment_text"=>$comment_text
58 | ));
59 | $comment = $comment->add();
60 | // Right now, we don't now the id of added comment
61 | $captured_id = DB::getInstance()->query("SELECT id FROM comment WHERE comment_owner = ? AND comment_date = ?", array(
62 | "comment_owner"=>$comment->get_property("comment_owner"),
63 | "comment_date"=>$comment->get_property("comment_date")
64 | ))->results()[0]->id;
65 |
66 | $comment->set_property("id", $captured_id);
67 |
68 |
69 | $post_manager = Post_Manager::generate_comment($comment, $current_user_id);
70 |
71 | echo $post_manager;
72 |
73 | /* you can only add and return the following array, but we want to return a comment component
74 | echo json_encode(array(
75 | "message"=>"Comment added successfully !",
76 | "success"=>true
77 | ));*/
--------------------------------------------------------------------------------
/api/follow/add.php:
--------------------------------------------------------------------------------
1 | "You should provide current_user_id as post form input",
20 | "success"=>false
21 | )
22 | );
23 |
24 | exit();
25 | }
26 | if(!isset($_POST["current_profile_id"])) {
27 | echo json_encode(
28 | array(
29 | "message"=>"You should provide followed_id as post form input",
30 | "success"=>false
31 | )
32 | );
33 |
34 | exit();
35 | }
36 |
37 | $follower = $_POST["current_user_id"];
38 | $followed = $_POST["current_profile_id"];
39 |
40 | /*
41 | Here we can't allow user to follow himself because we create a UNIQUE constraint(follower_id, followed_id) in the database,
42 | If you want to allow user follow himself, remove the constraint and also remove the following if statement
43 | */
44 | if($follower === $followed) {
45 | echo json_encode(
46 | array(
47 | "message"=>"You can't follow yourself",
48 | "success"=>false
49 | )
50 | );
51 |
52 | exit();
53 | }
54 |
55 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
56 | if(($follower = sanitize_id($follower)) &&
57 | User::user_exists("id", $follower)) {
58 | // Same check here with the followed user
59 | if(isset($followed) &&
60 | ($followed = sanitize_id($followed)) &&
61 | User::user_exists("id", $followed)) {
62 | if(Follow::follow_exists($follower, $followed)) {
63 | echo json_encode(
64 | array(
65 | "message"=>"The follower user is already following the followed user",
66 | "success"=>false
67 | )
68 | );
69 | } else {
70 | // Now we know the follower id is valid as well as the followed id, now we can add it to our database
71 | $follow = new Follow();
72 | $follow->set_data(array(
73 | "follower"=>$follower,
74 | "followed"=>$followed
75 | ));
76 | $follow->add();
77 |
78 | echo json_encode(
79 | array(
80 | "message"=>"user with id: " . $follower . " followed user with id: " . $followed . " successfully !",
81 | "success"=>true
82 | )
83 | );
84 | }
85 | } else {
86 | echo json_encode(
87 | array(
88 | "message"=>"followed id is either not valid or not exists in our db",
89 | "success"=>false
90 | )
91 | );
92 | }
93 | } else {
94 | echo json_encode(
95 | array(
96 | "message"=>"follower id is either not valid or not exists in our db",
97 | "success"=>false
98 | )
99 | );
100 | }
--------------------------------------------------------------------------------
/api/follow/delete.php:
--------------------------------------------------------------------------------
1 | "You should provide current_user_id as post form input",
20 | "success"=>false
21 | )
22 | );
23 |
24 | exit();
25 | }
26 | if(!isset($_POST["current_profile_id"])) {
27 | echo json_encode(
28 | array(
29 | "message"=>"You should provide followed_id as post form input",
30 | "success"=>false
31 | )
32 | );
33 |
34 | exit();
35 | }
36 |
37 | $follower = $_POST["current_user_id"];
38 | $followed = $_POST["current_profile_id"];
39 |
40 | /*
41 | Here we can't allow user to follow himself because we create a UNIQUE constraint(follower_id, followed_id) in the database,
42 | If you want to allow user follow himself, remove the constraint and also remove the following if statement
43 | */
44 | if($follower === $followed) {
45 | echo json_encode(
46 | array(
47 | "message"=>"You can't unfollow yourself",
48 | "success"=>false
49 | )
50 | );
51 |
52 | exit();
53 | }
54 |
55 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
56 | if(($follower = sanitize_id($follower)) &&
57 | User::user_exists("id", $follower)) {
58 | // Same check here with the followed user
59 | if(($followed = sanitize_id($followed)) &&
60 | User::user_exists("id", $followed)) {
61 | if(Follow::follow_exists($follower, $followed)) {
62 |
63 | $follow = new Follow();
64 |
65 | $follow->set_data(array(
66 | "follower"=>$follower,
67 | "followed"=>$followed
68 | ));
69 |
70 | $follow->fetch_follow();
71 |
72 | $follow->delete();
73 |
74 | echo json_encode(
75 | array(
76 | "message"=>"The follower with id: $follower unfollows the user with id: $followed successully !",
77 | "success"=>true
78 | )
79 | );
80 | } else {
81 | echo json_encode(
82 | array(
83 | "message"=>"The user with id: $follower cannot unfollow the user with id: $followed because he is not followed him !",
84 | "success"=>false
85 | )
86 | );
87 | }
88 | } else {
89 | echo json_encode(
90 | array(
91 | "message"=>"followed id is either not valid or not exists in our db",
92 | "success"=>false
93 | )
94 | );
95 | }
96 | } else {
97 | echo json_encode(
98 | array(
99 | "message"=>"follower id is either not valid or not exists in our db",
100 | "success"=>false
101 | )
102 | );
103 | }
--------------------------------------------------------------------------------
/api/follow/get_followed_users.php:
--------------------------------------------------------------------------------
1 | "You should provide user_id as query string parameter along with path",
20 | "success"=>false
21 | )
22 | );
23 |
24 | exit();
25 | }
26 |
27 | $user_id = $_GET["user_id"];
28 |
29 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
30 | if(($user_id = sanitize_id($_GET["user_id"])) &&
31 | User::user_exists("id", $user_id)) {
32 | // If the user has followers(at least one we get them as array and encode them and return the json array)
33 | $followed_users = Follow::get_followed_users($user_id);
34 | if(count($followed_users) > 0) {
35 | $followed_users = json_encode($followed_users);
36 | echo json_encode(
37 | array(
38 | "followers"=>$followed_users,
39 | "message"=>"followed users return successfully !",
40 | "success"=>true
41 | )
42 | );
43 | } else {
44 | echo json_encode(
45 | array(
46 | "followers"=>null,
47 | "message"=>"This user follows no one.",
48 | "success"=>true
49 | )
50 | );
51 | }
52 | } else {
53 | echo json_encode(
54 | array(
55 | "message"=>"user with id: $user_id is either not valid or not exists in our db",
56 | "success"=>false
57 | )
58 | );
59 | }
--------------------------------------------------------------------------------
/api/follow/get_followers.php:
--------------------------------------------------------------------------------
1 | "You should provide user_id as query string parameter along with path",
20 | "success"=>false
21 | )
22 | );
23 |
24 | exit();
25 | }
26 |
27 | $user_id = $_GET["user_id"];
28 |
29 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
30 | if(($user_id = sanitize_id($_GET["user_id"])) &&
31 | User::user_exists("id", $user_id)) {
32 |
33 | // If the user has followers(at least one we get them as array and encode them and return the json array)
34 | $followers = Follow::get_user_followers($user_id);
35 | if(count($followers) > 0) {
36 | $followers = json_encode($followers);
37 | echo json_encode(
38 | array(
39 | "followers"=>$followers,
40 | "message"=>"followers return successfully !",
41 | "success"=>true
42 | )
43 | );
44 | } else {
45 | echo json_encode(
46 | array(
47 | "followers"=>null,
48 | "message"=>"This user has no followers.",
49 | "success"=>true
50 | )
51 | );
52 | }
53 | } else {
54 | echo json_encode(
55 | array(
56 | "message"=>"user id is either not valid or not exists in our db",
57 | "success"=>false
58 | )
59 | );
60 | }
--------------------------------------------------------------------------------
/api/like/post.php:
--------------------------------------------------------------------------------
1 | "post id required !",
20 | "success"=>false
21 | ));
22 | }
23 |
24 | if(!isset($_POST["current_user_id"])) {
25 | echo json_encode(array(
26 | "message"=>"Current user id required !",
27 | "success"=>false
28 | ));
29 | }
30 |
31 | $post_id = sanitize_id($_POST["post_id"]);
32 | $current_user_id = sanitize_id($_POST["current_user_id"]);
33 |
34 | $like = new Like();
35 | $like->setData(array(
36 | "post_id"=>$post_id,
37 | "user_id"=>$current_user_id,
38 | ));
39 | $res = $like->add();
40 |
41 | /*
42 | 1: added successfully
43 | 2: deleted successfully
44 | -1: there's a problem
45 | */
46 | if($res == 1) {
47 | echo 1;
48 | } else if ($res == -1) {
49 | if($like->delete()) {
50 | echo 2;
51 | }
52 | } else {
53 | echo -1;
54 | }
55 |
56 | /* you can only add and return the following array, but we want to return a comment component
57 | echo json_encode(array(
58 | "message"=>"Comment added successfully !",
59 | "success"=>true
60 | ));*/
--------------------------------------------------------------------------------
/api/messages/DELETE.php:
--------------------------------------------------------------------------------
1 | set_property("id", $message_id);
31 |
32 | if($is_received == 'yes') {
33 | $message_manager->delete_received_message();
34 | } else {
35 | $message_manager->delete_sended_message();
36 | }
37 |
38 | echo json_encode(array(
39 | "success"=>true,
40 | "message"=>'message deleted successfully !'
41 | ));
42 | } else {
43 | echo json_encode(array(
44 | "success"=>false,
45 | "message"=>'message not exists'
46 | ));
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/api/messages/Send.php:
--------------------------------------------------------------------------------
1 | fetchUser("id", (int)$sender);
36 |
37 | $message_model = new Message();
38 | $message_model->set_data(array(
39 | "sender"=>$sender,
40 | "receiver"=>$receiver,
41 | "message"=>$message,
42 | "message_date"=>$message_date
43 | ));
44 |
45 | $chat_wrapper = new ChatComponent();
46 |
47 | if($is_reply) {
48 | $message_model->set_property("is_reply", 1);
49 | $message_model->set_property("reply_to", $replied_message_id);
50 | $res = $message_model->add();
51 |
52 | // Get original message and reply message creators
53 | $original_message_creator = Message::get_creator_by_id($replied_message_id);
54 | $original_message_creator = $original_message_creator->message_creator;
55 | $reply_message_creator = Message::get_creator_by_id($res);
56 | $reply_message_creator = $reply_message_creator->message_creator;
57 |
58 | // Then we generate a replied message components
59 | // Here we need to pass the original message id, reply_message_id, original message creator and reply creator
60 | $chat_component = $chat_wrapper->generate_sender_reply_message($replied_message_id, $res, $original_message_creator, $reply_message_creator);
61 | echo $chat_component;
62 | } else {
63 | $res = $message_model->add();
64 |
65 | $message_obj = Message::get_message_obj("id", $res);
66 |
67 | $chat_wrapper = new ChatComponent();
68 | $chat_component = $chat_wrapper->generate_current_user_message($sender_user, $message_obj, $message_date);
69 | echo $chat_component;
70 | }
71 |
72 | } else {
73 | echo json_encode(
74 | array(
75 | "message"=>"receiver's id is either not valid or not exists in our db",
76 | "success"=>false
77 | )
78 | );
79 | }
80 | } else {
81 | echo json_encode(
82 | array(
83 | "message"=>"sender's id is either not valid or not exists in our db",
84 | "success"=>false
85 | )
86 | );
87 | }
--------------------------------------------------------------------------------
/api/messages/get_friend_messages.php:
--------------------------------------------------------------------------------
1 | fetchUser("id", $sender);
31 | $receiver_user = new User();
32 | $receiver_user->fetchUser("id", $receiver);
33 |
34 | $chat_component = new ChatComponent();
35 |
36 | $sender_to_receiver = Message::getMessages($sender, $receiver);
37 | $receiver_to_sender = Message::getMessages($receiver, $sender);
38 | $messages = array_merge($sender_to_receiver, $receiver_to_sender);
39 |
40 | function sortFunction($a, $b) {
41 | return strtotime($a->create_date) - strtotime($b->create_date);
42 | }
43 |
44 | usort($messages, "sortFunction");
45 | $content = '';
46 |
47 | foreach($messages as $message) {
48 | if($message->message_creator == $sender) {
49 | if($message->is_reply) {
50 | //Now we have a message as a reply, so first we have reply_message_id
51 | $reply_message_id = $message->id;
52 | $message_obj = Message::get_message_obj('id', $reply_message_id);
53 |
54 | // Then, we need to fetch the message that the above is a reply to
55 | $original_message_id = $message->reply_to;
56 |
57 | $original_creator = Message::get_creator_by_id($original_message_id);
58 | $original_creator = $original_creator->message_creator;
59 | $reply_creator = Message::get_creator_by_id($reply_message_id);
60 | $reply_creator = $reply_creator->message_creator;
61 | // Here we need to pass the original message id, reply_message_id, original message creator and reply creator
62 | $content .= $chat_component->generate_sender_reply_message($original_message_id, $reply_message_id, $original_creator, $reply_creator);
63 | } else {
64 | $content .= $chat_component->generate_current_user_message($sender_user, $message, $message->create_date);
65 | }
66 | } else {
67 | if($message->is_reply) {
68 | //Now we have a message as a reply, so first we have reply_message_id
69 | $reply_message_id = $message->id;
70 | $message_obj = Message::get_message_obj('id', $reply_message_id);
71 |
72 | // Then, we need to fetch the message that the above is a reply to
73 | $original_message_id = $message->reply_to;
74 |
75 | $original_creator = Message::get_creator_by_id($original_message_id);
76 | $original_creator = $original_creator->message_creator;
77 | $reply_creator = Message::get_creator_by_id($reply_message_id);
78 | $reply_creator = $reply_creator->message_creator;
79 |
80 | $content .= $chat_component->generate_received_reply_message($original_message_id, $reply_message_id, $original_creator, $reply_creator);
81 | } else {
82 | $content .= $chat_component->generate_friend_message($receiver_user, $message, $message->create_date);
83 | }
84 | }
85 | }
86 | Message::dump_channel($receiver, $sender);
87 | echo $content;
88 |
89 | } else {
90 | echo json_encode(
91 | array(
92 | "message"=>"receiver's id is either not valid or not exists in our db",
93 | "success"=>false
94 | )
95 | );
96 | }
97 | } else {
98 | echo json_encode(
99 | array(
100 | "message"=>"sender's id is either not valid or not exists in our db",
101 | "success"=>false
102 | )
103 | );
104 | }
--------------------------------------------------------------------------------
/api/messages/message_writing_notifier/add.php:
--------------------------------------------------------------------------------
1 | set_property("message_sender", $sender);
31 | $message_model->set_property("message_receiver", $receiver);
32 |
33 | $message_model->add_writing_message_notifier();
34 | } else {
35 | echo json_encode(
36 | array(
37 | "message"=>"receiver's id is either not valid or not exists in our db",
38 | "success"=>false
39 | )
40 | );
41 | }
42 | } else {
43 | echo json_encode(
44 | array(
45 | "message"=>"sender's id is either not valid or not exists in our db",
46 | "success"=>false
47 | )
48 | );
49 | }
--------------------------------------------------------------------------------
/api/messages/message_writing_notifier/delete.php:
--------------------------------------------------------------------------------
1 | set_property("message_sender", $sender);
31 | $message_model->set_property("message_receiver", $receiver);
32 |
33 | $message_model->delete_writing_message_notifier();
34 | } else {
35 | echo json_encode(
36 | array(
37 | "message"=>"receiver's id is either not valid or not exists in our db",
38 | "success"=>false
39 | )
40 | );
41 | }
42 | } else {
43 | echo json_encode(
44 | array(
45 | "message"=>"sender's id is either not valid or not exists in our db",
46 | "success"=>false
47 | )
48 | );
49 | }
--------------------------------------------------------------------------------
/api/post/delete.php:
--------------------------------------------------------------------------------
1 | "post id required !",
20 | "success"=>false
21 | ));
22 | return;
23 | }
24 | if(!isset($_POST["post_owner"])) {
25 | echo json_encode(array(
26 | "message"=>"post owner id required !",
27 | "success"=>false
28 | ));
29 | return;
30 | }
31 |
32 | $post_id = sanitize_id($_POST["post_id"]);
33 | $post_owner = sanitize_id($_POST["post_owner"]);
34 |
35 | if(Post::exists($post_id)) {
36 | /*
37 | We first need to make shure that the post exists with that id, then we need to check if the user
38 | who makes the request is the owner of the post because we only allow the owner of the post to delete it.
39 | */
40 | if($post_owner == Post::get_post_owner($post_id)->post_owner) {
41 |
42 | Like::delete_post_likes($post_id);
43 | Comment::delete_post_comments($post_id);
44 |
45 | $post = new Post();
46 | $post->set_property('post_id', $post_id);
47 | $post->delete();
48 |
49 | /*
50 | When the original post is deleted we want to edit all postst that are a shared post of that post and edit the column
51 | shared_post_id to empty
52 | */
53 | $shared_posts = Post::get('post_shared_id', $post_id);
54 | foreach($shared_posts as $p) {
55 | $p->set_property('post_shared_id', null);
56 | $test = $p->update();
57 | }
58 |
59 | echo json_encode(array(
60 | "success"=>true,
61 | "message"=>'post deleted successfully !'
62 | ));
63 | } else {
64 | echo json_encode(array(
65 | "success"=>false,
66 | "message"=>'user\'s id is invalide!'
67 | ));
68 | }
69 |
70 | } else {
71 | echo json_encode(array(
72 | "success"=>false,
73 | "message"=>'post not exists'
74 | ));
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/api/post/edit.php:
--------------------------------------------------------------------------------
1 | "post id required !",
21 | "success"=>false
22 | ));
23 | }
24 |
25 | if(!isset($_POST["new_post_text"])) {
26 | echo json_encode(array(
27 | "message"=>"new post text required !",
28 | "success"=>false
29 | ));
30 | }
31 |
32 | $post_id = sanitize_id($_POST["post_id"]);
33 | $new_post_text = sanitize_text($_POST["new_post_text"]);
34 |
35 | $post = new Post();
36 | $post->fetchPost($post_id);
37 | $post->set_property('text_content', $new_post_text);
38 |
39 | if($post->update()) {
40 | echo $new_post_text;
41 | } else {
42 | echo -1;
43 | }
--------------------------------------------------------------------------------
/api/post/shared/add.php:
--------------------------------------------------------------------------------
1 | "post owner id required !",
20 | "success"=>false
21 | ));
22 | }
23 |
24 | if(!isset($_POST["post_visibility"])) {
25 | echo json_encode(array(
26 | "message"=>"post_visibility required !",
27 | "success"=>false
28 | ));
29 | }
30 |
31 | if(!isset($_POST["post_place"])) {
32 | echo json_encode(array(
33 | "message"=>"post_place required !",
34 | "success"=>false
35 | ));
36 | }
37 |
38 | if(!isset($_POST["post_shared_id"])) {
39 | echo json_encode(array(
40 | "message"=>"post shared id required !",
41 | "success"=>false
42 | ));
43 | }
44 |
45 | $post_owner = sanitize_id($_POST["post_owner"]);
46 | $post_visibility = is_numeric($_POST["post_visibility"]) ? $_POST["post_visibility"] : 1;
47 | $post_place = is_numeric($_POST["post_place"]) ? $_POST["post_place"] : 1;
48 | $post_shared_id = sanitize_id($_POST["post_shared_id"]);
49 |
50 | /*
51 | Text cotent is not necessary because we make edit later; so that the user when he shares the post then he could edit it
52 | and add his own text content. We set photo and video directories to null because we don't want them in shared post;
53 | In shared post the user could only change text, post visibility, or post place
54 | We set is_shared to 1 because it's a shared post and we set the original_post to post_shared_id
55 | */
56 |
57 | $post = new Post();
58 | $post->setData(array(
59 | "post_owner"=> $post_owner,
60 | "post_visibility"=> $post_visibility,
61 | "post_place"=> $post_place,
62 | "text_content"=> "",
63 | "picture_media"=>null,
64 | "video_media"=>null,
65 | "is_shared"=>1,
66 | "post_shared_id"=>$post_shared_id
67 | ));
68 |
69 | $res = $post->add();
70 |
71 | if($res) {
72 | echo 1;
73 | } else {
74 | echo -1;
75 | }
--------------------------------------------------------------------------------
/api/user/GET.php:
--------------------------------------------------------------------------------
1 | fetchUser("id", $id)) {
17 | echo json_encode($user);
18 | } else {
19 | echo json_encode(array(
20 | 'problem'=>'Invalid data provided or the id is not within our database'
21 | ));
22 | }
23 |
--------------------------------------------------------------------------------
/api/user/get_by_username.php:
--------------------------------------------------------------------------------
1 | fetchUser("username", $username)) {
21 | echo json_encode(array(
22 | "user"=>$user,
23 | "success"=>true
24 | ));
25 | } else {
26 | echo json_encode(array(
27 | "success"=>false
28 | ));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/api/user_relation/accept_request.php:
--------------------------------------------------------------------------------
1 | "You can't add yourself or cancel request",
28 | "success"=>false
29 | )
30 | );
31 |
32 | exit();
33 | }
34 |
35 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
36 | if(($current_user) &&
37 | User::user_exists("id", $current_user)) {
38 | // Same check here with the followed user
39 | if($friend &&
40 | User::user_exists("id", $friend)) {
41 |
42 | $user_relation = new UserRelation();
43 |
44 | $user_relation->set_property("from", $friend);
45 | $user_relation->set_property("to", $current_user);
46 |
47 | if($user_relation->accept_request()) {
48 | echo json_encode(
49 | array(
50 | "message"=>"user with id: $current_user accepts a request sent by user with id: $friend successfully !",
51 | "success"=>true,
52 | "error"=>false
53 | )
54 | );
55 | } else {
56 | echo json_encode(
57 | array(
58 | "message"=>"user with id: $friend did not send a friend request to user with id: $current_user",
59 | "success"=>false,
60 | "error"=>false
61 | )
62 | );
63 | }
64 |
65 | } else {
66 | echo json_encode(
67 | array(
68 | "message"=>"friend's id is either not valid or not exists in our db",
69 | "error"=>true
70 | )
71 | );
72 | }
73 | } else {
74 | echo json_encode(
75 | array(
76 | "message"=>"your id is either not valid or not exists in our db",
77 | "error"=>true
78 | )
79 | );
80 | }
--------------------------------------------------------------------------------
/api/user_relation/cancel_request.php:
--------------------------------------------------------------------------------
1 | "You can't add yourself or cancel request",
28 | "success"=>false
29 | )
30 | );
31 |
32 | exit();
33 | }
34 |
35 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
36 | if(($current_user) &&
37 | User::user_exists("id", $current_user)) {
38 | // Same check here with the followed user
39 | if($friend &&
40 | User::user_exists("id", $friend)) {
41 |
42 | $user_relation = new UserRelation();
43 |
44 | $user_relation->set_property("from", $current_user);
45 | $user_relation->set_property("to", $friend);
46 |
47 | if($user_relation->cancel_request()) {
48 | echo json_encode(
49 | array(
50 | "message"=>"user with id: $current_user cancels a request that was sent to user with id: $friend successfully !",
51 | "success"=>true,
52 | "error"=>false
53 | )
54 | );
55 | } else {
56 | echo json_encode(
57 | array(
58 | "message"=>"user with id: $current_user is not a friend to user with id: $friend",
59 | "success"=>false,
60 | "error"=>false
61 | )
62 | );
63 | }
64 |
65 | } else {
66 | echo json_encode(
67 | array(
68 | "message"=>"friend's id is either not valid or not exists in our db",
69 | "error"=>true
70 | )
71 | );
72 | }
73 | } else {
74 | echo json_encode(
75 | array(
76 | "message"=>"your id is either not valid or not exists in our db",
77 | "error"=>true
78 | )
79 | );
80 | }
--------------------------------------------------------------------------------
/api/user_relation/decline_request.php:
--------------------------------------------------------------------------------
1 | "You can't add yourself or cancel request",
28 | "success"=>false
29 | )
30 | );
31 |
32 | exit();
33 | }
34 |
35 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
36 | if(($current_user) &&
37 | User::user_exists("id", $current_user)) {
38 | // Same check here with the followed user
39 | if($friend &&
40 | User::user_exists("id", $friend)) {
41 |
42 | $user_relation = new UserRelation();
43 |
44 | $user_relation->set_property("from", $friend);
45 | $user_relation->set_property("to", $current_user);
46 |
47 | if($user_relation->delete_relation()) {
48 | echo json_encode(
49 | array(
50 | "message"=>"user with id: $current_user decline a request that was sent to user with id: $friend successfully !",
51 | "success"=>true
52 | )
53 | );
54 | } else {
55 | echo json_encode(
56 | array(
57 | "message"=>"user with id: $friend did not send a friend request to user with id: $current_user",
58 | "success"=>false
59 | )
60 | );
61 | }
62 |
63 | } else {
64 | echo json_encode(
65 | array(
66 | "message"=>"friend's id is either not valid or not exists in our db",
67 | "success"=>false
68 | )
69 | );
70 | }
71 | } else {
72 | echo json_encode(
73 | array(
74 | "message"=>"your id is either not valid or not exists in our db",
75 | "success"=>false
76 | )
77 | );
78 | }
--------------------------------------------------------------------------------
/api/user_relation/send_request.php:
--------------------------------------------------------------------------------
1 | "You can't add yourself",
28 | "success"=>false
29 | )
30 | );
31 |
32 | exit();
33 | }
34 |
35 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
36 | if(($current_user) &&
37 | User::user_exists("id", $current_user)) {
38 | // Same check here with the followed user
39 | if($friend &&
40 | User::user_exists("id", $friend)) {
41 |
42 | $user_relation = new UserRelation();
43 |
44 | $user_relation->set_property("from", $current_user);
45 | $user_relation->set_property("to", $friend);
46 |
47 | if($user_relation->send_request()) {
48 | echo json_encode(
49 | array(
50 | "message"=>"user with id: $current_user sends a friend request to user with id: $friend",
51 | "success"=>true,
52 | "error"=>false
53 | )
54 | );
55 | } else {
56 | echo json_encode(
57 | array(
58 | "message"=>"user with id: $current_user elready send a friend request to user with id: $friend",
59 | "success"=>false,
60 | "error"=>false
61 | )
62 | );
63 | }
64 |
65 | } else {
66 | echo json_encode(
67 | array(
68 | "message"=>"friend's id is either not valid or not exists in our db",
69 | "error"=>true
70 | )
71 | );
72 | }
73 | } else {
74 | echo json_encode(
75 | array(
76 | "message"=>"your id is either not valid or not exists in our db",
77 | "error"=>true
78 | )
79 | );
80 | }
--------------------------------------------------------------------------------
/api/user_relation/unfriend_relation.php:
--------------------------------------------------------------------------------
1 | "You can't unfriend yourself",
28 | "success"=>false
29 | )
30 | );
31 |
32 | exit();
33 | }
34 |
35 | // Check if the follower id is set, and if it is numeric by calling sanitize_id, and exists in the database using user_exists
36 | if(($current_user) &&
37 | User::user_exists("id", $current_user)) {
38 | // Same check here with the followed user
39 | if($friend &&
40 | User::user_exists("id", $friend)) {
41 |
42 | $user_relation = new UserRelation();
43 |
44 | $user_relation->set_property("from", $current_user);
45 | $user_relation->set_property("to", $friend);
46 |
47 | if($user_relation->unfriend()) {
48 | echo json_encode(
49 | array(
50 | "message"=>"user with id: $current_user unfriends user with id: $friend successfully",
51 | "success"=>true,
52 | "error"=>false
53 | )
54 | );
55 | } else {
56 | echo json_encode(
57 | array(
58 | "message"=>"user with id: $current_user is not a friend of user with id: $friend or some invalide data is provided",
59 | "success"=>false,
60 | "error"=>false
61 | )
62 | );
63 | }
64 |
65 | } else {
66 | echo json_encode(
67 | array(
68 | "message"=>"friend's id is either not valid or not exists in our db",
69 | "success"=>false,
70 | "error"=>true
71 | )
72 | );
73 | }
74 | } else {
75 | echo json_encode(
76 | array(
77 | "message"=>"your id is either not valid or not exists in our db",
78 | "success"=>false,
79 | "error"=>true
80 | )
81 | );
82 | }
--------------------------------------------------------------------------------
/classes/Common.php:
--------------------------------------------------------------------------------
1 | getPropertyValue($key), $key_array)) {
26 | $key_array[$i] = $val->getPropertyValue($key);
27 | $temp_array[$i] = $val;
28 | }
29 | $i++;
30 | }
31 | return $temp_array;
32 | }
33 | }
--------------------------------------------------------------------------------
/classes/Config.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/classes/Cookie.php:
--------------------------------------------------------------------------------
1 | query("SELECT * FROM users");
7 | DB::getInstance()->get("user", array('username', '=', 'mouad'))
8 | 1^^^^ 2^^^^^^^^ ^ 3^^^^^
9 | 1: table,
10 | 2, 3: where username equals (=) mouad
11 | I think i will not use this method, i don't know we'll see !
12 | */
13 |
14 |
15 | class DB {
16 | // This will store database isntance if it is available
17 | private static $_instance = null;
18 | private $_pdo,
19 | $_error = false,
20 | $_query,
21 | $_results,
22 | $_count = 0;
23 |
24 | private function __construct() {
25 | $this->_pdo = new \PDO("mysql:host=" . Config::get('mysql/host') . ";dbname=" . Config::get('mysql/db'), Config::get('mysql/username'), Config::get('mysql/password'));
26 | }
27 |
28 | public static function getInstance() {
29 | /*
30 | This function will first check if we've already instaiated an instance it will simply return th instance,
31 | otherwise, we're going to instatiate it by creating a DB object;
32 | Hint: In case we use getInstance function twice on a page it will simply return the instance in the second
33 | call because it will be instantiated in the first call
34 | Hint: Notice that DB class cannot be instatiated outiside the class because the constructor is private
35 | */
36 |
37 | if(!isset(self::$_instance)) {
38 | self::$_instance = new DB();
39 | }
40 |
41 | return self::$_instance;
42 | }
43 |
44 | /*
45 | DB::getInstance()->query("SELECT * FROM user_info WHERE username = ?", array('MOUAD')); HERE MOUAD shuld be replaced
46 | in the first ? mark, if we have two parameters in query string, we need array of two values to replace each value to
47 | its correspondent place
48 | */
49 | public function query($sql, $params = array()) {
50 | /* Here we set error to false in order to not return error of some previous query */
51 | $this->error = false;
52 |
53 | // Check if the query has been prepared successfully
54 | // Here we assign and at the sametime check if a prepared statement has been set
55 | if($this->_query = $this->_pdo->prepare($sql)) {
56 | //Check if parameters exists (one at least should be exist) in case we need to bind them to the prepared statement
57 | if(count($params)) {
58 | $count = 1;
59 | foreach($params as $param) {
60 |
61 | /* FROM Documentation:
62 | Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the 1-indexed position of the parameter.
63 |
64 | We are using quesion mark in our queries
65 |
66 | if query = "SELECT * FROM user_info WHERE username = ? AND password = ?;
67 | ^ ^
68 | count:1 count:2
69 | count1 will point to username value which will be filled by first array element, and the same thing occur to the second part
70 | */
71 | $this->_query->bindValue($count, $param);
72 | $count++;
73 | }
74 | }
75 |
76 | // We're going to execute the query anyway regardless whether the query has params or not
77 | if($this->_query->execute()) {
78 | $this->_results = $this->_query->fetchAll(\PDO::FETCH_OBJ);
79 | $this->_count = $this->_query->rowCount();
80 | } else {
81 | $this->_error = true;
82 | }
83 | }
84 |
85 | // This allows you to chain everything with query function
86 | return $this;
87 | }
88 |
89 | public function pdo() {
90 | return $this->_pdo;
91 | }
92 |
93 | public function error() {
94 | return $this->_error;
95 | }
96 |
97 | public function results() {
98 | return $this->_results;
99 | }
100 |
101 | public function count() {
102 | return $this->_count;
103 | }
104 | }
105 |
106 |
107 |
--------------------------------------------------------------------------------
/classes/Hash.php:
--------------------------------------------------------------------------------
1 | array(
13 | 'host'=>'127.0.0.1',
14 | 'username'=>'root',
15 | 'password'=>'',
16 | 'db'=>'chat'
17 | ),
18 | "remember"=> array(
19 | 'cookie_name'=>'hash',
20 | 'cookie_expiry'=>604800
21 | ),
22 | "session"=>array(
23 | 'session_name'=>'user',
24 | "token_name" => "token",
25 | "tokens"=>array(
26 | "register"=>"register",
27 | "login"=>"login",
28 | "reset-pasword"=>"reset-pasword",
29 | "saveEdits"=>"saveEdits",
30 | "share-post"=>"share-post",
31 | "logout"=>"logout"
32 | )
33 | ),
34 | "root"=> array(
35 | 'path'=>'http://127.0.0.1/CHAT/',
36 | 'project_name'=>"CHAT"
37 | )
38 | );
39 |
40 | /*
41 |
42 | Here we create a user object with no data associated to it, and in the user constructor, we check if there's already a session
43 | if so we get the data from session which is the user id, and we fetch data from database of that id and we see if that id really
44 | exists in database, if it is, WE ASSIGN TRUE TO isLoggedIn
45 |
46 | Then we check if there's a cookie set in user machine and there's no session (This case is like we switch user's computer and later tries to logged in)
47 | in this case we fetch the hash of user's machine and see if this hash exists in users_session table in database, if hash matches we fetch user_id associated with it
48 | and use it to fetch user with that id. if the count of fetching is 1 then we give username, password and true($remember=true) to login function
49 |
50 | go to login function's comment
51 |
52 | */
53 |
54 | /*
55 | Notice that getting the root path is a common case for almost every page, so it's a good idea to put it in $root
56 | variable and only use root variable to reference it because init file also included in every page deal with config
57 | */
58 | $root = Config::get("root/path");
59 | $proj_name = Config::get("root/project_name");
60 |
61 | $user = new User();
62 |
63 | if(Cookie::exists(Config::get("remember/cookie_name")) && !Session::exists(Config::get("session/session_name"))) {
64 | $hash = Cookie::get(Config::get("remember/cookie_name"));
65 | $res = DB::getInstance()->query("SELECT * FROM users_session WHERE hash = ?", array($hash));
66 |
67 | if($res->count()) {
68 | $user->fetchUser("id", $res->results()[0]->user_id);
69 | $user->login($user->getPropertyValue("username"),$user->getPropertyValue("password"),true);
70 | }
71 | }
72 |
73 | if($user->getPropertyValue("isLoggedIn")) {
74 | $user->update_active();
75 | }
76 |
77 | /*
78 | IMPORTANT :
79 | 1 - sanitize function file could not be included here because the path will be relative to the caller script
80 | so if for example include it like following: include_once "functions/sanitize.php" only scripts in the root
81 | directory can use it, otherwise a fatal error will be thrown
82 | So you should include it along with autoload and init file in every page needs it
83 |
84 | 2 - Composer autoload file also follow the same rule you can't import it here
85 | */
--------------------------------------------------------------------------------
/core/rest_init.php:
--------------------------------------------------------------------------------
1 | array(
10 | 'host'=>'127.0.0.1',
11 | 'username'=>'root',
12 | 'password'=>'',
13 | 'db'=>'chat'
14 | ),
15 | "remember"=> array(
16 | 'cookie_name'=>'hash',
17 | 'cookie_expiry'=>604800
18 | ),
19 | "session"=>array(
20 | 'session_name'=>'user',
21 | "token_name" => "token",
22 | "tokens"=>array(
23 | "register"=>"register",
24 | "login"=>"login",
25 | "reset-pasword"=>"reset-pasword",
26 | "share-post"=>"share-post",
27 | "saveEdits"=>"saveEdits",
28 | "logout"=>"logout"
29 | )
30 | ),
31 | "root"=> array(
32 | 'path'=>'http://127.0.0.1/CHAT/'
33 | )
34 | );
--------------------------------------------------------------------------------
/functions/get_extension.php:
--------------------------------------------------------------------------------
1 | getPropertyValue($key), $key_array)) {
15 | $key_array[$i] = $val->getPropertyValue($key);
16 | $temp_array[$i] = $val;
17 | }
18 | $i++;
19 | }
20 | return $temp_array;
21 | }
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 |
2 | getPropertyValue("isLoggedIn")) {
15 | Redirect::to("login/login.php");
16 | }
17 |
18 | $welcomeMessage = '';
19 | if(Session::exists("register_success") && $user->getPropertyValue("username") == Session::get("new_username")) {
20 | $welcomeMessage = Session::flash("new_username") . ", " . Session::flash("register_success");
21 | }
22 |
23 |
24 | $current_user_id = $user->getPropertyValue("id");
25 | $journal_posts = Post::fetch_journal_posts($current_user_id);
26 | // Let's randomly sort array for now
27 | shuffle($journal_posts);
28 | /*usort($journal_posts, 'post_date_latest_sort');
29 |
30 | function post_date_latest_sort($post1, $post2) {
31 | return $post1->get_property('post_date') == $post2->get_property('post_date') ? 0 : ($post1->get_property('post_date') > $post2->get_property('post_date')) ? -1 : 1;
32 | }*/
33 | ?>
34 |
35 |
36 |
37 |
38 |
39 |
40 | V01D47
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
80 |
85 |
86 |
87 |
88 |
89 |
Try to add friends, or follow them to see their posts ..
90 | click here to go to the search page
91 |
92 | generate_post($post, $user);
97 | }
98 | }
99 | ?>
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/layouts/chat/discussions/get_user_discussions.php:
--------------------------------------------------------------------------------
1 | $discussion->message_receiver,
45 | "receiver"=>$discussion->message_creator
46 | );
47 |
48 | if(in_array($current_disc, $temp)) {
49 | continue;
50 | }
51 |
52 | $temp[] = array(
53 | "sender"=>$discussion->message_creator,
54 | "receiver"=>$discussion->message_receiver
55 | );
56 | $result[] = $discussion;
57 | }
58 |
59 | $content = '';
60 | foreach($result as $discussion) {
61 | $chat_comp = new ChatComponent();
62 |
63 | $content .= $chat_comp->generate_discussion($current_user_id, $discussion);
64 | }
65 |
66 | echo $content;
67 |
--------------------------------------------------------------------------------
/layouts/chat/generate_chat_container.php:
--------------------------------------------------------------------------------
1 | "You should provide current_user_id as post form input",
21 | "success"=>false
22 | )
23 | );
24 |
25 | exit();
26 | }
27 | if(!isset($_POST["receiver"])) {
28 | echo json_encode(
29 | array(
30 | "message"=>"You should provide followed_id as post form input",
31 | "success"=>false
32 | )
33 | );
34 |
35 | exit();
36 | }
37 |
38 | $sender = sanitize_id($_POST["sender"]);
39 | $receiver = sanitize_id($_POST["receiver"]);
40 |
41 | if(($sender) &&
42 | User::user_exists("id", $sender)) {
43 | if(sanitize_id($receiver) &&
44 | User::user_exists("id", $receiver)) {
45 | $chat_container = ChatComponent::generate_chat_section($sender, $receiver);
46 | return array(
47 | $chat_container,
48 | "success"=>true
49 | );
50 | } else {
51 | echo json_encode(
52 | array(
53 | "message"=>"sender id is either not valid or not exists in our db",
54 | "success"=>false
55 | )
56 | );
57 | }
58 | } else {
59 | echo json_encode(
60 | array(
61 | "message"=>"sender id is either not valid or not exists in our db",
62 | "success"=>false
63 | )
64 | );
65 | }
--------------------------------------------------------------------------------
/layouts/chat/get_chat_friend_by_username.php:
--------------------------------------------------------------------------------
1 | getPropertyValue("id");
19 | $username = isset($_POST["username"]) ? sanitize_text($_POST["username"]) : "";
20 |
21 | if(!empty($username)) {
22 | $user_relation = new UserRelation();
23 | $friends = $user_relation->get_friends($current_user_id);
24 |
25 | $content = '';
26 | foreach($friends as $friend) {
27 | if(strpos($friend->getPropertyValue("username"), $username) !== false) {
28 | $content .= ChatComponent::generate_chat_page_friend_contact($current_user_id, $friend);
29 | }
30 | }
31 | echo $content;
32 | } else {
33 | $user_relation = new UserRelation();
34 | $friends = $user_relation->get_friends($current_user_id);
35 |
36 | $content = '';
37 | foreach($friends as $friend) {
38 | $content .= ChatComponent::generate_chat_page_friend_contact($current_user_id, $friend);
39 | }
40 | echo $content;
41 | }
--------------------------------------------------------------------------------
/layouts/general/CreatePost.php:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 | EOS;
15 | }
16 |
17 | public static function generatePostCreationVideo() {
18 | // Path will be set in src in javascript file when the user upload a file
19 | echo <<
21 |
22 |
23 |
24 |
25 |
26 |
27 |
35 |
36 | EOS;
37 | }
38 | }
39 | ?>
--------------------------------------------------------------------------------
/layouts/master_right/Right.php:
--------------------------------------------------------------------------------
1 | getPropertyValue("id");
9 | $user_name = $user->getPropertyValue("username");
10 | $user_picture = Config::get("root/path") . (empty($user->getPropertyValue("picture")) ? "public/assets/images/logos/logo512.png" : $user->getPropertyValue("picture"));
11 | if(strlen($user_name) > 15) {
12 | $user_name = substr($user_name, 0, 15) . " ..";
13 | }
14 |
15 | $now = strtotime(date("Y/m/d h:i:s"));
16 | $last_active_date = strtotime($user->getPropertyValue("last_active_update"));
17 | $interval = abs($last_active_date - $now);
18 | $minutes = round($interval / 60);
19 |
20 | $online_status = ($minutes < 5) ? "online.png" : "offline.png";
21 |
22 | // Here we need to implement some code to see if the yuser is online or not
23 |
24 | echo <<
26 |
29 | $user_name
30 |
31 |
37 |
38 |
39 |
40 | EOS;
41 | }
42 | }
43 | ?>
--------------------------------------------------------------------------------
/layouts/post/generate_last_post.php:
--------------------------------------------------------------------------------
1 | fetchPost($post->id);
22 |
23 | $post_component = new Post_Manager();
24 | $post_component = $post_component->generate_post($p, $user);
25 |
26 | echo $post_component;
--------------------------------------------------------------------------------
/layouts/post/generate_post.php:
--------------------------------------------------------------------------------
1 | fetchPost($post_id);
28 |
29 | $post_component = new Post_Manager();
30 | $post_component = $post_component->generate_post($post, $user);
31 |
32 | echo $post_component;
33 |
--------------------------------------------------------------------------------
/layouts/post/generate_post_creation_image.php:
--------------------------------------------------------------------------------
1 | generatePostCreationImage();
12 |
13 | ?>
--------------------------------------------------------------------------------
/layouts/post/generate_post_creation_video.php:
--------------------------------------------------------------------------------
1 | generatePostCreationVideo();
12 |
13 | ?>
--------------------------------------------------------------------------------
/layouts/post/generate_post_data_item.php:
--------------------------------------------------------------------------------
1 | generatePostCreationImage();
13 |
14 | ?>
--------------------------------------------------------------------------------
/layouts/search/Search.php:
--------------------------------------------------------------------------------
1 | picture)) ? Config::get("root/path") . $user->picture : Config::get("root/path") . "public/assets/images/logos/logo512.png";
12 | $fullname = $user->firstname . " " . $user->lastname;
13 | $username = $user->username;
14 | $id = $user->id;
15 |
16 | $follower_id = $current_user_id;
17 | $followed_id = $user->id;
18 |
19 | $follow = new Follow();
20 | $follow->set_data(array(
21 | "follower"=>$follower_id,
22 | "followed"=>$followed_id
23 | ));
24 |
25 | if($follow->fetch_follow()) {
26 | $follow_btn = <<
28 | F_BTN;
29 | } else {
30 | $follow_btn = <<
32 | F_BTN;
33 | }
34 |
35 | return <<
37 |
38 |
39 |
40 |
41 |
42 |
{$fullname}
43 |
@{$username}
44 |
45 |
46 |
51 |
52 |
53 | QQ;
54 | }
55 |
56 | public function generateSearchGroup() {
57 | return <<
59 |
60 |
61 |
62 |
Loupgarou
63 |
3.5K members
64 |
65 |
66 |
67 | QQ;
68 | }
69 | }
--------------------------------------------------------------------------------
/models/Comment.php:
--------------------------------------------------------------------------------
1 | db = DB::getInstance();
17 | $this->comment_date = date("Y/m/d H:i:s");
18 | }
19 |
20 | public function get_property($propertyName) {
21 | return $this->$propertyName;
22 | }
23 |
24 | public function set_property($propertyName, $propertyValue) {
25 | $this->$propertyName = $propertyValue;
26 | }
27 |
28 | public function setData($data = array()) {
29 | $this->comment_owner = $data["comment_owner"];
30 | $this->post_id = $data["post_id"];
31 | $this->comment_text = $data["comment_text"];
32 | }
33 |
34 | public function add() {
35 | $this->db->query("INSERT INTO `comment`
36 | (`comment_owner`, `post_id`, `comment_date`, `comment_edit_date`, `comment_text`)
37 | VALUES (?, ?, ?, ?, ?)", array(
38 | $this->comment_owner,
39 | $this->post_id,
40 | $this->comment_date,
41 | $this->comment_edit_date,
42 | $this->comment_text
43 | ));
44 |
45 | return $this->db->error() == false ? $this : false;
46 | }
47 |
48 | public function update() {
49 | $this->db->query("UPDATE comment SET `comment_owner` = ?,
50 | `post_id` = ?, `comment_date` = ?, `comment_edit_date` = ?, `comment_text` = ? WHERE `id` = ?
51 | ", array(
52 | $this->comment_owner,
53 | $this->post_id,
54 | $this->comment_date,
55 | // Notice we set the edit time to current time because we only call update when we want to edit a comment
56 | date("Y/m/d H:i:s"),
57 | $this->comment_text,
58 | $this->id,
59 | ));
60 |
61 | $i = $this->id;
62 |
63 | return $this->db->error() == false ? $this : false;
64 | }
65 |
66 | public function delete() {
67 | $this->db->query("DELETE FROM `comment` WHERE id = ?",
68 | array($this->id));
69 |
70 | return $this->db->error() == false ? true : false;
71 | }
72 |
73 | public function fetch_comment($value, $property="id") {
74 | $this->db->query("SELECT * FROM comment WHERE $property = ?", array($value));
75 | if($this->db->count() > 0) {
76 | $fetched_comment = $this->db->results()[0];
77 |
78 | $this->id = $fetched_comment->id;
79 | $this->comment_owner = $fetched_comment->comment_owner;
80 | $this->post_id = $fetched_comment->post_id;
81 | $this->comment_date = $fetched_comment->comment_date;
82 | $this->comment_edit_date = $fetched_comment->comment_edit_date;
83 | $this->comment_text = $fetched_comment->comment_text;
84 |
85 | return true;
86 | }
87 |
88 | return false;
89 | }
90 |
91 | public static function fetch_post_comments($post_id) {
92 | DB::getInstance()->query("SELECT * FROM comment WHERE post_id = ?", array($post_id));
93 | if(DB::getInstance()->count() > 0) {
94 | return DB::getInstance()->results();
95 | }
96 |
97 | return array();
98 | }
99 |
100 | public static function get($field_name, $field_value) {
101 | DB::getInstance()->query("SELECT * FROM post WHERE $field_name = ?", array($field_value));
102 |
103 | if(DB::getInstance()->count() > 0) {
104 | return DB::getInstance()->results();
105 | }
106 |
107 | return array();
108 | }
109 |
110 | public static function delete_post_comments($post_id) {
111 | DB::getInstance()->query("DELETE FROM `comment` WHERE post_id = ?",
112 | array($post_id)
113 | );
114 |
115 | return DB::getInstance()->error() == false ? true : false;
116 | }
117 |
118 | public function toString() {
119 | return 'Post with id: ' . $this->post_id . " and owner of id: " . $this->post_owner . " published at: " . $this->post_date . " ";
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/models/Follow.php:
--------------------------------------------------------------------------------
1 | db = DB::getInstance();
16 | }
17 |
18 | public function get_property($propertyName) {
19 | return $this->$propertyName;
20 | }
21 |
22 | public function set_property($propertyName, $propertyValue) {
23 | $this->$propertyName = $propertyValue;
24 | }
25 |
26 | public function set_data($data = array()) {
27 | $this->follower = $data["follower"];
28 | $this->followed = $data["followed"];
29 | }
30 |
31 | public function fetch_follow() {
32 | $this->db->query("SELECT * FROM user_follow WHERE follower_id = ? AND followed_id = ?",
33 | array(
34 | $this->follower,
35 | $this->followed
36 | ));
37 |
38 | if($this->db->count() > 0) {
39 | $fetched_follow = $this->db->results()[0];
40 |
41 | $this->id = $fetched_follow->id;
42 | $this->follower = $fetched_follow->follower_id;
43 | $this->followed = $fetched_follow->followed_id;
44 |
45 | return true;
46 | }
47 |
48 | return false;
49 | }
50 |
51 | public static function get_user_followers($id) {
52 | DB::getInstance()->query("SELECT * FROM user_follow WHERE followed_id = ?", array($id));
53 |
54 | // Here we will store posts fetched by query method
55 | $followers = array();
56 |
57 | if(DB::getInstance()->count() > 0) {
58 | $fetched_followers = DB::getInstance()->results();
59 |
60 | foreach($fetched_followers as $fetched_follower) {
61 | $follower = new User();
62 | $follower->fetchUser("id", $fetched_follower->followed_id);
63 |
64 | $followers[] = $follower;
65 | }
66 | }
67 |
68 | return $followers;
69 | }
70 |
71 | public static function get_user_followers_number($id) {
72 | DB::getInstance()->query("SELECT * FROM user_follow WHERE followed_id = ?", array($id));
73 |
74 | return DB::getInstance()->count();
75 | }
76 |
77 | public static function get_followed_users_number($id) {
78 | DB::getInstance()->query("SELECT * FROM user_follow WHERE follower_id = ?", array($id));
79 |
80 | return DB::getInstance()->count();
81 | }
82 |
83 | public static function get_followed_users($id) {
84 | DB::getInstance()->query("SELECT * FROM user_follow WHERE follower_id = ?", array($id));
85 |
86 | // Here we will store posts fetched by query method
87 | $followed_users = array();
88 |
89 | if(DB::getInstance()->count() > 0) {
90 | $fetched_followed_users = DB::getInstance()->results();
91 |
92 | foreach($fetched_followed_users as $fetched_followed_user) {
93 | $followed_user = new User();
94 | $followed_user->fetchUser("id", $fetched_followed_user->followed_id);
95 |
96 | $followed_users[] = $followed_user;
97 | }
98 | }
99 |
100 | return $followed_users;
101 | }
102 |
103 | public function add() {
104 | $this->db->query("INSERT INTO user_follow
105 | (follower_id, followed_id)
106 | VALUES (?, ?)", array(
107 | $this->follower,
108 | $this->followed
109 | ));
110 |
111 | return $this->db->error() == false ? true : false;
112 | }
113 |
114 | public function delete() {
115 | $this->db->query("DELETE FROM user_follow WHERE id = ?", array($this->id));
116 |
117 | return ($this->db->error()) ? false : true;
118 | }
119 |
120 | public static function follow_exists($follower, $followed) {
121 | DB::getInstance()->query("SELECT * FROM user_follow WHERE follower_id = ? AND followed_id = ?",
122 | array(
123 | $follower,
124 | $followed
125 | ));
126 |
127 | return DB::getInstance()->count() > 0 ? true : false;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/models/Like.php:
--------------------------------------------------------------------------------
1 | db = DB::getInstance();
15 | $this->like_date = date("Y/m/d H:i:s");
16 | }
17 |
18 | public function get_property($propertyName) {
19 | return $this->$propertyName;
20 | }
21 |
22 | public function set_property($propertyName, $propertyValue) {
23 | $this->$propertyName = $propertyValue;
24 | }
25 |
26 | public function setData($data = array()) {
27 | $this->post_id = $data["post_id"];
28 | $this->user_id = $data["user_id"];
29 | }
30 |
31 | public function exists() {
32 | $this->db->query("SELECT * FROM `like`
33 | WHERE `post_id` = ? AND `user_id` = ?", array(
34 | $this->post_id,
35 | $this->user_id
36 | ));
37 |
38 | return $this->db->count() > 0 ? true : false;
39 | }
40 |
41 | public function add() {
42 | if($this->exists()) {
43 | return -1;
44 | }
45 |
46 | $this->db->query("INSERT INTO `like`
47 | (`post_id`, `user_id`, `like_date`)
48 | VALUES (?, ?, ?)", array(
49 | $this->post_id,
50 | $this->user_id,
51 | $this->like_date,
52 | ));
53 |
54 | return $this->db->error() == false ? 1 : false;
55 | }
56 |
57 | public function delete() {
58 | $this->db->query("DELETE FROM `like` WHERE `post_id` = ? AND `user_id` = ?",
59 | array(
60 | $this->post_id,
61 | $this->user_id
62 | )
63 | );
64 |
65 | return $this->db->error() == false ? true : false;
66 | }
67 |
68 | public static function delete_post_likes($post_id) {
69 | DB::getInstance()->query("DELETE FROM `like` WHERE `post_id` = ?",
70 | array(
71 | $post_id
72 | )
73 | );
74 |
75 | return DB::getInstance()->error() == false ? true : false;
76 | }
77 |
78 | public function get_post_users_likes_by_post($post_id) {
79 | $this->db->query("SELECT * FROM `like` WHERE post_id = ?", array($post_id));
80 | $users = array();
81 | if($this->db->count() > 0) {
82 | $fetched_like_users = $this->db->results();
83 | foreach($fetched_like_users as $user) {
84 | $u = new User();
85 | $u->fetchUser("id", $user->id);
86 |
87 | $users[] = $u;
88 | }
89 | }
90 |
91 | return $users;
92 | }
93 |
94 | public function toString() {
95 | return 'Post with id: ' . $this->post_id . " and owner of id: " . $this->post_owner . " published at: " . $this->post_date . " ";
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/page_parts/basic/log-header.php:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
">
12 |
13 | 〡
14 |
46 |
--------------------------------------------------------------------------------
/page_parts/basic/master-right.php:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
Contacts
14 |
17 |
21 |
22 |
34 | EMPTY;
35 | } else {
36 | $master_right = new MasterRightComponents();
37 | foreach($friends as $friend) {
38 | $master_right->generateFriendContact($current_user_id, $friend);
39 | }
40 | }
41 |
42 | ?>
43 |
44 |
45 |
--------------------------------------------------------------------------------
/page_parts/errors/404.php:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | V01D47 - ERROR
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
26 | getPropertyValue("isLoggedIn")) {
28 | include_once "../basic/header.php";
29 | } else {
30 | include_once "../basic/log-header.php";
31 | }
32 | ?>
33 |
34 |
35 |
404 ERROR
36 |
Page Not Found
37 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/page_parts/profile/owner-profile-header.php:
--------------------------------------------------------------------------------
1 | getPropertyValue("picture")) ? "public/assets/images/logos/logo512.png" : $fetched_user->getPropertyValue("picture"));
5 | $private = $user->getPropertyValue("private");
6 | ?>
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
Edit profile
18 |
19 |
20 |
30 |
31 |
51 |
52 |
53 | First name
54 | " name="firstname">
55 |
56 |
57 | Last name
58 | " name="lastname">
59 |
60 |
61 | Bio
62 |
63 |
64 |
65 |
Private account
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/page_parts/settings/left-panel.php:
--------------------------------------------------------------------------------
1 | logout();
8 | Redirect::to("login/login.php");
9 | }
10 | }
11 |
12 | $logo_path = $root . "public/assets/images/logos/large.png";
13 | $index_page_path = $root . "index.php";
14 |
15 | $setting_profile_path = $root . "settings.php";
16 | $setting_account_path = $root . "settings-account.php";
17 |
18 | ?>
19 |
--------------------------------------------------------------------------------
/people.php:
--------------------------------------------------------------------------------
1 | getPropertyValue("isLoggedIn")) {
12 | Redirect::to("login/login.php");
13 | }
14 | if(Session::exists("register_success") && $user->getPropertyValue("username") == Session::get("new_username")) {
15 | $welcomeMessage = Session::flash("register_success");
16 | }
17 | if(isset($_POST["logout"])) {
18 | if(Token::check(Common::getInput($_POST, "token_logout"), "logout")) {
19 | $user->logout();
20 | Redirect::to("login/login.php");
21 | }
22 | }
23 | $welcomeMessage = '';
24 |
25 | $search = new Search();
26 | $showingNumber = 4;
27 |
28 | $searchKeyword = isset($_GET["q"]) ? $_GET["q"] : '';
29 |
30 | /*
31 | We perform search by comparing username,firstname and last name to every query string parameter and we get only users with username,firtname, or lastname
32 | that is like the data specified in the query string
33 | */
34 | $searchUsersResult = User::search($searchKeyword);
35 | $number_of_users = count($searchUsersResult);
36 | $dataExists = false;
37 | ?>
38 |
39 |
40 |
41 |
42 |
43 |
44 | V01D47 - search
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
73 |
74 |
No search results.
75 |
76 |
77 |
78 |
79 |
People
80 |
81 |
Showing
82 | $showingNumber) ? $showingNumber : $number_of_users; ?>
83 | of results
84 |
85 |
86 | generateSearchPerson($user->getPropertyValue("id"), $u);
89 | }
90 | ?>
91 |
92 |
93 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/public/assets/audios/tone.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/audios/tone.mp3
--------------------------------------------------------------------------------
/public/assets/images/favicons/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/favicons/android-chrome-192x192.png
--------------------------------------------------------------------------------
/public/assets/images/favicons/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/favicons/android-chrome-512x512.png
--------------------------------------------------------------------------------
/public/assets/images/favicons/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/favicons/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/assets/images/favicons/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/favicons/favicon-16x16.png
--------------------------------------------------------------------------------
/public/assets/images/favicons/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/favicons/favicon-32x32.png
--------------------------------------------------------------------------------
/public/assets/images/favicons/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/favicons/favicon.ico
--------------------------------------------------------------------------------
/public/assets/images/icons/add-friend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/add-friend.png
--------------------------------------------------------------------------------
/public/assets/images/icons/black-comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/black-comment.png
--------------------------------------------------------------------------------
/public/assets/images/icons/black-live.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/black-live.png
--------------------------------------------------------------------------------
/public/assets/images/icons/black-more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/black-more.png
--------------------------------------------------------------------------------
/public/assets/images/icons/black-refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/black-refresh.png
--------------------------------------------------------------------------------
/public/assets/images/icons/black-search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/black-search.png
--------------------------------------------------------------------------------
/public/assets/images/icons/calendar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/calendar.png
--------------------------------------------------------------------------------
/public/assets/images/icons/change-image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/change-image.png
--------------------------------------------------------------------------------
/public/assets/images/icons/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/close.png
--------------------------------------------------------------------------------
/public/assets/images/icons/dotted-more-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/dotted-more-white.png
--------------------------------------------------------------------------------
/public/assets/images/icons/dotted-more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/dotted-more.png
--------------------------------------------------------------------------------
/public/assets/images/icons/down-arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/down-arrow.png
--------------------------------------------------------------------------------
/public/assets/images/icons/download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/download.png
--------------------------------------------------------------------------------
/public/assets/images/icons/explore-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/explore-green.png
--------------------------------------------------------------------------------
/public/assets/images/icons/explore-w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/explore-w.png
--------------------------------------------------------------------------------
/public/assets/images/icons/eye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/eye.png
--------------------------------------------------------------------------------
/public/assets/images/icons/follow-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/follow-black.png
--------------------------------------------------------------------------------
/public/assets/images/icons/follow-user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/follow-user.png
--------------------------------------------------------------------------------
/public/assets/images/icons/followed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/followed.png
--------------------------------------------------------------------------------
/public/assets/images/icons/friends.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/friends.png
--------------------------------------------------------------------------------
/public/assets/images/icons/full-screen-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/full-screen-black.png
--------------------------------------------------------------------------------
/public/assets/images/icons/full-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/full-screen.png
--------------------------------------------------------------------------------
/public/assets/images/icons/group-w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/group-w.png
--------------------------------------------------------------------------------
/public/assets/images/icons/group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/group.png
--------------------------------------------------------------------------------
/public/assets/images/icons/home-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/home-green.png
--------------------------------------------------------------------------------
/public/assets/images/icons/home-w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/home-w.png
--------------------------------------------------------------------------------
/public/assets/images/icons/is-friend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/is-friend.png
--------------------------------------------------------------------------------
/public/assets/images/icons/left-arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/left-arrow.png
--------------------------------------------------------------------------------
/public/assets/images/icons/like-black-filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/like-black-filled.png
--------------------------------------------------------------------------------
/public/assets/images/icons/like-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/like-black.png
--------------------------------------------------------------------------------
/public/assets/images/icons/like-white-filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/like-white-filled.png
--------------------------------------------------------------------------------
/public/assets/images/icons/like-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/like-white.png
--------------------------------------------------------------------------------
/public/assets/images/icons/live-red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/live-red.png
--------------------------------------------------------------------------------
/public/assets/images/icons/live-w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/live-w.png
--------------------------------------------------------------------------------
/public/assets/images/icons/lock-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/lock-white.png
--------------------------------------------------------------------------------
/public/assets/images/icons/lock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/lock.png
--------------------------------------------------------------------------------
/public/assets/images/icons/log.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/log.png
--------------------------------------------------------------------------------
/public/assets/images/icons/logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/logout.png
--------------------------------------------------------------------------------
/public/assets/images/icons/media.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/media.png
--------------------------------------------------------------------------------
/public/assets/images/icons/messages.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/messages.png
--------------------------------------------------------------------------------
/public/assets/images/icons/more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/more.png
--------------------------------------------------------------------------------
/public/assets/images/icons/multimedia.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/multimedia.png
--------------------------------------------------------------------------------
/public/assets/images/icons/no-result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/no-result.png
--------------------------------------------------------------------------------
/public/assets/images/icons/notification.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/notification.png
--------------------------------------------------------------------------------
/public/assets/images/icons/off-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/off-white.png
--------------------------------------------------------------------------------
/public/assets/images/icons/off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/off.png
--------------------------------------------------------------------------------
/public/assets/images/icons/offline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/offline.png
--------------------------------------------------------------------------------
/public/assets/images/icons/on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/on.png
--------------------------------------------------------------------------------
/public/assets/images/icons/online.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/online.png
--------------------------------------------------------------------------------
/public/assets/images/icons/page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/page.png
--------------------------------------------------------------------------------
/public/assets/images/icons/profile-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/profile-white.png
--------------------------------------------------------------------------------
/public/assets/images/icons/profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/profile.png
--------------------------------------------------------------------------------
/public/assets/images/icons/public-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/public-white.png
--------------------------------------------------------------------------------
/public/assets/images/icons/public.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/public.png
--------------------------------------------------------------------------------
/public/assets/images/icons/received.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/received.png
--------------------------------------------------------------------------------
/public/assets/images/icons/reply-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/reply-black.png
--------------------------------------------------------------------------------
/public/assets/images/icons/reply.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/reply.png
--------------------------------------------------------------------------------
/public/assets/images/icons/right-arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/right-arrow.png
--------------------------------------------------------------------------------
/public/assets/images/icons/save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/save.png
--------------------------------------------------------------------------------
/public/assets/images/icons/seen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/seen.png
--------------------------------------------------------------------------------
/public/assets/images/icons/sent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/sent.png
--------------------------------------------------------------------------------
/public/assets/images/icons/settings-w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/settings-w.png
--------------------------------------------------------------------------------
/public/assets/images/icons/settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/settings.png
--------------------------------------------------------------------------------
/public/assets/images/icons/timeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/timeline.png
--------------------------------------------------------------------------------
/public/assets/images/icons/unfollow-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/unfollow-black.png
--------------------------------------------------------------------------------
/public/assets/images/icons/unfriend-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/unfriend-black.png
--------------------------------------------------------------------------------
/public/assets/images/icons/unfriend-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/unfriend-white.png
--------------------------------------------------------------------------------
/public/assets/images/icons/unfriend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/unfriend.png
--------------------------------------------------------------------------------
/public/assets/images/icons/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/user.png
--------------------------------------------------------------------------------
/public/assets/images/icons/video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/video.png
--------------------------------------------------------------------------------
/public/assets/images/icons/videos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/videos.png
--------------------------------------------------------------------------------
/public/assets/images/icons/white-close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/white-close.png
--------------------------------------------------------------------------------
/public/assets/images/icons/white-comment-filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/white-comment-filled.png
--------------------------------------------------------------------------------
/public/assets/images/icons/white-comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/white-comment.png
--------------------------------------------------------------------------------
/public/assets/images/icons/white-eye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/white-eye.png
--------------------------------------------------------------------------------
/public/assets/images/icons/white-logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/white-logout.png
--------------------------------------------------------------------------------
/public/assets/images/icons/white-refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/white-refresh.png
--------------------------------------------------------------------------------
/public/assets/images/icons/white-search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/icons/white-search.png
--------------------------------------------------------------------------------
/public/assets/images/logos/large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/logos/large.png
--------------------------------------------------------------------------------
/public/assets/images/logos/large.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/logos/large.xcf
--------------------------------------------------------------------------------
/public/assets/images/logos/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/logos/logo512.png
--------------------------------------------------------------------------------
/public/assets/images/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hostname47/PHP-CHAT/a0e4e6e588e80c96b414b77afbca3670f8ced159/public/assets/images/preview.png
--------------------------------------------------------------------------------
/public/css/create-post-style.css:
--------------------------------------------------------------------------------
1 | .create-post-container {
2 | background-color: rgb(236, 236, 236);
3 | border-radius: 12px;
4 | margin-bottom: 12px;
5 | padding-bottom: 10px;
6 | }
7 |
8 | #create-post-textual-content {
9 | white-space: pre-wrap;
10 | }
11 |
12 | .create-post-header {
13 | border-radius: 8px 8px 0 0;
14 | padding: 8px;
15 | border-bottom: 1px solid rgb(51, 51, 51);
16 | background-color: rgb(24, 24, 24);
17 | }
18 |
19 | .post-assets-uploaded-container {
20 | display: flex;
21 | margin: 4px 8px;
22 | }
23 |
24 | .image-post-uploaded {
25 | display: block;
26 | background-color: gray;
27 | }
28 |
29 | .delete-uploaded-item {
30 | border: none;
31 | cursor: pointer;
32 | border-radius: 50%;
33 | top: 6px;
34 | right: 6px;
35 |
36 | z-index: 1;
37 | width: 20px;
38 | height: 20px;
39 | background-color: rgb(90, 90, 90);
40 | background-image: url(../assets/images/icons/white-close.png);
41 | background-size: 8px;
42 | background-repeat: no-repeat;
43 | background-position: center;
44 | }
45 |
46 | .delete-uploaded-item:hover {
47 | background-color: rgb(26, 26, 26);
48 | }
49 |
50 | .post-created-message {
51 | display: none;
52 | opacity: 0;
53 | padding: 0 8px 0 36px;
54 | background-color: rgb(20, 20, 20);
55 | margin: 0;
56 | border-radius: 8px;
57 | position: fixed;
58 | bottom: 14px;
59 | left: 14px;
60 | padding-left: 36px;
61 | background-image: url(../assets/images/icons/seen.png);
62 | background-size: 20px;
63 | background-repeat: no-repeat;
64 | background-position: 10px center;
65 | }
66 |
67 | .post-creation-item {
68 | display: flex;
69 | align-items: flex-start;
70 | height: 80px;
71 | width: 80px;
72 |
73 | margin: 0 4px;
74 |
75 | overflow: hidden;
76 | }
77 |
78 | .live-button-style {
79 | background-size: 22px;
80 | background-position: center;
81 | background-repeat: no-repeat;
82 | background-image: url(../assets/images/icons/black-live.png);
83 |
84 | height: 40px;
85 | width: 40px;
86 |
87 | cursor: pointer;
88 | }
89 |
90 | .create-post-profile-owner-picture-container {
91 | height: 30px;
92 | width: 30px;
93 |
94 | border-radius: 50%;
95 |
96 | overflow: hidden;
97 | display: flex;
98 | align-items: center;
99 | justify-content: center;
100 | }
101 |
102 | .create-post-profile-owner-picture {
103 | height: 30px;
104 | display: flex;
105 | }
106 |
107 | .assets-pending {
108 | z-index: 0;
109 | position: absolute;
110 | left: 0;
111 | top: 0;
112 |
113 | width: 100%;
114 | height: 100%;
115 |
116 | background-color: rgb(185, 185, 185);
117 |
118 | display: none;
119 | align-items: center;
120 | justify-content: center;
121 | }
122 |
123 | .pending-container {
124 | display: flex;
125 | align-items: center;
126 | justify-content: center;
127 | height: 80%;
128 | width: 80%;
129 |
130 | border-radius: 50%;
131 |
132 | background-color: rgb(185, 185, 185);
133 | }
134 |
135 | .pending-inner {
136 | position: relative;
137 | height: 95%;
138 | width: 95%;
139 |
140 | border-radius: 50%;
141 | display: flex;
142 | align-items: center;
143 | justify-content: center;
144 | }
145 |
146 | .pendulum {
147 | top: 40%;
148 | height: 68%;
149 | position: absolute;
150 | width: 8px;
151 |
152 | background-color: rgba(0, 0, 0, 0.4);
153 |
154 | transform-origin: 50% 6px;
155 | transform: translate(50%, 50%);
156 | animation: orbita 2s linear infinite;
157 | -webkit-animation: orbita 2s linear infinite;
158 | -moz-animation: orbita 2s cubic-bezier(.86,-0.51,.47,.99) infinite;
159 | -o-animation: orbita 2s linear infinite;
160 | }
161 |
162 | .pendulum-wrapper {
163 | height: 100%;
164 | width: 100%;
165 | z-index: 2;
166 | position: absolute;
167 | top: 0;
168 | left: 0;
169 |
170 | border-radius: 50%;
171 | background-color: rgb(185, 185, 185);
172 | }
173 |
174 | @keyframes orbita {
175 | 0% {
176 | transform:translate(0%, 0%) rotate(0deg);
177 | }
178 | 100% {
179 | transform:translate(0%, 0%) rotate(360deg);
180 | }
181 | }
182 |
183 | .post-creation-video-image-container {
184 | position: absolute;
185 | left: 0;
186 | top: 0;
187 |
188 | width: 100%;
189 | height: 100%;
190 | background-color: rgba(0, 0, 0, 0.4);
191 |
192 | display: none;
193 | align-items: center;
194 | justify-content: center;
195 | }
196 |
197 | .post-creations-video-image {
198 | height: 40px;
199 | width: 40px;
200 | display: flex;
201 | }
--------------------------------------------------------------------------------
/public/css/error.css:
--------------------------------------------------------------------------------
1 | body, html {
2 | height: 100%;
3 | }
4 |
5 | main {
6 | display: flex;
7 | justify-content: center;
8 | }
9 |
10 | #main-wrapper {
11 | display: flex;
12 | justify-content: center;
13 | flex-direction: column;
14 | }
15 |
16 | .big-error-title {
17 | font-size: 38px;
18 | text-align: center;
19 | margin: 80px 0 0 0;
20 | }
21 |
22 | .medium-error-title {
23 | margin: 15px 0 15px 0;
24 | font-size: 24px;
25 | font-weight: 500;
26 | text-align: center;
27 | }
--------------------------------------------------------------------------------
/public/css/header.css:
--------------------------------------------------------------------------------
1 | header {
2 | display: flex;
3 | justify-content: center;
4 | width: 100%;
5 | background-color: black;
6 | position: fixed;
7 | z-index: 8;
8 | top: 0;
9 | }
10 |
11 | #top-header {
12 | z-index: 1;
13 | width: 100%;
14 | height: 55px;
15 | background-color: black;
16 | display: flex;
17 | justify-content: center;
18 | }
19 |
20 | #header-logo-container {
21 | display: flex;
22 | align-items: center;
23 |
24 | margin-left: 14px;
25 | }
26 |
27 | #header-logo {
28 | width: 180px;
29 | height: 28px;
30 | }
31 |
32 | #header-search-form {
33 | display: flex;
34 | align-items: center;
35 |
36 | width: 380px;
37 | }
38 |
39 | #global-header-strip-container {
40 | display: flex;
41 | align-items: center;
42 |
43 | margin-right: 16px;
44 | margin-left: auto;
45 | }
46 |
47 | .horizontal-menu-item-wrapper {
48 | display: flex;
49 | position: relative;
50 | }
51 |
52 | .horizontal-menu-link {
53 | color: white;
54 | text-decoration: none;
55 | margin: 0px 10px;
56 | }
57 |
58 | .header-menu {
59 | display: flex;
60 | align-items: center;
61 | margin: 0 4px;
62 | }
63 |
64 | #user-photo-button {
65 | margin: 0 4px;
66 | width: 36px;
67 | height: 36px;
68 |
69 | border-radius: 50%;
70 | background-color: rgb(71, 71, 71);
71 | background-position: center center;
72 | background-size: 30px 30px;
73 | background-repeat: no-repeat;
74 | background-image: url(../assets/images/icons/more.png);
75 | }
76 |
77 | .options-separator-style-1 {
78 | height: 1px;
79 | background-color: rgb(231, 231, 231);
80 | width: 100%;
81 | }
82 |
83 | .sub-option {
84 | display: block;
85 | padding: 4px;
86 | border-radius: 4px;
87 | text-decoration: none;
88 | color: black;
89 | margin: 3px 0;
90 | }
91 |
92 | .sub-option:last-child {
93 | margin-bottom: 0px;
94 | }
95 |
96 | .sub-option:hover {
97 | background-color: rgb(231, 231, 231);
98 | }
99 |
100 | .friend-request-option-item, .message-option-item {
101 | display: flex;
102 | text-decoration: none;
103 | font-size: 14px;
104 | margin: 4px 0;
105 | padding: 4px;
106 | border-radius: 4px;
107 | }
108 |
109 | .friend-request-option-item:hover {
110 | background-color: rgb(234, 234, 234);
111 | }
112 |
113 | .friend-request-content-container {
114 | padding: 0 0 0 6px;
115 | }
116 |
117 | .message-content-container {
118 | padding: 0 0 0 6px;
119 | }
120 |
121 | .notif-content {
122 | margin: 0;
123 | padding: 0;
124 | }
125 |
126 | .notif-date {
127 | margin: 0;
128 | margin-top: 3px;
129 | font-size: 12px;
130 | color: rgb(0, 107, 207);
131 | }
132 |
133 | .action-doer {
134 | font-size: 15px;
135 | font-weight: 600;
136 | }
137 |
138 | .account-user {
139 | font-size: 17px;
140 | font-weight: 600;
141 | margin: 0;
142 | }
143 |
144 | .message-sender {
145 | font-size: 15px;
146 | font-weight: 600;
147 | margin: 0;
148 | }
149 |
150 | #user-profile-button {
151 | padding: 3px 6px 3px 4px;
152 | display: flex;
153 | color: white;
154 | text-decoration: none;
155 | border-radius: 20px;
156 | font-weight: 600;
157 | margin: 0 4px;
158 |
159 | background-color: rgb(37, 37, 37);
160 | transition: all 0.4s ease;
161 | }
162 |
163 | #user-profile-button:hover {
164 | background-color: rgb(70, 70, 70);
165 | }
166 |
167 | .options-container {
168 | max-height: 450px;
169 | }
170 |
171 | .message-content {
172 | margin: 0;
173 | padding: 0;
174 | }
175 |
176 | .message-state-sign {
177 | margin-top: 12px;
178 | margin-left: 2px;
179 | display: block;
180 | border-radius: 50%;
181 | height: 18px;
182 | width: 18px;
183 | align-self: center;
184 | }
185 |
186 | .logout-button {
187 | width: 100%;
188 | background: none;
189 | border: none;
190 | cursor: pointer;
191 | }
192 |
193 | #header-picture-container {
194 | display: flex;
195 | align-items: center;
196 | justify-content: center;
197 | border-radius: 50%;
198 | height: 33px;
199 | width: 33px;
200 | overflow: hidden;
201 | margin-right: 8px;
202 | }
203 |
204 | #header-picture {
205 | display: flex;
206 | height: 33px;
207 | }
208 |
209 | .header-menu-profile-picture-container {
210 | height: 55px;
211 | width: 55px;
212 | display: flex;
213 | align-items: center;
214 | justify-content: center;
215 |
216 | border-radius: 50%;
217 | overflow: hidden;
218 | }
219 |
220 | .header-menu-profile-picture {
221 | height: 100%;
222 | display: flex;
223 | }
224 |
225 | .num-of-requests {
226 | position: absolute;
227 | height: 18px;
228 | width: 18px;
229 | border-radius: 50%;
230 | color: white;
231 | font-weight: bold;
232 | font-size: 12px;
233 | background-color: rgb(226, 59, 59);
234 | top: -4px;
235 | right: -4px;
236 |
237 | display: flex;
238 | align-items: center;
239 | justify-content: center;
240 |
241 | }
242 |
--------------------------------------------------------------------------------
/public/css/index.css:
--------------------------------------------------------------------------------
1 |
2 | main {
3 | margin-top: 55px;
4 | z-index: -1;
5 | }
6 |
7 | #master-middle {
8 | border-radius: 4px;
9 | width: 40%;
10 | margin: 0 auto;
11 | margin-top: 12px;
12 | max-width: 600px;
13 | box-sizing: border-box;
14 | }
--------------------------------------------------------------------------------
/public/css/log-header.css:
--------------------------------------------------------------------------------
1 | header {
2 | background-color: black;
3 | height: 74px;
4 | display: flex;
5 | align-items: center;
6 | }
7 |
8 | .wide-logo {
9 | display: flex;
10 | width: 220px;
11 | margin-left: 20px;
12 | height: 35px;
13 | }
14 |
15 | #menu-login-credentials-container {
16 | display: flex;
17 | margin-left: auto;
18 | }
19 |
20 | #keep-me-connected {
21 | margin: 0 3px 0 0;
22 | }
23 |
24 | #connect {
25 | cursor: pointer;
26 | }
27 |
--------------------------------------------------------------------------------
/public/css/login.css:
--------------------------------------------------------------------------------
1 | .login-img-reg-container {
2 | display: flex;
3 | }
4 |
5 | #registration-section {
6 | padding: 14px;
7 | margin-right: 14px;
8 | width: 300px;
9 | flex: 0 0 300px;
10 | }
11 |
12 | #left-asset-wrapper {
13 | width: 100%;
14 | display: flex;
15 | flex-direction: column;
16 | justify-content: center;
17 | box-sizing: border-box;
18 |
19 | padding: 0px 60px;
20 | }
21 |
22 | #login-image-preview {
23 | display: flex;
24 | margin: 0 auto;
25 | max-width: 800px;
26 | }
27 |
28 | #login-left-text {
29 | font-size: 19px;
30 | text-align: center;
31 | margin: 0 0 18px 0;
32 | }
--------------------------------------------------------------------------------
/public/css/master-left-panel.css:
--------------------------------------------------------------------------------
1 | #master-left {
2 | position: fixed;
3 | left: 0;
4 | top: 55px;
5 | padding: 6px 6px 0 6px;
6 | box-sizing: border-box;
7 | overflow: hidden;
8 | width: 320px;
9 |
10 | background-color: rgb(40, 40, 40);
11 | }
12 |
13 | #master-left-container {
14 | overflow-y: scroll;
15 | box-sizing: border-box;
16 | padding-right: 4px;
17 | }
18 |
19 | .left-menu-selected-page {
20 | background-color: rgba(45, 221, 45, 0.5);
21 | }
22 |
23 | .contact-user-button:hover {
24 | background-color: rgb(56, 56, 56);
25 | }
26 |
27 | .menu-item-style-1 {
28 | cursor: pointer;
29 | padding: 6px 8px;
30 |
31 | border-radius: 4px;
32 | }
33 |
34 | .menu-item-style-1:hover {
35 | background-color: rgb(99, 99, 99);
36 | }
37 |
38 | .menu-item-style-2 {
39 | cursor: pointer;
40 | padding: 5px 5px;
41 | margin-top: 2px;
42 | border-radius: 4px;
43 | }
44 |
45 | .menu-item-style-2:hover {
46 | background-color: rgb(56, 56, 56);
47 | }
48 |
49 | #menu-profile-container {
50 | margin: 0 3px 8px 3px;
51 | background: rgb(70,70,70);
52 | box-shadow: 0px 0px 4px 1px rgba(0, 0, 0, 0.699);
53 | padding: 4px;
54 |
55 | border-radius: 6px;
56 | }
57 |
58 | .cover-container {
59 | max-height: 120px;
60 | min-height: 120px;
61 | background-color: gray;
62 | display: flex;
63 | align-items: center;
64 | justify-content: center;
65 | overflow: hidden;
66 |
67 | border-radius: 6px 6px 0 0;
68 | }
69 |
70 | .cover-photo {
71 | display: flex;
72 | width: 100%;
73 | height: 100%;
74 | }
75 |
76 | .picture-container {
77 | height: 66px;
78 | width: 66px;
79 | box-sizing: border-box;
80 | background: linear-gradient(90deg, rgb(48, 48, 48) 0%, rgb(18, 18, 18) 100%);
81 | overflow: hidden;
82 | top: 90px;
83 | left: 20px;
84 | border-radius: 50%;
85 |
86 | display: flex;
87 | align-items: center;
88 | justify-content: center;
89 | }
90 |
91 | .picture-photo {
92 | height: 100%;
93 | box-sizing: border-box;
94 | }
95 |
96 | .header-profile-name-container {
97 | margin-left: 90px;
98 | }
99 |
100 | .header-profile-fullname {
101 | margin: 2px 0 1px 0;
102 | font-size: 16px;
103 | }
104 |
105 | .header-profile-username {
106 | margin:0;
107 | font-size: 13px;
108 | }
109 |
110 | .profile-owner-picture-left-panel-container {
111 | display: flex;
112 | align-items: center;
113 | justify-content: center;
114 |
115 | height: 44px;
116 | width: 44px;
117 | overflow: hidden;
118 |
119 | border-radius: 50%;
120 | }
121 |
122 | .profile-owner-picture-left-panel-container {
123 | height: 40px;
124 | width: 40px;
125 | }
126 |
127 | .profile-owner-picture-left-panel {
128 | height: 40px;
129 | display: flex;
130 | }
--------------------------------------------------------------------------------
/public/css/master-right-contacts.css:
--------------------------------------------------------------------------------
1 | #master-right {
2 | position: fixed;
3 | right: 0;
4 | width: 320px;
5 | padding-bottom: 2px;
6 | overflow: hidden;
7 | box-sizing: border-box;
8 | padding: 6px 4px 4px 4px;
9 | background-color: rgb(40, 40, 40);
10 | }
11 |
12 |
13 | #contact-search {
14 | display: block;
15 | width: 30px;
16 | height: 30px;
17 |
18 | border-radius: 50%;
19 | background-image: url(../assets/images/icons/white-search.png);
20 | background-position: center center;
21 | background-repeat: no-repeat;
22 | background-size: 16px 16px;
23 |
24 | transition: all 0.4s ease;
25 | }
26 |
27 | #contact-search:hover {
28 | background-color: rgb(102, 102, 102);
29 | }
30 |
31 | #contact-search-field-container {
32 | /*this is absolute*/
33 | box-sizing: border-box;
34 | display: flex;
35 | align-items: center;
36 |
37 | overflow: hidden;
38 | width: 0px;
39 | }
40 |
41 | #close-contact-search {
42 | margin-left: -26px;
43 | padding: 4px;
44 | }
45 |
46 | #close-contact-search:hover {
47 | background-color: rgb(187, 187, 187);
48 | }
49 |
50 | #contact-search-field {
51 | display: block;
52 | width: 100%;
53 | padding: 6px 30px 6px 10px;
54 | margin-left: 2px;
55 | box-sizing: border-box;
56 | border: 1px solid rgb(39, 39, 39);
57 | }
58 |
59 | #contacts-container {
60 | overflow-y: scroll;
61 | height: 100%;
62 | box-sizing: border-box;
63 | margin-top: 6px;
64 | }
65 |
66 | .contact-user {
67 | display: flex;
68 | align-items: center;
69 | padding: 8px 12px;
70 | height: 30px;
71 | cursor: pointer;
72 | border-radius: 8px;
73 | margin: 0 6px 0 3px;
74 | }
75 |
76 | .contact-user:hover {
77 | background-color: rgb(50, 50, 50);
78 | }
79 |
80 | .contact-user:last-child {
81 | margin-bottom: 6px;
82 | }
83 |
84 | .contact-user-connection-icon {
85 | margin-right: 4px;
86 | }
87 |
88 | .contact-item-button {
89 | height: 25px;
90 | width: 25px;
91 | display: flex;
92 | margin: 0 4px;
93 | border-radius: 4px;
94 | background-color: rgb(82, 82, 82);
95 | background-size: 50%;
96 | background-position: center;
97 | background-repeat: no-repeat;
98 | display: none;
99 | }
100 |
101 | .contact-go-to-profile {
102 | background-image: url(../assets/images/icons/profile-white.png);
103 | }
104 |
105 | .contact-go-to-chat {
106 | background-image: url(../assets/images/icons/messages.png);
107 | }
108 |
109 | .contact-user-name {
110 | margin: 0 0 0 6px;
111 | }
112 |
113 | .contact-item-buttons-container {
114 | display: flex;
115 | align-items: center;
116 | margin-right: 6px;
117 | }
118 |
119 | .contact-user-picture-container {
120 | display: flex;
121 | align-items: center;
122 | justify-content: center;
123 | overflow: hidden;
124 | border-radius: 50%;
125 | height: 26px;
126 | width: 26px;
127 | }
128 |
129 | .contact-user-picture {
130 | display: flex;
131 | height: 100%;
132 | }
--------------------------------------------------------------------------------
/public/css/post-viewer.css:
--------------------------------------------------------------------------------
1 | a, input {
2 | outline: none
3 | }
4 |
5 | header {
6 | /* We don't want header to be fixed, static is good here */
7 | position: static;
8 | }
9 |
10 | main {
11 | margin: 0;
12 | }
13 |
14 | body, html {
15 | color: black;
16 | height: 100%;
17 | box-sizing: border-box;
18 | }
19 |
20 | #post-viewer {
21 | width: 100%;
22 | height: 100%;
23 | position: absolute;
24 | display: flex;
25 | box-sizing: border-box;
26 | }
27 |
28 | #post-assets-container {
29 | height: 100%;
30 | width: 100%;
31 | background-color: black;
32 | }
33 |
34 | #post-info {
35 | overflow-y: scroll;
36 | width: 360px;
37 | min-width: 360px;
38 | box-sizing: border-box;
39 |
40 | padding: 14px;
41 |
42 | background-color: white;
43 | }
44 |
45 | #asset-wrapper {
46 | width: 100%;
47 | height: 100%;
48 |
49 | display: flex;
50 | align-items: center;
51 | justify-content: center;
52 | }
53 |
54 | .asset-move-button {
55 | height: 100%;
56 | width: 60px;
57 | display: none;
58 | opacity: 0;
59 |
60 | position: absolute;
61 | top: 0;
62 | background-color: rgba(255, 255, 255, 0.05);
63 | background-size: 15px;
64 | background-repeat: no-repeat;
65 | background-position: center;
66 |
67 | cursor: pointer;
68 | }
69 |
70 | .asset-next {
71 | right: 0;
72 | background-image: url(../assets/images/icons/right-arrow.png);
73 | }
74 |
75 | .asset-back {
76 | left: 0;
77 | background-image: url(../assets/images/icons/left-arrow.png);
78 | }
79 |
80 | .poster-image-container {
81 | height: 42px;
82 | width: 42px;
83 | display: flex;
84 | align-items: center;
85 | justify-content: center;
86 | border-radius: 50%;
87 | overflow: hidden;
88 | }
89 |
90 | .poster-image {
91 | height: 42px;
92 | display: flex;
93 | }
94 |
95 | .post-owner-name {
96 | color: black;
97 | margin-top: 2px;
98 | margin-bottom: 0;
99 | }
100 |
101 | .post-owner-name:hover {
102 | text-decoration: underline;
103 | }
104 |
105 | .post-date {
106 | color: rgb(78, 78, 78);
107 | }
108 |
109 | .post-text {
110 | margin-top: 8px;
111 | padding: 0;
112 | }
113 |
114 | .collapse-text {
115 | display: inline-block;
116 | cursor: pointer;
117 | font-weight: bold;
118 | }
119 |
120 | .collapse-text:hover {
121 | text-decoration: underline;
122 | }
123 |
124 | .sub-options-container-style-2 {
125 | z-index: 1;
126 | right: 4px;
127 | left: auto;
128 |
129 | box-shadow: 1px 3px 7px 0.1px rgba(0, 0, 0, 0.4);
130 | }
131 |
132 | .reaction-button-image {
133 | display: block;
134 | height: 20px;
135 | width: 20px;
136 | margin-right: 4px
137 | }
138 |
139 | .num-of-comments, .num-of-shares {
140 | margin-right: 2px;
141 | }
142 |
143 | .separator {
144 | height: 1px;
145 | width: 100%;
146 | margin: 10px 0;
147 | background-color: rgb(189, 189, 189);
148 | }
149 |
150 | .reaction-box {
151 | display: flex;
152 | justify-content: center;
153 | margin: 12px 0 0 0;
154 | padding: 6px 0;
155 | border-top: 1px solid rgb(189, 189, 189);
156 | border-bottom: 1px solid rgb(189, 189, 189);
157 | }
158 |
159 | .reaction-button {
160 | padding: 6px 12px;
161 | border-radius: 4px;
162 | flex: 3;
163 | display: flex;
164 | justify-content: center;
165 | align-items: center;
166 | }
167 |
168 | .reaction-button:hover {
169 | background-color: rgb(230, 230, 230);
170 | }
171 |
172 | .comment-wrapper {
173 | background-color: rgb(220, 220, 220);
174 | }
175 |
176 | .comment-owner {
177 | color: black;
178 | margin: 5px 0;
179 | }
180 |
181 | .comment-text {
182 | margin: 2px 0;
183 | }
184 |
185 | .link-style-3 {
186 | color: black
187 | }
188 |
189 | .comment-input-style {
190 | background-color: rgb(220, 220, 220);
191 | border: none;
192 | color: black;
193 | border-radius: 6px;
194 | margin-left: 2px;
195 | padding: 9px 9px 9px 12px;
196 | width: 100%;
197 | box-sizing: border-box;
198 | }
199 |
200 | .comment-input-style:focus {
201 | background-color: rgb(230, 230, 230);
202 | }
203 |
204 | .exit-button {
205 | position: absolute;
206 | left: 16px;
207 | top: 16px;
208 |
209 | height: 40px;
210 | width: 40px;
211 |
212 | background-image: url(../assets/images/icons/white-close.png);
213 | background-size: 16px;
214 | background-position: center;
215 | background-repeat: no-repeat;
216 | background-color: rgb(44, 44, 44);
217 |
218 | border-radius: 50%;
219 | z-index: 2;
220 |
221 | cursor: pointer;
222 | }
223 |
224 | .exit-button:hover {
225 | background-color: rgb(60, 60, 60);
226 | }
227 |
228 | .comment-options-button {
229 | background-image: url(../assets/images/icons/dotted-more.png);
230 | }
231 |
232 | .comment-options-button:hover {
233 | background-color: rgb(224, 224, 224);
234 | }
235 |
236 | .comment-op {
237 | margin-left: 0;
238 | }
239 |
240 | .comment_owner_picture_container {
241 | min-width: 34px;
242 | }
243 |
244 | .share-animation-outer-circle-container {
245 | background-color: black;
246 | }
247 |
248 | .share-animation-inner-circle-container {
249 | background-color: white;
250 | }
251 |
252 | .animation-hand {
253 | background-color: white;
254 | }
255 |
256 | .notification-bottom-sentence {
257 | color: white;
258 | }
--------------------------------------------------------------------------------
/public/css/search.css:
--------------------------------------------------------------------------------
1 |
2 | .search-result-type-container {
3 | display: none;
4 | margin-bottom: 12px;
5 | background-color: rgb(78, 78, 78);
6 | border-radius: 6px;
7 | box-shadow: 0 0px 3px 0px rgba(0, 0, 0, 0.89);
8 | }
9 |
10 | .search-result-item:nth-of-type(1) {
11 | border-top: 1px solid rgb(99, 99, 99);
12 | }
13 |
14 | .search-result-item:last-child {
15 | border-bottom: none;
16 | }
17 |
18 | .search-result-item {
19 | cursor: pointer;
20 | padding: 6px 12px;
21 | border-bottom: 1px solid rgb(99, 99, 99);
22 | border-radius: 6px;
23 | }
24 |
25 | .search-result-item:hover {
26 | background-color: rgb(90, 90, 90);
27 | }
28 |
29 | .search-result {
30 | margin-top: 6px;
31 | }
32 |
33 | .no-search-container {
34 | display: none;
35 | border-radius: 6px;
36 |
37 | background-color: rgb(78, 78, 78);
38 | padding: 12px;
39 | margin: 0;
40 | }
41 |
42 | .no-search-results {
43 | padding: 40px 0 4px 0;
44 | background-image: url(../assets/images/icons/no-result.png);
45 | background-size: 30px;
46 | background-repeat: no-repeat;
47 | background-position: center 0;
48 | margin: 0;
49 | }
50 |
51 | .empty-search {
52 | display: none;
53 | border-radius: 6px;
54 | padding: 12px;
55 | background-color: rgb(78, 78, 78);
56 | }
57 |
58 | .search-result-item-picture-container {
59 | display: flex;
60 | align-items: center;
61 | justify-content: center;
62 |
63 | height: 55px;
64 | width: 55px;
65 | overflow: hidden;
66 |
67 | border-radius: 50%;
68 | }
69 |
70 | .search-result-item-picture {
71 | height: 55px;
72 | display: flex;
73 | }
--------------------------------------------------------------------------------
/public/css/settings.css:
--------------------------------------------------------------------------------
1 |
2 | a {
3 | outline: none;
4 | }
5 |
6 | #setting-left-pannel {
7 | position: fixed;
8 | z-index: 1;
9 | overflow-y: scroll;
10 | top: 0;
11 | left: 0;
12 | width: 300px;
13 | height: 100%;
14 | margin-bottom: 20px;
15 |
16 | background-color: rgb(26, 26, 26);
17 | }
18 |
19 | #setting-master-container {
20 | margin-left: 300px;
21 | width: 100%;
22 | padding: 50px;
23 | }
24 |
25 | #setting-panel-header-logo-box {
26 | width: 100%;
27 | display: flex;
28 | justify-content: center;
29 | margin: 24px 0;
30 | }
31 |
32 | #setting-panel-header-logo {
33 | display: flex;
34 | height: 28px;
35 | width: 180px;
36 | }
37 |
38 | .button-with-suboption {
39 | border-radius: 6px;
40 | margin-bottom: 4px;
41 | }
42 |
43 | .button-with-suboption:hover {
44 | background-color: rgb(41, 41, 41);
45 | }
46 |
47 | .selected-button {
48 | background-color: rgb(41, 41, 41);
49 | border-radius: 6px;
50 | }
51 |
52 | .red-label {
53 | color: rgb(255, 119, 119);
54 | margin-left: 2px;
55 | }
56 |
57 | .menu-button {
58 | display: block;
59 | padding: 8px 8px 8px 30px;
60 | text-decoration: none;
61 | color: white;
62 | font-size: 17px;
63 | font-weight: 600;
64 | }
65 |
66 | .menu-button-icon {
67 | background-repeat: no-repeat;
68 | background-size: 16px;
69 | background-position: 2px center;
70 | height: 20px;
71 | width: 20px;
72 |
73 | top: 8px;
74 | left: 6px;
75 | }
76 |
77 | .profile-button-icon {
78 | background-image: url(../assets/images/icons/settings-w.png);
79 | }
80 | .logout-button-icon {
81 | background-image: url(../assets/images/icons/white-logout.png);
82 | }
83 | .account-button-icon {
84 | background-image: url(../assets/images/icons/profile-white.png);
85 | }
86 | .not-yet {
87 | background-image: url(../assets/images/icons/public-white.png);
88 | }
89 |
90 | #left-panel-menu {
91 | margin-top: 16px;
92 | padding: 5px;
93 | }
94 |
95 | .has-suboption {
96 | background-image: url(../assets/images/icons/right-arrow.png);
97 | background-size: 12px;
98 | background-repeat: no-repeat;
99 | background-position: right 10px center;
100 | }
101 |
102 |
103 |
104 | .button-subotions-container {
105 | margin-left: 40px;
106 | display: none;
107 | padding-bottom: 4px;
108 | }
109 |
110 | .subotion {
111 | display: block;
112 | text-decoration: none;
113 | color: white;
114 | padding: 8px;
115 | }
116 |
117 | .subotion:hover {
118 | background-color: rgb(62, 62, 62);
119 | margin-right: 4px;
120 | border-radius: 6px;
121 | }
122 |
123 | #global-container {
124 | padding: 16px;
125 | }
126 |
127 | .setting-block-line-separator {
128 | height: 1px;
129 | margin: 40px 0;
130 | width: 90%;
131 | background-color: rgb(59, 59, 59);
132 | }
133 |
134 | .setting-input-text-style {
135 | padding: 10px 12px;
136 | border: 1px solid #0f0f0f;
137 | background-color: #1a1a1a;
138 | border-radius: 6px;
139 | color: white;
140 | width: 400px;
141 | box-sizing: border-box;
142 | margin: 6px 0 10px 0;
143 | font-size: 16px;
144 | }
145 |
146 | .meta-data-input {
147 | margin-right: 10px;
148 | width: 195px;
149 | }
150 |
151 | .setting-input-text-style:focus {
152 | border: 1px solid #5adf5a;
153 | }
154 |
155 | .textarea-style {
156 | resize: vertical;
157 | max-height: 160px;
158 | min-height: 80px;
159 | }
160 |
161 | #setting-cover-container {
162 | width: 400px;
163 | min-height: 120px;
164 | max-height: 140px;
165 | display: flex;
166 | align-items: center;
167 |
168 | background-color: gray;
169 |
170 | overflow: hidden;
171 | }
172 |
173 | .setting-cover {
174 | display: flex;
175 | width: 100%;
176 | height: 100%;
177 | }
178 |
179 | #setting-picture-container {
180 | display: flex;
181 | justify-content: center;
182 | height: 55px;
183 | width: 55px;
184 | overflow: hidden;
185 |
186 | border-radius: 6px;
187 | }
188 |
189 | #setting-picture {
190 | display: block;
191 | height: 55px;
192 | }
193 |
194 | #assets-wrapper {
195 | box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.4);
196 | border-radius: 2px;
197 | background-color: rgb(45, 45, 45);
198 | cursor: pointer;
199 | overflow: hidden;
200 |
201 | text-decoration: none;
202 | color: white;
203 | }
204 |
205 | #setting-file-inputs-container {
206 | margin-left: 16px;
207 | }
208 |
209 | .setting-label {
210 | color: #8aff8a;
211 | display: block;
212 | margin-bottom: 8px;
213 | }
214 |
215 | .setting-label1 {
216 | display: block;
217 | font-size: 16px;
218 | }
219 |
220 | .input-hint {
221 | color: rgb(102, 102, 102);
222 | font-size: 12px;
223 | margin-top: 4px;
224 | }
225 |
226 | #private-account-status {
227 | margin-top: 2px;
228 | font-size: 14px;
229 | color: rgb(184, 184, 184);
230 | }
231 |
232 | #save-button {
233 | margin-top: 12px;
234 | border-radius: 6px;
235 | background-color: rgb(44, 138, 72);
236 | border: 2px solid rgb(42, 211, 92);
237 | cursor: pointer;
238 | color: white;
239 | font-weight: 600;
240 |
241 | padding: 8px 14px;
242 | }
243 |
244 | #save-button:hover {
245 | background-color: rgb(42, 211, 92);
246 | }
247 |
248 | .logout-btn {
249 | position: absolute;
250 | height: 100%;
251 | width: 100%;
252 |
253 | z-index: 1;
254 | border: none;
255 | background: none;
256 | cursor: pointer;
257 | }
--------------------------------------------------------------------------------
/public/javascript/config.js:
--------------------------------------------------------------------------------
1 | let root = "/CHAT/";
2 |
3 | let current_user_id = null;
4 |
5 | function handle_return(data) {
6 | current_user_id = data;
7 | }
8 |
9 | function get_current(handle_return) {
10 | $.ajax({
11 | url: root + 'security/get_current_user.php',
12 | type: 'get',
13 | success: function(current_user) {
14 | handle_return(current_user["id"]);
15 | }
16 | });
17 | };
18 | get_current(handle_return);
19 |
20 | // Update the presence active every 2 minutes as long as the user logging in.
21 | /*
22 | IMPORTANT: This file(config.js) should by in every page of the app, If this file is missed to be included in one of the
23 | files, then the activeness of the current user will not be updated and his friends will see him offline even if he's not
24 | */
25 |
26 | var stillAlive = setInterval(function () {
27 | update_active_presence();
28 | }, 120000);
29 |
30 | function update_active_presence() {
31 | $.ajax({
32 | url: root + 'server/update_active_presence.php'
33 | });
34 | }
35 |
--------------------------------------------------------------------------------
/public/javascript/index.js:
--------------------------------------------------------------------------------
1 |
2 | $("#contact-search").click(function() {
3 | let contact_search_container = $("#contact-search-field-container");
4 | if(contact_search_container.css("width") != "230px") {
5 | contact_search_container.animate({
6 | width: "230px"
7 | }, 300);
8 |
9 | } else {
10 | contact_search_container.animate({
11 | width: "0px"
12 | }, 300);
13 | }
14 |
15 | return false;
16 | });
17 |
18 | $("#close-contact-search").click(function() {
19 | $("#contact-search-field-container").animate({
20 | width: "0px"
21 | }, 300);
22 | return false;
23 | })
24 |
25 | $(".user-info-section-link").on( {
26 | mouseenter: function() {
27 | $(this).find("div p").css("textDecoration", "underline");
28 | },
29 | mouseleave: function() {
30 | $(this).find("div p").css("textDecoration", "none");
31 | }
32 | });
--------------------------------------------------------------------------------
/public/javascript/master-right.js:
--------------------------------------------------------------------------------
1 | $(".contact-user").on({
2 | mouseenter: function() {
3 | $(this).find(".contact-item-button").css("display", "block");
4 | },
5 | mouseleave: function() {
6 | $(this).find(".contact-item-button").css("display", "none");
7 | },
8 | click: function() {
9 | console.log("user button get clicked !");
10 | }
11 | });
12 |
13 | $(".contact-go-to-profile").click(function() {
14 | //window.location.href = root + "profile.php?username=grotto";
15 |
16 | let captured_id = $(this).parent().find(".uid").val();
17 | let current_id = $(this).parent().find(".current").val();
18 | console.log(captured_id);
19 | var values = {
20 | 'uid': captured_id,
21 | 'current_user_id': current_id
22 | };
23 |
24 | let url = root + "security/check_current_user.php";
25 |
26 | $.ajax({
27 | type: "POST",
28 | url: url,
29 | data: values,
30 | success: function(response) {
31 | url = root + "security/check_user_existence.php";
32 | if(response) {
33 | $.ajax({
34 | type: "POST",
35 | url: url,
36 | data: values,
37 | success: function(response) {
38 | if(response) {
39 | window.location.href = root + "profile.php?username=" + response["username"];
40 | }
41 | }
42 | });
43 | }
44 | }
45 | });
46 |
47 | return false;
48 | });
49 |
50 | $(".contact-go-to-chat").click(function() {
51 | //window.location.href = root + "profile.php?username=grotto";
52 |
53 | let captured_id = $(this).parent().find(".uid").val();
54 | let current_id = $(this).parent().find(".current").val();
55 | console.log(captured_id);
56 | var values = {
57 | 'uid': captured_id,
58 | 'current_user_id': current_id
59 | };
60 |
61 | let url = root + "security/check_current_user.php";
62 |
63 | $.ajax({
64 | type: "POST",
65 | url: url,
66 | data: values,
67 | success: function(response) {
68 | url = root + "security/check_user_existence.php";
69 | if(response) {
70 | $.ajax({
71 | type: "POST",
72 | url: url,
73 | data: values,
74 | success: function(response) {
75 | if(response) {
76 | window.location.href = root + "chat.php?username=" + response["username"];
77 | }
78 | }
79 | });
80 | }
81 | }
82 | });
83 |
84 | return false;
85 | });
86 |
87 | $(".contact-user").click(function() {
88 | //window.location.href = root + "profile.php?username=grotto";
89 |
90 | let captured_id = $(this).find(".uid").val();
91 | let current_id = $(this).find(".current").val();
92 | console.log(captured_id);
93 | var values = {
94 | 'uid': captured_id,
95 | 'current_user_id': current_id
96 | };
97 |
98 | let url = root + "security/check_current_user.php";
99 |
100 | $.ajax({
101 | type: "POST",
102 | url: url,
103 | data: values,
104 | success: function(response) {
105 | url = root + "security/check_user_existence.php";
106 | if(response) {
107 | $.ajax({
108 | type: "POST",
109 | url: url,
110 | data: values,
111 | success: function(response) {
112 | if(response) {
113 | window.location.href = root + "profile.php?username=" + response["username"];
114 | }
115 | }
116 | });
117 | }
118 | }
119 | });
120 |
121 | return false;
122 | });
--------------------------------------------------------------------------------
/public/javascript/search.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(".search-result-person").click(function() {
4 | /*
5 | Handle person click to redirect user to the user clickable profile
6 | PLEASE Read [IMPORTANT#6]
7 | Now We only use the hidden id in the container
8 | */
9 | let id = $(this).find(".uid").attr("value");
10 |
11 | xmlhttprequest = new XMLHttpRequest();
12 | xmlhttprequest.onreadystatechange = function() {
13 | if (this.readyState == 4 && this.status == 200) {
14 | let result = JSON.parse(this.responseText);
15 | if(result["problem"] == undefined) {
16 | let username = result["username"];
17 |
18 | location.href = root + "profile.php?username="+username;
19 | } else {
20 | // Handle when the id is not present in database, or an invalid data is provided
21 | }
22 | }
23 | };
24 | xmlhttprequest.open("GET", root+"api/user/GET.php?id="+id, true);
25 | xmlhttprequest.send();
26 |
27 | return false;
28 | });
--------------------------------------------------------------------------------
/public/javascript/settings.js:
--------------------------------------------------------------------------------
1 |
2 | $(document).ready(function() {
3 | if($("#private-account-state").val() == "1") {
4 | $("#private-account-button").css("backgroundImage", "url('"+root+"public/assets/images/icons/on.png')");
5 | $("#private-account-status").text("(ON)");
6 | } else {
7 | $("#private-account-button").css("backgroundImage", "url('" + root+"public/assets/images/icons/off-white.png')");
8 | $("#private-account-status").text("(OFF)");
9 | }
10 | });
11 |
12 |
13 | $(".button-with-suboption").click(function() {
14 | let contains = $(this).find(".button-subotions-container").length > 0;
15 |
16 | if(contains) {
17 | if($(this).find(".button-subotions-container").css("display") == "none") {
18 | $(this).find(".button-subotions-container").css("display", "block");
19 | let back = root+"public/assets/images/icons/down-arrow.png";
20 | $(this).find(".has-suboption").css("backgroundImage","url('"+back+"')");
21 | }
22 | else {
23 | let back = root+"public/assets/images/icons/right-arrow.png";
24 | $(this).find(".has-suboption").css("backgroundImage","url('"+back+"')");
25 | $(this).find(".button-subotions-container").css("display", "none");
26 | }
27 | return false;
28 | }
29 | });
30 |
31 | $("#assets-wrapper").on({
32 | mouseenter: function() {
33 | $("#assets-wrapper").css("backgroundColor", "rgb(50,50,50)");
34 | },
35 | mouseleave: function() {
36 | $("#assets-wrapper").css("backgroundColor", "rgb(45,45,45)");
37 | }
38 | });
39 |
40 | $("#private-account-button").click(function() {
41 | let status = $("#private-account-state").val();
42 |
43 | if(status == 1) {
44 | $("#private-account-button").css("backgroundImage", "url('" + root+"public/assets/images/icons/off-white.png')");
45 | $("#private-account-status").text("(OFF)");
46 | $("#private-account-state").val('-1');
47 | } else {
48 | $("#private-account-button").css("backgroundImage", "url('"+root+"public/assets/images/icons/on.png')");
49 | $("#private-account-status").text("(ON)");
50 | $("#private-account-state").val('1');
51 | }
52 | });
53 |
54 | $("#cover-input").change(function(event) {
55 | if (this.files && this.files[0]) {
56 | let cover = $(".setting-cover").get(0);
57 | let reader = new FileReader();
58 |
59 | reader.onload = function(){
60 | cover.src = reader.result;
61 | }
62 | reader.readAsDataURL(event.target.files[0]);
63 | }
64 | });
65 |
66 | $("#avatar-input").change(function(event) {
67 | if (this.files && this.files[0]) {
68 | let picture = $("#setting-picture").get(0);
69 | let reader = new FileReader();
70 |
71 | reader.onload = function(){
72 | picture.src = reader.result;
73 | }
74 | reader.readAsDataURL(event.target.files[0]);
75 | }
76 | });
77 |
78 | function imageIsLoaded(e) {
79 | $('#myImg').attr('src', e.target.result);
80 | $('#yourImage').attr('src', e.target.result);
81 | };
82 |
83 | $(".logout-button").click(function() {
84 | $("#logout-form").submit();
85 | });
--------------------------------------------------------------------------------
/security/check_current_user.php:
--------------------------------------------------------------------------------
1 | getPropertyValue("id") == $id) {
26 | echo json_encode(1);
27 | } else {
28 | echo json_encode(0);
29 | }
30 | } else {
31 | echo json_encode(0);
32 | }
33 |
--------------------------------------------------------------------------------
/security/check_user_existence.php:
--------------------------------------------------------------------------------
1 | fetchUser("id", $id);
22 |
23 | echo json_encode($user);
24 | } else {
25 | echo json_encode(0);
26 | }
27 | } else {
28 | echo json_encode(0);
29 | }
30 |
--------------------------------------------------------------------------------
/security/generate_new_token_post.php:
--------------------------------------------------------------------------------
1 | getPropertyValue("id");
20 | $receiver = isset($_POST["receiver"]) ? $_POST["receiver"] : null;
21 |
22 | while(true) {
23 | $channel_buffer = DB::getInstance()->query("SELECT * FROM `channel` WHERE sender = ? AND receiver = ?", array($receiver, $current_user_id))->results();
24 | $isEmpty = empty($channel_buffer);
25 |
26 | /*
27 | If there's a message sent by $sender to the receiver (we check this in channel table by checking message array
28 | returned from results) and the receiver is the same user who is loging in then we have a a message comming
29 | Actually checking the current user who is get the message is done in the query above when we put current_user_id
30 | to receiver query parameter :)
31 | */
32 | if(!$isEmpty) {
33 | $content = '';
34 | $chat_component = new ChatComponent();
35 |
36 | /*
37 | Why we only append one message per iteration :
38 | That's because the user could send more than one message, let's say 4 messages to his friend, well these 4
39 | messages are stored in the channel and wait for his friend to fetch them.
40 | Now the important part is that we fetch these messages one by one because we want to assign events belong to them
41 | one by one using javascript and delete the message immediately from channel because it's consumed by the receiver.
42 | if we append the 4 messages in one variable and add it to the chat-section it
43 | will not work
44 |
45 | NOTE: This code may be improved in the future
46 | HINT: T think some of what I wrote above is wrong, let's see
47 | */
48 | foreach($channel_buffer as $message) {
49 | $sender_user = new User();
50 | $sender_user->fetchUser("id", $message->sender);
51 |
52 | $msg = new Message();
53 | $msg->get_message("id", $message->message_id);
54 | $msg_obj = Message::get_message_obj("id", $message->message_id);
55 |
56 | $is_reply = $msg->get_property("reply_to");
57 |
58 | if($is_reply) {
59 | $original_message_id = $msg->get_property("reply_to");
60 | $reply_message_id = $msg->get_property("id");
61 | $reply_creator = $msg->get_property("message_sender");
62 |
63 | $original_message = new Message();
64 | $msg->get_message("id", $original_message_id);
65 | $original_creator = $original_message->get_property("message_sender");
66 |
67 | $content .= $chat_component->generate_received_reply_message($original_message_id, $reply_message_id, $original_creator, $reply_creator);
68 | } else {
69 | $content .= $chat_component->generate_friend_message($sender_user, $msg_obj, $msg->get_property("message_date"));
70 | }
71 | //$content .= $chat_component->generate_friend_message($sender_user, $msg_obj, $msg->get_property("message_date"));
72 | }
73 |
74 | echo json_encode($content);
75 | Message::dump_channel($receiver, $current_user_id);
76 | /*
77 | The following break get me stuck for more than 3 hours a row :-(
78 | when I was reviewing the code, I thought that this break is uneccessary but later, I realize that this script
79 | need to be stopped in some place, and the case is when he found some new data, that script echo out the content
80 | and exit and then when the code in javascript get that data it send the request again ! and so this break is
81 | the foundation of this script
82 | */
83 | break;
84 | }
85 |
86 | // wait for 1 sec (not very sexy as this blocks the PHP/Apache process, but that's how it goes)
87 | usleep(10000);
88 | }
--------------------------------------------------------------------------------
/server/message_writing_notifier.php:
--------------------------------------------------------------------------------
1 | getPropertyValue("id");
20 | $receiver = isset($_POST["receiver"]) ? $_POST["receiver"] : null;
21 |
22 | $channel_buffer = DB::getInstance()->query("SELECT * FROM `writing_message_notifier` WHERE message_writer = ? AND message_waiter = ?", array($receiver, $current_user_id))->results();
23 | $isEmpty = empty($channel_buffer);
24 |
25 | if(!$isEmpty) {
26 | echo json_encode(array(
27 | "finished"=>false
28 | ));
29 | } else {
30 | echo json_encode(array(
31 | "finished"=>true
32 | ));
33 | }
--------------------------------------------------------------------------------
/server/update_active_presence.php:
--------------------------------------------------------------------------------
1 | update_active();
14 |
--------------------------------------------------------------------------------