72 lines
2.7 KiB
PHP
72 lines
2.7 KiB
PHP
|
|
<?php header('Content-type: application/json');
|
||
|
|
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/');
|
||
|
|
include_once(PATHTOINCLUDES."bebop/regular.php");
|
||
|
|
date_default_timezone_set('UTC'); // don't know
|
||
|
|
$em="";
|
||
|
|
$offset=0;
|
||
|
|
$varhour = date('H');
|
||
|
|
if($varhour > 4){$offset=1;}
|
||
|
|
if($varhour > 8){$offset=0;}
|
||
|
|
if($varhour > 12){$offset=2;}
|
||
|
|
if($varhour > 18){$offset=3;}
|
||
|
|
$sql="SELECT
|
||
|
|
`se_media`.`media_id`,
|
||
|
|
`se_media`.`media_album_id`,
|
||
|
|
`se_media`.`media_date`,
|
||
|
|
`se_media`.`media_desc`,
|
||
|
|
`se_media`.`media_title`,
|
||
|
|
`se_media`.`media_ext`,
|
||
|
|
`se_media`.`media_filesize`,
|
||
|
|
`se_media`.`media_totalcomments`,
|
||
|
|
`se_media`.`media_cache_rating_total`,
|
||
|
|
`se_media`.`media_cache_rating_weighted`,
|
||
|
|
`se_albums`.`album_title`,
|
||
|
|
`se_albums`.`album_search`,
|
||
|
|
`se_albums`.`album_privacy`,
|
||
|
|
`se_albums`.`album_user_id`,
|
||
|
|
`se_albums`.`album_views`,
|
||
|
|
`se_users`.`user_id`,
|
||
|
|
`se_users`.`user_username`,
|
||
|
|
`se_users`.`user_displayname`,
|
||
|
|
`se_users`.`user_blocklist`
|
||
|
|
FROM
|
||
|
|
`se_media`
|
||
|
|
Right Outer Join `se_albums` ON `se_media`.`media_album_id` = `se_albums`.`album_id`
|
||
|
|
Right Outer Join `se_users` ON `se_users`.`user_id` = `se_albums`.`album_user_id`
|
||
|
|
WHERE
|
||
|
|
`se_media`.`media_date` > UNIX_TIMESTAMP()-(60*60*9) AND `se_albums`.`album_search` = 1 AND `se_albums`.`album_privacy` = 31 AND `se_users`.`user_wh_privacy` = 'N' AND `se_users`.`user_enabled` = 1
|
||
|
|
ORDER BY
|
||
|
|
`se_media`.`media_totalcomments` DESC
|
||
|
|
LIMIT 6 OFFSET ".$offset;
|
||
|
|
|
||
|
|
$result=$database->database_query($sql) or $em.=$database->database_error();
|
||
|
|
$setcontinue="yes";
|
||
|
|
$imagepath="";
|
||
|
|
|
||
|
|
while ($row = $database->database_fetch_assoc($result))
|
||
|
|
{
|
||
|
|
|
||
|
|
$blocklist = explode(",", $row["user_blocklist"]);
|
||
|
|
if(!isset($_GET["uid"])){$_GET["uid"]=-1;}
|
||
|
|
$key = array_search($_GET["uid"], $blocklist);//array search will only evaluate to false or not false;
|
||
|
|
if($key!==false){continue;}
|
||
|
|
$viewerbl=explode(",", $_GET["ubl"]);
|
||
|
|
$vkey = array_search($row["user_id"], $viewerbl);//array search will only evaluate to false or not false;
|
||
|
|
if($vkey!==false){continue;}
|
||
|
|
|
||
|
|
$weirdnumber = (((int)($row["user_id"]/1000))*1000)+1000;
|
||
|
|
$imagepath="/uploads_user/".$weirdnumber."/".$row["user_id"]."/".$row["media_id"].".".$row["media_ext"];
|
||
|
|
$checkimage= $_SERVER["DOCUMENT_ROOT"].$imagepath;
|
||
|
|
if (file_exists($checkimage)) {$setcontinue="no";} else {$setcontinue="yes";continue;}
|
||
|
|
$profile="/profile.php?user=".$row["user_username"];
|
||
|
|
$profile="/album.php?user=".$row["user_username"]."&album_id=".$row["media_album_id"];
|
||
|
|
$pun=$row["user_username"];
|
||
|
|
$pc=$row["media_totalcomments"];
|
||
|
|
$psr=round($row["media_cache_rating_weighted"],2);
|
||
|
|
$atitle=$row["album_title"];
|
||
|
|
break;
|
||
|
|
|
||
|
|
}
|
||
|
|
$arr = array ('error'=>$em, 'imagepath'=>$imagepath, 'pun' => $pun, 'profile'=> $profile, 'pc' => $pc, 'psr' => $psr, 'atitle' => $atitle);
|
||
|
|
echo json_encode($arr);
|
||
|
|
?>
|