0% found this document useful (0 votes)
65 views111 pages

All Chapters

The document outlines a project to develop a new social media website. It will provide users a platform to connect, share content, and interact within a virtual community. A team will assess the current website and technical infrastructure, identify opportunities, and gather stakeholder feedback to design an enhanced platform. The new system aims to address issues like improved UX, responsiveness, privacy controls and integration with other platforms. It seeks to deliver a feature-rich social networking experience that fosters online connections and expressions.

Uploaded by

masoom raja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views111 pages

All Chapters

The document outlines a project to develop a new social media website. It will provide users a platform to connect, share content, and interact within a virtual community. A team will assess the current website and technical infrastructure, identify opportunities, and gather stakeholder feedback to design an enhanced platform. The new system aims to address issues like improved UX, responsiveness, privacy controls and integration with other platforms. It seeks to deliver a feature-rich social networking experience that fosters online connections and expressions.

Uploaded by

masoom raja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 111

Project Profile 2022 - 2023

Chapter-1

Project-Profile

1.1-Project Definition

The project aims to develop a social media website that provides a platform for users to connect,
communicate, and share content with others. The website will serve as a virtual community where
individuals can create profiles, connect with friends or followers, and engage in social interactions.
It will enable users to share various types of content, including text, images, and and provide
features for liking, commenting, and sharing content within the network.

The primary goal of the project is to create a user-friendly and visually appealing social media
website that caters to the needs and preferences of the target audience. The website will offer a
seamless and intuitive user experience, with a responsive design that adapts to different devices
and screen sizes.

Privacy and security of user data will be a top priority, with robust measures implemented to
safeguard personal information and ensure a safe online environment. The website will provide
users with control over their privacy settings, allowing them to manage the visibility of their
content and choose who can access their profiles.
Additionally, the social media website will include features for notifications, allowing users to stay
updated on the activities and interactions of their friends and connections. Messaging functionality
will enable private conversations between users, enhancing communication within the community.

The project will involve a multidisciplinary team, including project managers, business analysts,
UX/UI designers, front-end and back-end developers, quality assurance engineers, technical
writers, and system administrators. They will work collaboratively to design, develop, test, and
deploy the social media website, ensuring its functionality, reliability, and performance.

Overall, the project aims to deliver a comprehensive social media platform that fosters connection,
engagement, and content sharing among users, while prioritizing user experience, privacy, and
security.

1.2-Project Description

The project involves the development of a social media website that aims to provide users with a
platform to connect, communicate, and share content with others in a virtual community. The

YourThoughts 1
Project Profile 2022 - 2023

website will serve as a central hub for users to create personal profiles, build networks of friends
or followers, and engage in social interactions.

Users will have the ability to share various types of content, such as text posts, images and links,
allowing them to express themselves and showcase their interests. The website will include
features for users to like, comment on, and share content within their network, fostering
engagement and interactions among users.

Privacy and security will be key considerations in the project. The social media website will
incorporate robust privacy settings, giving users control over the visibility of their profiles and
content. Measures will be implemented to protect user data and ensure a safe and secure online
environment.

The website will have a user-friendly and intuitive interface, designed to provide a seamless user
experience across different devices and screen sizes. Responsive design principles will be
employed to optimize the website's layout and functionality for desktop computers, laptops,
tablets, and mobile phones.

The project will involve a team of professionals with diverse roles and expertise, including project
managers, business analysts, UX/UI designers, front-end and back-end developers, quality
assurance engineers, technical writers, and system administrators. They will collaborate
throughout the project lifecycle to design, develop, test, and deploy the social media website.
The ultimate goal of the project is to deliver a feature-rich social media website that enables users
to connect with others, share content, and engage in meaningful interactions. The website will
provide an enjoyable and secure online platform for individuals to express themselves, build
relationships, and stay connected with friends, communities, and the world around them.

1.3-Existing Website / Work Environment

Scenario: Twitter Social Network is an existing social media website that has been in operation
for several years. The management of Twitter Social Network has decided to revamp and
enhance the website to meet the evolving needs of its users and stay competitive in the market.
The project team is tasked with conducting an assessment of the current website and work
environment before proceeding with the development of the new social media website.

Assessment of Current Website:


The project team thoroughly examines the features and functionality of the Twitter Social
Network website. They evaluate the user interface, user registration process, profile creation,
content sharing, commenting, and liking features.
They identify that the current website lacks some modern features such as live video streaming,
direct messaging, and advanced privacy settings.

YourThoughts 2
Project Profile 2022 - 2023

The team also reviews user feedback and discovers that users have expressed a desire for a more
intuitive user experience, improved mobile responsiveness, and better content discovery
mechanisms.

Competitor Analysis:
The team analyzes other popular social media websites like facebook Network and memchat
Social to understand their features and design.
They observe that Twitter Network excels in real-time news updates and event coverage, while
Facebook Social focuses on niche interest groups and forums.
Based on the analysis, the team identifies an opportunity to differentiate Twitter Social Network
by incorporating a combination of real-time updates, interest-based communities, and enhanced
privacy controls.

Technical Infrastructure:
The team assesses the current technical infrastructure of Twitter Social Network, including the
web servers, database systems, and network capabilities.
They find that the infrastructure is outdated and may not handle the increased traffic and data
demands of the enhanced social media website.
As a result, the team determines the need to upgrade the servers, optimize the database systems,
and ensure scalable architecture to accommodate future growth.

Integration Requirements:
The team identifies that ABC Social Network needs seamless integration with popular third-
party platforms like Facebook and Twitter to allow users to import their contacts and share
content across platforms.
They analyze the available APIs provided by these platforms to ensure smooth integration and
data synchronization between YourThoughts Social Network and external platforms.

Work Environment and Team Collaboration:


The team evaluates the existing work environment and collaboration tools used by the
development team.
They find that communication and collaboration among team members can be improved by
implementing project management and collaboration software, such as Jira and Slack.
The team also identifies the need for regular meetings and status updates to enhance coordination
and teamwork.

Stakeholder Engagement:
The project team organizes meetings with management, marketing teams, and a focus group of
current YourThoughts Social Network users.
They gather feedback and understand stakeholders' expectations, such as the need for improved
monetization strategies, targeted advertising options, and seamless user experience across
devices.
The team ensures ongoing communication and involvement of stakeholders throughout the
development process.

YourThoughts 3
Project Profile 2022 - 2023

1.4-Problem Statements

This system developed will give the user a perfact interface for writing there articles and blogs.
The user can easily create there account on this website by there email and name. the user can
make there password for security of there account. the user can create there profile for easily
interaction to the people. There will be a timeline where every people see all other people article
and stories.

1.5-Need for New System


Currently students in schools or colleges are unable to express their ideas, their talent or
anything that can expressed for some benefits for everyone. The reason is, schools or
colleges don’t have any proper medium to accomplish it. But proposed online blogging
system can help in accomplish these things and even much more. We will cover the
objectives of this online blogging system in next section. This website is not only for
student anyone can create there account on this website and share there ideas to everyone.
They can write there article and blogs on this website and comment on others blogs.

1.6-Proposed System & Features

This project was developed to fulfil the requirement of common Social media platform
for educational purposes. However, there are lots of scope to improve the performance of
the Online Blogging System in the area of user interface, database performance, and
query processing time etc.
So, there are many things for future enhancement of this project. The future
enhancements that are possible in the project are as follows:

• Possibility of account creation of parents/guardians with limited rights.

• Web based interface for generate reports, like who has published more contents,
who has commented most, the logged in time etc.
• Linking and integration of other online educational web sites.
• Integration with school/college database through Web Services.

YourThoughts 4
Project Profile 2022 - 2023

• Development of mobile application which can run on multiple OS and devices.


• We can also add a quiz feature and winners will get some educational assistance
or any other reward.

1.7-Scope

The Social media System will allow the users to publish the writings, images if he/she
should have credentials to login. The main users of this project are students, teachers and
administrators.

From an end-user perspective, the social media System project consists of following
functional elements:

• Dashboard: It is the default page of the site and we can access this option from
left hand side anytime. All links are available on this page. We can also find the
Quick Draft and Activity section here.

• Posts: Here we can see all the published contents by clicking on “All Posts”
option and we can also publish new content by “Add New” option.

• Media: We can see the uploaded media items ( images, ) by clicking on “Library”
option and we can also add new media item from local system with the help of
“Add New” button.

• Comments: In this section, we can check that who, when and what has been
commented.

• Profile: In this section, we can personalize our profile like Password Change,
Profile Picture Change, Display Name, Nickname etc.

• Tools: This option is having additional plugins to install, which may enhance the
current functionality.

• Collapse: We can collapse the menu with this option.

YourThoughts 5
Project Profile 2022 - 2023

• Home Button: It is located at the top left portion and we can use this button to
check the timeline where we can view the contents published by everyone.

1.8-Outcomes
The system aims to promote critical and analytical thinking, increase access and exposure to
quality content, and provide a combination of solitary and social interactions with peers. It will
also help students to develop their communication and writing skills.

1.9-Tools & Technology used

The Social media System project will utilize the following tools and technologies:

Front-end Development:

HTML (Hypertext Markup Language): For structuring the web pages.

CSS (Cascading Style Sheets): For styling and designing the user interface.

JavaScript: For client-side interactivity and dynamic behavior.

Back-end Development:

PHP (Hypertext Preprocessor): A server-side scripting language for processing user requests
and generating dynamic web content.

MySQL: A relational database management system for storing user data, blog posts, and other
relevant information.

Web Development Frameworks:

Laravel: A PHP web framework that provides a robust and scalable foundation for building web
applications. It offers features such as routing, database management, and authentication.

Version Control:

Git: A distributed version control system for tracking changes in the project's source code and
facilitating collaboration among developers.

Integrated Development Environment (IDE):

YourThoughts 6
Project Profile 2022 - 2023

Visual Studio Code: A popular and lightweight code editor with excellent support for web
development.

Web Server:

Apache: A widely used web server software that will host the Online Blogging System
application.

Additional Libraries and Technologies:

jQuery: A JavaScript library for simplifying client-side scripting and DOM manipulation.

Bootstrap: A CSS framework for responsive and mobile-first web design.

AJAX (Asynchronous JavaScript and XML): A technique for performing asynchronous server
requests and updating web content without reloading the entire page.

These tools and technologies will collectively contribute to the development and deployment of
the Online Blogging System, ensuring a robust, user-friendly, and feature-rich platform for users
to create and share their blog po

YourThoughts 7
Project Profile 2022 - 2023

1.10-Project Plan

No. Description Date

1. Project Profile 30.03.2023


1.1 Project Definition
1.2 Project Description
1.3 Existing System / Work Environment
1.4 Problem Statements
1.5 Need for New System
1.6 Proposed System & Features
1.7 Scope
1.8 Outcomes
1.9 Tools & Technology used
1.10 Project Plan
2. Requirement Analysis
2.1 Feasibility Study 19.04.2023
2.2 Users of the System
2.3 Modules
2.4 Process Model
2.5 Hardware & Software Requirements
2.6 Use Cases
2.7 Use Case Diagram
3. Design 19.04.2023
3.1 Use Case Scenarios
3.2 Diagrams
3.2.1 UML / DFD
3.2.2 Entity Relationship Diagram
3.3 Data Dictionary
4. Implementation 03.05.2023
4.1 Form Layouts
4.2 Report Layouts
4.3 Coding Convention
4.4 Code
5. Testing 17.05.2023
5.1 Test Strategy
5.2 Test Cases
6. Future Enhancement 24.05.2023
7. Bibliography 24.05.2023

YourThoughts 8
Requirement Analysis 2022 - 2023

Chapter-2

Requirement Analysis

2.1 Feasibility Study:

A feasibility study is conducted to assess the viability and potential success of a project before
committing resources to its development. In the context of developing a social media website, a
feasibility study helps determine whether the project is technically, financially, and operationally feasible.
Here are the key aspects considered in a feasibility study:

Technical Feasibility:
Assess the technical requirements and capabilities needed to develop the social media website.
Evaluate the availability of required technologies, programming languages, frameworks, and
tools.
Determine if the development team has the necessary expertise and skills to implement the
required functionalities.
Consider any technical risks or challenges that may arise during the development process.

Financial Feasibility:
Analyze the project's financial aspects, including the estimated development costs and ongoing
maintenance expenses.
Evaluate the potential revenue streams, such as advertising, premium subscriptions, or
partnerships.
Consider the return on investment (ROI) and assess whether the project is financially viable and
sustainable.
Identify any potential funding sources or investment opportunities to support the development
and maintenance of the website.

Operational Feasibility:
Evaluate the operational aspects of running and managing the social media website.
Assess the availability of resources, such as human resources, infrastructure, and technical
support.
Consider the scalability of the website to handle increasing user activity and data storage
requirements.
Determine the feasibility of implementing necessary policies and procedures for user
management, content moderation, and data privacy.

Market Feasibility:
Conduct a market analysis to understand the target audience, user demographics, and
competition.
Identify the unique selling points and potential differentiators of the social media website.
Evaluate the demand for social media platforms and potential user adoption rates.

YourThoughts 9
Requirement Analysis 2022 - 2023

Assess the potential growth opportunities and challenges in the market.


Legal and Ethical Feasibility:
Consider the legal and regulatory requirements related to data privacy, user consent, and content
moderation.
Assess the ethical implications of data collection, user profiling, and targeted advertising.
Ensure compliance with applicable laws and regulations to mitigate legal risks.

Risk Assessment:
Identify and assess potential risks and uncertainties associated with the project.
Evaluate the impact and likelihood of risks related to technology, market dynamics, competition,
and user adoption.
Develop risk mitigation strategies and contingency plans to minimize potential negative impacts.

2.2 Users of the System:

The social media website will cater to various categories of users, each with their own roles,
responsibilities, and interactions within the system. Here are the key user categories:

Registered Users:
These are individuals who create an account on the social media website.
Registered users have their profiles, which they can customize and update with personal
information, profile pictures, and cover photos.
They can connect with other users by sending friend requests or following their profiles.
Registered users can post content, such as text updates, photos, videos, and links, on their
profiles or in designated community spaces.
They have the ability to like, comment on, and share content posted by other users.
Registered users can customize their privacy settings to control the visibility of their content and
manage their network connections.

Administrators:
Administrators have special privileges and responsibilities in managing the social media website.
They have the authority to enforce community guidelines, terms of service, and content
moderation policies.
Administrators can review reported content, handle user disputes, and take appropriate actions,
such as warning, suspending, or banning users who violate the platform's rules.
They have access to administrative tools and features to monitor system performance, manage
user accounts, and ensure the overall integrity and security of the website.

YourThoughts 10
Requirement Analysis 2022 - 2023

Content Creators:
 Content creators are users who actively produce and share original content on the social
media website.
 They may include bloggers, influencers, artists, photographers, journalists, and other
creative individuals.
 Content creators play a crucial role in generating engaging and diverse content that
attracts and retains users on the platform.
 They can gain visibility, recognition, and followers through their content and interactions
within the social media website.

Community Managers:
 Community managers are responsible for cultivating and managing user communities
within the social media website.
 They facilitate discussions, engage with users, and foster a positive and inclusive
environment.
 Community managers may organize events, campaigns, or initiatives to encourage user
participation and interaction.
 They provide support, address user concerns, and promote user-generated content that
aligns with the platform's objectives and values.

Advertisers and Marketers:


 Advertisers and marketers are businesses or individuals who leverage the social media
website's advertising features to promote their products, services, or brands.
 They create targeted ad campaigns, select audience demographics, and set advertising
budgets.
 Advertisers and marketers track ad performance, engagement metrics, and conversions to
optimize their marketing strategies.

Public Users:
 Public users refer to individuals who can access certain parts of the social media website
without creating an account.
 They can view public profiles, read public posts, and engage in limited interactions, such
as liking or sharing public content.
 Public users may decide to join the platform as registered users based on their
interactions and interests.
 Each category of user plays a unique role in contributing to the social media website's
ecosystem, fostering connections, and shaping the overall user experience. The system is
designed to cater to the diverse needs and expectations of these users, providing them
with a platform to connect, share, and engage with others in a virtual community.

YourThoughts 11
Requirement Analysis 2022 - 2023

2.3 Modules:

Modules are distinct components or functionalities within a system. For the Online Blogging
System, the following modules can be identified:

User Management: Handles user registration, login, and profile management.

Content Creation: Allows users to write, edit, and publish blog posts.

Content Management: Manages and organizes published blog posts.

Commenting: Enables users to comment on blog posts and engage in discussions.

Search and Filtering: Provides functionality to search for specific blog posts or filter content
based on categories or tags.

Social Sharing: Allows users to share blog posts on social media platforms.

Notifications: Sends notifications to users for new comments or activity on their blog posts.

2.4 Process Model:

The process model outlines the sequence of activities and steps involved in the development and
deployment of the social media website. Different process models can be employed based on the
project's requirements, team size, timeline, and development approach. Here, we will discuss an
example process model commonly used in software development projects called the Agile
Scrum model.

Agile Scrum Model: The Agile Scrum model is an iterative and incremental process model that
promotes collaboration, flexibility, and rapid development. It consists of the following key
components:

a. Product Backlog:
 The product backlog is a prioritized list of features, functionalities, and user stories that
need to be implemented in the social media website.
 The product backlog is continuously refined and updated throughout the development
process based on user feedback, market trends, and stakeholder inputs.

YourThoughts 12
Requirement Analysis 2022 - 2023

b. Sprint Planning:
 A sprint is a time-boxed iteration usually lasting 1-4 weeks.
 At the beginning of each sprint, the development team and the product owner collaborate
to select a set of user stories from the product backlog to be implemented during the
sprint.
 The team estimates the effort required for each user story and determines the sprint goal.

c. Sprint Execution:
 During the sprint, the development team works collaboratively to implement the selected
user stories.
 Daily stand-up meetings are held to discuss progress, address any issues, and plan the
day's work.
 The development team follows the Agile principles and values, focusing on delivering
working software increments.

2.5 Hardware & Software Requirements:

The hardware and software requirements for the Social media System include:

Hardware: A web server to host the application, database server to store user data and blog
posts, and network infrastructure for connectivity.

Software: Web development tools such as HTML, CSS, JavaScript, PHP, and a database
management system like MySQL. Additionally, a web browser for accessing the system.

2.6 Use Cases:

Use cases describe interactions between actors (users) and the system. They represent specific
actions or tasks performed within the system. Examples of use cases for the Online Blogging
System include:

1. Create an Account
2. Log in
3. Create a Post
4. Edit a Post
5. Delete a Post
6. Comment on a Post
7. View Posts
8. Search for Posts
9. Filter Posts by Category or Tag

YourThoughts 13
Requirement Analysis 2022 - 2023

2.7 Use Case Diagram: The use case diagram for the system will illustrate the various use
cases and how they relate to each other.

Fig.1-Use Case Diagram

YourThoughts 14
Design 2022 - 2023

Chapter-3

Design

3.1 Use Case Scenarios:

User Registration:
 User navigates to the website's registration page.
 User enters their personal details, such as name, email address, and password.
 User agrees to the terms and conditions and completes the registration process.
 The system validates the user's information and creates a new account.
 User receives a confirmation email to verify their account.

User Profile Creation:


 User logs into their account.
 User accesses the profile settings page.
 User uploads a profile picture and adds personal information, such as bio, location, and
interests.
 User customizes privacy settings to control the visibility of their profile and personal
information.
 User saves the profile changes, and the system updates the user's profile accordingly.

Posting Content:
 User composes a new post or status update.
 User adds text, images, videos, or links to the post.
 User selects the desired privacy settings for the post (e.g., public, friends-only, specific
groups).
 User publishes the post, and the system displays it on their profile and the appropriate
news feeds.

Connecting with Friends:


 User searches for friends or acquaintances on the social media website.
 User sends friend requests to desired individuals.
 User receives friend requests from other users and accepts or declines them.
 Once the friend request is accepted, the users are connected, and they can view each
other's profiles, posts, and updates.

Commenting and Interacting:


 User navigates to a post or content shared by another user.
 User reads the post and any associated comments.
 User leaves a comment on the post to share their thoughts or engage in a conversation.

YourThoughts 15
Design 2022 - 2023

 User can like or react to the post or comments to express their appreciation or agreement.
 User can share the post on their own profile or with specific groups or individuals.

Discovering and Following Content:


 User explores the website's discover or explore section.
 User browses through trending topics, popular posts, or recommended content.
 User finds content or profiles of interest and chooses to follow them.
 User receives updates and notifications about new posts or activities from the followed
content or profiles.

Managing Privacy and Notifications:


 User accesses the account settings or privacy settings page.
 User configures privacy preferences, such as who can view their profile, posts, or contact
them.
 User manages notification settings, including email notifications, push notifications, and
frequency of updates.
 User saves the changes, and the system updates the user's preferences accordingly.

YourThoughts 16
Design 2022 - 2023

3.2 Diagrams:

3.2.1 UML / DFD:

UML (Unified Modeling Language) and DFD (Data Flow Diagram) are graphical
representations used to depict system architecture and information flow. For the Online Blogging
System, a UML class diagram can be created to illustrate the relationships between
classes/entities, while a DFD can show the flow of data within the system.

Zero level DFD :

Fig. 2- Zero level DFD

YourThoughts 17
Design 2022 - 2023

First level DFD :

Fig. 3 - First level DFD

YourThoughts 18
Design 2022 - 2023

Second Level DFD :

Fig.4 - Second Level DFD

YourThoughts 19
Design 2022 - 2023

3.2.2- Entity Relationship Diagram:

An Entity Relationship Diagram (ERD) represents the entities, relationships, and attributes in a
system. It visualizes the structure of the database and how different entities are related to each
other. An ERD for the Online Blogging System would include entities like users, blog posts,
comments, categories, and tags, along with their respective attributes and relationships.

YourThoughts ER-Daigram :

Fig.5- ER-Daigram

YourThoughts 20
Design 2022 - 2023

3.3 -Data Dictionary:

A data dictionary provides a detailed description of the data elements used in the system,
including their names, definitions, data types, and any additional constraints. For the Online
Blogging System, the data dictionary would include entries for entities like users, blog posts,
comments, categories, and tags, specifying their attributes and characteristics.

User Name Database Table:

Fig.6- Database Table

YourThoughts 21
Design 2022 - 2023

User name database table 2:

Fig.7- User name database

YourThoughts 22
Design 2022 - 2023

Data type table:

Fig.8- Data type table

YourThoughts 23
Design 2022 - 2023

Data type table 2:

Fig.9- Data type table

YourThoughts 24
Implementation 2022 - 2023

Chapter-4
Implementation

4.1 Form Layouts

Login page

Fig.10 - Login Page

YourThoughts 25
Implementation 2022 - 2023

Signup page

Fig.11 – Signup Page

YourThoughts 26
Implementation 2022 - 2023

4.2 Report Layouts

User profile

Fig.12 - User profile

YourThoughts 27
Implementation 2022 - 2023

Post feed where user can see other posts

Fig.13 - Post feed

YourThoughts 28
Implementation 2022 - 2023

Notification Area

Fig.14 - Notification Area

YourThoughts 29
Implementation 2022 - 2023

4.3 Coding Convention:

A coding convention is a set of guidelines and standards that define how code should be written
and formatted in a consistent and readable manner. Following a coding convention is important
for ensuring code quality, maintainability, and collaboration among developers. Here are some
common coding conventions:

Naming Conventions:
Use meaningful and descriptive names for variables, functions, classes, and other code elements.
Follow a consistent naming style, such as camelCase, snake_case, or PascalCase.
Avoid using single-letter variable names or ambiguous abbreviations.

Indentation and Formatting:


Use consistent indentation to enhance code readability (e.g., spaces or tabs).
Place braces and parentheses on separate lines to improve code clarity.
Align code elements vertically to improve visual structure and organization.
Use proper spacing around operators, commas, and other punctuation for readability.

Commenting and Documentation:


Add comments to explain complex logic, algorithms, or any non-obvious code sections.
Document functions, classes, and public interfaces to provide clear usage instructions and
expected behavior.
Use a consistent style for comments (e.g., single-line or multi-line) and document headers.

Modularity and Code Organization:


Break down complex tasks into smaller functions or modules.
Group related functions and classes together.
Use meaningful folder and file names to organize code files logically.
Maintain a consistent file and directory structure.

Error Handling and Exception Handling:


Implement proper error handling techniques, such as try-catch blocks, to handle exceptions and
prevent application crashes.
Provide meaningful error messages or log information for troubleshooting.

Version Control and Collaboration:


Follow best practices for version control, such as using branches, committing changes
frequently, and writing meaningful commit messages.
Collaborate effectively by adhering to consistent coding conventions to ensure code readability
and minimize conflicts.

YourThoughts 30
Implementation 2022 - 2023

Testing and Quality Assurance:


Write code that is easily testable.
Include unit tests and test cases to validate the code's functionality.
Follow quality assurance practices, such as code reviews and static code analysis, to identify and
fix potential issues.

4.4 Code:

Account Creation Code:


<?php

include 'core/init.php';

$user_id = $_SESSION['user_id'];

$user = User::getData($user_id);
$who_users = Follow::whoToFollow($user_id);
$notify_count = User::CountNotification($user_id);

if (User::checkLogIn() === false)


header('location: index.php');

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings | YourThoughts</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/all.min.css">

<!-- time function to force css file to reload -->

<link rel="stylesheet" href="assets/css/profile_style.css?v=<?php echo time(); ?>">


<link rel="shortcut icon" type="image/png" href="logopic2.jpg">

</head>

YourThoughts 31
Implementation 2022 - 2023

<body>

<div id="mine">
<div class="wrapper-left">
<div class="sidebar-left">
<div class="grid-sidebar" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "logopic2.jpg"; ?>" alt="" style=" height:30px;
width:200px; " />
</div>
</div>

<a href="home.php">
<div class="grid-sidebar bg-active" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweethome.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>
<div class="wrapper-left-elements">
<a href="home.php" style="margin-top: 4px;"><strong>Home</strong></a>
</div>
</div>
</a>

<a href="notification.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align position-relative">
<?php if ($notify_count > 0) { ?>
<i class="notify-count"><?php echo $notify_count; ?></i>
<?php } ?>
<img
src="<?php echo BASE_URL . "/includes/icons/tweetnotif.png"; ?>"
alt=""
height="26.25px"
width="26.25px"
/>
</div>

<div class="wrapper-left-elements">
<a href="notification.php" style="margin-top:
4px"><strong>Notifications</strong></a>
</div>

YourThoughts 32
Implementation 2022 - 2023

</div>
</a>

<a href="<?php echo BASE_URL . $user->username; ?>">


<div class="grid-sidebar">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweetprof.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<!-- <a href="/twitter/<?php echo $user->username; ?>" style="margin-top:
4px"><strong>Profile</strong></a> -->
<a href="<?php echo BASE_URL . $user->username; ?>" style="margin-top:
4px"><strong>Profile</strong></a>

</div>
</div>
</a>
<a href="<?php echo BASE_URL . "account.php"; ?>">
<div class="grid-sidebar ">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweetsetting.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<a class="wrapper-left-active" href="<?php echo BASE_URL . "account.php"; ?>"
style="margin-top: 4px"><strong>Settings</strong></a>
</div>

</div>
</a>
<a href="includes/logout.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align">
<i style="font-size: 26px;" class="fas fa-sign-out-alt"></i>
</div>

<div class="wrapper-left-elements">
<a href="includes/logout.php" style="margin-top: 4px"><strong>Logout</strong></a>
</div>
</div>

YourThoughts 33
Implementation 2022 - 2023

</a>
<button class="button-twittear">
<strong>Post</strong>
</button>

<div class="box-user">
<div class="grid-user">
<div>
<img
src="assets/images/users/<?php echo $user->img ?>"
alt="user"
class="img-user"
/>
</div>
<div>
<p class="name"><strong><?php if($user->name !== null) {
echo $user->name; } ?></strong></p>
<p class="username">@<?php echo $user->username; ?></p>
</div>
<div class="mt-arrow">
<img
src="https://i.ibb.co/mRLLwdW/arrow-down.png"
alt=""
height="18.75px"
width="18.75px"
/>
</div>
</div>
</div>
</div>
</div>

<div class="grid-posts">
<div class="border-right">
<div class="grid-toolbar-center">
<div class="center-input-search">

</div>

</div>

<div class="box-fixed" id="box-fixed"></div>

YourThoughts 34
Implementation 2022 - 2023

<div class="box-home feed">


<div class="container">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-
orientation="vertical">
<a style="color:black !important;" class="nav-link active text-center" id="v-pills-
home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-
selected="true">Change Email or Username</a>
<a style="color:black !important;" class="nav-link text-center" id="v-pills-profile-
tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-
selected="false">Change Password</a>

</div>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-
labelledby="v-pills-home-tab">
<!-- Change EMAIL and USAERNAME Form -->

<form method="POST" action="handle/handleAccountSetting.php" class="py-4" >

<?php if (isset($_SESSION['errors_account'] )) {

?>

<?php foreach ($_SESSION['errors_account'] as $error) { ?>

<div class="alert alert-danger" role="alert">


<p style="font-size: 15px;" class="text-center"> <?php echo $error ; ?>
</p>
</div>
<?php } ?>

<?php } unset($_SESSION['errors_account']) ?>


<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" name="email" value="<?php echo $user->email; ?>"
class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp"
placeholder="Enter email">

</div>
<div class="form-group">
<label for="exampleInputPassword1">Username</label>
<input type="text" name="username" value="<?php echo $user->username; ?>"
class="form-control" id="exampleInputPassword1" placeholder="Username">

YourThoughts 35
Implementation 2022 - 2023

</div>

<div class="text-center">

<button type="submit" name="submit" class="btn btn-primary">Save


Changes</button>
</div>

</form>

</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-
pills-profile-tab">

<!-- Change Password Form -->

<form method="POST" action="handle/handleChangePassword.php" class="py-4"


>
<script src="assets/js/jquery-3.5.1.min.js"></script>
<?php if (isset($_SESSION['errors_password'] )) {

?>

<script>
$(document).ready(function(){
// Open modal on page load
$("#v-pills-profile-tab").click();

});
</script>

<?php foreach ($_SESSION['errors_password'] as $error) { ?>

<div class="alert alert-danger" role="alert">


<p style="font-size: 15px;" class="text-center"> <?php echo $error ; ?>
</p>
</div>
<?php } ?>

<?php } unset($_SESSION['errors_password']) ?>

<div class="form-group">

YourThoughts 36
Implementation 2022 - 2023

<label for="exampleInputEmail1">Old Password</label>


<input type="password" name="old_password" class="form-control"
id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Old Password">

</div>
<div class="form-group">
<label for="exampleInputPassword1">New Password</label>
<input type="password" name="new_password" class="form-control"
id="exampleInputPassword1" placeholder="New Password">
</div>

<div class="form-group">
<label for="exampleInputPassword1">Verify Password</label>
<input type="password" name="ver_password" class="form-control"
id="exampleInputPassword1" placeholder="New Password">
</div>

<div class="text-center">

<button type="submit" name="submit" class="btn btn-primary">Save


Changes</button>
</div>

</form>

</div>

</div>

</div>

</div>
</div>
<div>

<div style="width: 90%;" class="container">

<div class="input-group py-2 m-auto pr-5 position-relative">

<i id="icon-search" class="fas fa-search tryy"></i>


<input type="text" class="form-control search-input" placeholder="Search Twitter">
<div class="search-result">

YourThoughts 37
Implementation 2022 - 2023

</div>
</div>
</div>

<div class="box-share">
<p class="txt-share"><strong>Who to follow</strong></p>
<?php
foreach($who_users as $user) {
// $u = User::getData($user->user_id);
$user_follow = Follow::isUserFollow($user_id , $user->id) ;
?>
<div class="grid-share">
<a style="position: relative; z-index:5; color:black" href="<?php echo $user-
>username; ?>">
<img
src="assets/images/users/<?php echo $user->img; ?>"
alt=""
class="img-share"
/>
</a>
<div>
<p>
<a style="position: relative; z-index:5; color:black" href="<?php echo $user-
>username; ?>">
<strong><?php echo $user->name; ?></strong>
</a>
</p>
<p class="username">@<?php echo $user->username; ?>
<?php if (Follow::FollowsYou($user->id , $user_id)) { ?>
<span class="ml-1 follows-you">Follows You</span></p>
<?php } ?></p></p>
</div>
<div>
<button class="follow-btn follow-btn-m
<?= $user_follow ? 'following' : 'follow' ?>"
data-follow="<?php echo $user->id; ?>"
data-user="<?php echo $user_id; ?>"
data-profile="<?php echo $u_id; ?>"
style="font-weight: 700;">

YourThoughts 38
Implementation 2022 - 2023

<?php if($user_follow) { ?>


Following
<?php } else { ?>
Follow
<?php } ?>
</button>
</div>
</div>

<?php }?>

</div>

</div>
</div> </div>
<script src="assets/js/search.js"></script>
<script src="assets/js/follow.js"></script>
<script src="https://kit.fontawesome.com/38e12cc51b.js"
crossorigin="anonymous"></script>
<!-- <script src="assets/js/jquery-3.4.1.slim.min.js"></script> -->
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</body>

<style>

.container {
padding-left: 55px;
}

</style>

</html>

YourThoughts 39
Implementation 2022 - 2023

Home Page Code:


<?php

include 'core/init.php';

$user_id = $_SESSION['user_id'];

$user = User::getData($user_id);

if (User::checkLogIn() === false)


header('location: index.php');

$tweets = Tweet::tweets($user_id);
$who_users = Follow::whoToFollow($user_id);
$notify_count = User::CountNotification($user_id);

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

YourThoughts 40
Implementation 2022 - 2023

<title>Home | YourThoughts</title>

<link rel="shortcut icon" type="image/png" href="logopic2.jpg">


<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/all.min.css">
<link rel="stylesheet" href="assets/css/home_style.css?v=<?php echo time(); ?>">

</head>
<body>
<!-- This is a modal for welcome the new signup account! -->

<script src="assets/js/jquery-3.5.1.min.js"></script>

<?php if (isset($_SESSION['welcome'])) { ?>


<script>
$(document).ready(function(){
// Open modal on page load
$("#welcome").modal('show');

});
</script>

<!-- Modal -->


<div class="modal fade" id="welcome" tabindex="-1" role="dialog" aria-
labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="">
<div class="text-center">
<span class="modal-title font-weight-bold text-center" id="exampleModalLongTitle">
<span style="font-size: 20px;">Welcome <span style="color:#207ce5"><?php echo $user-
>name; ?></span> </span>
</span>
</div>
<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button> -->
</div>
<div class="modal-body">
<div class="text-center">

<h4 style="font-weight: 600; " >You've Signed up Successfully!</h4>

YourThoughts 41
Implementation 2022 - 2023

</div>
<p>This is developed by <span style="font-weight: 700;">Ahmad Raza</span>hi</p>
<p>The project includes post , repost , quote or even quote the quoted article , like post and
nested comments.
You can mention or add hashtag to yout post , change password or username.
Follow or unfollow people. get notificaction if any action happen. Search users by name or
username. and more!
</p>
<p>By default you followed
<a style="color:#207ce5;" href="codeastro"></a>
to see their posts.</p>
</div>

</div>
</div>
</div>

<?php unset($_SESSION['welcome']); } ?>

<!-- End welcome -->

<div id="mine">

<div class="wrapper-left">
<div class="sidebar-left">
<div class="grid-sidebar" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img class="Ahmad" src="<?php echo BASE_URL . "logopic2.jpg"; ?>" alt="" style="
height:30px; width:200px; "/>
</div>
</div>

<a href="home.php">
<div class="grid-sidebar bg-active" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweethome.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>
<div class="wrapper-left-elements">
<a class="wrapper-left-active" href="home.php" style="margin-top:
4px;"><strong>Home</strong></a>
</div>
</div>

YourThoughts 42
Implementation 2022 - 2023

</a>

<a href="notification.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align position-relative">
<?php if ($notify_count > 0) { ?>
<i class="notify-count"><?php echo $notify_count; ?></i>
<?php } ?>
<img
src="<?php echo BASE_URL . "/includes/icons/tweetnotif.png"; ?>"
alt=""
height="26.25px"
width="26.25px"
/>

</div>

<div class="wrapper-left-elements">
<a href="notification.php" style="margin-top:
4px"><strong>Notifications</strong></a>
</div>
</div>
</a>

<a href="<?php echo BASE_URL . $user->username; ?>">


<div class="grid-sidebar">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweetprof.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<!-- <a href="/twitter/<?php echo $user->username; ?>" style="margin-top:
4px"><strong>Profile</strong></a> -->
<a href="<?php echo BASE_URL . $user->username; ?>" style="margin-top:
4px"><strong>Profile</strong></a>

</div>
</div>
</a>
<a href="<?php echo BASE_URL . "account.php"; ?>">
<div class="grid-sidebar ">
<div class="icon-sidebar-align">

YourThoughts 43
Implementation 2022 - 2023

<img src="<?php echo BASE_URL . "/includes/icons/tweetsetting.png"; ?>" alt=""


height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<a href="<?php echo BASE_URL . "account.php"; ?>" style="margin-top:
4px"><strong>Settings</strong></a>
</div>

</div>
</a>
<a href="includes/logout.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align">
<i style="font-size: 26px;" class="fas fa-sign-out-alt"></i>
</div>

<div class="wrapper-left-elements">
<a href="includes/logout.php" style="margin-top: 4px"><strong>Logout</strong></a>
</div>
</div>
</a>
<button class="button-twittear">
<strong>Post</strong>
</button>

<div class="box-user">
<div class="grid-user">
<div>
<img
src="assets/images/users/<?php echo $user->img ?>"
alt="user"
class="img-user"
/>
</div>
<div>
<p class="name"><strong><?php if($user->name !== null) {
echo $user->name; } ?></strong></p>
<p class="username">@<?php echo $user->username; ?></p>
</div>
<div class="mt-arrow">
<img
src="https://i.ibb.co/mRLLwdW/arrow-down.png"

YourThoughts 44
Implementation 2022 - 2023

alt=""
height="18.75px"
width="18.75px"
/>
</div>
</div>
</div>
</div>
</div>

<div class="grid-posts">
<div class="border-right">
<div class="grid-toolbar-center">
<div class="center-input-search">
<div class="input-group-login" id="whathappen">

<div class="container">
<div class="part-1">
<div class="header">
<div class="home">
<h2>Home</h2>
</div>
<!-- <div class="icon">
<button type="button" name="button">+</button>
</div> -->
</div>

<div class="text">
<form class="" action="handle/handleTweet.php" method="post"
enctype="multipart/form-data">
<div class="inner">

<img src="assets/images/users/<?php echo $user->img ?>" alt="profile


photo">

<label>

<textarea class="text-whathappen" name="status" rows="8" cols="80"


placeholder="What's happening?"></textarea>

</label>
</div>

YourThoughts 45
Implementation 2022 - 2023

<!-- tmp image upload place -->


<div class="position-relative upload-photo">
<img class="img-upload-tmp" src="assets/images/tweets/tweet-
60666d6b426a1.jpg" alt="">
<div class="icon-bg">
<i id="#upload-delete-tmp" class="fas fa-times position-absolute upload-
delete"></i>

</div>
</div>

<div class="bottom">

<div class="bottom-container">

<label for="tweet_img" class="ml-3 mb-2 uni">

<i class="fa fa-image item1-pair"></i>


</label>
<input class="tweet_img" id="tweet_img" type="file" name="tweet_img">

</div>
<div class="hash-box">

<ul style="margin-bottom: 0;">

</ul>

</div>
<?php if (isset($_SESSION['errors_tweet'])) {

foreach($_SESSION['errors_tweet'] as $t) {?>

<div class="alert alert-danger">


<span class="item2-pair"> <?php echo $t; ?> </span>
</div>

<?php } } unset($_SESSION['errors_tweet']); ?>


<div>

YourThoughts 46
Implementation 2022 - 2023

<span class="bioCount" id="count">140</span>


<input id="tweet-input" type="submit" name="tweet" value="Post"
class="submit"
>
</div>
</div>
</form>
</div>
</div>
<div class="part-2">

</div>

</div>

</div>
</div>
<!-- <div class="mt-icon-settings">
<img src="https://i.ibb.co/W5T9ycN/settings.png" alt="" />
</div> -->
</div>
<div class="box-fixed" id="box-fixed"></div>

<?php include 'includes/tweets.php'; ?>

</div>

<div class="wrapper-right">
<div style="width: 90%;" class="container">

<div class="input-group py-2 m-auto pr-5 position-relative">

<i id="icon-search" class="fas fa-search tryy"></i>


<input type="text" class="form-control search-input" placeholder="Search
YourThoughts">
<div class="search-result">

</div>
</div>
</div>

YourThoughts 47
Implementation 2022 - 2023

Profile Page Code:


<?php

if (isset($_GET['username']) === true && empty($_GET['username']) === false ) {


include 'core/init.php';
$username = User::checkInput($_GET['username']);
$profileId = User::getIdByUsername($username);
$profileData = User::getData($profileId);
$user_id = $_SESSION['user_id'];
$user = User::getData($user_id);
$who_users = Follow::whoToFollow($user_id);
$tweets = Tweet::tweetsUser($profileData->id);
$liked_tweets = Tweet::likedTweets($profileData->id);
$media_tweets = Tweet::mediaTweets($profileData->id);
$notify_count = User::CountNotification($user_id);

if (!$profileData)
header('location: index.php');

if (User::checkLogIn() === false)


header('location: index.php');

/* $ah = " <link rel='stylesheet' href='assets/css/profile_style.css?v=<?php echo time(); ?>'>";


*/
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> <?php echo $profileData->name; ?> (@<?php echo $profileData->username; ?>) |
Twitter</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/all.min.css">
<link rel="stylesheet" href="assets/css/profile_style.css?v=<?php echo time(); ?>">

<link rel="shortcut icon" type="image/png" href="logopic2.jpg">

</head>
<body>

YourThoughts 48
Implementation 2022 - 2023

<script src="assets/js/jquery-3.5.1.min.js"></script>

<div id="mine">
<div class="wrapper-left">
<div class="sidebar-left">
<div class="grid-sidebar" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "logopic2.jpg"; ?>" alt="" style=" height:30px;
width:200px; " />
</div>
</div>

<a href="home.php">
<div class="grid-sidebar bg-active" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweethome.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>
<div class="wrapper-left-elements">
<a href="home.php" style="margin-top: 4px;"><strong>Home</strong></a>
</div>
</div>
</a>

<a href="notification.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align position-relative">
<?php if ($notify_count > 0) { ?>
<i class="notify-count"><?php echo $notify_count; ?></i>
<?php } ?>
<img
src="<?php echo BASE_URL . "/includes/icons/tweetnotif.png"; ?>"
alt=""
height="26.25px"
width="26.25px"
/>
</div>

<div class="wrapper-left-elements">
<a href="notification.php" style="margin-top:
4px"><strong>Notifications</strong></a>
</div>

YourThoughts 49
Implementation 2022 - 2023

</div>
</a>

<a href="<?php echo BASE_URL . $user->username; ?>">


<div class="grid-sidebar">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweetprof.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<!-- <a href="/twitter/<?php echo $user->username; ?>" style="margin-top:
4px"><strong>Profile</strong></a> -->
<a class="wrapper-left-active" href="<?php echo BASE_URL . $user->username;
?>" style="margin-top: 4px"><strong>Profile</strong></a>

</div>
</div>
</a>
<a href="<?php echo BASE_URL . "account.php"; ?>">
<div class="grid-sidebar ">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweetsetting.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<a href="<?php echo BASE_URL . "account.php"; ?>" style="margin-top:
4px"><strong>Settings</strong></a>
</div>

</div>
</a>
<a href="includes/logout.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align">
<i style="font-size: 26px;" class="fas fa-sign-out-alt"></i>
</div>

<div class="wrapper-left-elements">
<a href="includes/logout.php" style="margin-top: 4px"><strong>Logout</strong></a>
</div>
</div>

YourThoughts 50
Implementation 2022 - 2023

</a>
<button class="button-twittear">
<strong>Tweet</strong>
</button>

<div class="box-user">
<div class="grid-user">
<div>
<img
src="assets/images/users/<?php echo $user->img ?>"
alt="user"
class="img-user"
/>
</div>
<div>
<p class="name"><strong><?php if($user->name !== null) {
echo $user->name; } ?></strong></p>
<p class="username">@<?php echo $user->username; ?></p>
</div>
<div class="mt-arrow">
<img
src="https://i.ibb.co/mRLLwdW/arrow-down.png"
alt=""
height="18.75px"
width="18.75px"
/>
</div>
</div>
</div>
</div>
</div>

<div class="grid-posts">
<div class="border-right">
<div class="grid-toolbar-center">
<div class="center-input-search">

</div>

</div>

<div class="box-fixed" id="box-fixed"></div>

YourThoughts 51
Implementation 2022 - 2023

<div class="box-home feed">


<div class="container">
<div class="row position-fixed box-name">
<div class="col-xs-2">
<a href="javascript: history.go(-1);"> <i style="font-size:20px;" class="fas fa-
arrow-left arrow-style"></i> </a>
</div>
<div class="col-xs-10">
<span class="home-name"> <?php echo $profileData->name; ?></span>
<p class="home-tweets-num">
<?php echo Tweet::countTweets($profileData->id); ?> Post</p>
</div>
</div>

<div class="row mt-5">

<div class="col-md-12">
<img class="w-100 home-img-cover" src="assets/images/users/<?php echo
$profileData->imgCover; ?>" alt="">
</div>

</div>

<div class="row justify-content-between">


<img class="home-img-user" src="assets/images/users/<?php echo $profileData-
>img; ?>" alt="">

<?php if ($user->id == $profileData->id) { ?>


<button class="home-edit-button" data-toggle="modal" data-target="#edit">Edit
Profile</button>

<!-- Modal Edit Profile -->


<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-
labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">

<form method="POST" action="handle/handleUpdateData.php"


enctype="multipart/form-data">

<div style="width: 300%;" class="d-flex justify-content-between">

YourThoughts 52
Implementation 2022 - 2023

<div>
<h5 class="modal-title d-inline" id="exampleModalLongTitle">Edit
Profile</h5>
</div>
<div>

<!-- <button type="button" class="close" data-dismiss="modal" aria-


label="Close"> -->
<!-- btn submit form -->
<button type="submit" name="update" class="btn btn-
primary">Save</button>
</div>

</div>
<!-- <span aria-hidden="true">&times;</span> -->

</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="image-upload">
<label for="cover-input">
<i style="top: 80px;
left:200px;
color:white;
font-size:18px " class="far fa-images position-absolute"></i>
</label>
<input id="cover-input" type="file" name="cover"/>
<a href="handle/handleDeleteCover.php" style="top: 80px;
left:260px;
color:red;
font-size:18px " class="fas fa-times position-absolute"></a>

<img id="preview-cover" class="w-100 home-img-cover"


src="assets/images/users/<?php echo $profileData->imgCover; ?>" alt="">
</div>
</div>

<div class="image-upload">

<label for="file-input">
<i style="top: 240px;
left:100px;

YourThoughts 53
Implementation 2022 - 2023

color:white;
font-size:18px;
z-index:20 " class="far fa-images position-absolute"></i>
</label>
<input id="file-input" name="image" type="file"/>
</div>

<img id="preview-user" class="home-img-user"


src="assets/images/users/<?php echo $profileData->img; ?>" alt="">

</div>
<!-- <form class="" action=""> -->
<?php if (isset($_SESSION['errors'] )) { ?>
<script>
$(document).ready(function(){
// Open modal on page load
$("#edit").modal('show');

});
</script>
<?php foreach ($_SESSION['errors'] as $error) { ?>
<div class="alert alert-danger" role="alert">
<p style="font-size: 15px;" class="text-center"> <?php echo $error ;
?> </div> <?php } }
unset($_SESSION['errors']) ?> </p>

<div class="form-group">
<input type="text" name="name" class="form-control"
id="exampleInputEmail1" value="<?php echo $user->name; ?>" aria-describedby="emailHelp"
placeholder="Name">
</div>
<div class="form-group">
<input type="text" name="bio" class="form-control"
id="exampleInputEmail1" value="<?php if ($user->bio !== null)
echo $user->bio ;?>" aria-describedby="emailHelp" placeholder="Bio">
</div>
<div class="form-group">

<input type="text" name="website" class="form-control"


id="exampleInputEmail1" value="<?php if ($user->website !== null)
echo $user->website ;?>" aria-describedby="emailHelp"
placeholder="Website">

YourThoughts 54
Implementation 2022 - 2023

</div>
<div class="form-group">

<input type="text" name="location" class="form-control" value="<?php if


($user->location !== null)
echo $user->location ;?>" id="exampleInputPassword1"
placeholder="Location">
</div>
<div class="text-center">
<!-- <button type="submit" name="signup" class="btn btn-primary">Sign
Up</button> -->
</div>
</form>
</div>

</div>
</div>
</div>
<!-- End Edit Modal -->

<?php } else {
$user_follow = Follow::isUserFollow($user_id , $profileData->id) ;
?>
<button class=" follow-btn
<?= $user_follow ? 'following' : 'follow' ?>"
data-follow="<?php echo $profileData->id; ?>">
<?php if($user_follow) { ?>
Following
<?php } else { ?>
Follow
<?php } ?>
</button>
<?php } ?>

</div>
<div class="home-title">
<h4><?php echo $profileData->name; ?></h4>
<p class="user-handle" style="color: gray;">@<?php echo $profileData->username;
?>
<?php if (Follow::FollowsYou($profileData->id , $user_id)) { ?>
<span class="ml-1 follows-you">Follows You</span></p>
<?php } ?>

YourThoughts 55
Implementation 2022 - 2023

<p class="bio"><?php echo $profileData->bio; ?> </p>


</div>

<div class="row home-loc-link ml-2">


<?php if (!empty($profileData->location)) { ?>
<div class="col-md-4">
<li class=""> <i class="fas fa-map-marker-alt"></i> <?php echo $profileData-
>location; ?></li>
</div>
<?php } ?>
<?php if (!empty($profileData->website)) { ?>
<div class="col-md-4">
<li><i class="fas fa-link"></i>
<a href="<?php echo $profileData->website ;?>" target="_blank">
<?php echo parse_url($profileData->website, PHP_URL_HOST);; ?>
</a> </li>
</div>
<?php } ?>

</div>
<div class="row home-follow ml-2 mt-1">
<div class="col-md-3">
<div class="count-following-i"
data-follow = "<?php echo $profileData->id; ?>" >
<span class="home-follow-count count-following"><?php echo
Follow::countFollowing($profileData->id); ?></span> Followings</div>
</div>
<div class="col-md-3">
<div class="count-followers-i"
data-follow = "<?php echo $profileData->id; ?>">
<span class="home-follow-count count-followers"><?php echo
Follow::countFollowers($profileData->id); ?></span> Followers</div>
</div>
</div>

<div class="popupUsers">

</div>

<ul class="nav nav-tabs justify-content-center mt-4" id="myTab" role="tablist">


<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home"
role="tab" aria-controls="home" aria-selected="true">

YourThoughts 56
Implementation 2022 - 2023

Posts</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab"
aria-controls="profile" aria-selected="false">
Media</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact"
role="tab" aria-controls="contact" aria-selected="false">
Likes</a>
</li>
</ul>

<div class="tab-content" id="myTabContent">


<div class="tab-pane fade show active" id="home" role="tabpanel" aria-
labelledby="home-tab">

<?php include 'includes/tweets.php'; ?>

</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-
tab">
<?php
$tweets = $media_tweets;
include 'includes/tweets.php'; ?>
</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-
tab">

<?php
$tweets = $liked_tweets;
include 'includes/tweets.php'; ?>

</div>
</div>

</div>

</div>
</div>
<div class="wrapper-right">
<div style="width: 90%;" class="container">

YourThoughts 57
Implementation 2022 - 2023

<div class="input-group py-2 m-auto pr-5 position-relative">

<i id="icon-search" class="fas fa-search tryy"></i>


<input type="text" class="form-control search-input" placeholder="Search Twitter">
<div class="search-result">

</div>
</div>
</div>

<div class="box-share">
<p class="txt-share"><strong>Who to follow</strong></p>
<?php
foreach($who_users as $user) {
// $u = User::getData($user->user_id);
$user_follow = Follow::isUserFollow($user_id , $user->id) ;
?>
<div class="grid-share">
<a style="position: relative; z-index:5; color:black" href="<?php echo $user-
>username; ?>">
<img
src="assets/images/users/<?php echo $user->img; ?>"
alt=""
class="img-share"
/>
</a>
<div>
<p>
<a style="position: relative; z-index:5; color:black" href="<?php echo $user-
>username; ?>">
<strong><?php echo $user->name; ?></strong>
</a>
</p>
<p class="username">@<?php echo $user->username; ?>
<?php if (Follow::FollowsYou($user->id , $user_id)) { ?>
<span class="ml-1 follows-you">Follows You</span></p>
<?php } ?></p></p>
</div>
<div>
<button class="follow-btn follow-btn-m
<?= $user_follow ? 'following' : 'follow' ?>"

YourThoughts 58
Implementation 2022 - 2023

data-follow="<?php echo $user->id; ?>"


data-user="<?php echo $user_id; ?>"
data-profile="<?php echo $profileData->id; ?>"
style="font-weight: 700;">
<?php if($user_follow) { ?>
Following
<?php } else { ?>
Follow
<?php } ?>
</button>
</div>
</div>

<?php }?>

</div>

</div>
</div> </div>

<script src="assets/js/search.js"></script>
<script src="assets/js/photo.js"></script>
<script src="assets/js/follow.js?v=<?php echo time(); ?>"></script>
<script src="assets/js/users.js?v=<?php echo time(); ?>"></script>
<script type="text/javascript" src="assets/js/hashtag.js"></script>
<script type="text/javascript" src="assets/js/like.js"></script>
<script type="text/javascript" src="assets/js/comment.js?v=<?php echo time();
?>"></script>
<script type="text/javascript" src="assets/js/retweet.js?v=<?php echo time();
?>"></script>
<script src="https://kit.fontawesome.com/38e12cc51b.js"
crossorigin="anonymous"></script>
<!-- <script src="assets/js/jquery-3.4.1.slim.min.js"></script> -->
<script src="assets/js/jquery-3.5.1.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</body>

<style>

YourThoughts 59
Implementation 2022 - 2023

.container {
padding-left: 55px;
}

</style>
</html>

<?php
include 'core/init.php';

$user_id = $_SESSION['user_id'];

$user = User::getData($user_id);

if (User::checkLogIn() === false)


header('location: index.php');

$tweet_id = $_GET['post_id'];
$tweet = Tweet::getData($tweet_id);
$who_users = Follow::whoToFollow($user_id);
$notify_count = User::CountNotification($user_id);

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Status | YourThoughts</title>
<base href="<?php echo BASE_URL; ?>">
<link rel="shortcut icon" type="image/png" href="logopic2.jpg">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/all.min.css">
<link rel="stylesheet" href="assets/css/home_style.css?v=<?php echo time(); ?>">

</head>
<body>
<script src="assets/js/jquery-3.5.1.min.js"></script>

YourThoughts 60
Implementation 2022 - 2023

<div id="mine">

<div class="wrapper-left">
<div class="sidebar-left">
<div class="grid-sidebar" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "logopic2.jpg"; ?>" alt="" style=" height:30px;
width:200px; "/>
</div>
</div>

<a href="home.php">
<div class="grid-sidebar bg-active" style="margin-top: 12px">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweethome.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>
<div class="wrapper-left-elements">
<a class="wrapper-left-active" href="home.php" style="margin-top:
4px;"><strong>Home</strong></a>
</div>
</div>
</a>

<a href="notification.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align position-relative">
<?php if ($notify_count > 0) { ?>
<i class="notify-count"><?php echo $notify_count; ?></i>
<?php } ?>
<img
src="<?php echo BASE_URL . "/includes/icons/tweetnotif.png"; ?>"
alt=""
height="26.25px"
width="26.25px"
/>
</div>

<div class="wrapper-left-elements">
<a href="notification.php" style="margin-top:
4px"><strong>Notifications</strong></a>
</div>
</div>
</a>

YourThoughts 61
Implementation 2022 - 2023

<a href="<?php echo BASE_URL . $user->username; ?>">


<div class="grid-sidebar">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweetprof.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<!-- <a href="/twitter/<?php echo $user->username; ?>" style="margin-top:
4px"><strong>Profile</strong></a> -->
<a href="<?php echo BASE_URL . $user->username; ?>" style="margin-top:
4px"><strong>Profile</strong></a>

</div>
</div>
</a>
<a href="<?php echo BASE_URL . "account.php"; ?>">
<div class="grid-sidebar ">
<div class="icon-sidebar-align">
<img src="<?php echo BASE_URL . "/includes/icons/tweetsetting.png"; ?>" alt=""
height="26.25px" width="26.25px" />
</div>

<div class="wrapper-left-elements">
<a href="<?php echo BASE_URL . "account.php"; ?>" style="margin-top:
4px"><strong>Settings</strong></a>
</div>

</div>
</a>
<a href="includes/logout.php">
<div class="grid-sidebar">
<div class="icon-sidebar-align">
<i style="font-size: 26px;" class="fas fa-sign-out-alt"></i>
</div>

<div class="wrapper-left-elements">
<a href="includes/logout.php" style="margin-top: 4px"><strong>Logout</strong></a>
</div>
</div>
</a>
<button class="button-twittear">

YourThoughts 62
Implementation 2022 - 2023

<strong>Tweet</strong>
</button>

<div class="box-user">
<div class="grid-user">
<div>
<img
src="assets/images/users/<?php echo $user->img ?>"
alt="user"
class="img-user"
/>
</div>
<div>
<p class="name"><strong><?php if($user->name !== null) {
echo $user->name; } ?></strong></p>
<p class="username">@<?php echo $user->username; ?></p>
</div>
<div class="mt-arrow">
<img
src="https://i.ibb.co/mRLLwdW/arrow-down.png"
alt=""
height="18.75px"
width="18.75px"
/>
</div>
</div>
</div>
</div>
</div>

<div class="grid-posts">
<div class="border-right">
<div class="grid-toolbar-center">
<div class="center-input-search">

<div class="container" style="border-bottom: 1px solid #E9ECEF;">

<div class="row">
<div class="col-xs-1">
<!-- history go to the perv page and specific section user come from -->

YourThoughts 63
Implementation 2022 - 2023

<a href="javascript: history.go(-1);"> <i style="font-size:20px;" class="fas fa-arrow-


left arrow-style"></i> </a>
</div>
<div class="col-xs-10 mt-1">
<p class="tweet-name" style="
font-weight:700"> Post</p>

</div>

</div>
<div class="part-2">

</div>

</div>

</div>
<!-- <div class="mt-icon-settings">
<img src="https://i.ibb.co/W5T9ycN/settings.png" alt="" />
</div> -->
</div>

<div class="box-fixed" id="box-fixed"></div>

<?php

$retweet_sign = false;
$retweet_comment =false;
$qoq = false;

if (Tweet::isTweet($tweet->id)) {

$tweet_user = User::getData($tweet->user_id) ;
$tweet_real = Tweet::getTweet($tweet->id);
$timeAgo = Tweet::getTimeAgo($tweet->post_on) ;
$likes_count = Tweet::countLikes($tweet->id) ;
$user_like_it = Tweet::userLikeIt($user_id ,$tweet->id);
$retweets_count = Tweet::countRetweets($tweet->id) ;
$user_retweeted_it = Tweet::userRetweeetedIt($user_id ,$tweet->id);

YourThoughts 64
Implementation 2022 - 2023

} else if (Tweet::isRetweet($tweet->id)) {

$retweet = Tweet::getRetweet($tweet->id);

if ($retweet->retweet_msg == null) {

if ($retweet->retweet_id == null) {

// if retweeted normal tweet


$retweeted_tweet = Tweet::getTweet($retweet->tweet_id);
$tweet_user = User::getData($retweeted_tweet->user_id) ;
$tweet_real = Tweet::getTweet($retweet->tweet_id);
$timeAgo = Tweet::getTimeAgo($tweet_real->post_on) ;
$likes_count = Tweet::countLikes($retweet->tweet_id) ;
$user_like_it = Tweet::userLikeIt($user_id ,$retweet->tweet_id);
$retweets_count = Tweet::countRetweets($retweet->tweet_id) ;
$user_retweeted_it = Tweet::userRetweeetedIt($user_id ,$retweet->tweet_id);
$retweeted_user = User::getData($tweet->user_id);
$retweet_sign = true;
} else {

// this condtion if user retweeted quoted tweet or quote of quote tweet

$retweeted_tweet = Tweet::getRetweet($retweet->retweet_id);

if($retweeted_tweet->tweet_id != null) {
// here it's retweeted quoted
// if($retweeted_tweet->)
$tweet_user = User::getData($retweeted_tweet->user_id) ;
$timeAgo = Tweet::getTimeAgo($retweeted_tweet->post_on) ;
$likes_count = Tweet::countLikes($retweeted_tweet->post_id) ;
$user_like_it = Tweet::userLikeIt($user_id ,$retweeted_tweet->post_id);
$retweets_count = Tweet::countRetweets($retweeted_tweet->post_id) ;
$user_retweeted_it = Tweet::userRetweeetedIt($user_id ,$retweeted_tweet-
>post_id);

$tweet_inner = Tweet::getTweet($retweeted_tweet->tweet_id);
$user_inner_tweet = User::getData($tweet_inner->user_id) ;
$timeAgo_inner = Tweet::getTimeAgo($tweet_inner->post_on);
$retweeted_user = User::getData($tweet->user_id);
$retweet_sign = true;

YourThoughts 65
Implementation 2022 - 2023

$qoute = $retweeted_tweet->retweet_msg;
$retweet_comment = true;
} else {
// here is retweeted quoted of quoted

$retweet_sign = true;
$tweet_user = User::getData($retweeted_tweet->user_id) ;

$timeAgo = Tweet::getTimeAgo($retweeted_tweet->post_on) ;
$likes_count = Tweet::countLikes($retweeted_tweet->post_id) ;
$user_like_it = Tweet::userLikeIt($user_id ,$retweeted_tweet->post_id);
$retweets_count = Tweet::countRetweets($retweeted_tweet->post_id) ;
$user_retweeted_it = Tweet::userRetweeetedIt($user_id ,$retweeted_tweet-
>post_id);

$qoq = true; // stand for quote of quote


$qoute = $retweeted_tweet->retweet_msg;
$tweet_inner = Tweet::getRetweet($retweeted_tweet->retweet_id);
$user_inner_tweet = User::getData($tweet_inner->user_id) ;
$timeAgo_inner = Tweet::getTimeAgo($tweet_inner->post_on);
$inner_qoute = $tweet_inner->retweet_msg;

$retweeted_user = User::getData($tweet->user_id);

}
}

} else {
// quote tweet condtion
if ($retweet->retweet_id == null) {
$tweet_user = User::getData($tweet->user_id) ;
$timeAgo = Tweet::getTimeAgo($tweet->post_on) ;
$likes_count = Tweet::countLikes($tweet->id) ;
$user_like_it = Tweet::userLikeIt($user_id ,$tweet->id);
$retweets_count = Tweet::countRetweets($tweet->id) ;
$user_retweeted_it = Tweet::userRetweeetedIt($user_id ,$tweet->id);
$qoute = $retweet->retweet_msg;
$retweet_comment = true;

$tweet_inner = Tweet::getTweet($retweet->tweet_id);

YourThoughts 66
Implementation 2022 - 2023

$user_inner_tweet = User::getData($tweet_inner->user_id) ;
$timeAgo_inner = Tweet::getTimeAgo($tweet_inner->post_on);
} else {

// this condtion for quote of quote which retweet_id not null and retweet msg not null
$tweet_user = User::getData($tweet->user_id) ;
$timeAgo = Tweet::getTimeAgo($tweet->post_on) ;
$likes_count = Tweet::countLikes($tweet->id) ;
$user_like_it = Tweet::userLikeIt($user_id ,$tweet->id);
$retweets_count = Tweet::countRetweets($tweet->id) ;
$user_retweeted_it = Tweet::userRetweeetedIt($user_id ,$tweet->id);
$qoute = $retweet->retweet_msg;
$qoq = true; // stand for quote of quote

$tweet_inner = Tweet::getRetweet($retweet->retweet_id);
$user_inner_tweet = User::getData($tweet_inner->user_id) ;
$timeAgo_inner = Tweet::getTimeAgo($tweet_inner->post_on);
$inner_qoute = $tweet_inner->retweet_msg;
if($inner_qoute == null) {

$tweet_innerr = Tweet::getRetweet($tweet_inner->retweet_id);
$inner_qoute = $tweet_innerr->retweet_msg;

// $inner_quote = "qork";

}
$tweet_link = $tweet->id;

// show real tweet comments if retweeted tweet


if ($retweet_sign)
$comments = Tweet::comments($retweeted_tweet->id);
else $comments = Tweet::comments($tweet_id);

if($retweet_sign)
$comment_count = Tweet::countComments($retweeted_tweet->id);
else $comment_count = Tweet::countComments($tweet->id);

YourThoughts 67
Implementation 2022 - 2023

?>

<div class="box-tweet feed" style="position: relative;" >


<a href="status/<?php echo $tweet->id; ?>">
<span style="position:absolute; width:100%; height:100%; top:0;left: 0; z-index:
1;"></span>
</a>
<?php if ($retweet_sign) { ?>
<span class="retweed-name"> <i class="fa fa-retweet retweet-name-i" aria-
hidden="true"></i>
<a style="position: relative; z-index:100; color:rgb(102, 117, 130);" href="<?php echo
$retweeted_user->name; ?> "> <?php if($retweeted_user->id == $user_id) echo "You";
else echo $retweeted_user->name; ?> </a> retweeted</span>
<?php } ?>
<div class="grid-tweet">
<a style="position: relative; z-index:1000" href="<?php echo $tweet_user-
>username; ?>">
<img
src="assets/images/users/<?php echo $tweet_user->img; ?>"
alt=""
class="img-user-tweet"
/>
</a >

<div>
<p>
<a style="position: relative; z-index:1000; color:black" href="<?php echo $tweet_user-
>username; ?>">
<strong> <?php echo $tweet_user->name ?> </strong>
</a>
<span class="username-twitter">@<?php echo $tweet_user->username ?> </span>
<span class="username-twitter"><?php echo $timeAgo ?></span>
</p>
<p>
<?php
// check if it's quote or normal tweet
if ($retweet_comment || $qoq)
echo Tweet::getTweetLinks($qoute);
else echo Tweet::getTweetLinks($tweet_real->status); ?>
</p>
<?php if ($retweet_comment == false && $qoq == false) { ?>

YourThoughts 68
Implementation 2022 - 2023

<?php if ($tweet_real->img != null) { ?>


<p class="mt-post-tweet">
<img
src="assets/images/tweets/<?php echo $tweet_real->img; ?>"
alt=""
class="img-post-tweet"
/>
</p>
<?php } } else { ?>
<!-- ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss -->

<div class="mt-post-tweet comment-post" style="position: relative;">

<a href="status/<?php echo $tweet_inner->id; ?>">


<span class="" style="position:absolute; width:100%; height:100%; top:0;left: 0;
z-index: 2;"></span>
</a>
<div class="grid-tweet py-3 " >

<a style="position: relative; z-index:1000" href="<?php echo $user_inner_tweet-


>username; ?>">
<img
src="assets/images/users/<?php echo $user_inner_tweet->img; ?>"
alt=""
class="img-user-tweet"
/>
</a >

<div>
<p>
<a style="position: relative; z-index:1000; color:black" href="<?php echo
$user_inner_tweet->username; ?>">
<strong> <?php echo $user_inner_tweet->name ?> </strong>
</a>
<span class="username-twitter">@<?php echo $user_inner_tweet->username ?>
</span>
<span class="username-twitter"><?php echo $timeAgo_inner ?></span>
</p>
<p>
<?php
if ($qoq)
echo Tweet::getTweetLinks($inner_qoute);
else echo Tweet::getTweetLinks($tweet_inner->status); ?>
</p>

YourThoughts 69
Implementation 2022 - 2023

<?php // don't show img if quote of quote


if ($qoq == false) {
if ($tweet_inner->img != null) { ?>
<p class="mt-post-tweet">
<img
src="assets/images/tweets/<?php echo $tweet_inner->img; ?>"
alt=""
class="img-post-retweet"
/>
</p>
<?php } } ?

Javascript Code:
$(function(){

$(document).on('click','.comment', function(){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
$counter = $(this).find(".likes-count");
$count = $counter.text();
$button = $(this);

console.log(tweet_id);
console.log(user_id);
$.post('core/ajax/comment.php', {showPopup:tweet_id,user_id:user_id}, function(data){
$('.popupComment').html(data);

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
});
});

$(document).one('click', '.comment-it', function(event){


$('.retweet-popup').addClass('active');
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
// var flag = $(this).data('tmp');
// var qoq = $(this).data('qoq');

YourThoughts 70
Implementation 2022 - 2023

// tricky hint each function to select one class only


var comment ;
$('.retweet-msg').each(function(){
comment = $(this).val()
});
// event.stopImmediatePropagation();

// console.log(tweet_id);
// console.log(user_id);
// console.log(comment);

$.post('http://localhost/twitterclone/core/ajax/comment.php',
{qoute:tweet_id,user_id:user_id,comment:comment}, function(data){

$('.retweet-popup').hide();
$('.comments').html(data);

location.reload();

// $counter.text(data);
// $button.removeClass('retweet').addClass('retweeted');
});

});

$(document).on('click','.reply', function(){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
$counter = $(this).find(".likes-count");
$count = $counter.text();
$button = $(this);

console.log(tweet_id);
console.log(user_id);
$.post('http://localhost/twitterclone/core/ajax/comment.php',
{showReply:tweet_id,user_id:user_id}, function(data){
$('.popupComment').html(data);

YourThoughts 71
Implementation 2022 - 2023

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
});
});

$(document).one('click', '.reply-it', function(event){


$('.retweet-popup').addClass('active');
var comment_id = $(this).data('tweet');
var user_id = $(this).data('user');
// var flag = $(this).data('tmp');
// var qoq = $(this).data('qoq');

// tricky hint each function to select one class only


var comment ;
$('.retweet-msg').each(function(){
comment = $(this).val()
});
// event.stopImmediatePropagation();

// console.log(comment_id);
// console.log(user_id);
// console.log(comment);

$.post('http://localhost/twitterclone/core/ajax/comment.php',
{reply:comment_id,user_id:user_id,comment:comment}, function(data){

$('.retweet-popup').hide();
$('.comments').html(data);

location.reload();

// $counter.text(data);
// $button.removeClass('retweet').addClass('retweeted');
});

});
});
$(function(){

YourThoughts 72
Implementation 2022 - 2023

$(document).on('click','.follow-btn', function(e){
let follow_id = $(this).data('follow');
let user = $(this).data('user');
let profile = $(this).data('profile');
let following , followers;

$button = $(this);
if($button.hasClass('follow')) {
// alert(follow_id);
$.post('core/ajax/follow.php', {follow:follow_id}, function(data){
// alert(data);
$button.addClass('following');
$button.removeClass('follow');
$button.text("Following");
if (user == profile && profile != null) {
following = $('.count-following').html() ;
following++;
$('.count-following').html(following);
}
if (profile == null)
$('.count-followers').html(data);

// $counter.text(data);
// $button.removeClass('retweeted').addClass('retweet');
// $c.removeClass('retweeted-i').addClass('retweet-i');

});
} else {
$.post('core/ajax/follow.php', {unfollow:follow_id}, function(data){
$button.addClass('follow');
$button.removeClass('following');
$button.text("Follow");

if (user == profile && profile != null) {


following = $('.count-following').html() ;
following--;
$('.count-following').html(following);
}
if (profile == null)
$('.count-followers').html(data);

// $counter.text(data);

YourThoughts 73
Implementation 2022 - 2023

// $button.removeClass('retweeted').addClass('retweet');
// $c.removeClass('retweeted-i').addClass('retweet-i');

});
}

});

$(document).on('mouseover' , '.following' , function(e) {

$(this).html("Unfollow");

});
$(document).on('mouseout' , '.following' , function(e) {

$(this).html("Following");

});

});
$(function(){

$(document).on('click','.option', function(e){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
var retweeted_it = $(this).data('retweeted');
var status = $(this).data('status');

$counter = $(this).find(".likes-count");
$count = $counter.text();
$button = $(this);
$op = $(this).next();
// $op = $(this).find('.options');
var flag = $(this).data('tmp');
var sign = $(this).data('sign');
var qoq = $(this).data('qoq');

YourThoughts 74
Implementation 2022 - 2023

$.post('core/ajax/retweet.php', {option:tweet_id,user_id:user_id,retweeted:retweeted_it ,
sign:sign , tmp:flag,qoq:qoq , status:status}, function(data){
$op.html(data);

$(document).click(function(e){
if( $(e.target).closest('.options').length > 0 ) {
return false;
}

$('.retweet-div').hide();
})
});

$(document).one('click','.retweet-i', function(event){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
$c = $(this);

var qoq = $(this).data('qoq');


// event.stopPropagation();
event.stopImmediatePropagation();

$.post('core/ajax/retweet.php', {retweet:tweet_id,user_id:user_id,isQoute:flag,qoq:qoq},
function(data){
// $('.popupTweet').html(data);

$counter.text(data);
$button.removeClass('retweet').addClass('retweeted');
$c.removeClass('retweet-i').addClass('retweeted-i');
$('.retweet-div').hide();

// $.ajax({
// url: 'http://localhost/twitterclone/home.php',
// success: function(data) {

// window.location.reload(); // This is not jQuery but simple plain ol' JS

// }
// });

YourThoughts 75
Implementation 2022 - 2023

location.reload();
});

});

$(document).one('click','.retweeted-i', function(event){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
var status = $(this).data('status');

$c = $(this);

event.stopImmediatePropagation();
console.log(tweet_id);
$.post('core/ajax/retweet.php', {unretweet:tweet_id,user_id:user_id}, function(data){

// if (data == 0)
// $counter.text('');
// else
$counter.text(data);
$button.removeClass('retweeted').addClass('retweet');
$c.removeClass('retweeted-i').addClass('retweet-i');

$('.retweet-div').hide();
if (!status)
location.reload();
else history.go(-1);

});

});

$(document).on('click','.qoute', function(){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
$counter = $(this).find(".likes-count");
$count = $counter.text();

YourThoughts 76
Implementation 2022 - 2023

$button = $(this);

// console.log(tweet_id);
// console.log($retweeted_it);
// console.log($sign);
$.post('core/ajax/retweet.php', {showPopup:tweet_id,user_id:user_id}, function(data){
$('.popupTweet').html(data);

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
});
});

});

$(document).one('click', '.qoute-it', function(event){


$('.retweet-popup').addClass('active');
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
var flag = $(this).data('tmp');
var qoq = $(this).data('qoq');

event.stopImmediatePropagation();

// tricky hint each function to select one class only


var comment ;
$('.retweet-msg').each(function(){
comment = $(this).val()
});

console.log(tweet_id);
console.log(user_id);
console.log(comment);

$.post('core/ajax/retweet.php',
{qoute:tweet_id,user_id:user_id,comment:comment,isQoute:flag,qoq:qoq}, function(data){

$('.retweet-popup').hide();
location.reload();

// $counter.text(data);

YourThoughts 77
Implementation 2022 - 2023

// $button.removeClass('retweet').addClass('retweeted');
});

});
});

PhP Code:
<?php
include '../core/init.php';
require_once '../core/classes/validation/Validator.php';
use validation\Validator;

if (isset($_POST['login']) && !empty($_POST['login'])) {

$email = $_POST['email'];
$password = $_POST['password'];
if(!empty($email) && !empty($password)) {
$email = User::checkInput($email);
$password = User::checkInput($password);
}

$v = new Validator;
$v->rules('email' , $email , ['required' , 'email']);
$v->rules('password' , $password , ['required' , 'string']);
$errors = $v->errors;
if($errors == []) {
User::login($email , $password);
if(User::login($email , $password) === false ) {
// $errors = 'the email or password is not correct';/
$_SESSION['errors'] = ['the email or password is not correct'];
header('location: ../index.php') ;
}

} else {
$_SESSION['errors'] = $errors;
header('location: ../index.php') ;

YourThoughts 78
Implementation 2022 - 2023

} else header('location: ../index.php') ;

?>
<?php
include '../core/init.php';
require_once '../core/classes/validation/Validator.php';
use validation\Validator;

if (isset($_POST['signup'])) {

$email = $_POST['email'];
$name = $_POST['name'];
$password = $_POST['password'];
$username = $_POST['username'];

if(!empty($email) || !empty($password) || !empty($name) || !empty($username)) {


$email = User::checkInput($email);
$password = User::checkInput($password);
$name = User::checkInput($name);
$username = User::checkInput($username);

$v = new Validator;
$v->rules('name' , $name , ['required' , 'string' , 'max:20']);
$v->rules('username' , $username , ['required' , 'string' , 'max:20']);
$v->rules('email' , $email , ['required' , 'email']);
$v->rules('password' , $password , ['required' , 'string' , 'min:5']);
$errors = $v->errors;

if ($errors == []){
$username = str_replace(' ', '', $username);

YourThoughts 79
Implementation 2022 - 2023

if(User::checkEmail($email) === true) {


$_SESSION['errors_signup'] = ['This email is already use'];
header('location: ../index.php') ;
} else if (User::checkUserName($username) === true) {
$_SESSION['errors_signup'] = ['This username is already use'];
header('location: ../index.php') ;
} else if (!preg_match("/^[a-zA-Z0-9_]*$/" , $username)) {
$_SESSION['errors_signup'] = ['Only Chars and Numbers allowed in username'];
header('location: ../index.php') ;
} else {
User::register($email , $password ,$name , $username);

}
} else {

$_SESSION['errors_signup'] = $errors;
header('location: ../index.php'); }

} else header('location: ../index.php') ;

?>
<?php

include '../core/init.php';
require_once '../core/classes/validation/Validator.php';

use validation\Validator;

if (User::checkLogIn() === false)


header('location: index.php');

$user =User::getData($_SESSION['user_id']);

if (isset($_POST['submit'])) {

YourThoughts 80
Implementation 2022 - 2023

$email = User::checkInput($_POST['email']) ;
$username = User::checkInput($_POST['username']);

$v = new Validator;
$v->rules('username' , $username , ['required' , 'string' , 'max:20']);
$v->rules('email' , $email , ['required' , 'email']);
$errors = $v->errors;

if ($errors == []) {

if(User::checkEmail($email) === true && $email != $user->email) {


$_SESSION['errors_account'] = ['This email is already use'];
header('location: ../account.php') ;
} else if (User::checkUserName($username) === true && $username != $user->username)
{
$_SESSION['errors_account'] = ['This username is already use'];
header('location: ../account.php') ;
} else if (preg_match("/[^a-zA-Z0-9\!]/" , $username)) {
$_SESSION['errors_account'] = ['Only Chars and Numbers allowed in username'];
header('location: ../account.php') ;
} else {
$data = [
'email' => $email ,
'username' => $username
];

$sign= User::update('users' , $_SESSION['user_id'], $data);


header('location: ../account.php') ;
}

} else {

$_SESSION['errors_account'] = $errors;
header('location: ../account.php');

} else header('location: ../home.php');

?>
<?php
include '../core/init.php';
require_once '../core/classes/validation/Validator.php';

YourThoughts 81
Implementation 2022 - 2023

require_once '../core/classes/image.php';

use validation\Validator;

if (User::checkLogIn() === false)


header('location: index.php');

$username = User::getUserNameById($_SESSION['user_id']);

$user =User::getData($_SESSION['user_id']);
$currentImg = $user->img;
$currentCover = $user->imgCover;

if (isset($_POST['update'])) {

$name = User::checkInput($_POST['name']) ;
$bio = User::checkInput($_POST['bio']);
$website = User::checkInput($_POST['website']);
$location = User::checkInput($_POST['location']);
$cover = $_FILES['cover'];
$image = $_FILES['image'];

$v = new Validator;
$v->rules('name' , $name , ['required' , 'string' , 'max:20']);
$v->rules('bio' , $bio , ['string' , 'max:100']);
$v->rules('image' , $image , ['image']);
$v->rules('cover' , $cover , ['image']);

$errors = $v->errors;

if ($errors == []) {

if ($image['name'] !== "") {


$img = new Image($image);
$userImg = $img->new_name ;
} else $userImg = $user->img;

if ($cover['name'] !== "") {


$coverImg = new Image($cover);
$userCover = $coverImg->new_name;

YourThoughts 82
Implementation 2022 - 2023

} else $userCover = $user->imgCover;

// var_dump($userCover) ;
// echo "<br>";
// var_dump($userImg) ;

// die();

$data = [
'name' => $name ,
'bio' => $bio ,
'website' => $website ,
'location' => $location ,
'imgCover' => $userCover ,
'img' => $userImg ,
];

$sign= User::update('users' , $_SESSION['user_id'], $data);

if ($sign === true) {


if ($image['name'] !== "") {
if ($currentImg !== 'default.jpg')
unlink('../assets/images/users/' . $currentImg);

$img->upload();

}
if ($cover['name'] !== "") {
if ($currentCover !== 'cover.png')
unlink('../assets/images/users/' . $currentCover);

$coverImg->upload();
}

header('location: ../' . $username);


}

} else {

$_SESSION['errors'] = $errors;
header('location: ../' . $username);

YourThoughts 83
Implementation 2022 - 2023

} else header('location: ../' . $username);

?>
<?php

include '../core/init.php';

if (User::checkLogIn() === false)


header('location: index.php');

$username = User::getUserNameById($_SESSION['user_id']);

$user =User::getData($_SESSION['user_id']);

$currentCover = $user->imgCover;

if ($currentCover !== 'cover.png')


unlink('../assets/images/users/' . $currentCover);

YourThoughts 84
Implementation 2022 - 2023

$data = [
'imgCover' => 'cover.png' ,
];

$sign= User::update('users' , $_SESSION['user_id'], $data);

if ($sign == true) {
header('location: ../' . $username);
} else header('location: ../' . $username);

?>
<?php

include 'core/init.php' ;

if (isset($_SESSION['user_id'])) {
header('location: home.php');
}

?>

<html>
<head>
<title>YourThoughts</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.6.3/css/font-awesome.css"/>
<!-- <link rel="stylesheet" href="assets/css/style-complete.css"/> -->
<link rel="stylesheet" href="assets/css/index_style.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/all.min.css">

<link rel="shortcut icon" type="image/png" href="logopic2.jpg">


<style>
.login-bird{
width: 110px;
}
</style>
</head>

YourThoughts 85
Implementation 2022 - 2023

<body>
<main class="twt-main">
<section class="twt-login">
<?php include 'includes/login.php'; ?>
<div class="slow-login">
<img style=";" class="login-bird" src=" <?php echo BASE_URL .
"logopic2.jpg"; ?>" alt="bird">
<button class="login-small-display signin-btn pri-btn">Log in</button>
<span class="front-para">See what’s happening in the world right now</span>
<span class="join">Join YourThoughts Today.</span>
<button type="button" id="auto" onclick="" class="signup-btn pri-btn" data-
toggle="modal" data-target="#exampleModalCenter">
Sign Up</button>

<!-- Modal -->


<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-
labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 style="font-weight: 700;" class="modal-title" id="exampleModalLongTitle">Sign Up
For Free</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">

<?php include 'includes/signup-form.php' ?>


</div>

</div>
</div>
</div>

</div>
</section>
<section class="twt-features">
<div class="features-div">
<img class="twt-icon" src='https://image.ibb.co/bzvrkp/search_icon.png'>
<p>Follow your interests.</p>
<img class="twt-icon" src="https://image.ibb.co/mZPTWU/heart_icon.png">

YourThoughts 86
Implementation 2022 - 2023

<p>Hear what people are talking about.</p>


<img class="twt-icon" src="https://image.ibb.co/kw2Ad9/conv_icon.png">
<p>Join the conversation.</p>
</div>
</section>
<footer>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Help Center</a></li>
<li><a href="#">Terms</a></li>
<li><a href="#">Privacy Policy</a></li>
<li><a href="#">Cookies</a></li>
<li><a href="#">Ads info</a></li>
<li><a href="#">Brand</a></li>
<li><a href="#">Advertise</a></li>
<li><a href="#">Developers</a></li>
<li><a href="#">Settings</a></li>
<li>© 2023 - YourThoughts</li>
<li style="color:#1DA1F2;"><b>- Developed By Ahmad Raza -</b></li>
</ul>
</footer>
</main>

<script src="assets/js/jquery-3.4.1.slim.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/mine.js"></script>
</body>
</html>

$(function(){

$glo = this;
$(document).on('change','#file-input', function(e){

if (this.files && this.files[0]) {


let reader = new FileReader();
reader.onload=function(e){
let image = document.querySelector("#preview-user");
image.src = e.target.result;
}
reader.readAsDataURL(this.files[0]);
}

YourThoughts 87
Implementation 2022 - 2023

});

$(document).on('change','#cover-input', function(e){

if (this.files && this.files[0]) {


let reader = new FileReader();
reader.onload=function(e){
let image = document.querySelector("#preview-cover");
image.src = e.target.result;
}
reader.readAsDataURL(this.files[0]);
}

});

$(document).on('change','#tweet_img', function(e){
console.log(this);
$glo = this;
if (this.files && this.files[0]) {
let reader = new FileReader();
reader.onload=function(e){
let container = document.querySelector(".upload-photo");
container.style.display = "block";
let image = document.querySelector(".img-upload-tmp");
image.src = e.target.result;
}
// alert("all right");
reader.readAsDataURL(this.files[0]);
this.files = null;
}

});

$(document).on('click','.upload-delete', function(e){

let container = document.querySelector(".upload-photo");


container.style.display = "none";
let control =$("#tweet_img");
control.val("");
});
});
$(function(){

YourThoughts 88
Implementation 2022 - 2023

$(document).on('click','.option', function(e){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
var retweeted_it = $(this).data('retweeted');
var status = $(this).data('status');

$counter = $(this).find(".likes-count");
$count = $counter.text();
$button = $(this);
$op = $(this).next();
// $op = $(this).find('.options');
var flag = $(this).data('tmp');
var sign = $(this).data('sign');
var qoq = $(this).data('qoq');

$.post('core/ajax/retweet.php', {option:tweet_id,user_id:user_id,retweeted:retweeted_it ,
sign:sign , tmp:flag,qoq:qoq , status:status}, function(data){
$op.html(data);

$(document).click(function(e){
if( $(e.target).closest('.options').length > 0 ) {
return false;
}

$('.retweet-div').hide();
})
});

$(document).one('click','.retweet-i', function(event){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
$c = $(this);

var qoq = $(this).data('qoq');


// event.stopPropagation();
event.stopImmediatePropagation();

YourThoughts 89
Implementation 2022 - 2023

$.post('core/ajax/retweet.php', {retweet:tweet_id,user_id:user_id,isQoute:flag,qoq:qoq},
function(data){
// $('.popupTweet').html(data);

$counter.text(data);
$button.removeClass('retweet').addClass('retweeted');
$c.removeClass('retweet-i').addClass('retweeted-i');
$('.retweet-div').hide();

// $.ajax({
// url: 'http://localhost/twitterclone/home.php',
// success: function(data) {

// window.location.reload(); // This is not jQuery but simple plain ol' JS

// }
// });

location.reload();
});

});

$(document).one('click','.retweeted-i', function(event){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
var status = $(this).data('status');

$c = $(this);

event.stopImmediatePropagation();
console.log(tweet_id);
$.post('core/ajax/retweet.php', {unretweet:tweet_id,user_id:user_id}, function(data){

// if (data == 0)
// $counter.text('');
// else
$counter.text(data);

YourThoughts 90
Implementation 2022 - 2023

$button.removeClass('retweeted').addClass('retweet');
$c.removeClass('retweeted-i').addClass('retweet-i');

$('.retweet-div').hide();
if (!status)
location.reload();
else history.go(-1);

});

});

$(document).on('click','.qoute', function(){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
$counter = $(this).find(".likes-count");
$count = $counter.text();
$button = $(this);

// console.log(tweet_id);
// console.log($retweeted_it);
// console.log($sign);
$.post('core/ajax/retweet.php', {showPopup:tweet_id,user_id:user_id}, function(data){
$('.popupTweet').html(data);

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
});
});

});

$(document).one('click', '.qoute-it', function(event){


$('.retweet-popup').addClass('active');
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
var flag = $(this).data('tmp');
var qoq = $(this).data('qoq');

event.stopImmediatePropagation();

YourThoughts 91
Implementation 2022 - 2023

// tricky hint each function to select one class only


var comment ;
$('.retweet-msg').each(function(){
comment = $(this).val()
});

console.log(tweet_id);
console.log(user_id);
console.log(comment);

$.post('core/ajax/retweet.php',
{qoute:tweet_id,user_id:user_id,comment:comment,isQoute:flag,qoq:qoq}, function(data){

$('.retweet-popup').hide();
location.reload();

// $counter.text(data);
// $button.removeClass('retweet').addClass('retweeted');
});

});
});
$(function(){

$(document).on('click','.retweets-u', function(){
var tweet_id = $(this).data('tweet');

// console.log(tweet_id);

$.post('core/ajax/users.php', {retweetby:tweet_id}, function(data){


$('.popupUsers').html(data);

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
$(document).click(function(e){
if( $(e.target).closest('.retweet-popup-body-wrap').length > 0 ) {
return false;
}

YourThoughts 92
Implementation 2022 - 2023

$('.retweet-popup').hide();
})
});
});

$(document).on('click','.likes-u', function(){
var tweet_id = $(this).data('tweet');

// console.log(tweet_id);

$.post('core/ajax/users.php', {likeby:tweet_id}, function(data){


$('.popupUsers').html(data);

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
$(document).click(function(e){
if( $(e.target).closest('.retweet-popup-body-wrap').length > 0 ) {
return false;
}

$('.retweet-popup').hide();
})
});
});

$(document).on('click','.count-following-i', function(){
var user_id = $(this).data('follow');

$.post('core/ajax/users.php', {following:user_id}, function(data){


$('.popupUsers').html(data);

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
$(document).click(function(e){
if( $(e.target).closest('.retweet-popup-body-wrap').length > 0 ) {
return false;
}

YourThoughts 93
Implementation 2022 - 2023

$('.retweet-popup').hide();
})
});
});

$(document).on('click','.count-followers-i', function(){
var user_id = $(this).data('follow');

$.post('core/ajax/users.php', {follower:user_id}, function(data){


$('.popupUsers').html(data);

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
$(document).click(function(e){
if( $(e.target).closest('.retweet-popup-body-wrap').length > 0 ) {
return false;
}

$('.retweet-popup').hide();
})
});
});

$(document).on('click','.reply', function(){
var tweet_id = $(this).data('tweet');
var user_id = $(this).data('user');
$counter = $(this).find(".likes-count");
$count = $counter.text();
$button = $(this);

console.log(tweet_id);
console.log(user_id);
$.post('core/ajax/comment.php', {showReply:tweet_id,user_id:user_id}, function(data){
$('.popupComment').html(data);

YourThoughts 94
Implementation 2022 - 2023

$('.close-retweet-popup').click(function(){
$('.retweet-popup').hide();
})
});
});

});

<?php

class Follow extends User {

protected static $pdo;

public static function countFollowers($user_id) {


$stmt = self::connect()->prepare("SELECT COUNT(following_id) as count FROM
`follow`
WHERE following_id = :user_id");
$stmt->bindParam(":user_id" , $user_id , PDO::PARAM_STR);
$stmt->execute();
$count = $stmt->fetch(PDO::FETCH_OBJ);
return $count->count;
}
public static function countFollowing($user_id) {
$stmt = self::connect()->prepare("SELECT COUNT(follower_id) as count FROM `follow`
WHERE follower_id = :user_id");
$stmt->bindParam(":user_id" , $user_id , PDO::PARAM_STR);
$stmt->execute();
$count = $stmt->fetch(PDO::FETCH_OBJ);
return $count->count;
}
public static function isUserFollow($user_id ,$profile_id){

$stmt = self::connect()->prepare("SELECT `follower_id` , `following_id` FROM `follow`


WHERE `follower_id` = :user_id and `following_id` = :profile_id");
$stmt->bindParam(":user_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam(":profile_id", $profile_id, PDO::PARAM_INT);

YourThoughts 95
Implementation 2022 - 2023

$stmt->execute();

if ($stmt->rowCount() > 0) {
return true;
} else return false;

}
public static function usersFollowing($user_id){

$stmt = self::connect()->prepare("SELECT `following_id` as user_id FROM `follow`


WHERE follower_id = :user_id");
$stmt->bindParam(":user_id", $user_id, PDO::PARAM_INT);
$stmt->execute();

return $stmt->fetchAll(PDO::FETCH_OBJ);

}
public static function usersFollowers($user_id){

$stmt = self::connect()->prepare("SELECT `follower_id` as user_id FROM `follow`


WHERE following_id = :user_id");
$stmt->bindParam(":user_id", $user_id, PDO::PARAM_INT);
$stmt->execute();

return $stmt->fetchAll(PDO::FETCH_OBJ);

}
public static function whoToFollow($user_id){
$stmt = self::connect()->prepare("SELECT * FROM `users`
WHERE `id` != :user_id AND `id` NOT IN
(SELECT `following_id` FROM `follow` WHERE `follower_id` = :user_id) ORDER BY
rand() LIMIT 3");
// $stmt->execute(array("user_id" => $user_id));
$stmt->bindParam(":user_id", $user_id, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_OBJ);
}
public static function FollowsYou($profile_id , $user_id){
$stmt = self::connect()->prepare("SELECT * FROM `follow`
WHERE `follower_id` = :profile_id AND `following_id` = :user_id");
$stmt->bindParam(":user_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam(":profile_id", $profile_id, PDO::PARAM_INT);
$stmt->execute();
if ($stmt->rowCount() > 0) {

YourThoughts 96
Implementation 2022 - 2023

return true;
} else return false;
}

}
<?php

class Image {

private $name;
private $tmp_name;
public $new_name;
protected $sign;

public function __construct($img , $tweet = null) {

$this->name =$img['name'];
$this->tmp_name =$img['tmp_name'];

$ext = pathinfo($this->name)['extension'];

if ($tweet != null) {
$this->new_name = 'tweet-' . uniqid() . '.' . $ext ;
$this->sign = true;
} else $this->new_name = 'user-' . uniqid() . '.' . $ext ;

public function upload () {


if ($this->sign == true)
move_uploaded_file($this->tmp_name , '../assets/images/tweets/' . $this->new_name);
else move_uploaded_file($this->tmp_name , '../assets/images/users/' . $this->new_name);
}

YourThoughts 97
Implementation 2022 - 2023

<?php

class User extends Connect {

protected static $pdo;

// public function __construct($pdo) {


// $this->pdo = $pdo;
// }

public static function checkInput ($input) {


$input = htmlspecialchars($input);
$input = trim($input);
$input = stripslashes($input);
return $input;
}

public static function login ($email , $password) {


$stmt = self::connect()->prepare("SELECT `id` from `users` WHERE `email` = :email
AND `password` = :password");
$stmt->bindParam(":email" , $email , PDO::PARAM_STR);
$password =md5($password);
$stmt->bindParam(":password" , $password , PDO::PARAM_STR);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_OBJ);

if ($stmt->rowCount() > 0) {
$_SESSION['user_id'] = $user->id;
header('location: ../home.php');
} else {return false; }
}

public static function create($table , $fields = array()) {


$colms = implode(',' , array_keys($fields));
$values = ':' . implode(', :' , array_keys($fields));
$sql = "INSERT INTO {$table} ({$colms}) VALUES ({$values})";
$pdo = self::connect();
$pdo->beginTransaction();
if($stmt = $pdo->prepare($sql)) {
foreach($fields as $key => $data) {

YourThoughts 98
Implementation 2022 - 2023

$stmt->bindValue(':'. $key , $data );


}
if ($stmt->execute() === FALSE) {
$pdo->rollback();
} else {
$user_id = $pdo->lastInsertId();
$pdo->commit();
}
return $user_id;
}
}
public static function register($email , $password , $name , $username) {

$pdo = self::connect();
$pdo->beginTransaction();
$stmt = $pdo->prepare("INSERT INTO `users` (`email` , `password` , `name` , `username`)
Values (:email , :password , :name , :username)");

$stmt->bindParam(":email" , $email , PDO::PARAM_STR);


$password =md5($password);
$stmt->bindParam(":password" , $password , PDO::PARAM_STR);
$stmt->bindParam(":name" , $name , PDO::PARAM_STR);
$stmt->bindParam(":username" , $username , PDO::PARAM_STR);

if ($stmt->execute() === FALSE) {


$pdo->rollback();
echo 'Unable to insert data';
} else {
$user_id = $pdo->lastInsertId();
$pdo->commit();
}
$_SESSION['user_id'] = $user_id;

// make user follow the owner by default and notofications also


date_default_timezone_set("Africa/Cairo");
$data = [
'follower_id' => $user_id ,
'following_id' => 2 ,
'time' => date("Y-m-d H:i:s")
];
User::create('follow' , $data);
$data_notify = [
'notify_for' => 2,
'notify_from' => $user_id ,

YourThoughts 99
Implementation 2022 - 2023

'target' => 0,
'type' => 'follow' ,
'time' => date("Y-m-d H:i:s") ,
'count' => '0' ,
'status' => '0'
];
Tweet::create('notifications' , $data_notify);

$_SESSION['welcome'] = 'welcome';
header('location: ../home.php') ;

}
public static function update($table , $user_id , $fields = array()){
$colms = '';
$loopCount = 1;
// to know when i insert ','
foreach ($fields as $name => $value) {
$colms .= "`{$name}` = :{$name}";
if($loopCount < count($fields)) {
$colms .= ', ' ; }

$loopCount++;
}
$sql = "UPDATE {$table} SET {$colms} WHERE id = {$user_id}";
$pdo = self::connect();
if($stmt = $pdo->prepare($sql)) {
foreach($fields as $key => $data) {
$stmt->bindValue(':'. $key , $data );
}
$stmt->execute();
return true;
}

public static function delete($table, $array){


$sql = "DELETE FROM " . $table;
$where = " WHERE ";

foreach($array as $key => $value){


$sql .= $where . $key . " = " . $value . "";
$where = " AND ";
}
$sql .= ";";

YourThoughts 100
Implementation 2022 - 2023

$stmt = self::connect()->prepare($sql);
$stmt->execute();
}

public static function getData($id) {


$stmt = self::connect()->prepare("SELECT * from `users` WHERE `id` = :id");
$stmt->bindParam(":id" , $id , PDO::PARAM_STR);
$stmt->execute();
return $stmt->fetch(PDO::FETCH_OBJ);
}
public static function logout () {
$_SESSION = array();
session_destroy();
header('location: ../index.php');
}

public static function checkEmail($email) {


$stmt = self::connect()->prepare("SELECT `email` from `users` WHERE `email` =
:email");
$stmt->bindParam(":email" , $email , PDO::PARAM_STR);
$stmt->execute();

if ($stmt->rowCount() > 0) {
return true;
} else return false;
}

public static function checkUserName($username) {


$stmt = self::connect()->prepare("SELECT `username` from `users` WHERE `username`
= :username");
$stmt->bindParam(":username" , $username , PDO::PARAM_STR);
$stmt->execute();

if ($stmt->rowCount() > 0) {
return true;
} else return false;
}

public static function checkLogIn () {


if (isset($_SESSION['user_id']))
return true;
else return false;
}

YourThoughts 101
Implementation 2022 - 2023

public static function getIdByUsername($username) {


$stmt = self::connect()->prepare("SELECT `id` from `users` where `username` =
:username");
$stmt->bindParam(":username" , $username , PDO::PARAM_STR);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_OBJ);
return $user->id;
}

public static function getUserNameById($id) {


$stmt = self::connect()->prepare("SELECT `username` from `users` where `id` = :id");
$stmt->bindParam(":id" , $id , PDO::PARAM_STR);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_OBJ);
return $user->username;
}

public static function search($search){


$stmt = self::connect()->prepare("SELECT `id`,`username`,`name`,`img`,`imgCover`
FROM `users`
WHERE `username` LIKE ? OR `name` LIKE ?");
$stmt->bindValue(1, $search.'%', PDO::PARAM_STR);
$stmt->bindValue(2, $search.'%', PDO::PARAM_STR);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_OBJ);
}
public static function CountNotification($user_id){
$stmt = self::connect()->prepare("SELECT COUNT(notify_for) as count FROM
`notifications`
WHERE notify_for = :user_id AND count = 0");
$stmt->bindParam(":user_id" , $user_id , PDO::PARAM_STR);
$stmt->execute();
$u = $stmt->fetch(PDO::FETCH_OBJ);
return $u->count;
}
public static function notification($user_id){
$stmt = self::connect()->prepare("SELECT * FROM `notifications`
WHERE notify_for = :user_id ORDER BY time DESC");
$stmt->bindParam(":user_id" , $user_id , PDO::PARAM_STR);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_OBJ);
}
public static function updateNotifications($user_id){

YourThoughts 102
Implementation 2022 - 2023

$stmt = self::connect()->prepare("UPDATE `notifications` SET count = 1


WHERE notify_for = :user_id AND count = 0" );
$stmt->bindParam(":user_id" , $user_id , PDO::PARAM_STR);
$s =$stmt->execute();
if($s)
return true;
else return false;
}

YourThoughts 103
Testing 2022 - 2023

Chapter-5
Testing

5.1 Test Strategy:-

Testing a program consists of subjecting the program to a set of test inputs and observing if the
program behaves as expected then the condition under which failure occurs are noted for letter
debugging and correction.

Testing Principals: -

• All tests should be traceable to customer requirements.

• Testing Schedule: An overall testing schedule and resource planning must be made well in
advance.

• The Pareto principle implies that 80% of all errors uncovered during testing will likely be
traceable to 20% of program modules.

• Testing scheduling begins “in small “ and progress towards testing “in the large”

• Exhaustive testing is not possible for any system.

• To be most effective an independent third party should conduct testing.

YourThoughts 104
Testing 2022 - 2023

5.2 Test Cases:-

User Registration:
 Test Case 1: Verify that a new user can successfully register with valid credentials.
 Input: User provides a unique username, valid email address, password, and other
required details.
 Expected Output: User account is created, and the user is redirected to the login page.
 Test Case 2: Verify that an error is displayed when attempting to register with an existing
username or email.
 Input: User provides a username or email address that is already registered in the system.
 Expected Output: An error message is displayed indicating that the username or email is
already taken.
 Test Case 3: Verify that all required fields are validated and appropriate error messages
are displayed for missing or invalid information.
 Input: User tries to register without providing a username, email, or password, or enters
an invalid email format.
 Expected Output: Error messages are displayed for each missing or invalid field,
prompting the user to correct the information.

Fig.15 – User signup picture

YourThoughts 105
Testing 2022 - 2023

User Login:
 Test Case 1: Verify that a registered user can log in with correct username and password.
 Input: User enters the correct username and password.
 Expected Output: User is successfully logged in and redirected to the home page.
 Test Case 2: Verify that an error is displayed for invalid login credentials.
 Input: User enters an incorrect username or password.
 Expected Output: An error message is displayed indicating that the login credentials are
invalid.

Fig.16 – User Login Picture

YourThoughts 106
Testing 2022 - 2023

Post Creation:
 Test Case 1: Verify that a logged-in user can create a new tweet with valid content.
 Input: User enters a tweet message within the character limit.
 Expected Output: The tweet is successfully posted and displayed in the user's feed.
 Test Case 2: Verify that the tweet character limit is enforced correctly.
 Input: User exceeds the maximum character limit while creating a tweet.
 Expected Output: An error message is displayed indicating that the tweet exceeds the
character limit.
 Test Case 3: Verify that appropriate error messages are displayed for empty or
excessively long tweets.
 Input: User tries to post an empty tweet or a tweet with an extremely long content.
 Expected Output: Error messages are displayed prompting the user to enter valid tweet
content.

Fig.17 – Post Creation Picture

YourThoughts 107
Testing 2022 - 2023

User Profile:
 Verify that the user's profile page displays accurate information, including username
and bio.
 Verify that the user's tweets and comments are correctly displayed on their profile
page.
 Verify that the user's profile can be updated with new information.

Fig.18 – User Profile Picture

YourThoughts 108
Future Enhancement 2022 - 2023

Chapter-6

Future Enhancement

6.-Future Enhancement

Multimedia Support: Enhance the social media website to support multimedia content, such as
images, videos, and GIFs. Users will be able to upload and share media files along with their
posts, providing a more engaging and visually appealing experience.

Real-Time Notifications: Implement real-time notification features to notify users about new
followers, likes, comments, and mentions. This enhancement will improve user engagement and
keep users updated with the latest activities and interactions on their profiles.

Advanced Search and Filtering: Enhance the search functionality to provide advanced search
and filtering options. Users will be able to search for specific keywords, filter results based on
different criteria (e.g., date, location, user), and refine their search queries to find relevant
content more efficiently.

Social Sharing Integration: Integrate social sharing capabilities with popular platforms like
Facebook, Twitter, and LinkedIn. Users will have the option to share their posts directly from the
social media website to other platforms, expanding their reach and allowing for broader content
distribution.

Customization and Theming: Provide users with the ability to customize their profile pages by
choosing different themes, color schemes, and layout options. This enhancement will allow users
to personalize their profiles and make their social media experience more unique.

Analytics and Insights: Incorporate analytics and insights features to provide users with data
about their post engagements, audience demographics, and overall social media presence. Users
will be able to track their performance, identify trends, and make informed decisions to improve
their content strategy.

Privacy and Security Enhancements: Strengthen the privacy and security measures of the
social media website by implementing features such as two-factor authentication, privacy
settings, and content moderation tools. This will enhance user trust, protect user data, and create
a safer online environment.

YourThoughts 109
Future Enhancement 2022 - 2023

Mobile App Development: Develop a mobile application for the social media website to offer a
seamless and optimized user experience on smartphones and tablets. The mobile app will allow
users to access and interact with the platform conveniently from their mobile devices.
These future enhancements will add value to the social media website, enhance user experience,
and provide additional features and capabilities to meet the evolving needs of the users.

YourThoughts 110
Bibliography 2022 - 2023

Chapter-6

Bibliography

7.- Bibliography:-

Websites Reference:

Website and Forms Layouts:-

• https://getbootstrap.com/

MySQL Connection and Backend:-

• https://www.youtube.com
• https://www.geeksforgeeks.com

Javascript,PHP:-

• https://www.geeksforgeeks.com
• https://www.tutorrialspoint.com
• https://www.javatpoint.com

Website and forms layouts:-

• https://templatemo.com/
• https://freefrontend.com/bootstrap-login-foms/

Flexboxes, grids and other CSS components:-

• https://www.geeksforgeeks.org

YourThoughts 111

You might also like