mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +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) {
|
||||
$count = 0;
|
||||
$query = $conn->prepare("SELECT member FROM pastes WHERE member=?");
|
||||
function getTotalPastes(PDO $conn, string $username) : int {
|
||||
$query = $conn->prepare("SELECT COUNT(*) FROM pastes WHERE member = ?");
|
||||
$query->execute([$username]);
|
||||
while ($row = $site_info_rows->fetch()) {
|
||||
$count = $count + 1;
|
||||
}
|
||||
return $count;
|
||||
|
||||
return intval($query->fetch(PDO::FETCH_NUM)[0]);
|
||||
}
|
||||
|
||||
function isValidUsername(string $str) : bool {
|
||||
|
|
|
@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
|
||||
updatePageViews($conn);
|
||||
|
||||
$total_pastes = getTotalPastes($con, $user_username);
|
||||
$total_pastes = getTotalPastes($conn, $user_username);
|
||||
|
||||
// Theme
|
||||
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'])) {
|
||||
$profile_username = trim($_GET['user']);
|
||||
|
||||
if (!existingUser($con, $profile_username)) {
|
||||
if (!existingUser($conn, $profile_username)) {
|
||||
// Invalid username
|
||||
header("Location: ../error.php");
|
||||
die();
|
||||
|
|
Loading…
Add table
Reference in a new issue