Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Edited Map preview image look
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianP26 committed Dec 12, 2022
1 parent 78edd7c commit 70b7da3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 44 deletions.
4 changes: 2 additions & 2 deletions inc/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* Database Config */

$db_host = 'your_database_host'; // DB Hostame
$db_port = 3306; // DB Port (Default: 3306)
$db_port = 3306; // DB Port (Default: 3306)
$db_username = 'your_database_username'; // DB Username
$db_password = 'your_database_password'; // DB Password
$db_database = 'your_database_name'; // DB Database
Expand Down Expand Up @@ -37,7 +37,7 @@
$settings_navbar_title = "Surf Stats";
$settings_player_profile_icon = TRUE; // TRUE or FALSE # FALSE will disable player profile icons
$settings_map_link_icon = TRUE; // TRUE or FALSE # FALSE will disable link icon after map name
$settings_map_image_preview = TRUE; // TRUE or FALSE # FALSE will disable map images preview
$settings_map_image_preview = TRUE; // TRUE or FALSE # FALSE will disable map images preview // TRUE may have effect on page load
$settings_map_mapper = TRUE; // TRUE or FALSE # FALSE will disable map mapper name


Expand Down
89 changes: 71 additions & 18 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ function BackgroundImage(): string
return $settings_background_image;
}

if($settings_language_enable):
function LanguageActive($language): string
{
if($_SESSION['language'] == $language)
Expand All @@ -151,7 +150,6 @@ function LanguageURL($language): string
else
return '?language='.$language;
}
endif;

function MapDownload($map_name): string
{
Expand All @@ -176,27 +174,82 @@ function MapDownload($map_name): string
}


function MapPreviewImage($map_name): string
function MapInfo($m_name, $m_mapper, $m_type, $m_tier, $m_bonus, $m_added, $m_added_d, $m_velocity): string
{
global $settings_map_image_preview;
global $settings_map_mapper;

$images_source_url = "https://raw.githubusercontent.com/Sayt123/SurfMapPics/Maps-and-bonuses/csgo/";
if($settings_map_image_preview === TRUE):
$image_url = $images_source_url.$map_name.".jpg";

if ($settings_map_image_preview):
$image_url = $images_source_url.$m_name.".jpg";
$file_headers = @get_headers($image_url);
if(str_contains($file_headers[0], '200'))
return '<img src="'.$image_url.'" class="img-thumbnail my-3 shadow-sm" alt="'.$map_name.' - Preview Image">';
else
return '';
else:
return '';
if (str_contains($file_headers[0], '200'))
$m_image = $image_url;
endif;
}

function MapMapper($map_mapper): string
{
global $settings_map_mapper;
if($settings_map_mapper === TRUE)
return '<div class="text-center">'.MAPS_MAP_CREATED_BY.': <strong>'.$map_mapper.'</strong></div>';
if (($settings_map_mapper) && ($m_mapper !== null))
$m_mapper_text = '<div class="text-center">'.MAPS_MAP_CREATED_BY.': <strong>'.$m_mapper.'</strong></div>';
else
return '';
$m_mapper_text = '';

if (isset($m_image)):
return '
<div id="carouselExampleSlidesOnly" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="'.$m_image.'" class="d-block w-100 img-thumbnail" alt="'.$m_name.' - Preview Image">
<div class="carousel-caption d-none d-md-block bg-dark bg-opacity-50 pt-1 mb-5 rounded-5">
<h2 class="text-center">'.$m_name.'</h2>
'.$m_mapper_text.'
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto text-center">
'.TABLE_TYPE.': <b>'.$m_type.'</b>
</div>
<div class="col-12 col-md-auto text-center">
'.TABLE_TIER.': <b>'.$m_tier.'</b>
</div>
<div class="col-12 col-md-auto text-center">
'.TABLE_BONUS.': <b>'.$m_bonus.'</b>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto text-center">
'.TABLE_ADDED.': <b>'.$m_added.' <small>('.$m_added_d.')</small></b>
</div>
<div class="col-12 col-md-auto text-center">
'.MAPS_MAX_VELOCITY.': <b>'.number_format($m_velocity).'</b>
</div>
</div>
</div>
</div>
</div>
</div>
';

else:
return '
<h3 class="text-center">'.$m_name.'</h3>
'.$m_mapper_text.'
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto text-center">
'.TABLE_TYPE.': <b>'.$m_type.'</b>
</div>
<div class="col-12 col-md-auto text-center">
'.TABLE_TIER.': <b>'.$m_tier.'</b>
</div>
<div class="col-12 col-md-auto text-center">
'.TABLE_BONUS.': <b>'.$m_bonus.'</b>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto text-center">
'.TABLE_ADDED.': <b>'.$m_added.' <small>('.$m_added_d.')</small></b>
</div>
<div class="col-12 col-md-auto text-center">
'.MAPS_MAX_VELOCITY.': <b>'.number_format($m_velocity).'</b>
</div>
</div>
';
endif;
}
26 changes: 2 additions & 24 deletions inc/pages/dashboard_maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@

$map_name = $row_map['mapname'];
$map_tier = $row_map['tier'];
if(isset($row_map['mapper']))
$map_mapper = $row_map['mapper'];
$map_mapper = $row_map['mapper'] ?? null;
$map_dateadded = $row_map['date'];
$map_maxvelocity = $row_map['maxvelocity'];

Expand Down Expand Up @@ -425,28 +424,7 @@
<?php if(mysqli_num_rows($results_map) > 0): ?>
<?php if(isset($row_map['date'])): ?>
<div class="my-4">
<h3 class="text-center"><?php echo $mapname; ?></h3>
<?php if(isset($map_mapper)) echo MapMapper($map_mapper); ?>
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto text-center">
<?php echo TABLE_TYPE; ?>: <b><?php echo $map_stages_info;?></b>
</div>
<div class="col-12 col-md-auto text-center">
<?php echo TABLE_TIER; ?>: <b><?php echo $map_tier;?></b>
</div>
<div class="col-12 col-md-auto text-center">
<?php echo TABLE_BONUS; ?>: <b><?php echo $map_bonuses_info;?></b>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto text-center">
<?php echo TABLE_ADDED; ?>: <b><?php echo $map_dateadded_edit;?> <small>(<?php echo $map_dateadded_edit_d;?>)</small></b>
</div>
<div class="col-12 col-md-auto text-center">
<?php echo MAPS_MAX_VELOCITY; ?>: <b><?php echo number_format($map_maxvelocity); ?></b>
</div>
</div>
<?php echo MapPreviewImage($mapname) ?>
<?php echo MapInfo($map_name, $map_mapper, $map_stages_info, $map_tier, $map_bonuses_info, $map_dateadded_edit, $map_dateadded_edit_d, $map_maxvelocity) ?>
</div>
<h5 class="text-center my-1"><?php echo MAPS_TOTAL_COMPLETIONS; ?></h5>
<div class="row justify-content-md-center">
Expand Down

0 comments on commit 70b7da3

Please sign in to comment.