403Webshell
Server IP : 65.1.209.187  /  Your IP : 216.73.216.144
Web Server : nginx/1.24.0
System : Linux ip-172-31-5-206 6.14.0-1015-aws #15~24.04.1-Ubuntu SMP Tue Sep 23 22:44:48 UTC 2025 x86_64
User :  ( 1001)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/ttc_wordpress/wp-content/themes/ttc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/ttc_wordpress/wp-content/themes/ttc/page-match-results.php
<?php
/*
Template Name: Match Results
*/
get_header('inner');

if (have_posts()) : the_post();

function get_match_status($match_date, $match_time, $duration) {
    $ist_timezone = new DateTimeZone('Asia/Kolkata');
    $match_datetime = DateTime::createFromFormat('Y-m-d H:i:s', $match_date . ' ' . $match_time, $ist_timezone);
    $now = new DateTime('now', $ist_timezone);

    if (!$match_datetime) return 'upcoming';

    if (strpos($duration, ':') !== false) {
        list($hours, $minutes) = explode(':', $duration);
        $duration_minutes = ($hours * 60) + $minutes;
    } else {
        $duration_minutes = $duration;
    }

    $match_end = clone $match_datetime;
    $match_end->add(new DateInterval('PT' . $duration_minutes . 'M'));

    if ($match_datetime > $now) {
        return 'upcoming';
    } elseif ($match_datetime <= $now && $match_end >= $now) {
        return 'live';
    } else {
        return 'completed';
    }
}

// Get filter values
$category = isset($_GET['category']) ? sanitize_text_field($_GET['category']) : '';
$team = isset($_GET['team']) ? intval($_GET['team']) : '';
$venue = isset($_GET['venue']) ? sanitize_text_field($_GET['venue']) : '';
$season = isset($_GET['season']) ? sanitize_text_field($_GET['season']) : '';

// Get all teams for dropdown
$teams = get_posts(array(
    'post_type' => 'teams',
    'posts_per_page' => -1,
    'orderby' => 'title',
    'order' => 'ASC'
));

// Get all venues
global $wpdb;
$venues = $wpdb->get_col(
    "SELECT DISTINCT meta_value FROM {$wpdb->postmeta}
    WHERE meta_key = 'match_datetime_venue' AND meta_value != ''"
);

// Get taxonomies
$seasons = get_terms(['taxonomy' => 'season', 'hide_empty' => false]);
$categories = get_terms(['taxonomy' => 'match_category', 'hide_empty' => false]);
?>

<div class="py-20">
    <div class="container">
        <div class="px-4 sm:px-8">
            <!-- Filter Form -->
            <form method="get" class="mb-8">
                <div class="lg:grid lg:grid-cols-12 lg:gap-4 gray-bg rounded-xl py-2.5 pl-4 pr-4 lg:pl-24 lg:pr-10">
                    <div class="lg:col-span-2 mb-3 lg:mb-0">
                        <select name="category" class="bg-gray-50 border border-gray-300 text-slate-400 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
                            <option value="">All Categories</option>
                            <?php foreach($categories as $cat): ?>
                                <option value="<?php echo esc_attr($cat->term_id); ?>" <?php selected($category, $cat->term_id); ?>>
                                    <?php echo esc_html($cat->name); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </div>

                    <div class="lg:col-span-3 mb-3 lg:mb-0">
                        <select name="team" class="bg-gray-50 border border-gray-300 text-slate-400 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
                            <option value="">All Teams</option>
                            <?php foreach($teams as $t): ?>
                                <option value="<?php echo esc_attr($t->ID); ?>" <?php selected($team, $t->ID); ?>>
                                    <?php echo esc_html($t->post_title); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </div>

                    <div class="lg:col-span-3 mb-3 lg:mb-0">
                        <select name="venue" class="bg-gray-50 border border-gray-300 text-slate-400 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
                            <option value="">All Venues</option>
                            <?php foreach($venues as $v): ?>
                                <option value="<?php echo esc_attr($v); ?>" <?php selected($venue, $v); ?>>
                                    <?php echo esc_html($v); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </div>

                    <div class="lg:col-span-3 mb-3 lg:mb-0">
                        <select name="season" class="bg-gray-50 border border-gray-300 text-slate-400 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
                            <option value="">All Seasons</option>
                            <?php foreach($seasons as $s): ?>
                                <option value="<?php echo esc_attr($s->term_id); ?>" <?php selected($season, $s->term_id); ?>>
                                    <?php echo esc_html($s->name); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </div>

                    <div class="lg:col-span-1 mb-3 lg:mb-0">
                        <button type="submit" class="w-full text-white green-bg rounded-lg px-4 py-2.5">Filter</button>
                    </div>
                </div>
            </form>

            <div class="relative overflow-x-auto">
                <?php
                // Base query args
                $matches_args = array(
                    'post_type' => 'match',
                    'posts_per_page' => -1,
                    'meta_query' => array(
                        array(
                            'key' => 'match_winner',
                            'compare' => 'EXISTS'
                        )
                    )
                );

                // Add taxonomy queries
                $tax_query = array();
                if ($category) {
                    $tax_query[] = array(
                        'taxonomy' => 'match_category',
                        'field' => 'term_id',
                        'terms' => $category
                    );
                }
                if ($season) {
                    $tax_query[] = array(
                        'taxonomy' => 'season',
                        'field' => 'term_id',
                        'terms' => $season
                    );
                }
                if (!empty($tax_query)) {
                    $matches_args['tax_query'] = $tax_query;
                }

                // Add meta queries
                $meta_query = array();
                if ($venue) {
                    $meta_query[] = array(
                        'key' => 'match_datetime_venue',
                        'value' => $venue,
                        'compare' => '='
                    );
                }
                if ($team) {
                    $meta_query['relation'] = 'OR';
                    $meta_query[] = array(
                        'key' => 'teams_team_1',
                        'value' => $team,
                        'compare' => '='
                    );
                    $meta_query[] = array(
                        'key' => 'teams_team_2',
                        'value' => $team,
                        'compare' => '='
                    );
                }
                if (!empty($meta_query)) {
                    $matches_args['meta_query'] = array_merge(array('relation' => 'AND'), array($matches_args['meta_query']), array($meta_query));
                }

                $all_matches = new WP_Query($matches_args);
                $completed_matches = array();

                if ($all_matches->have_posts()) {
                    while ($all_matches->have_posts()) {
                        $all_matches->the_post();

                        $match_datetime = get_field('match_datetime');
                        $duration = get_field('duration') ?: 120;

                        $status = get_match_status(
                            $match_datetime['match_date'],
                            $match_datetime['match_time'],
                            $duration
                        );

                        if ($status === 'completed') {
                            $completed_matches[] = get_post();
                        }
                    }
                    wp_reset_postdata();
                }

                // Sort completed matches by date (most recent first)
                usort($completed_matches, function($a, $b) {
                    $a_datetime = get_field('match_datetime', $a->ID);
                    $b_datetime = get_field('match_datetime', $b->ID);
                    return strtotime($b_datetime['match_date']) - strtotime($a_datetime['match_date']);
                });

                // Pagination
                $matches_per_page = 1;
                $current_page = get_query_var('paged') ? get_query_var('paged') : 1;
                $total_matches = count($completed_matches);
                $total_pages = ceil($total_matches / $matches_per_page);
                $offset = ($current_page - 1) * $matches_per_page;

                $current_matches = array_slice($completed_matches, $offset, $matches_per_page);

                if (!empty($current_matches)) {
                    foreach ($current_matches as $post) {
                        setup_postdata($post);

                        $match_datetime = get_field('match_datetime');
                        $teams = get_field('teams');
                        $winner = get_field('match_winner');
                        $results = get_field('results');
                        ?>
                        <div class="border-b-4 border-white lg:grid lg:grid-cols-12 lg:gap-1 ash-bg rounded-xl light-blue p-6 mb-1">
                            <div class="lg:col-span-7">
                                <img src="<?php echo get_template_directory_uri(); ?>/images/pdf-view.png" class="float-left"/>

                                <h4 class="text-base font-bold lg:pl-20 pl-8">
                                    <?php echo esc_html($teams['team_1']->post_title . ' vs ' . $teams['team_2']->post_title); ?>
                                </h4>
                                <p class="font-normal text-base lg:pl-20 pl-8">
                                    Winner: <?php echo esc_html($winner->post_title); ?><br>
                                    Score: <?php echo esc_html($teams['team_1_score'] . ' - ' . $teams['team_2_score']); ?><br>
                                    <?php if (!empty($results['result_highlights'])): ?>
                                        <span class="font-bold">Highlights:</span> <?php echo esc_html($results['result_highlights']); ?><br>
                                    <?php endif; ?>
                                    Venue: <?php echo esc_html($match_datetime['venue']); ?><br>
                                    Date: <?php
                                        $date = DateTime::createFromFormat('Y-m-d', $match_datetime['match_date']);
                                        echo $date ? $date->format('M d, Y') : '';
                                    ?>
                                </p>
                            </div>
                            <div class="lg:col-span-5 flex lg:justify-end justify-center lg:mt-0 mt-8">
                              <?php if (!empty($results['result_pdf'])) : ?>
                              <a href="<?php echo esc_url($results['result_pdf']); ?>" target="_blank" class="float-left" title="View Result">
                                  <img src="<?php echo get_template_directory_uri(); ?>/images/view.png" class="lg:mr-8 mr-4"/>
                              </a>
                              <?php endif; ?>
                                <?php if (!empty($results['result_pdf'])) :  ?>
                                  <a href="<?php echo esc_url($results['result_pdf']); ?>"
                                     class="float-left"
                                     title="Download Match Report"
                                     download="Results"
                                     onclick="forceDownload(event, '<?php echo esc_url($results['result_pdf']); ?>', 'results.pdf')">
                                      <img src="<?php echo get_template_directory_uri(); ?>/images/download.png"/>
                                  </a>
                                <script>
                                function forceDownload(event, url, filename) {
                                    event.preventDefault();
                                    const a = document.createElement('a');
                                    a.href = url;
                                    a.download = filename;
                                    document.body.appendChild(a);
                                    a.click();
                                    document.body.removeChild(a);
                                }
                                </script>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php
                    }
                    wp_reset_postdata();

                    if ($total_pages > 1) : ?>
                        <div class="lg:col-span-12"></div>
                        <nav aria-label="Page navigation example mx-auto">
                            <ul class="flex items-center gap-2 h-8 text-sm justify-center my-4">
                                <?php if ($current_page > 1) : ?>
                                <li>
                                    <a href="<?php echo add_query_arg('paged', $current_page - 1); ?>" class="flex items-center justify-center px-3 h-8 ms-0 leading-tight bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 text-lg hover:text-gray-700 text-white dark:hover:bg-gray-700 dark:hover:text-white rounded green-bg">
                                        <span class="sr-only">Previous</span>
                                        <svg class="w-2.5 h-2.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
                                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 1 1 5l4 4"/>
                                        </svg>
                                    </a>
                                </li>
                                <?php endif; ?>

                                <?php
                                for ($i = 1; $i <= $total_pages; $i++) :
                                    $is_current = $current_page == $i;
                                ?>
                                <li>
                                    <a href="<?php echo add_query_arg('paged', $i); ?>"
                                       class="flex items-center justify-center px-3 h-8 leading-tight <?php echo $is_current ? 'green-bg text-white' : 'text-gray-500 light-bg'; ?> border border-gray-300 text-base font-medium hover:bg-gray-100 hover:text-gray-700 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white rounded">
                                        <?php echo $i; ?>
                                    </a>
                                </li>
                                <?php endfor; ?>

                                <?php if ($current_page < $total_pages) : ?>
                                <li>
                                    <a href="<?php echo add_query_arg('paged', $current_page + 1); ?>" class="flex items-center justify-center px-3 h-8 ms-0 leading-tight bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 text-lg hover:text-gray-700 text-white dark:hover:bg-gray-700 dark:hover:text-white rounded green-bg">
                                        <span class="sr-only">Next</span>
                                        <svg class="w-2.5 h-2.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
                                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
                                        </svg>
                                    </a>
                                </li>
                                <?php endif; ?>
                            </ul>
                        </nav>
                    <?php endif;
                } else { ?>
                    <div class="text-center py-8">
                        <p class="text-gray-500">No completed matches found.</p>
                    </div>
                <?php } ?>
            </div>
        </div>
    </div>
</div>

<?php endif;
get_footer(); ?>

Youez - 2016 - github.com/yon3zu
LinuXploit