Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $match_id;
- global $wpdb;
- $match_id = get_query_var( 'id' );
- if(!$match_id) { echo 'No Match Selected <a href="#" onclick="javascript:history.back()">Go Back</a>'; goto skip; }
- $curl = curl_init();
- curl_setopt_array($curl, [
- CURLOPT_URL => "https://.com/match.json?match=$match_id",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "GET",
- CURLOPT_HTTPHEADER => [
- "x-rapidapi-host: ",
- "x-rapidapi-key: "
- ],
- ]);
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- $json_decoded = $response;
- $json_decoded = json_decode($json_decoded, true);
- }
- function display_match_comments() {
- global $current_user; wp_get_current_user();
- global $match_id;
- global $wpdb;
- echo '<div class="latest_results" style="background:#ffffff; text-align:left !important;"">';
- echo '<h6 style="text-align:center !important;">User Comments and Pictures';
- if ( is_user_logged_in() ) {
- echo ' <a href="#add_comment">Add Comment</a>';
- }
- echo '</h6>';
- $content_size = 'one_half';
- $table_name = 'wp_match_comments';
- $row2 = $wpdb->get_results( "SELECT * FROM $table_name WHERE gameid = $match_id");
- if(!$row2) { echo 'No Comments Found</span>'; }
- foreach($row2 as $row2) {
- if(!$content_size){ $content_size = "one_half"; }
- echo '<div class="'.$content_size.'">';
- echo '<div class="latest_results" style="background:#ffffff;">';
- echo '<h6><a href="https://www.husupporters.club/forums/users/'.$row2->name.'">'.$row2->name.'</a></h6>';
- echo '<span>'.$row2->content.'</span><br>';
- $text_to_be_wrapped_in_shortcode = '<span><a href="https://www.husupporters.club/wp-admin/admin.php?page=match_comments&id='.$row2->id.'">Manage Comment</a></span>';
- echo do_shortcode( '[UAS_role roles="administrator, moderator"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_role]' );
- echo '</div>';
- echo '</div>';
- if ($content_size == "one_half") { $content_size = "one_half last_column"; goto skip2; }else{ $content_size = "one_half"; goto skip2; }
- skip2:
- }
- echo '<div id="add_comment" class="latest_results" style="background:#ffffff; text-align:left !important;"">';
- if ( is_user_logged_in() ) {
- echo '<h6 style="text-align:center !important;">Add your own comment and pictures below</h6>';
- ?>
- <form method="POST" action="#">
- <?php wp_editor($content,"content", array('textarea_rows'=>12, 'editor_class'=>'content_class')); ?>
- <input type="hidden" name="name" value="<?php echo $current_user->user_login; ?>"/>
- <input type="hidden" name="gameid" value="<?php echo $match_id; ?>"/>
- <input type="submit" name="submitComment" value="submit" />
- </form>
- <?php
- $default = array(
- 'name' => '',
- 'content' => '',
- 'moderation' => '0',
- 'gameid' => '',
- );
- $item = shortcode_atts( $default, $_REQUEST );
- if($_POST['submitComment']) {
- $wpdb->prepare($wpdb->insert( $table_name, $item ));
- $comment_success = '1';
- global $comment_success;
- }
- if($comment_success == 1) { echo '<br></span>Comment has been successfully added, once approved it will appear here</span>'; }
- }else{
- echo '<h6 style="text-align:center !important;"> you must be <a href="https://www.husupporters.club/login-register/">logged in</a>
- to comment</h6>';
- }
- echo '</div>';
- echo '</div>';
- }
- foreach ( $json_decoded as $match ){
- display_match($match);
- }
- function display_home_player($home_player, $match){
- $home_player_id = $home_player['player']['id'];
- $matchid = $match['id'];
- if($home_player['sort'] == 12) { echo '<hr>'; }
- echo '<span style="text-align:left !important;">'.$home_player['shirt'].' - '.$home_player['player']['first-name'].' '.$home_player['player']['last-name'].' ';
- if ($home_player['cautioned']['minute']) {
- echo '<span class="fwp-card yellow-card" style="color:#000000;">'.$home_player['cautioned']['minute'].'\' </span>';
- }
- if ($home_player['sent-off']['minute']) {
- echo '<span class="fwp-card red-card" style="color:#ffffff;">'.$home_player['sent-off']['minute'].'\' </span>';
- }
- foreach ( $match['home-team']['goals'] as $home_goals ){
- display_home_goals($home_goals, $home_player_id, $matchid);
- }
- foreach ( $match['home-team']['line-up'] as $home_player_sub ){
- display_home_sub($home_player_sub, $home_player_id, $matchid);
- }
- if ($home_player['substitution']['minute']) { echo '<span style="color:#52FF33; font-size:25px;"> ↑ </span><span> '.$home_player['substitution']['minute'].'\' </span>'; }
- echo '</span><br>';
- }
- function display_away_player($away_player, $match){
- $away_player_id = $away_player['player']['id'];
- if($away_player['sort'] == 12) { echo '<hr>'; }
- echo '<span style="text-align:left !important;">'.$away_player['shirt'].' - '.$away_player['player']['first-name'].' '.$away_player['player']['last-name'].' ';
- if ($away_player['cautioned']['minute']) {
- echo '<span class="fwp-card yellow-card" style="color:#000000;">'.$away_player['cautioned']['minute'].'\' </span>';
- }
- if ($away_player['sent-off']['minute']) {
- echo '<span class="fwp-card red-card" style="color:#ffffff;">'.$away_player['sent-off']['minute'].'\' </span>';
- }
- foreach ( $match['away-team']['goals'] as $away_goals ){
- display_away_goals($away_goals, $away_player_id);
- }
- foreach ( $match['away-team']['line-up'] as $away_player_sub ){
- display_away_sub($away_player_sub, $away_player_id);
- }
- if ($away_player['substitution']['minute']) { echo '<span style="color:#52FF33; font-size:25px;"> ↑ </span><span> '.$away_player['substitution']['minute'].'\' </span>'; }
- echo '</span><br>';
- }
- function display_home_goals($home_goals, $home_player_id, $matchid){
- if($matchid == 364310) { goto ebbsfleet_skip2; }
- if ($home_goals['player']['id'] == $home_player_id) {
- echo '<span>⚽ '.$home_goals['minute'].'\' </span> ';
- }
- ebbsfleet_skip2:
- }
- function display_home_sub($home_player_sub, $home_player_id, $matchid){
- if($matchid == 364310) { goto ebbsfleet_skip; }
- if ($home_player_sub['substitution']['replaced']['player']['id'] == $home_player_id) {
- echo '<span style="color:#FF0000; font-size:25px;"> ↓ </span><span> '.$home_player_sub['substitution']['minute'].'\'</span> ';
- }
- ebbsfleet_skip:
- }
- function display_away_goals($away_goals, $away_player_id){
- if ($away_goals['player']['id'] == $away_player_id) {
- echo '<span>⚽ '.$away_goals['minute'].'\' </span>';
- }
- }
- function display_away_sub($away_player_sub, $away_player_id){
- if ($away_player_sub['substitution']['replaced']['player']['id'] == $away_player_id) {
- echo '<span style="color:#FF0000; font-size:25px;"> ↓ </span><span> '.$away_player_sub['substitution']['minute'].'\' </span>';
- }
- }
- function display_match_report($gameid) {
- global $wpdb;
- $row2 = $wpdb->get_results("SELECT * FROM wp_hufc_match_report WHERE gameid = $gameid ");
- foreach ($row2 as $row2) {
- if($row2->author) { echo '<a href="'.$row2->matchlink.'" class="gamedetail" target="_blank">Match Report by '.$row2->author.'</a><br>'; }else{ echo '<a href="'.$row2->matchlink.'" class="gamedetail" target="_blank">Match Report</a><br>'; }
- }
- if(!$row2) {
- $text_to_be_wrapped_in_shortcode = '<span><a href="https://www.husupporters.club/wp-admin/admin.php?page=hufc_match_report&addid='.$gameid.'">Click here</a> to add a report link</span><br>';
- echo do_shortcode( '[UAS_role roles="administrator, moderator"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_role]' );
- echo do_shortcode( '[UAS_specific ids="48, 3"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_specific]' );
- }else {
- $text_to_be_wrapped_in_shortcode = '<span><a href="https://www.husupporters.club/wp-admin/admin.php?page=hufc_match_report&id='.$gameid.'">Click here</a> to edit a report link</span><br>';
- echo do_shortcode( '[UAS_role roles="administrator, moderator"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_role]' );
- echo do_shortcode( '[UAS_specific ids="48, 3"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_specific]' );
- }
- }
- function display_match($match){
- global $wpdb;
- global $match_id;
- $home_team_name = strtolower($match['home-team']['name']);
- $home_team_name = preg_replace('/\s+/', '_',$home_team_name);
- $away_team_name = strtolower($match['away-team']['name']);
- $away_team_name = preg_replace('/\s+/', '_',$away_team_name);
- $match_date = date("M jS, Y", strtotime($match['date']));
- echo '<a href="#" onclick="javascript:history.back()" style="float:left !important;">Go Back</a><br>';
- echo '<div class="one_half">';
- echo '<div class="latest_results" style="background:#ffffff;">';
- echo '<h6>Final Result</h6>';
- echo '<div class="latest_results_col"><img src="https://www.husupporters.club/wp-content/uploads/team_logos/'.$home_team_name.'.png"><span><a href="https://www.husupporters.club/team-info/'.$match['home-team']['id'].'">'.$match['home-team']['name'].'</a></span>';
- $text_to_be_wrapped_in_shortcode = '<br><span>team ID: '.$match['home-team']['id'].'</span>';
- echo do_shortcode( '[UAS_role roles="administrator"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_role]' );
- echo '</div>';
- echo '<div class="latest_results_col goalscore">'.$match['home-team']['score'].'</div>';
- echo '<div class="latest_results_col goalscore">'.$match['away-team']['score'].'</div>';
- echo '<div class="latest_results_col"><img src="https://www.husupporters.club/wp-content/uploads/team_logos/'.$away_team_name.'.png"><span><a href="https://www.husupporters.club/team-info/'.$match['away-team']['id'].'">'.$match['away-team']['name'].'</a></span>';
- $text_to_be_wrapped_in_shortcode = '<br><span>team ID: '.$match['away-team']['id'].'</span>';
- echo do_shortcode( '[UAS_role roles="administrator"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_role]' );
- echo '</div>';
- echo '<div class="clear">';
- if ($match['home-team']['penalties-score']) {
- $p_home = $match['home-team']['penalties-score'];
- $p_away = $match['away-team']['penalties-score'];
- if ($p_home > $p_away) {
- echo '<span><a href="https://www.husupporters.club/team-info/'.$match['home-team']['id'].'">'.$match['home-team']['name'].'</a> wins '.$match['home-team']['penalties-score'].' - '.$match['away-team']['penalties-score'].' on penalties.</span>';
- }
- if ($p_away > $p_home) {
- echo '<span><a href="https://www.husupporters.club/team-info/'.$match['away-team']['id'].'">'.$match['away-team']['name'].'</a> wins '.$match['away-team']['penalties-score'].' - '.$match['home-team']['penalties-score'].' on penalties.</span>';
- }
- }
- echo '</div>';
- echo '</div>';
- echo '</div>';
- echo '<div class="one_half last_column">';
- echo '<div class="latest_results" style="background:#ffffff">';
- echo '<h6>Match Information</h6><br>';
- echo '<span>Date: '.$match_date.'</span><br>';
- echo '<span>Competition: '.$match['competition']['name'].'</span><br>';
- echo '<span>Kick Off: '.$match['time'].'</span><br>';
- echo '<span>Venue: '.$match['venue'].'</span><br>';
- echo '<span>Half Time: <a href="https://www.husupporters.club/team-info/'.$match['home-team']['id'].'">'.$match['home-team']['name'].'</a> '.$match['home-team']['half-time-score'].' - '.$match['away-team']['half-time-score'].' <a href="https://www.husupporters.club/team-info/'.$match['away-team']['id'].'">'.$match['away-team']['name'].'</a></span><br>';
- echo '<span>Attendance: '.$match['attendance'].'</span><br>';
- $gameid = $match['id'];
- display_match_report($gameid);
- $text_to_be_wrapped_in_shortcode = '<span>Match ID: '.$match['id'].'</span>';
- echo do_shortcode( '[UAS_role roles="administrator, moderator"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_role]' );
- echo '</div></div>';
- echo '<div class="one_half">';
- echo '<div class="latest_results" style="background:#ffffff; text-align:left !important;" >';
- echo '<h6 style="text-align:center !important;"><a href="https://www.husupporters.club/team-info/'.$match['home-team']['id'].'">'.$match['home-team']['name'].'</a></h6>';
- if($match['id'] == 364310) { echo '<span>We are aware of an issue with goal and substitution data of this game, this is due to the data not being recorded correctly<br> Goal scorers for Ebbsfleet were: Lee Martin (59\' pen) & Ben Chapman (90\')<br>Substitutions are as follows: Jack Paxman Replaced Michael West 45\', Rakish Bingham Replaced Reece Grant 45\', Charlie Rowan Replaced James Dobson 87\'</span><br>'; }
- foreach ( $match['home-team']['line-up'] as $home_player ){
- display_home_player($home_player, $match);
- }
- echo '</div></div>';
- echo '<div class="one_half last_column">';
- echo '<div class="latest_results" style="background:#ffffff; text-align:left !important;"">';
- echo '<h6 style="text-align:center !important;"><a href="https://www.husupporters.club/team-info/'.$match['away-team']['id'].'">'.$match['away-team']['name'].'</a></h6>';
- foreach ( $match['away-team']['line-up'] as $away_player ){
- display_away_player($away_player, $match);
- }
- echo '</div></div>';
- display_match_comments();
- }
- skip:
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement