List of commits:
Subject Hash Author Date (UTC)
Added new models 0af667e894277c7a08499ac0bb2a82650485ccb9 EyadMohammedOsama 2019-08-04 23:13:03
Added new views e4ba7fc0daf2c8a9200a76e8d122ea52a9e56972 EyadMohammedOsama 2019-08-04 23:12:09
Added a helper file 86cd8e39ae94a78b3caa4e5eedea0f465c5716dd EyadMohammedOsama 2019-08-04 23:11:00
Deleted some files 9c2486581af5e537a7f9ffa64b2b02e8c9d5f42e EyadMohammedOsama 2019-08-02 23:30:55
Updated to ignore Thumbs.db files 3baa87ecef6d298d4a8a2904baf08f7102f23074 EyadMohammedOsama 2019-08-01 21:27:32
Added SnackBar library 99f7cc6ce12deccc4c37ff89eb54d49e0e48d9c9 EyadMohammedOsama 2019-08-01 21:25:47
Added custom style file 99bb9924d4314c9e42be2f3be869b04aeaec134c EyadMohammedOsama 2019-08-01 21:25:28
Added Index view 667711e6118a09a284371bc12fc29c767ded5e9c EyadMohammedOsama 2019-08-01 21:25:18
Added layout views a2c90b3e7b9f5ff340ac8e59a5b48d89758681c1 EyadMohammedOsama 2019-08-01 21:25:08
Added Index controller 9dd0b66b1b62d562af373cfcc3bcf78d250f5ee3 EyadMohammedOsama 2019-08-01 21:24:43
Added Index router 3ff42e9e886700b0bde981bbe2e3c2252215b575 EyadMohammedOsama 2019-08-01 21:24:33
Added carousel images cb9537d5fcf4df2aa2d7ddddaeec4eacc179f84c EyadMohammedOsama 2019-08-01 21:24:03
Updated to skip /public/avatars 00aae37be4441d132f567125ac52dcbb7fea8173 EyadMohammedOsama 2019-08-01 21:23:26
Initial Commit 85fd17c94da1aae46dbd6c80b5376a4dcc4b15ef EyadMohammedOsama 2019-08-01 20:45:13
Commit 0af667e894277c7a08499ac0bb2a82650485ccb9 - Added new models
Author: EyadMohammedOsama
Author date (UTC): 2019-08-04 23:13
Committer name: EyadMohammedOsama
Committer date (UTC): 2019-08-04 23:13
Parent(s): e4ba7fc0daf2c8a9200a76e8d122ea52a9e56972
Signing key:
Tree: 68676b56db3e236b25bb4ff1ccadf1a492edac99
File Lines added Lines deleted
app/Errors.php 19 0
app/FavoriteFiddles.php 52 0
app/Fiddles.php 110 0
app/ReportedFiddles.php 22 0
app/Users.php 61 0
app/UsersSettings.php 53 0
File app/Errors.php added (mode: 100644) (index 0000000..f74e04e)
1 <?php
2
3 namespace SICSF;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 class Errors extends Model
8 {
9 public $timestamps = FALSE;
10
11 public function AddError($description)
12 {
13 self::insert([
14 "Description" => $description,
15 "Date" => date_timestamp_get(date_create()),
16 "HasBeenViewed" => 0
17 ]);
18 }
19 }
File app/FavoriteFiddles.php added (mode: 100644) (index 0000000..8aec2b9)
1 <?php
2
3 namespace SICSF;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 class FavoriteFiddles extends Model
8 {
9 protected $table = "FavoriteFiddles";
10 protected $primaryKey = NULL;
11 public $incrementing = FALSE;
12 protected $keyType = NULL;
13 public $timestamps = FALSE;
14
15 public static function GetFavoriteFiddles($username) {
16 return \DB::table("FavoriteFiddles")
17 ->join("Fiddles", "FavoriteFiddles.FiddleID", "=", "Fiddles.ID")
18 ->select("Fiddles.Title", "FavoriteFiddles.*")
19 ->get();
20 }
21
22 public static function GetFavoriteFiddlesCount($username) {
23 return self::where("Username", $username)->count();
24 }
25
26 public static function DeleteFavoriteFiddle($id, $username = "") {
27 if (empty($username)) {
28 self::where("FiddleID", $id)->delete();
29 }
30 else {
31 self::where([
32 ["FiddleID", "=", $id],
33 ["Username", "=", $username]
34 ])->delete();
35 }
36 }
37
38 public static function IsFavoriteFiddle($username, $id) {
39 return (self::where([
40 ["Username", "=", $username],
41 ["FiddeID", "=", $id]
42 ])->count() === 1);
43 }
44
45 public static function AddFavoriteFiddle($data) {
46 self::insert([
47 "FiddleID" => $data["FiddleID"],
48 "Username" => $data["Username"],
49 "FavoritingDate" => date_timestamp_get(date_create())
50 ]);
51 }
52 }
File app/Fiddles.php added (mode: 100644) (index 0000000..749a655)
1 <?php
2
3 namespace SICSF;
4
5 use Illuminate\Database\Eloquent\Model;
6 use SICSF\FavoriteFiddles;
7
8 class Fiddles extends Model
9 {
10 protected $primaryKey = "ID";
11 public $incrementing = FALSE;
12 protected $keyType = "string";
13 public $timestamps = FALSE;
14
15 public static function GetPublicFiddles($username) {
16 return self::where([
17 ["Username", "=", $username],
18 ["Privacy", "=", "Public"]
19 ])->select("ID", "Title", "Date")->get();
20 }
21
22 public static function GetPrivateFiddles($username) {
23 return self::where([
24 ["Username", "=", $username],
25 ["Privacy", "=", "Private"]
26 ])->select("ID", "Title", "Date")->get();
27 }
28
29 public static function GetFiddlesCount($username) {
30 return self::where("Username", $username)->count();
31 }
32
33 public static function GetPublicFiddlesCount($username) {
34 return self::where([
35 ["Username", "=", $username],
36 ["Privacy", "=", "Public"]
37 ])->count();
38 }
39
40 public static function GetPrivateFiddlesCount($username) {
41 return self::where([
42 ["Username", "=", $username],
43 ["Privacy", "=", "Private"]
44 ])->count();
45 }
46
47 public static function FiddleExists($id) {
48 return (self::where("ID", $id)->first() !== NULL);
49 }
50
51 public static function GetFiddle($id) {
52 return self::where("ID", $id)->first();
53 }
54
55 public static function AddFiddle($username, $data) {
56 self::insert([
57 "Username" => $username,
58 "ID" => md5($data["Code"]) . "-" . bin2hex(random_bytes(16)),
59 "Title" => $data["Title"],
60 "Code" => $data["Code"],
61 "Privacy" => $data["Privacy"],
62 "Date" => date_timestamp_get(date_create())
63 ]);
64 }
65
66 public static function GetAllFiddles($offset) {
67 if ($offset === -1) {
68 return self::where([
69 ["Privacy", "=", "Public"]
70 ])->select("ID", "Title", "Date", "Username")->get();
71 }
72 else {
73 return self::where([
74 ["Privacy", "=", "Public"]
75 ])->select("ID", "Title", "Date", "Username")
76 ->offset($offset * 20)
77 ->limit(20)
78 ->get();
79 }
80 }
81
82 public static function UpdateFiddle($data) {
83 self::transaction(function() use ($data) {
84 self::where("ID", $data["ID"])->update([
85 "Title" => $data["Title"],
86 "Code" => $data["Code"],
87 "Privacy" => $data["Privacy"]
88 ]);
89
90 if ($data["Privacy"] === "Private") {
91 FavoriteFiddles::DeleteFavoriteFiddle($data["ID"]);
92 }
93 });
94 }
95
96 public static function DeleteFiddle($id) {
97 self::transaction(function() use ($id) {
98 self::where("ID", $id)->delete();
99 FavoriteFiddles::DeleteFavoriteFiddle($id);
100 });
101 }
102
103 public static function GetAllFiddlesCount() {
104 return self::where("Privacy", "Public")->count();
105 }
106
107 public static function GetFiddleTitle($id) {
108 return self::where("ID", $id)->select("Title")->first();
109 }
110 }
File app/ReportedFiddles.php added (mode: 100644) (index 0000000..4a7b296)
1 <?php
2
3 namespace SICSF;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 class ReportedFiddles extends Model
8 {
9 protected $primaryKey = NULL;
10 public $incrementing = FALSE;
11 protected $keyType = NULL;
12 public $timestamps = FALSE;
13
14 public static function ReportFiddle($data) {
15 $Date = date_timestamp_get(date_create());
16 self::insert([
17 "FiddleID" => $data["FiddleID"],
18 "ReportReason" => $data["ReportReason"],
19 "Date" => $Date
20 ]);
21 }
22 }
File app/Users.php added (mode: 100644) (index 0000000..fc0d8e8)
1 <?php
2
3 namespace SICSF;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 class Users extends Model
8 {
9 protected $primaryKey = "Username";
10 public $incrementing = FALSE;
11 protected $keyType = "string";
12 public $timestamps = FALSE;
13
14 public static function EmailExists($email) {
15 return (self::where("Email", $email)->count() === 1);
16 }
17
18 public static function UsernameExists($username) {
19 return (self::where("Username", $username)->count() === 1);
20 }
21
22 public static function AddUser($data) {
23 $Hash = NULL;
24 while (($Hash = password_hash($data["Password"], PASSWORD_BCRYPT)) === FALSE) {}
25
26 self::insert([
27 "Username" => $data["Username"],
28 "Email" => $data["Email"],
29 "Password" => $Hash,
30 "RegisterationDate" => date_timestamp_get(date_create()),
31 "IsConfirmed" => FALSE
32 ]);
33 }
34
35 public static function UserExists($data) {
36 $Row = self::where("Email", $data["Email"])->first();
37 $Hash = $Row->Password;
38 $Password = $data["Password"];
39 return password_verify($Password, $Hash);
40 }
41
42 public static function GetUserByEmail($email) {
43 return self::where("Email", $email)->first();
44 }
45
46 public static function GetUserByUsername($username) {
47 return self::where("Username", $username)->first();
48 }
49
50 public static function IsConfirmed($username) {
51 $Row = self::where([
52 ["Username", "=", $username],
53 ["IsConfirmed", "=", 1]
54 ])->first();
55 return ($Row->IsConfirmed == TRUE);
56 }
57
58 public static function GetAllUsers() {
59 return self::select("Username", "RegisterationDate")->orderBy("RegisterationDate", "asc")->get();
60 }
61 }
File app/UsersSettings.php added (mode: 100644) (index 0000000..ef05090)
1 <?php
2
3 namespace SICSF;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 class UsersSettings extends Model
8 {
9 protected $table = "UsersSettings";
10 protected $primaryKey = NULL;
11 public $incrementing = FALSE;
12 protected $keyType = NULL;
13 public $timestamps = FALSE;
14
15 public static function GetUserSettings($username) {
16 $SettingsObject = new \stdClass();
17 $Settings = self::where("Username", $username)
18 ->select("Property", "Value")
19 ->get();
20
21 foreach ($Settings as $Setting) {
22 $SettingsObject->{$Setting->Property} = $Setting->Value;
23 }
24 return $SettingsObject;
25 }
26
27 public static function SetUserSettings($username, $data) {
28 foreach ($data as $property => $value) {
29 $PropertyExist = (self::where([
30 ["Username", "=", $username],
31 ["Property", "=", $property]
32 ])->count() === 1);
33
34 if ($PropertyExist) {
35 self::where([
36 ["Username", "=", $username],
37 ["Property", "=", $property]
38 ])->update([
39 "Value" => $value
40 ]);
41 }
42 else {
43 self::insert([
44 "Username" => $username,
45 "Property" => $property,
46 "Value" => $value
47 ]);
48 }
49 }
50 }
51
52
53 }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/EyadMohammedOsama/sicsf

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/EyadMohammedOsama/sicsf

Clone this repository using git:
git clone git://git.rocketgit.com/user/EyadMohammedOsama/sicsf

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main