Passed
Push — master ( 69d941...0f6eba )
by Maxwell
02:19
created
func/func.php 2 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -11,144 +11,144 @@
 block discarded – undo
11 11
 }
12 12
 
13 13
 function validateCSS($validate) {
14
-	$DISALLOWED = array("<?php", "?>", "behavior: url", ".php", "@import", "@\import", "@/import"); 
14
+    $DISALLOWED = array("<?php", "?>", "behavior: url", ".php", "@import", "@\import", "@/import"); 
15 15
 
16
-	$validated = str_replace($DISALLOWED, "", $validate);
16
+    $validated = str_replace($DISALLOWED, "", $validate);
17 17
     return $validated;
18 18
 }
19 19
 function validateMarkdown($comment) {
20
-	$markdown = new Michelf\Markdown;
21
-	$markdown->no_markup = true;
22
-	$transformed = $markdown->transform($comment);
23
-	return preg_replace(
24
-		"/<a href=(?:'|\")javascript:(.*?)(?:'|\")>(.*?)<\/a>/i",
25
-		"Attempted XSS: $2 ($1)",
26
-		$transformed
27
-	);
20
+    $markdown = new Michelf\Markdown;
21
+    $markdown->no_markup = true;
22
+    $transformed = $markdown->transform($comment);
23
+    return preg_replace(
24
+        "/<a href=(?:'|\")javascript:(.*?)(?:'|\")>(.*?)<\/a>/i",
25
+        "Attempted XSS: $2 ($1)",
26
+        $transformed
27
+    );
28 28
 }
29 29
 
30 30
 function validateCaptcha($privatekey, $response) {
31
-	$responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response));
32
-	return $responseData->success;
31
+    $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response));
32
+    return $responseData->success;
33 33
 }
34 34
 
35 35
 function requireLogin() {
36
-	if (!isset($_SESSION['user'])) {
37
-		header("Location: /login.php?r_login"); die();
38
-	}
36
+    if (!isset($_SESSION['user'])) {
37
+        header("Location: /login.php?r_login"); die();
38
+    }
39 39
 }
40 40
 
41 41
 function getGroup($id, $conn) {
42
-	$stmt = $conn->prepare("SELECT * FROM `groups` WHERE `id` = ?");
43
-	$stmt->bind_param("i", $id);
44
-	$stmt->execute();
45
-	$result = $stmt->get_result();
46
-	if ($result->num_rows === 0) return 'error';
47
-	return $result->fetch_assoc();
42
+    $stmt = $conn->prepare("SELECT * FROM `groups` WHERE `id` = ?");
43
+    $stmt->bind_param("i", $id);
44
+    $stmt->execute();
45
+    $result = $stmt->get_result();
46
+    if ($result->num_rows === 0) return 'error';
47
+    return $result->fetch_assoc();
48 48
 }
49 49
 
50 50
 function getID($user, $connection) {
51
-	$stmt = $connection->prepare("SELECT * FROM users WHERE username = ?");
52
-	$stmt->bind_param("s", $user);
53
-	$stmt->execute();
54
-	$result = $stmt->get_result();
55
-	if($result->num_rows === 0) return 'error';
56
-	while($row = $result->fetch_assoc()) {
57
-		$id = $row['id'];
58
-	} 
59
-	$stmt->close();
60
-	return $id;
51
+    $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?");
52
+    $stmt->bind_param("s", $user);
53
+    $stmt->execute();
54
+    $result = $stmt->get_result();
55
+    if($result->num_rows === 0) return 'error';
56
+    while($row = $result->fetch_assoc()) {
57
+        $id = $row['id'];
58
+    } 
59
+    $stmt->close();
60
+    return $id;
61 61
 }
62 62
 
63 63
 function getName($id, $connection) {
64
-	$stmt = $connection->prepare("SELECT * FROM users WHERE id = ?");
65
-	$stmt->bind_param("s", $id);
66
-	$stmt->execute();
67
-	$result = $stmt->get_result();
68
-	if($result->num_rows === 0) return('error');
69
-	while($row = $result->fetch_assoc()) {
70
-		$name = htmlspecialchars($row['username']);
71
-	} 
72
-	$stmt->close();
73
-	return $name;
64
+    $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?");
65
+    $stmt->bind_param("s", $id);
66
+    $stmt->execute();
67
+    $result = $stmt->get_result();
68
+    if($result->num_rows === 0) return('error');
69
+    while($row = $result->fetch_assoc()) {
70
+        $name = htmlspecialchars($row['username']);
71
+    } 
72
+    $stmt->close();
73
+    return $name;
74 74
 }
75 75
 
76 76
 function getPFP($user, $connection) {
77
-	$stmt = $connection->prepare("SELECT * FROM users WHERE username = ?");
78
-	$stmt->bind_param("s", $user);
79
-	$stmt->execute();
80
-	$result = $stmt->get_result();
81
-	if($result->num_rows === 0) return('error');
82
-	while($row = $result->fetch_assoc()) {
83
-		$pfp = htmlspecialchars($row['pfp']);
84
-	} 
85
-	$stmt->close();
86
-	return $pfp;
77
+    $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?");
78
+    $stmt->bind_param("s", $user);
79
+    $stmt->execute();
80
+    $result = $stmt->get_result();
81
+    if($result->num_rows === 0) return('error');
82
+    while($row = $result->fetch_assoc()) {
83
+        $pfp = htmlspecialchars($row['pfp']);
84
+    } 
85
+    $stmt->close();
86
+    return $pfp;
87 87
 }
88 88
 
89 89
 function checkIfFriended($friend1, $friend2, $connection)
90 90
 {
91
-	$stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?");
92
-	$stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1);
93
-	$stmt->execute();
94
-	$result = $stmt->get_result();
95
-	if($result->num_rows === 1){ return true; }
96
-	return false;
91
+    $stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?");
92
+    $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1);
93
+    $stmt->execute();
94
+    $result = $stmt->get_result();
95
+    if($result->num_rows === 1){ return true; }
96
+    return false;
97 97
 }
98 98
 
99 99
 function getUser($id, $connection) {
100
-	$userResult = array();
101
-	$stmt = $connection->prepare("SELECT * FROM users WHERE id = ?");
102
-	$stmt->bind_param("i", $id);
103
-	$stmt->execute();
104
-	$result = $stmt->get_result();
105
-	if($result->num_rows === 0) echo('That user does not exist.');
106
-	while($row = $result->fetch_assoc()) {
107
-		$userResult['username'] = $row['username'];
108
-		$userResult['id'] = $row['id'];
109
-		$userResult['date'] = $row['date'];
110
-		$userResult['bio'] = $row['bio'];
111
-		$userResult['css'] = $row['css'];
112
-		$userResult['pfp'] = $row['pfp'];
113
-		$userResult['badges'] = explode(';', $row['badges']);
114
-		$userResult['music'] = $row['music'];
115
-		$userResult['rank'] = $row['rank'];
116
-		$userResult['currentgroup'] = $row['currentgroup'];
117
-	}
118
-	$stmt->close();
119
-
120
-	$stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?");
121
-	$stmt->bind_param("s", $userResult['username']);
122
-	$stmt->execute();
123
-	$result = $stmt->get_result();
124
-
125
-	$userResult['comments'] = 0;
126
-	while($row = $result->fetch_assoc()) {
127
-		$userResult['comments']++;
128
-	}
129
-	$stmt->close();
130
-
131
-	$stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?");
132
-	$stmt->bind_param("s", $userResult['username']);
133
-	$stmt->execute();
134
-	$result = $stmt->get_result();
135
-
136
-	$userResult['profilecomments'] = 0;
137
-	while($row = $result->fetch_assoc()) {
138
-		$userResult['profilecomments']++;
139
-	}
140
-	$stmt->close();
141
-
142
-	$stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'");
143
-	$stmt->bind_param("s", $userResult['username']);
144
-	$stmt->execute();
145
-	$result = $stmt->get_result();
146
-
147
-	$userResult['filesuploaded'] = 0;
148
-	while($row = $result->fetch_assoc()) {
149
-		$userResult['filesuploaded']++;
150
-	}
151
-	$stmt->close();
152
-	return $userResult;
100
+    $userResult = array();
101
+    $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?");
102
+    $stmt->bind_param("i", $id);
103
+    $stmt->execute();
104
+    $result = $stmt->get_result();
105
+    if($result->num_rows === 0) echo('That user does not exist.');
106
+    while($row = $result->fetch_assoc()) {
107
+        $userResult['username'] = $row['username'];
108
+        $userResult['id'] = $row['id'];
109
+        $userResult['date'] = $row['date'];
110
+        $userResult['bio'] = $row['bio'];
111
+        $userResult['css'] = $row['css'];
112
+        $userResult['pfp'] = $row['pfp'];
113
+        $userResult['badges'] = explode(';', $row['badges']);
114
+        $userResult['music'] = $row['music'];
115
+        $userResult['rank'] = $row['rank'];
116
+        $userResult['currentgroup'] = $row['currentgroup'];
117
+    }
118
+    $stmt->close();
119
+
120
+    $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?");
121
+    $stmt->bind_param("s", $userResult['username']);
122
+    $stmt->execute();
123
+    $result = $stmt->get_result();
124
+
125
+    $userResult['comments'] = 0;
126
+    while($row = $result->fetch_assoc()) {
127
+        $userResult['comments']++;
128
+    }
129
+    $stmt->close();
130
+
131
+    $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?");
132
+    $stmt->bind_param("s", $userResult['username']);
133
+    $stmt->execute();
134
+    $result = $stmt->get_result();
135
+
136
+    $userResult['profilecomments'] = 0;
137
+    while($row = $result->fetch_assoc()) {
138
+        $userResult['profilecomments']++;
139
+    }
140
+    $stmt->close();
141
+
142
+    $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'");
143
+    $stmt->bind_param("s", $userResult['username']);
144
+    $stmt->execute();
145
+    $result = $stmt->get_result();
146
+
147
+    $userResult['filesuploaded'] = 0;
148
+    while($row = $result->fetch_assoc()) {
149
+        $userResult['filesuploaded']++;
150
+    }
151
+    $stmt->close();
152
+    return $userResult;
153 153
 }
154 154
 ?>
155 155
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
 	$stmt->bind_param("i", $id);
44 44
 	$stmt->execute();
45 45
 	$result = $stmt->get_result();
46
-	if ($result->num_rows === 0) return 'error';
46
+	if ($result->num_rows === 0) {
47
+	    return 'error';
48
+	}
47 49
 	return $result->fetch_assoc();
48 50
 }
49 51
 
@@ -52,7 +54,9 @@  discard block
 block discarded – undo
52 54
 	$stmt->bind_param("s", $user);
53 55
 	$stmt->execute();
54 56
 	$result = $stmt->get_result();
55
-	if($result->num_rows === 0) return 'error';
57
+	if($result->num_rows === 0) {
58
+	    return 'error';
59
+	}
56 60
 	while($row = $result->fetch_assoc()) {
57 61
 		$id = $row['id'];
58 62
 	} 
@@ -65,7 +69,9 @@  discard block
 block discarded – undo
65 69
 	$stmt->bind_param("s", $id);
66 70
 	$stmt->execute();
67 71
 	$result = $stmt->get_result();
68
-	if($result->num_rows === 0) return('error');
72
+	if($result->num_rows === 0) {
73
+	    return('error');
74
+	}
69 75
 	while($row = $result->fetch_assoc()) {
70 76
 		$name = htmlspecialchars($row['username']);
71 77
 	} 
@@ -78,7 +84,9 @@  discard block
 block discarded – undo
78 84
 	$stmt->bind_param("s", $user);
79 85
 	$stmt->execute();
80 86
 	$result = $stmt->get_result();
81
-	if($result->num_rows === 0) return('error');
87
+	if($result->num_rows === 0) {
88
+	    return('error');
89
+	}
82 90
 	while($row = $result->fetch_assoc()) {
83 91
 		$pfp = htmlspecialchars($row['pfp']);
84 92
 	} 
@@ -102,7 +110,9 @@  discard block
 block discarded – undo
102 110
 	$stmt->bind_param("i", $id);
103 111
 	$stmt->execute();
104 112
 	$result = $stmt->get_result();
105
-	if($result->num_rows === 0) echo('That user does not exist.');
113
+	if($result->num_rows === 0) {
114
+	    echo('That user does not exist.');
115
+	}
106 116
 	while($row = $result->fetch_assoc()) {
107 117
 		$userResult['username'] = $row['username'];
108 118
 		$userResult['id'] = $row['id'];
Please login to merge, or discard this patch.
view/profile.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
     <body> 
19 19
         <?php require(__DIR__ . "/../important/header.php"); 
20 20
         
21
-        if($_SERVER['REQUEST_METHOD'] == 'POST') 
21
+        if ($_SERVER['REQUEST_METHOD'] == 'POST') 
22 22
         {
23
-            if(!isset($_SESSION['user'])){ $error = "you are not logged in"; goto skipcomment; }
24
-            if(!$_POST['comment']){ $error = "your comment cannot be blank"; goto skipcomment; }
25
-            if(strlen($_POST['comment']) > 500){ $error = "your comment must be shorter than 500 characters"; goto skipcomment; }
23
+            if (!isset($_SESSION['user'])) { $error = "you are not logged in"; goto skipcomment; }
24
+            if (!$_POST['comment']) { $error = "your comment cannot be blank"; goto skipcomment; }
25
+            if (strlen($_POST['comment']) > 500) { $error = "your comment must be shorter than 500 characters"; goto skipcomment; }
26 26
 
27 27
             $stmt = $conn->prepare("INSERT INTO `comments` (toid, author, text) VALUES (?, ?, ?)");
28 28
             $stmt->bind_param("sss", $_GET['id'], $_SESSION['user'], $text);
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
                     </center>
48 48
                     <hr style="border-top: 1px dashed gray;">
49 49
                     <div id="userinfo" style="padding-left: 20px;">
50
-                        <span style="color: gold;">Rank:</span> <?php echo $user['rank'];?><br>
51
-                        <span style="color: gold;">ID:</span> <?php echo $user['id'];?><br>
52
-                        <span style="color: gold;">Other Comments:</span> <?php echo $user['comments'];?><br>
53
-                        <span style="color: gold;">Profile Comments:</span> <?php echo $user['profilecomments'];?><br>
54
-                        <?php $userGroup = getGroup($user['currentgroup'], $conn);?>
55
-                        <span style="color: gold;">Current Group:</span> <a href="/view/group?id=<?php echo $userGroup['id'];?>"><?php echo $userGroup['title'];?></a><br>
56
-                        <span style="color: gold;">Files Uploaded:</span> <?php echo $user['filesuploaded'];?>
50
+                        <span style="color: gold;">Rank:</span> <?php echo $user['rank']; ?><br>
51
+                        <span style="color: gold;">ID:</span> <?php echo $user['id']; ?><br>
52
+                        <span style="color: gold;">Other Comments:</span> <?php echo $user['comments']; ?><br>
53
+                        <span style="color: gold;">Profile Comments:</span> <?php echo $user['profilecomments']; ?><br>
54
+                        <?php $userGroup = getGroup($user['currentgroup'], $conn); ?>
55
+                        <span style="color: gold;">Current Group:</span> <a href="/view/group?id=<?php echo $userGroup['id']; ?>"><?php echo $userGroup['title']; ?></a><br>
56
+                        <span style="color: gold;">Files Uploaded:</span> <?php echo $user['filesuploaded']; ?>
57 57
                     </div><br>
58 58
                         <?php if (!isset($_GET["ed"])) { ?>
59 59
                             <audio autoplay controls>
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                     </div>
64 64
                     <br>
65 65
                     <div class="notegray">
66
-                    <?php if(isset($error)) { echo "<small style='color:red'>".$error."</small>"; } ?>
66
+                    <?php if (isset($error)) { echo "<small style='color:red'>" . $error . "</small>"; } ?>
67 67
                     <h2>Comment</h2>
68 68
                     <form method="post" enctype="multipart/form-data">
69 69
                         <textarea required cols="33" placeholder="Comment" name="comment"></textarea><br>
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
                     <div id="badges" class="notegray">
83 83
                         <h1>Badges</h1>
84 84
                         <?php
85
-                            foreach($user['badges'] as $badge) {
86
-                                if($badge == "good") {
85
+                            foreach ($user['badges'] as $badge) {
86
+                                if ($badge == "good") {
87 87
                                     echo "<img width='70px;' height='70px;' src='https://cdn.discordapp.com/attachments/740680780740821105/740776214523936808/340juojg3h.png'>";
88 88
                                 }
89 89
                             }
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
                         $stmt->bind_param("s", $username);
96 96
                         $stmt->execute();
97 97
                         $result = $stmt->get_result();
98
-                        if($result->num_rows > 0) echo('<h1>Files</h1>');
98
+                        if ($result->num_rows > 0) echo('<h1>Files</h1>');
99 99
                         
100
-                        while($row = $result->fetch_assoc()) { 
101
-                            echo '<a href="/view?id=' . $row['id'] . '">' . $row['title'] . ' [' , $row['type'] . ']</a><br>';
100
+                        while ($row = $result->fetch_assoc()) { 
101
+                            echo '<a href="/view?id=' . $row['id'] . '">' . $row['title'] . ' [', $row['type'] . ']</a><br>';
102 102
                         }?> 
103 103
                     </div><br>
104 104
                     <div id="bio" class="notegray">
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                             $stmt->execute();
113 113
                             $result = $stmt->get_result();
114 114
                             
115
-                            while($row = $result->fetch_assoc()) { ?>
115
+                            while ($row = $result->fetch_assoc()) { ?>
116 116
                                 <div class='commentRight' style='display: grid; grid-template-columns: 75% auto; padding:5px;'>
117 117
                                     <div style="word-wrap: break-word;">
118 118
                                         <small><?php echo $row['date']; ?></small>
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,9 @@
 block discarded – undo
95 95
                         $stmt->bind_param("s", $username);
96 96
                         $stmt->execute();
97 97
                         $result = $stmt->get_result();
98
-                        if($result->num_rows > 0) echo('<h1>Files</h1>');
98
+                        if($result->num_rows > 0) {
99
+                            echo('<h1>Files</h1>');
100
+                        }
99 101
                         
100 102
                         while($row = $result->fetch_assoc()) { 
101 103
                             echo '<a href="/view?id=' . $row['id'] . '">' . $row['title'] . ' [' , $row['type'] . ']</a><br>';
Please login to merge, or discard this patch.