Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1bc02c7

Browse files
35
1 parent 22ee4c0 commit 1bc02c7

File tree

308 files changed

+35878
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+35878
-0
lines changed

‎LESSON 25 - الدرس/app/active.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
2+
3+
<main class="container">
4+
5+
<?php
6+
7+
if(isset($_GET['code'])){
8+
$username = "root";
9+
$password = "";
10+
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
11+
12+
$checkCode = $database->prepare("SELECT SECURITY_CODE FROM users WHERE SECURITY_CODE = :SECURITY_CODE");
13+
$checkCode->bindParam("SECURITY_CODE",$_GET['code']);
14+
$checkCode->execute();
15+
if($checkCode->rowCount()>0){
16+
17+
$update = $database->prepare("UPDATE users SET SECURITY_CODE = :NEWSECURITY_CODE ,
18+
ACTIVATED=true WHERE SECURITY_CODE = :SECURITY_CODE");
19+
$securityCode = md5(date("h:i:s"));
20+
$update->bindParam("NEWSECURITY_CODE",$securityCode);
21+
$update->bindParam("SECURITY_CODE",$_GET['code']);
22+
23+
24+
if($update->execute()){
25+
echo '<div class="alert alert-success" role="alert">
26+
تم تحقق من حسابك بنجاح
27+
</div>';
28+
echo '<a class="btn btn-warning" href="login.php">تسجيل دخول</a>';
29+
}
30+
}else{
31+
echo '<div class="alert alert-danger" role="alert">
32+
هذا كود لم يعد صالحا للأستخدام
33+
</div>';
34+
}
35+
36+
}
37+
?>
38+
39+
40+
</main>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
<html >
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Home</title>
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
8+
9+
</head>
10+
<body>
11+
<!-- Image and text -->
12+
<nav class="navbar navbar-light bg-light">
13+
14+
<a class="navbar-brand" href="#">
15+
Coder Shiyar
16+
</a>
17+
18+
<img src="../img/logo.jpg" width="50" height="50" class="d-inline-block align-top" alt="" loading="lazy">
19+
20+
</nav>
21+
22+
<main class="container m-auto" style="max-width: 720px;">
23+
24+
<?php
25+
session_start();
26+
if(isset($_SESSION['user'])){
27+
if($_SESSION['user']->ROLE === "ADMIN"){
28+
echo '<div class="shadow p-3 mb-1 bg-white rounded mt-5"> Welcome ' .$_SESSION['user']->NAME . "</div>";
29+
echo '<a class="btn btn-light shadow w-100 mb-1" href="profile.php">تعديل ملف الشخصي</a>';
30+
31+
echo "<form> <button class='btn btn-danger w-100' type='submit' name='logout'>تسجيل خروج</button></form>";
32+
}else{
33+
header("location:http://localhost/App/login.php",true);
34+
die("");
35+
}
36+
}else{
37+
header("location:http://localhost/App/login.php",true);
38+
die("");
39+
}
40+
41+
if(isset($_GET['logout'])){
42+
session_unset();
43+
session_destroy();
44+
header("location:http://localhost/App/login.php",true);
45+
}
46+
?>
47+
</main>
48+
</body>
49+
</html>
50+
51+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Profile</title>
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
8+
9+
</head>
10+
<body>
11+
<nav class="navbar navbar-light bg-light">
12+
13+
<a class="navbar-brand" href="#">
14+
Coder Shiyar
15+
</a>
16+
17+
<img src="../img/logo.jpg" width="50" height="50" class="d-inline-block align-top" alt="" loading="lazy">
18+
19+
</nav>
20+
<main class="container " style="text-align: right; direction: rtl; max-width:760px; margin:auto;" >
21+
<?php
22+
session_start();
23+
if(isset($_SESSION['user'])){
24+
if($_SESSION['user']->ROLE === "ADMIN"){
25+
26+
27+
echo '<form method="POST">
28+
<div class="p-3 shadow "> اسم : </div>
29+
<input class="form-control mb-1" type="text" name="name" value="'.$_SESSION['user']->NAME.'" required />
30+
<div class="p-3 shadow "> العمر : </div>
31+
<input class="form-control mb-1" type="date" name="age" value="'.$_SESSION['user']->AGE.'" required />
32+
<div class="p-3 shadow "> كلمة المرور : </div>
33+
<input class="form-control mb-1" type="text" name="password" value="'.$_SESSION['user']->PASSWORD.'" required />
34+
35+
<button class="w-100 btn btn-warning mt-1" type="submit" name="update" value="'.$_SESSION['user']->ID.'">تحديث</button>
36+
<a class="w-100 btn btn-light mt-1" href="index.php"> عودة لصفحة الرئيسية</a>
37+
</form>';
38+
39+
if(isset($_POST['update'])){
40+
$username = "root";
41+
$password = "";
42+
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
43+
44+
$updateUserData = $database->prepare("UPDATE users SET NAME
45+
= :name ,PASSWORD = :password ,AGE=:age WHERE ID = :id ");
46+
$updateUserData->bindParam('name',$_POST['name']);
47+
$updateUserData->bindParam('password',$_POST['password']);
48+
$updateUserData->bindParam('age',$_POST['age']);
49+
$updateUserData->bindParam('id',$_POST['update']);
50+
if($updateUserData->execute()){
51+
echo '<div class="alert alert-success mt-3"> تم تحديث البيانات بنجاح </div>';
52+
$user = $database->prepare("SELECT * FROM users WHERE ID = :id ");
53+
$user->bindParam('id',$_POST['update']);
54+
$user->execute();
55+
$_SESSION['user'] = $user->fetchObject();
56+
header("refresh:2;");
57+
} else{
58+
echo '<div class="alert alert-alert mt-3"> فشل تحديث البيانات </div>';
59+
60+
61+
}
62+
}
63+
}else{
64+
session_unset();
65+
session_destroy();
66+
header("location:http://localhost/App/login.php",true);
67+
}
68+
}else{
69+
session_unset();
70+
session_destroy();
71+
header("location:http://localhost/App/login.php",true);
72+
}
73+
74+
?>
75+
76+
</main>
77+
</body>
78+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"phpmailer/phpmailer": "^6.1"
4+
}
5+
}

‎LESSON 25 - الدرس/app/composer.lock

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎LESSON 25 - الدرس/app/img/logo.jpg

24.9 KB
Loading[フレーム]

‎LESSON 25 - الدرس/app/index.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Coder Shiyar</title>
7+
<link rel="shortcut icon" href="img/logo.jpg" type="image/x-icon">
8+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
9+
</head>
10+
<body>
11+
<?php require_once 'nav.php' ?>
12+
13+
</body>
14+
</html>

‎LESSON 25 - الدرس/app/login.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Login</title>
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
8+
9+
</head>
10+
<body>
11+
<?php require_once 'nav.php' ?>
12+
13+
<main class="container mt-3" style="text-align: right!important;">
14+
<form method="POST">
15+
16+
<p class="font-weight-bold">بريد الكتروني </p>
17+
<input class="form-control" type="email" name="email" required/>
18+
19+
20+
<p class="font-weight-bold">كلمة المرور </p>
21+
<input class="form-control" type="password" name="password" required/>
22+
23+
<a class="btn btn-outline-dark mt-3" href="register.php">تسجيل </a>
24+
<button class="btn btn-warning mt-3" type="submit" name="login">تسجيل دخول</button>
25+
26+
</form>
27+
28+
<?php
29+
if(isset($_POST['login'])){
30+
$username = "root";
31+
$password = "";
32+
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
33+
34+
$login = $database->prepare("SELECT * FROM users WHERE EMAIL = :email AND PASSWORD = :password");
35+
$login->bindParam("email",$_POST['email']);
36+
$login->bindParam("password",$_POST['password']);
37+
$login->execute();
38+
if($login->rowCount()===1){
39+
$user = $login->fetchObject();
40+
if($user->ACTIVATED === "1"){
41+
session_start();
42+
$_SESSION['user'] = $user;
43+
44+
if($user->ROLE ==="USER"){
45+
header("location:user/index.php",true);
46+
}else if($user->ROLE ==="ADMIN"){
47+
header("location:admin/index.php",true);
48+
}else if($user->ROLE ==="SUPER-ADMIN"){
49+
header("location:super-admin/index.php",true);
50+
}
51+
52+
}else{
53+
echo '
54+
<div class="alert alert-warning">
55+
يرجى تفعيل حسابك في البداية , لقد ارسلنا
56+
رمز تحقق من حسابك إلى بريد الكتروني خاص بك
57+
</div>
58+
';
59+
}
60+
}else{
61+
echo '
62+
<div class="alert alert-danger">
63+
كلمة مرور او بريد الكتروني غير صحيح
64+
</div>
65+
';
66+
}
67+
}
68+
?>
69+
</main>
70+
71+
72+
</body>
73+
</html>

‎LESSON 25 - الدرس/app/mail.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
// Import PHPMailer classes into the global namespace
3+
// These must be at the top of your script, not inside a function
4+
use PHPMailer\PHPMailer\PHPMailer;
5+
use PHPMailer\PHPMailer\SMTP;
6+
use PHPMailer\PHPMailer\Exception;
7+
8+
// Load Composer's autoloader
9+
require 'mailer/autoload.php';
10+
11+
// Instantiation and passing `true` enables exceptions
12+
$mail = new PHPMailer();
13+
14+
//Server settings
15+
// $mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
16+
$mail->isSMTP(); // Send using SMTP
17+
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
18+
$mail->SMTPAuth = true; // Enable SMTP authentication
19+
$mail->Username = ''; // SMTP username
20+
$mail->Password = ''; // SMTP password
21+
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
22+
$mail->Port = 465; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
23+
24+
// Content
25+
$mail->isHTML(true);
26+
$mail->CharSet = "UTF-8";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
require_once __DIR__ . '/composer/autoload_real.php';
6+
7+
return ComposerAutoloaderInitb7d6377ee324d8c3f56c6d308c8f812a::getLoader();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /