Added the images validation function.
This commit is contained in:
50
class.php
50
class.php
@@ -86,22 +86,56 @@ class ps4 {
|
|||||||
$sql = "UPDATE game_thumbnail SET thumbnail_url = '".$url."' WHERE game_id = '".$gameid."';";
|
$sql = "UPDATE game_thumbnail SET thumbnail_url = '".$url."' WHERE game_id = '".$gameid."';";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (($url == "") or ($url == "null")) {
|
if (($url == "") or ($url == "null")) {
|
||||||
echo "<strong>ERROR:</strong> No URL specified.";
|
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">No URL specified.</div>";
|
||||||
echo "<br/><br/>";
|
|
||||||
} else {
|
} else {
|
||||||
$result = $this->mysql_conn($sql);
|
if ($this->isImage($url)) {
|
||||||
if ($result == 1) {
|
$result = $this->mysql_conn($sql);
|
||||||
echo "<strong>SUCCESS:</strong> Updated image URL for <strong>". $gamename ."</strong> (". $gameid .")";
|
if ($result == 1) {
|
||||||
echo "<br/><br/>";
|
echo "<div class=\"message-success center500\"><div class=\"message-head\">SUCCESS</div><div class=\"message-details\">Updated image URL for <strong>". $gamename ."</strong> (". $gameid .")</div>";
|
||||||
|
} else {
|
||||||
|
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">Can't update image URL for <strong>". $gamename ."</strong> (". $gameid .")</div>";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "<strong>ERROR:</strong> Can't update image URL for <strong>". $gamename ."</strong> (". $gameid .")";
|
echo "<div class=\"message-error center500\"><div class=\"message-head\">ERROR</div><div class=\"message-details\">Not an image.</div>";
|
||||||
echo "<br/><br/>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isImage($url)
|
||||||
|
{
|
||||||
|
$params = array('http' => array(
|
||||||
|
'method' => 'HEAD'
|
||||||
|
));
|
||||||
|
$ctx = stream_context_create($params);
|
||||||
|
$fp = @fopen($url, 'rb', false, $ctx);
|
||||||
|
if (!$fp)
|
||||||
|
return false; // Problem with url
|
||||||
|
|
||||||
|
$meta = stream_get_meta_data($fp);
|
||||||
|
if ($meta === false)
|
||||||
|
{
|
||||||
|
fclose($fp);
|
||||||
|
return false; // Problem reading data from url
|
||||||
|
}
|
||||||
|
|
||||||
|
$wrapper_data = $meta["wrapper_data"];
|
||||||
|
if(is_array($wrapper_data)){
|
||||||
|
foreach(array_keys($wrapper_data) as $hh){
|
||||||
|
if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") // strlen("Content-Type: image") == 19
|
||||||
|
{
|
||||||
|
fclose($fp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function games_reorder($games,$orderby="last_played_desc") {
|
function games_reorder($games,$orderby="last_played_desc") {
|
||||||
function totaltime_asc($a,$b) {
|
function totaltime_asc($a,$b) {
|
||||||
return ($a["game_total_time"] <= $b["game_total_time"]) ? -1 : 1;
|
return ($a["game_total_time"] <= $b["game_total_time"]) ? -1 : 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user