mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 14:40:09 +01:00
Profile and user.php don't immediately crash
This commit is contained in:
parent
c8614b24cd
commit
970cda9f2e
3 changed files with 6 additions and 9 deletions
|
@ -263,14 +263,11 @@ function jsonView($paste_id, $p_title, $p_conntent, $p_code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getTotalPastes($conn, $username) {
|
function getTotalPastes(PDO $conn, string $username) : int {
|
||||||
$count = 0;
|
$query = $conn->prepare("SELECT COUNT(*) FROM pastes WHERE member = ?");
|
||||||
$query = $conn->prepare("SELECT member FROM pastes WHERE member=?");
|
|
||||||
$query->execute([$username]);
|
$query->execute([$username]);
|
||||||
while ($row = $site_info_rows->fetch()) {
|
|
||||||
$count = $count + 1;
|
return intval($query->fetch(PDO::FETCH_NUM)[0]);
|
||||||
}
|
|
||||||
return $count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidUsername(string $str) : bool {
|
function isValidUsername(string $str) : bool {
|
||||||
|
|
|
@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
|
||||||
updatePageViews($conn);
|
updatePageViews($conn);
|
||||||
|
|
||||||
$total_pastes = getTotalPastes($con, $user_username);
|
$total_pastes = getTotalPastes($conn, $user_username);
|
||||||
|
|
||||||
// Theme
|
// Theme
|
||||||
require_once('theme/' . $default_theme . '/header.php');
|
require_once('theme/' . $default_theme . '/header.php');
|
||||||
|
|
2
user.php
2
user.php
|
@ -28,7 +28,7 @@ $user_username = trim($_SESSION['username']);
|
||||||
if (isset($_GET['user'])) {
|
if (isset($_GET['user'])) {
|
||||||
$profile_username = trim($_GET['user']);
|
$profile_username = trim($_GET['user']);
|
||||||
|
|
||||||
if (!existingUser($con, $profile_username)) {
|
if (!existingUser($conn, $profile_username)) {
|
||||||
// Invalid username
|
// Invalid username
|
||||||
header("Location: ../error.php");
|
header("Location: ../error.php");
|
||||||
die();
|
die();
|
||||||
|
|
Loading…
Add table
Reference in a new issue