File: /home/u590867752/domains/himanshuartinstitute.com/public_html/wall/user/profile.php
<?php
session_start();
include($_SERVER['DOCUMENT_ROOT']."/wall/baba/shiva.php");
include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/user-auth.php");
if(!isset($_SESSION['wall_user'])){
header("Location: /wall/user/login.php");
exit;
}
$login_user = trim(
(string)$_SESSION['wall_user']
);
$profile_username = trim(
(string)($_GET['user'] ?? '')
);
if ($profile_username === '') {
http_response_code(400);
exit('Invalid user');
}
/* Only an existing and active user's profile can be viewed. */
$user_statement = mysqli_prepare($conn, "
SELECT
id,
name,
image,
banner_image,
about,
user_category
FROM wall_users
WHERE username = ?
AND is_active = 1
LIMIT 1
");
if (!$user_statement) {
http_response_code(500);
exit('Unable to load profile');
}
mysqli_stmt_bind_param(
$user_statement,
's',
$profile_username
);
if (!mysqli_stmt_execute($user_statement)) {
mysqli_stmt_close($user_statement);
http_response_code(500);
exit('Unable to load profile');
}
$user_result = mysqli_stmt_get_result(
$user_statement
);
$userRow = mysqli_fetch_assoc(
$user_result
);
mysqli_stmt_close($user_statement);
if (!$userRow) {
http_response_code(404);
exit('User not found');
}
$profile_user_id = (int)$userRow['id'];
$name = !empty($userRow['name'])
? trim((string)$userRow['name'])
: $profile_username;
/* Display profile name in consistent Title Case */
$name = preg_replace(
'/\s+/u',
' ',
$name
);
if (function_exists('mb_convert_case')) {
$name = mb_convert_case(
$name,
MB_CASE_TITLE,
'UTF-8'
);
} else {
$name = ucwords(
strtolower($name)
);
}
$image = !empty($userRow['image'])
? basename($userRow['image'])
: 'default-user.png';
$about = !empty($userRow['about'])
? trim((string)$userRow['about'])
: 'No description yet';
$usercategory = !empty($userRow['user_category'])
? trim((string)$userRow['user_category'])
: '';
$profile_image_url =
'/wall/user/user-images/'
. rawurlencode($image);
$banner_image = !empty($userRow['banner_image'])
? basename(
(string)$userRow['banner_image']
)
: '';
$profile_banner_url =
$banner_image !== ''
? (
'/wall/user/user-banners/'
. rawurlencode($banner_image)
)
: '';
/*
Logged-in active user की numeric ID प्राप्त करें।
*/
$viewer_statement = mysqli_prepare(
$conn,
"
SELECT id
FROM wall_users
WHERE username = ?
AND is_active = 1
LIMIT 1
"
);
if(!$viewer_statement){
http_response_code(500);
exit('Unable to load viewer');
}
mysqli_stmt_bind_param(
$viewer_statement,
's',
$login_user
);
if(!mysqli_stmt_execute($viewer_statement)){
mysqli_stmt_close($viewer_statement);
http_response_code(500);
exit('Unable to load viewer');
}
$viewer_result = mysqli_stmt_get_result(
$viewer_statement
);
$viewer_row = mysqli_fetch_assoc(
$viewer_result
);
mysqli_stmt_close($viewer_statement);
if(!$viewer_row){
header('Location: /wall/user/login.php');
exit;
}
$viewer_user_id = (int)$viewer_row['id'];
/*
Profile के Followers, Following और current viewer की
Follow स्थिति प्राप्त करें।
केवल active users को counts में शामिल करें।
*/
$follow_statement = mysqli_prepare(
$conn,
"
SELECT
(
SELECT COUNT(*)
FROM wall_follows AS followers
INNER JOIN wall_users AS follower_user
ON follower_user.id = followers.follower_id
AND follower_user.is_active = 1
WHERE followers.following_id = ?
) AS followers_count,
(
SELECT COUNT(*)
FROM wall_follows AS following
INNER JOIN wall_users AS followed_user
ON followed_user.id = following.following_id
AND followed_user.is_active = 1
WHERE following.follower_id = ?
) AS following_count,
EXISTS(
SELECT 1
FROM wall_follows
WHERE follower_id = ?
AND following_id = ?
LIMIT 1
) AS is_following
"
);
if(!$follow_statement){
http_response_code(500);
exit('Unable to load follow information');
}
mysqli_stmt_bind_param(
$follow_statement,
'iiii',
$profile_user_id,
$profile_user_id,
$viewer_user_id,
$profile_user_id
);
if(!mysqli_stmt_execute($follow_statement)){
mysqli_stmt_close($follow_statement);
http_response_code(500);
exit('Unable to load follow information');
}
$follow_result = mysqli_stmt_get_result(
$follow_statement
);
$follow_data = mysqli_fetch_assoc(
$follow_result
);
mysqli_stmt_close($follow_statement);
$followers_count = (int)(
$follow_data['followers_count'] ?? 0
);
$following_count = (int)(
$follow_data['following_count'] ?? 0
);
$is_following = (int)(
$follow_data['is_following'] ?? 0
) === 1;
/* अपनी profile पर Follow button नहीं आएगा */
$can_follow =
$viewer_user_id !== $profile_user_id;
/* Follow/Unfollow request के लिए CSRF token */
if(empty($_SESSION['follow_action_token'])){
$_SESSION['follow_action_token'] =
bin2hex(random_bytes(32));
}
$follow_action_token =
$_SESSION['follow_action_token'];
/*
Load active posts created by this profile user.
*/
$post_statement = mysqli_prepare($conn, "
SELECT
id,
page_url,
blog_name,
image,
post_type,
youtube_video_id,
likes,
views,
date
FROM HAIWALL
WHERE post_user = ?
AND status = '1'
ORDER BY date DESC, id DESC
");
if (!$post_statement) {
http_response_code(500);
exit('Unable to load profile posts');
}
mysqli_stmt_bind_param(
$post_statement,
's',
$profile_username
);
if (!mysqli_stmt_execute($post_statement)) {
mysqli_stmt_close($post_statement);
http_response_code(500);
exit('Unable to load profile posts');
}
$profile_posts = mysqli_stmt_get_result(
$post_statement
);
$profile_post_count = mysqli_num_rows(
$profile_posts
);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?=htmlspecialchars($name, ENT_QUOTES, 'UTF-8')?> | HAI Wall Profile</title>
<meta property="og:image" content="https://www.himanshuartinstitute.com/wall/bcknds/hai-wall.jpg">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../../codes/glry/js/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="shortcut icon" href="https://www.himanshuartinstitute.com/wall/bcknds/hai-wall.png" type="image/x-icon" >
<link href="../bcknds/css/wall-home.css?v=20260730-8" media="screen" rel="stylesheet" type="text/css" />
<link href="../bcknds/css/wall-profile.css?v=20260722-1" media="screen" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<!-- HEADER -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/header.php"); ?>
<!-- MAIN -->
<div class="container">
<!-- LEFT SIDEBAR -->
<div class="sidebar leftcolmn">
<!-- TOP LIKED POST -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/top-liked-post.php"); ?>
<!-- NEW USER SLIDER -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/new-users.php"); ?>
</div>
<!-- CENTER WALL -->
<div class="haifeed-colum">
<div class="wall-container">
<div class="profile-card">
<a
href="/wall/user/all-users.php"
class="profile-users-btn"
aria-label="View all users"
title="View All Users"
>
<i
class="fa fa-users"
aria-hidden="true"
></i>
</a>
<div
class="public-profile-banner<?=$profile_banner_url !== '' ? ' has-banner' : ''?>"
>
<?php if($profile_banner_url !== ''){ ?>
<img
src="<?=htmlspecialchars(
$profile_banner_url,
ENT_QUOTES,
'UTF-8'
)?>"
alt="<?=htmlspecialchars(
$name . ' profile banner',
ENT_QUOTES,
'UTF-8'
)?>"
loading="eager"
decoding="async"
>
<?php } ?>
</div>
<!-- PROFILE IMAGE -->
<div class="profile-img public-profile-image">
<img
src="<?=htmlspecialchars(
$profile_image_url,
ENT_QUOTES,
'UTF-8'
)?>"
id="profileImage"
alt="<?=htmlspecialchars(
$name,
ENT_QUOTES,
'UTF-8'
)?>"
>
</div>
<h2>
<?=htmlspecialchars($name, ENT_QUOTES, 'UTF-8')?>
</h2>
<?php if ($usercategory !== '') { ?>
<div class="profile-category">
<?=htmlspecialchars($usercategory, ENT_QUOTES, 'UTF-8')?>
</div>
<?php } ?>
<div class="profile-social-stats">
<!-- POSTS -->
<div class="profile-social-stat">
<strong>
<?=$profile_post_count?>
</strong>
<span>
<?=$profile_post_count === 1
? 'Post'
: 'Posts'
?>
</span>
</div>
<!-- FOLLOWERS -->
<button
type="button"
class="profile-social-stat profile-connections-btn"
data-list-type="followers"
data-profile-user-id="<?=$profile_user_id?>"
>
<strong id="profileFollowersCount">
<?=$followers_count?>
</strong>
<span>Followers</span>
</button>
<!-- FOLLOWING -->
<button
type="button"
class="profile-social-stat profile-connections-btn"
data-list-type="following"
data-profile-user-id="<?=$profile_user_id?>"
>
<strong id="profileFollowingCount">
<?=$following_count?>
</strong>
<span>Following</span>
</button>
</div>
<?php if($can_follow){ ?>
<div class="profile-follow-action">
<button
type="button"
id="profileFollowButton"
class="profile-follow-btn <?=$is_following
? 'is-following'
: ''
?>"
data-target-user-id="<?=$profile_user_id?>"
data-following="<?=$is_following ? '1' : '0'?>"
data-action-token="<?=htmlspecialchars(
$follow_action_token,
ENT_QUOTES,
'UTF-8'
)?>"
aria-pressed="<?=$is_following
? 'true'
: 'false'
?>"
>
<i
class="fa <?=$is_following
? 'fa-check'
: 'fa-user-plus'
?>"
aria-hidden="true"
></i>
<span class="profile-follow-label">
<?=$is_following
? 'Following'
: 'Follow'
?>
</span>
</button>
</div>
<?php } ?>
<p>
<?=nl2br(
htmlspecialchars(
$about,
ENT_QUOTES,
'UTF-8'
)
)?>
</p>
</div>
<section
class="profile-portfolio"
aria-labelledby="portfolioTitle"
>
<div class="profile-portfolio-header">
<h2 id="portfolioTitle">
Posts by
<?=htmlspecialchars($name, ENT_QUOTES, 'UTF-8')?>
</h2>
<span class="profile-post-count">
<?=$profile_post_count?>
<?=$profile_post_count === 1 ? 'Post' : 'Posts'?>
</span>
</div>
<?php if ($profile_post_count > 0) { ?>
<div class="profile-post-grid">
<?php while ($post = mysqli_fetch_assoc($profile_posts)) {
$post_title = trim(
(string)($post['blog_name'] ?? '')
);
if ($post_title === '') {
$post_title = 'Untitled post';
}
$profile_post_type = (string)(
$post['post_type'] ?? 'artwork'
);
if(
!in_array(
$profile_post_type,
[
'artwork',
'youtube',
'poll'
],
true
)
){
$profile_post_type = 'artwork';
}
$profile_youtube_id = trim(
(string)($post['youtube_video_id'] ?? '')
);
$is_profile_video =
$profile_post_type === 'youtube'
&&
preg_match(
'/^[A-Za-z0-9_-]{11}$/',
$profile_youtube_id
) === 1;
$is_profile_poll =
$profile_post_type === 'poll';
if ($is_profile_video) {
$post_image_url =
'https://i.ytimg.com/vi/'
. rawurlencode($profile_youtube_id)
. '/hqdefault.jpg';
} elseif ($is_profile_poll) {
$post_image_url =
'/wall/wall-feeds/default-poll.jpg';
} else {
$post_image = !empty($post['image'])
? basename($post['image'])
: 'default.jpg';
$post_image_url =
'/wall/wall-feeds/'
. rawurlencode($post_image);
}
$post_url =
'/wall/feed/'
. rawurlencode(
(string)($post['page_url'] ?? '')
);
?>
<a
href="<?=htmlspecialchars($post_url, ENT_QUOTES, 'UTF-8')?>"
class="profile-post-card<?=$is_profile_video ? ' profile-post-video' : ''?>"
aria-label="View <?=htmlspecialchars(
$post_title,
ENT_QUOTES,
'UTF-8'
)?>"
>
<div class="profile-post-image">
<img
src="<?=htmlspecialchars(
$post_image_url,
ENT_QUOTES,
'UTF-8'
)?>"
alt="<?=htmlspecialchars(
$post_title,
ENT_QUOTES,
'UTF-8'
)?>"
loading="lazy"
decoding="async"
>
<?php if ($is_profile_video) { ?>
<span
class="profile-post-video-play"
aria-hidden="true"
>
<i class="fa fa-play"></i>
</span>
<?php } ?>
</div>
<div class="profile-post-info">
<h3>
<?=htmlspecialchars(
$post_title,
ENT_QUOTES,
'UTF-8'
)?>
</h3>
<div class="profile-post-stats">
<span title="Likes">
<i class="fa fa-heart" aria-hidden="true"></i>
<?=(int)($post['likes'] ?? 0)?>
</span>
<span title="Views">
<i class="fa fa-eye" aria-hidden="true"></i>
<?=(int)($post['views'] ?? 0)?>
</span>
</div>
</div>
</a>
<?php } ?>
</div>
<?php } else { ?>
<div class="profile-empty-posts">
<i class="fa fa-picture-o" aria-hidden="true"></i>
<h3>No artwork shared yet</h3>
<p>
This artist has not shared any artwork on HAI Wall yet.
</p>
</div>
<?php } ?>
</section>
<?php mysqli_stmt_close($post_statement); ?>
</div>
</div>
<!-- RIGHT SIDEBAR -->
<div class="sidebar">
<!-- LATEST POSTS -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/latest-post-slider.php"); ?>
<!-- HAI BLOG SLIDER -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/hai-blog-slider.php"); ?>
<!-- FOLLOW US -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/follow-us.php"); ?>
</div>
</div>
<div
id="profileConnectionsModal"
class="profile-connections-modal"
hidden
>
<div
class="profile-connections-dialog"
role="dialog"
aria-modal="true"
aria-labelledby="profileConnectionsTitle"
>
<div class="profile-connections-header">
<h2 id="profileConnectionsTitle">
Artists
</h2>
<button
type="button"
id="closeProfileConnections"
class="profile-connections-close"
aria-label="Close"
>
×
</button>
</div>
<div
id="profileConnectionsList"
class="profile-connections-list"
></div>
</div>
</div>
<!-- FOOTER -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/footer.php"); ?>
<script>
(() => {
'use strict';
const forms = document.querySelectorAll('.needs-validation');
Array.from(forms).forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
})();
</script>
<script>
function hideR(){
var record = document.getElementById("record");
if(record){
record.style.display = "none";
}
}
var record = document.getElementById("record");
if(record){
window.addEventListener('mouseup', function(event){
if(event.target != record && event.target.parentNode != record){
record.style.display = "none";
}
});
}
</script>
<script src="../bcknds/hai-blog-slidr.js"></script>
<script src="../bcknds/search.js"></script>
<script src="../bcknds/post-mnu-btn.js"></script>
<script src="../bcknds/user-menu.js"></script>
<script src="../bcknds/follow-profile.js?v=20260724-1"></script>
<a href="javascript:history.back()" class="back-floating"><i class="fa fa-arrow-left"></i></a>
</body>
</html>