HEX
Server: LiteSpeed
System: Linux in-mum-web921.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: u590867752 (590867752)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: /home/u590867752/domains/himanshuartinstitute.com/public_html/wall/user/user-view-wall.php
<?php

session_start();

include(
    $_SERVER['DOCUMENT_ROOT']
    . "/wall/baba/shiva.php"
);

require_once(
    $_SERVER['DOCUMENT_ROOT']
    . "/wall/bcknds/like-identity.php"
);

if(empty($_SESSION['wall_user'])){
    header("Location: /wall/user/login.php");
    exit;
}

$login_user = trim(
    (string)$_SESSION['wall_user']
);

/* My Wall actions के लिए CSRF protection token */
if(empty($_SESSION['my_wall_action_token'])){

    $_SESSION['my_wall_action_token'] =
        bin2hex(random_bytes(32));
}

$my_wall_action_token =
    $_SESSION['my_wall_action_token'];

$like_identity = haiGetLikeIdentity($conn);
if(isset($_POST['verify_user'])){

    $regn = mysqli_real_escape_string($conn,$_POST['regn_no']);
    $mobile = mysqli_real_escape_string($conn,$_POST['mobile']);

    mysqli_query($conn,"
    UPDATE wall_users 
    SET regn_no='$regn', mobile='$mobile'
    WHERE username='$login_user'
    ");

    $_SESSION['verify_msg'] = 1;

    header("Location: user-view-wall.php");
    exit;
}


$userData = mysqli_query($conn, "
SELECT name, is_active, activation_requested, first_post_done
FROM wall_users
WHERE username='$login_user'
LIMIT 1
");
$userRow = mysqli_fetch_assoc($userData);

$userName = $userRow['name'];
$is_active = $userRow['is_active'];
$activation_requested = $userRow['activation_requested'];
$first_post_done = isset($userRow['first_post_done']) ? $userRow['first_post_done'] : 0;
$query = mysqli_query($conn,"SELECT * FROM HAIWALL WHERE post_user='$login_user' ORDER BY id DESC");

error_reporting(0);



/* SECURE POST STATUS UPDATE */

if(
    $_SERVER['REQUEST_METHOD'] === 'POST'
    &&
    isset($_POST['update_post_status'])
){

    $submitted_token = (string)(
        $_POST['action_token'] ?? ''
    );

    if(
        $submitted_token === ''
        ||
        !hash_equals(
            $my_wall_action_token,
            $submitted_token
        )
    ){
        http_response_code(403);
        exit;
    }

    $status_id = filter_input(
        INPUT_POST,
        'post_id',
        FILTER_VALIDATE_INT
    );

    $new_status = filter_input(
        INPUT_POST,
        'new_status',
        FILTER_VALIDATE_INT
    );

    if(
        !$status_id
        ||
        !in_array($new_status, [0, 1], true)
        ||
        (int)$is_active !== 1
    ){
        http_response_code(422);
        exit;
    }

    /* Check ownership and report block */
    $check = mysqli_prepare(
        $conn,
        "
        SELECT is_report_blocked
        FROM HAIWALL
        WHERE id = ?
          AND post_user = ?
        LIMIT 1
        "
    );

    if(!$check){
        http_response_code(500);
        exit;
    }

    mysqli_stmt_bind_param(
        $check,
        'is',
        $status_id,
        $login_user
    );

    mysqli_stmt_execute($check);

    $check_result = mysqli_stmt_get_result(
        $check
    );

    $post_data = mysqli_fetch_assoc(
        $check_result
    );

    mysqli_stmt_close($check);

    if(!$post_data){
        http_response_code(404);
        exit;
    }

    if(
        $new_status === 1
        &&
        (int)$post_data['is_report_blocked'] === 1
    ){
        $_SESSION['blocked_post'] = 1;

        header(
            'Location: /wall/user/user-view-wall.php'
        );
        exit;
    }

    if($new_status === 1){

        $update = mysqli_prepare(
            $conn,
            "
            UPDATE HAIWALL
            SET status = 1,
                last_activated_at = NOW(),
                disabled_at = NULL
            WHERE id = ?
              AND post_user = ?
            LIMIT 1
            "
        );

    }else{

        $update = mysqli_prepare(
            $conn,
            "
            UPDATE HAIWALL
            SET status = 0,
                disabled_at = NOW()
            WHERE id = ?
              AND post_user = ?
            LIMIT 1
            "
        );
    }

    if(!$update){
        http_response_code(500);
        exit;
    }

    mysqli_stmt_bind_param(
        $update,
        'is',
        $status_id,
        $login_user
    );

    mysqli_stmt_execute($update);
    mysqli_stmt_close($update);

    header(
        'Location: /wall/user/user-view-wall.php'
    );
    exit;
}













/* SECURE POST DELETE */

if(
    $_SERVER['REQUEST_METHOD'] === 'POST'
    &&
    isset($_POST['delete_post'])
){

    $submitted_token = (string)(
        $_POST['action_token'] ?? ''
    );

    if(
        $submitted_token === ''
        ||
        !hash_equals(
            $my_wall_action_token,
            $submitted_token
        )
    ){
        http_response_code(403);
        exit;
    }

    $delete_post_id = filter_input(
        INPUT_POST,
        'post_id',
        FILTER_VALIDATE_INT
    );

    if(!$delete_post_id || $delete_post_id < 1){
        http_response_code(422);
        exit;
    }

    $post_statement = mysqli_prepare(
        $conn,
        "
        SELECT
            image,
            post_type
        FROM HAIWALL
        WHERE id = ?
          AND post_user = ?
        LIMIT 1
        "
    );

    if(!$post_statement){
        http_response_code(500);
        exit;
    }

    mysqli_stmt_bind_param(
        $post_statement,
        'is',
        $delete_post_id,
        $login_user
    );

    if(!mysqli_stmt_execute($post_statement)){
        mysqli_stmt_close($post_statement);
        http_response_code(500);
        exit;
    }

    $post_result = mysqli_stmt_get_result(
        $post_statement
    );

    $delete_post_data = mysqli_fetch_assoc(
        $post_result
    );

    mysqli_stmt_close($post_statement);

    if(!$delete_post_data){
        http_response_code(404);
        exit;
    }

    $artwork_image = !empty(
        $delete_post_data['image']
    )
        ? basename(
            (string)$delete_post_data['image']
        )
        : '';

    $poll_option_images = [];

    $poll_image_statement = mysqli_prepare(
        $conn,
        "
        SELECT
            wall_poll_options.option_image
        FROM wall_poll_options

        INNER JOIN wall_polls
            ON wall_polls.id =
               wall_poll_options.poll_id

        WHERE wall_polls.post_id = ?
          AND wall_poll_options.option_image
              IS NOT NULL
          AND wall_poll_options.option_image != ''
        "
    );

    if(!$poll_image_statement){
        http_response_code(500);
        exit;
    }

    mysqli_stmt_bind_param(
        $poll_image_statement,
        'i',
        $delete_post_id
    );

    if(!mysqli_stmt_execute(
        $poll_image_statement
    )){
        mysqli_stmt_close(
            $poll_image_statement
        );

        http_response_code(500);
        exit;
    }

    $poll_image_result = mysqli_stmt_get_result(
        $poll_image_statement
    );

    while(
        $poll_image_row = mysqli_fetch_assoc(
            $poll_image_result
        )
    ){
        $poll_image_name = basename(
            (string)(
                $poll_image_row['option_image']
                ?? ''
            )
        );

        if($poll_image_name !== ''){
            $poll_option_images[] =
                $poll_image_name;
        }
    }

    mysqli_stmt_close(
        $poll_image_statement
    );

    mysqli_begin_transaction($conn);

    try {

        $delete_queries = [

            "
            DELETE FROM wall_poll_votes
            WHERE poll_id IN (
                SELECT id
                FROM wall_polls
                WHERE post_id = $delete_post_id
            )
            ",

            "
            DELETE FROM wall_poll_options
            WHERE poll_id IN (
                SELECT id
                FROM wall_polls
                WHERE post_id = $delete_post_id
            )
            ",

            "
            DELETE FROM wall_polls
            WHERE post_id = $delete_post_id
            ",

            "
            DELETE FROM wall_comments
            WHERE post_id = $delete_post_id
            ",

            "
            DELETE FROM wall_likes
            WHERE post_id = $delete_post_id
            ",

            "
            DELETE FROM wall_views
            WHERE post_id = $delete_post_id
            ",

            "
            DELETE FROM post_reports
            WHERE post_id = $delete_post_id
            "
        ];

        foreach($delete_queries as $delete_query){

            if(!mysqli_query($conn, $delete_query)){
                throw new Exception(
                    mysqli_error($conn)
                );
            }
        }

        $delete_post_statement = mysqli_prepare(
            $conn,
            "
            DELETE FROM HAIWALL
            WHERE id = ?
              AND post_user = ?
            LIMIT 1
            "
        );

        if(!$delete_post_statement){
            throw new Exception(
                'Post delete preparation failed'
            );
        }

        mysqli_stmt_bind_param(
            $delete_post_statement,
            'is',
            $delete_post_id,
            $login_user
        );

        if(!mysqli_stmt_execute(
            $delete_post_statement
        )){
            mysqli_stmt_close(
                $delete_post_statement
            );

            throw new Exception(
                'Post delete failed'
            );
        }

        if(
            mysqli_stmt_affected_rows(
                $delete_post_statement
            ) !== 1
        ){
            mysqli_stmt_close(
                $delete_post_statement
            );

            throw new Exception(
                'Post was not deleted'
            );
        }

        mysqli_stmt_close(
            $delete_post_statement
        );

        mysqli_commit($conn);

    } catch(Throwable $error){

        mysqli_rollback($conn);

        error_log(
            'HAI Wall post delete failed: '
            . $error->getMessage()
        );

        http_response_code(500);
        exit;
    }

    $artwork_directory =
        $_SERVER['DOCUMENT_ROOT']
        . '/wall/wall-feeds/';

    if(
        $artwork_image !== ''
        &&
        $artwork_image !== 'default.jpg'
    ){
        $artwork_path =
            $artwork_directory
            . $artwork_image;

        if(
            is_file($artwork_path)
            &&
            !unlink($artwork_path)
        ){
            error_log(
                'Unable to delete artwork image: '
                . $artwork_path
            );
        }
    }

    $poll_image_directory =
        $_SERVER['DOCUMENT_ROOT']
        . '/wall/wall-feeds/polls/';

    foreach(
        array_unique($poll_option_images)
        as $poll_option_image
    ){
        $poll_image_path =
            $poll_image_directory
            . $poll_option_image;

        if(
            is_file($poll_image_path)
            &&
            !unlink($poll_image_path)
        ){
            error_log(
                'Unable to delete poll image: '
                . $poll_image_path
            );
        }
    }

    $_SESSION['my_wall_action_token'] =
        bin2hex(random_bytes(32));

    header(
        'Location: /wall/user/user-view-wall.php'
    );
    exit;
}





?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Wall | HAI WALL</title>
<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="/wall/bcknds/css/wall-home.css?v=20260730-4" media="screen" rel="stylesheet" type="text/css">
<link href="/wall/bcknds/css/user-network-nav.css?v=20260730-5" 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">

<?php if($is_active == 0){ ?>

  <?php if($activation_requested == 0){ ?>
<div class="welcombcgrd">

    <!-- FORM -->
    <div class="activation-box">
      <h2>Welcome <?=$userName?></h2>

      <p><strong>Your Registration has been Successfully Completed 😊</strong></p>
       <p>At the Moment, Your Profile is Inactive.</p>
       <p>To Activate It, Simply Enter Your Registration Number and Mobile Number.</p>
       <p>👉 If You Do Not Know Your Registration Number, Please Contact the Campus Administration.</p>

      <div class="userwelcme">
      <input type="text" id="regn" placeholder="Regn No.">
      <input type="text" id="mobile" placeholder="Mobile Number">
      <button onclick="submitActivation()">Submit</button>
      </div>
    </div>
    
    
</div>
    
    
    

  <?php } else { ?>
<div class="welcombcgrd">
    <!-- SUCCESS MESSAGE -->
    <div class="activation-box success">
      <h2>Your Activation Request has been Submitted ✅</h2>
      <p>Your Profile will be Activated Shortly After Verification by the Admin.</p>
	<p>Please Contact the Admin for Future Updates.</p>
    </div>
    
    </div>

  <?php } ?>

<?php } ?>




<?php if($is_active == 1 && $first_post_done == 0){ ?>
<div class="welcombcgrd">


<div class="activation-box success">
  <h2>Your Profile is Now Active! 🎉</h2>

  <p>Start with Your First Post and Explore the HAI Wall.</p>
	<p><strong>Enjoy Your Experience!</strong></p>

  <a href="create-post.php?add" class="btn btn-primary">
    Create Your First Post
  </a>
</div>



</div>

<?php } ?>




<?php if($is_active == 1 && $first_post_done == 1){ ?>

<?php

$network_page = 'my-wall';

include(
    $_SERVER['DOCUMENT_ROOT']
    . '/wall/bcknds/user-network-nav.php'
);

?>

<div class="my-wall-nav-action">

    <a
        href="/wall/user/create-post.php?add"
        class="my-wall-create-btn"
    >
        <i
            class="fa fa-plus"
            aria-hidden="true"
        ></i>

        <span>Create Post</span>
    </a>

</div>

<?php } ?>

<?php if($is_active == 1): ?>

<?php while($row=mysqli_fetch_assoc($query)){ ?>
<?php
$post_id = (int)($row['id'] ?? 0);
$is_post_active =
    (int)($row['status'] ?? 0) === 1;

$is_liked = haiHasLikedPost(
    $conn,
    $post_id,
    $like_identity
);
?>

<div class="feed-blok">
<div class="post-header">
<div class="post-user">

<?php
if(!empty($row['post_user'])){

$userData = mysqli_query($conn,"
SELECT name,image,user_category
FROM wall_users 
WHERE username='".$row['post_user']."' 
LIMIT 1
");

$userrow = mysqli_fetch_assoc($userData);

$username = $userrow['name'];
$userimg = !empty($userrow['image']) ? $userrow['image'] : "default-user.png";
$usercategory = !empty($userrow['user_category']) ? $userrow['user_category'] : '';

}else{
$username = "Admin";
$userimg = "himanshu-art-institute.png";
}
?>

<img src="/wall/user/user-images/<?php echo $userimg; ?>" class="user-pic">
<div class="user-text">
<span class="user-name"><?php echo $username; ?></span>
<?php if(!empty($usercategory)){ ?>
        <div class="user-category"><?php echo $usercategory; ?></div>
    <?php } ?>
</div>

</div>

<?php if(!$is_post_active){ ?>

<span class="post-status-badge">
    Disabled
</span>

<?php } ?>
<div class="post-menu"><i class="fa fa-ellipsis-h menu-icon"></i>
<div class="menu-dropdown">
<form
    method="post"
    action="/wall/user/user-view-wall.php"
    class="post-status-form"
>

    <input
        type="hidden"
        name="update_post_status"
        value="1"
    >

    <input
        type="hidden"
        name="post_id"
        value="<?=$post_id?>"
    >

    <input
        type="hidden"
        name="new_status"
        value="<?=$is_post_active ? 0 : 1?>"
    >

    <input
        type="hidden"
        name="action_token"
        value="<?=htmlspecialchars(
            $my_wall_action_token,
            ENT_QUOTES,
            'UTF-8'
        )?>"
    >

    <button
        type="submit"
        class="post-status-action"
    >
        <?=$is_post_active ? 'Disable' : 'Activate'?>
    </button>

</form>
<a href="create-post.php?id=<?=$row['id']?>">Edit</a>
<form
    method="post"
    action="/wall/user/user-view-wall.php"
    class="delete-post-form"
>

    <input
        type="hidden"
        name="delete_post"
        value="1"
    >

    <input
        type="hidden"
        name="post_id"
        value="<?=$post_id?>"
    >

    <input
        type="hidden"
        name="action_token"
        value="<?=htmlspecialchars(
            $my_wall_action_token,
            ENT_QUOTES,
            'UTF-8'
        )?>"
    >

    <button
        type="submit"
        class="post-status-action"
    >
        Delete
    </button>

</form>

</div>
</div>

</div>



<div class="post-card">

<?php

$post_type = (string)(
    $row['post_type'] ?? 'artwork'
);

$is_youtube_post =
    $post_type === 'youtube'
    &&
    !empty($row['youtube_video_id']);

$post_title = !empty($row['blog_name'])
    ? (string)$row['blog_name']
    : 'Untitled Post';

$post_alt = !empty($row['othur_name'])
    ? (string)$row['othur_name']
    : $post_title;

$media_post_url =
    "/wall/feed.php?slug="
    . rawurlencode(
        (string)($row['page_url'] ?? '')
    );

$is_poll_post =
    $post_type === 'poll';

$poll_id = 0;
$poll_ends_at = null;
$poll_total_votes = 0;
$poll_options = [];
$poll_has_ended = false;
$current_user_poll_option_id = 0;
$current_user_poll_change_count = 0;
$current_user_poll_vote_removed = false;

/* Load poll information */
if($is_poll_post){

    $poll_query = mysqli_query(
        $conn,
        "
        SELECT
            wall_polls.id AS poll_id,
            wall_polls.ends_at,
            wall_poll_options.id AS option_id,
            wall_poll_options.option_text,
            wall_poll_options.option_image,
            wall_poll_options.display_order,
            COUNT(wall_poll_votes.id) AS vote_count

        FROM wall_polls

        INNER JOIN wall_poll_options
            ON wall_poll_options.poll_id = wall_polls.id

        LEFT JOIN wall_poll_votes
            ON wall_poll_votes.option_id =
               wall_poll_options.id
           AND wall_poll_votes.is_removed = 0

        WHERE wall_polls.post_id = $post_id

        GROUP BY
            wall_polls.id,
            wall_polls.ends_at,
            wall_poll_options.id,
            wall_poll_options.option_text,
            wall_poll_options.option_image,
            wall_poll_options.display_order

        ORDER BY
            wall_poll_options.display_order ASC,
            wall_poll_options.id ASC
        "
    );

    if($poll_query){

        while($poll_option = mysqli_fetch_assoc($poll_query)){

            $poll_id = (int)(
                $poll_option['poll_id'] ?? 0
            );

            $poll_ends_at =
                $poll_option['ends_at'] ?? null;

            $option_votes = (int)(
                $poll_option['vote_count'] ?? 0
            );

            $poll_total_votes += $option_votes;

            $poll_options[] = [
                'id' => (int)(
                    $poll_option['option_id'] ?? 0
                ),
                'text' => trim(
                    (string)(
                        $poll_option['option_text'] ?? ''
                    )
                ),
                'image' => !empty(
                    $poll_option['option_image']
                )
                    ? basename(
                        (string)$poll_option[
                            'option_image'
                        ]
                    )
                    : '',
                'votes' => $option_votes
            ];
        }
    }

    if(
        !empty($poll_ends_at)
        &&
        strtotime($poll_ends_at) <= time()
    ){
        $poll_has_ended = true;
    }

    if($poll_id > 0){

        $selected_option_statement = mysqli_prepare(
            $conn,
            "
            SELECT
                wall_poll_votes.option_id,
                wall_poll_votes.vote_change_count,
                wall_poll_votes.is_removed
            FROM wall_poll_votes

            INNER JOIN wall_users
                ON wall_users.id =
                   wall_poll_votes.user_id

            WHERE wall_poll_votes.poll_id = ?
              AND wall_users.username = ?

            LIMIT 1
            "
        );

        if($selected_option_statement){

            mysqli_stmt_bind_param(
                $selected_option_statement,
                "is",
                $poll_id,
                $login_user
            );

            if(
                mysqli_stmt_execute(
                    $selected_option_statement
                )
            ){
                $selected_option_result =
                    mysqli_stmt_get_result(
                        $selected_option_statement
                    );

                $selected_option_data =
                    mysqli_fetch_assoc(
                        $selected_option_result
                    );

                if($selected_option_data){

                    $current_user_poll_change_count =
                        (int)(
                            $selected_option_data[
                                'vote_change_count'
                            ] ?? 0
                        );

                    $current_user_poll_vote_removed =
                        (int)(
                            $selected_option_data[
                                'is_removed'
                            ] ?? 0
                        ) === 1;

                    if(!$current_user_poll_vote_removed){

                        $current_user_poll_option_id =
                            (int)(
                                $selected_option_data[
                                    'option_id'
                                ] ?? 0
                            );
                    }
                }
            }

            mysqli_stmt_close(
                $selected_option_statement
            );
        }
    }
}

?>

<?php if($is_poll_post){ ?>

<div class="wall-poll-card">

    <div class="wall-poll-label">
        <i class="fa fa-bar-chart" aria-hidden="true"></i>
        Poll
    </div>

    <h3 class="wall-poll-question">
        <?=htmlspecialchars(
            $post_title,
            ENT_QUOTES,
            'UTF-8'
        )?>
    </h3>

    <?php if(
        !empty(
            trim(
                (string)($row['short_des'] ?? '')
            )
        )
    ){ ?>

    <div class="wall-poll-description">
        <?=nl2br(
            htmlspecialchars(
                trim((string)$row['short_des']),
                ENT_QUOTES,
                'UTF-8'
            )
        )?>
    </div>

    <?php } ?>

    <div class="wall-poll-options">

        <?php foreach(
            $poll_options as
            $poll_option_index => $poll_option
        ){ ?>

        <?php

        $option_id = (int)(
            $poll_option['id'] ?? 0
        );

        $option_votes = (int)(
            $poll_option['votes'] ?? 0
        );

        $option_image_name = trim(
            (string)(
                $poll_option['image'] ?? ''
            )
        );

        $option_image_url =
            $option_image_name !== ''
                ? (
                    '/wall/wall-feeds/polls/'
                    . rawurlencode(
                        basename($option_image_name)
                    )
                )
                : '';

        $option_percentage =
            $poll_total_votes > 0
                ? (int)round(
                    ($option_votes / $poll_total_votes) * 100
                )
                : 0;

        $is_selected_option =
            $current_user_poll_option_id === $option_id;

        $option_letter = chr(
            65 + (int)$poll_option_index
        );

        ?>

        <button
            type="button"
            class="wall-poll-option<?=$is_selected_option ? ' is-selected' : ''?>"
            data-poll-id="<?=$poll_id?>"
            data-option-id="<?=$option_id?>"
            aria-pressed="<?=$is_selected_option ? 'true' : 'false'?>"
            <?=(
                $poll_has_ended
                ||
                !$is_post_active
                ||
                $current_user_poll_vote_removed
            ) ? 'disabled' : ''?>
        >

            <span
                class="wall-poll-progress"
                style="width:<?=$option_percentage?>%;"
                aria-hidden="true"
            ></span>

            <span class="wall-poll-option-content">

                <span class="wall-poll-option-main">

                    <?php if($option_image_url !== ''){ ?>

                    <span class="wall-poll-option-image">

                        <img
                            src="<?=htmlspecialchars(
                                $option_image_url,
                                ENT_QUOTES,
                                'UTF-8'
                            )?>"
                            alt="<?=htmlspecialchars(
                                'Image for '
                                . (
                                    $poll_option['text']
                                    ?? 'poll option'
                                ),
                                ENT_QUOTES,
                                'UTF-8'
                            )?>"
                            loading="lazy"
                            decoding="async"
                            onerror="this.parentElement.style.display='none';"
                        >

                    </span>

                    <?php } ?>

                    <span
                        class="wall-poll-option-letter"
                        aria-hidden="true"
                    >
                        <?=$option_letter?>
                    </span>

                    <span class="wall-poll-option-text">
                        <?=htmlspecialchars(
                            (string)($poll_option['text'] ?? ''),
                            ENT_QUOTES,
                            'UTF-8'
                        )?>
                    </span>

                </span>

                <strong class="wall-poll-percentage">
                    <?=$option_votes?>
                    <?=$option_votes === 1 ? 'vote' : 'votes'?>
                </strong>

            </span>

        </button>

        <?php } ?>

    </div>

    <?php if(
        $current_user_poll_option_id > 0
        &&
        $current_user_poll_change_count < 1
        &&
        !$current_user_poll_vote_removed
        &&
        !$poll_has_ended
        &&
        $is_post_active
    ){ ?>

    <div class="wall-poll-vote-management">

        <button
            type="button"
            class="wall-poll-remove-vote"
            data-poll-id="<?=$poll_id?>"
            data-option-id="<?=$current_user_poll_option_id?>"
        >
            <i
                class="fa fa-times-circle-o"
                aria-hidden="true"
            ></i>

            Remove My Vote
        </button>

    </div>

    <?php } ?>

    <?php if($current_user_poll_vote_removed){ ?>

    <div class="wall-poll-vote-status is-removed">

        <i
            class="fa fa-info-circle"
            aria-hidden="true"
        ></i>

        <span>
            Your vote was removed. You can no longer vote in this poll.
        </span>

    </div>

    <?php } ?>

    <div class="wall-poll-footer">

        <span>
            <?=$poll_total_votes?>
            <?=$poll_total_votes === 1 ? 'vote' : 'votes'?>
        </span>

        <?php if($poll_has_ended){ ?>

        <span>Poll ended</span>

        <?php }elseif(!empty($poll_ends_at)){ ?>

        <span>
            Ends <?=htmlspecialchars(
                date(
                    'd M Y, h:i A',
                    strtotime($poll_ends_at)
                ),
                ENT_QUOTES,
                'UTF-8'
            )?>
        </span>

        <?php } ?>

    </div>

</div>

<?php }elseif($is_youtube_post){ ?>

<?php

$youtube_id =
    (string)$row['youtube_video_id'];

$youtube_thumbnail =
    "https://i.ytimg.com/vi/"
    . rawurlencode($youtube_id)
    . "/hqdefault.jpg";

?>

<div class="wallpost youtube-wallpost">

<?php if($is_post_active){ ?>

<a
    href="<?=htmlspecialchars(
        $media_post_url,
        ENT_QUOTES,
        'UTF-8'
    )?>"
    class="youtube-media-link"
    aria-label="Watch <?=htmlspecialchars(
        $post_title,
        ENT_QUOTES,
        'UTF-8'
    )?>"
>

<?php }else{ ?>

<div class="youtube-media-link">

<?php } ?>

<img
    src="<?=htmlspecialchars(
        $youtube_thumbnail,
        ENT_QUOTES,
        'UTF-8'
    )?>"
    alt="<?=htmlspecialchars(
        $post_alt,
        ENT_QUOTES,
        'UTF-8'
    )?>"
    title="<?=htmlspecialchars(
        $post_title,
        ENT_QUOTES,
        'UTF-8'
    )?>"
    loading="lazy"
    decoding="async"
>

<span class="youtube-post-label">

    <i
        class="fa fa-youtube-play"
        aria-hidden="true"
    ></i>

    Video
</span>

<span class="youtube-wall-play">

    <i
        class="fa fa-play"
        aria-hidden="true"
    ></i>

</span>

<?php if($is_post_active){ ?>

</a>

<?php }else{ ?>

</div>

<?php } ?>

</div>

<?php }else{ ?>

<?php

$img = !empty($row['image'])
    ? basename((string)$row['image'])
    : 'default.jpg';

?>

<div class="wallpost">

<img
    src="/wall/wall-feeds/<?=rawurlencode($img)?>"
    alt="<?=htmlspecialchars(
        $post_alt,
        ENT_QUOTES,
        'UTF-8'
    )?>"
    title="<?=htmlspecialchars(
        $post_title,
        ENT_QUOTES,
        'UTF-8'
    )?>"
    loading="lazy"
    decoding="async"
>

</div>

<?php } ?>

<?php
$comment_count = 0;

$comment_count_query = mysqli_query(
    $conn,
    "
    SELECT COUNT(*) AS total
    FROM wall_comments
    WHERE post_id = $post_id
      AND is_deleted = 0
    "
);

if($comment_count_query){

    $comment_count_row = mysqli_fetch_assoc(
        $comment_count_query
    );

    $comment_count = (int)(
        $comment_count_row['total'] ?? 0
    );
}
?>

<?php
$action_post_url = "/wall/feed.php?slug="
    . rawurlencode($row["page_url"] ?? "");

$share_post_url =
    "https://www.himanshuartinstitute.com/wall/feed/"
    . rawurlencode($row["page_url"] ?? "");
?>

<div class="like-box">

    <div class="likdvd post-actions-left">

        <span
            class="view-count post-action-item"
            title="Views"
        >
            <i
                class="fa fa-eye"
                aria-hidden="true"
            ></i>

            <span id="view-<?=$post_id?>">
                <?=(int)($row["views"] ?? 0)?>
            </span>
        </span>


        <span class="post-action-pair">

            <button
                type="button"
                class="like-btn<?=$is_liked ? " is-liked" : ""?>"
                data-id="<?=$post_id?>"
                <?php if(!$is_post_active){ ?>
				disabled
				<?php } ?>
                aria-label="<?=$is_liked ? "Unlike this post" : "Like this post"?>"
                aria-pressed="<?=$is_liked ? "true" : "false"?>"
                title="<?=$is_liked ? "Unlike" : "Like"?>"
            >
                <i
                    class="fa <?=$is_liked ? "fa-heart" : "fa-heart-o"?>"
                    aria-hidden="true"
                ></i>
            </button>

            <span class="like-count">
                <?=(int)($row["likes"] ?? 0)?>
            </span>

        </span>


<?php if($is_post_active){ ?>

<a
    class="comment-action post-action-pair"
    href="<?=htmlspecialchars(
        $action_post_url,
        ENT_QUOTES,
        "UTF-8"
    )?>"
    title="View comments"
>
    <i
        class="fa fa-comment-o"
        aria-hidden="true"
    ></i>

    <span class="comment-count">
        <?=(int)$comment_count?>
    </span>
</a>

<?php } else { ?>

<span
    class="comment-action post-action-pair engagement-disabled"
    title="Activate this post to enable comments"
>
    <i
        class="fa fa-comment-o"
        aria-hidden="true"
    ></i>

    <span class="comment-count">
        <?=(int)$comment_count?>
    </span>
</span>

<?php } ?>
    </div>


    <div class="likdvd post-actions-right">

        <span class="post-action-pair">

            <button
                type="button"
                class="share-btn"
                data-id="<?=$post_id?>"
                <?php if(!$is_post_active){ ?>
				disabled
				<?php } ?>
                data-url="<?=htmlspecialchars(
                    $share_post_url,
                    ENT_QUOTES,
                    "UTF-8"
                )?>"
                data-type="<?=$is_poll_post ? 'poll' : ($is_youtube_post ? 'youtube' : 'artwork')?>"
                aria-label="Share this post"
                title="Share"
            >
                <i
                    class="fa fa-share"
                    aria-hidden="true"
                ></i>
            </button>

            <span
                class="share-count"
                id="share-count-<?=$post_id?>"
            >
                <?=(int)($row["shares"] ?? 0)?>
            </span>

        </span>

    </div>

</div>

<?php if(!$is_poll_post){ ?>

<div class="feeddscrpn"> 
<h2><?=$row['blog_name']?></h2>
<p><?=nl2br($row['short_des'])?></p>
</div>

<?php } ?>
</div>
</div>

<?php } ?>

<?php endif; ?>

</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>

<!-- FOOTER -->
<?php include($_SERVER['DOCUMENT_ROOT']."/wall/bcknds/footer.php"); ?>











<?php if(isset($_SESSION['verify_msg'])): ?>
<script>
Swal.fire({
  icon: 'success',
  title: 'Request Submitted',
  text: 'Admin verify karke jaldi activate karega'
});
</script>
<?php unset($_SESSION['verify_msg']); endif; ?>



<?php if(isset($_SESSION['blocked_post'])): ?>
<script>
Swal.fire({
  icon: 'warning',
  title: 'Blocked',
  text: 'This post is blocked by admin and cannot be activated',
  confirmButtonColor: '#e0245e'
});
</script>
<?php unset($_SESSION['blocked_post']); endif; ?>


<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>

<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>
document.querySelectorAll(
    ".delete-post-form"
).forEach(function(form){

    form.addEventListener(
        "submit",
        function(event){

            event.preventDefault();

            Swal.fire({
                title: "Delete this post?",
                text:
                    "The post and all related data will be permanently deleted.",
                icon: "warning",
                showCancelButton: true,
                confirmButtonColor: "#d33",
                cancelButtonColor: "#3085d6",
                confirmButtonText: "Yes, Delete",
                cancelButtonText: "Cancel"
            }).then(function(result){

                if(result.isConfirmed){
                    form.submit();
                }
            });
        }
    );
});
</script>

<script>
document.querySelectorAll(".menu-icon").forEach(function(btn){

btn.addEventListener("click",function(e){

let menu = this.nextElementSibling;

document.querySelectorAll(".menu-dropdown").forEach(function(m){
if(m!=menu){
m.style.display="none";
}
});

menu.style.display = menu.style.display === "block" ? "none" : "block";

});

});


document.addEventListener("click",function(e){

if(!e.target.closest(".post-menu")){

document.querySelectorAll(".menu-dropdown").forEach(function(m){
m.style.display="none";
});

}

});

</script>


<script>
function submitActivation(){

  let regn = document.getElementById("regn").value.trim();
  let mobile = document.getElementById("mobile").value.trim();

  if(regn === "" || mobile === ""){
    Swal.fire("Error","All fields required","warning");
    return;
  }

  fetch("/wall/bcknds/request-activation.php", {
    method:"POST",
    headers:{"Content-Type":"application/x-www-form-urlencoded"},
    body:"regn="+regn+"&mobile="+mobile
  })
  .then(res=>res.text())
  .then(data=>{

    if(data === "success"){
      location.reload(); // 🔥 यही magic है
    }

  });
}

</script>





<div class="share-panel" id="sharePanel">
<div class="share-box">
<h3>Share</h3>
<a id="share-facebook" target="_blank"><i class="fa fa-facebook"></i> Facebook</a>
<a id="share-whatsapp" target="_blank"><i class="fa fa-whatsapp"></i> WhatsApp</a>
<a id="share-twitter" target="_blank"><i class="fa fa-twitter"></i> Twitter</a>
<a id="copy-link"><i class="fa fa-link"></i> Copy Links</a>
<button class="close-share">Close</button>
</div>
</div>
<script src="../bcknds/hai-blog-slidr.js"></script>
<script src="../bcknds/search.js"></script>
<script src="../bcknds/views-update.js?v=20260824-1"></script>
<script src="../bcknds/likebtns.js"></script>
<script src="/wall/bcknds/shared.js?v=20260731-2"></script>
<script src="/wall/bcknds/poll-vote.js?v=20260802-1"></script>
<script src="../bcknds/post-mnu-btn.js"></script>
<script src="../bcknds/user-menu.js"></script>
<a href="javascript:history.back()" class="back-floating"><i class="fa fa-arrow-left"></i></a>
</body>
</html>