106 lines
3.6 KiB
PHP
106 lines
3.6 KiB
PHP
|
|
<?php header('Content-type: application/json');
|
||
|
|
ini_set('display_errors', 1);
|
||
|
|
ini_set('display_startup_errors', 1);
|
||
|
|
error_reporting(E_ALL);
|
||
|
|
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/');
|
||
|
|
include_once(PATHTOINCLUDES."bebop/regular.php");
|
||
|
|
date_default_timezone_set('UTC'); // don't know
|
||
|
|
|
||
|
|
//http://www.the-art-of-web.com/php/truncate/;
|
||
|
|
function myTruncate($string, $limit, $break=".", $pad="...")
|
||
|
|
{
|
||
|
|
// return with no change if string is shorter than $limit
|
||
|
|
if(strlen($string) <= $limit) return $string;
|
||
|
|
|
||
|
|
// is $break present between $limit and the end of the string?
|
||
|
|
if(false !== ($breakpoint = strpos($string, $break, $limit))) {
|
||
|
|
if($breakpoint < strlen($string) - 1) {
|
||
|
|
$string = substr($string, 0, $breakpoint) . $pad;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return $string;
|
||
|
|
}
|
||
|
|
|
||
|
|
$em="";
|
||
|
|
$sql="SELECT
|
||
|
|
`se_blogentries`.`blogentry_id`,
|
||
|
|
`se_blogentries`.`blogentry_user_id`,
|
||
|
|
`se_blogentries`.`blogentry_date`,
|
||
|
|
`se_blogentries`.`blogentry_views`,
|
||
|
|
`se_blogentries`.`blogentry_title`,
|
||
|
|
`se_blogentries`.`blogentry_body`,
|
||
|
|
`se_blogentries`.`blogentry_search`,
|
||
|
|
`se_blogentries`.`blogentry_privacy`,
|
||
|
|
`se_blogentries`.`blogentry_comments`,
|
||
|
|
`se_blogentries`.`blogentry_totalcomments`,
|
||
|
|
`se_blogentries`.`blogentry_id`,
|
||
|
|
`se_blogentries`.`blogentry_user_id`,
|
||
|
|
`se_blogentries`.`blogentry_date`,
|
||
|
|
`se_blogentries`.`blogentry_views`,
|
||
|
|
`se_blogentries`.`blogentry_title`,
|
||
|
|
`se_blogentries`.`blogentry_body`,
|
||
|
|
`se_blogentries`.`blogentry_search`,
|
||
|
|
`se_blogentries`.`blogentry_privacy`,
|
||
|
|
`se_blogentries`.`blogentry_comments`,
|
||
|
|
`se_blogentries`.`blogentry_totalcomments`,
|
||
|
|
`se_users`.`user_id`,
|
||
|
|
`se_users`.`user_username`,
|
||
|
|
`se_users`.`user_blocklist`,
|
||
|
|
`se_users`.`thumb`,
|
||
|
|
`se_users`.`user_photo`
|
||
|
|
FROM
|
||
|
|
`se_blogentries`
|
||
|
|
Right Outer Join `se_users` ON `se_users`.`user_id` = `se_blogentries`.`blogentry_user_id`
|
||
|
|
WHERE
|
||
|
|
`se_blogentries`.`blogentry_user_id` <> 70022 AND `se_blogentries`.`blogentry_privacy` = 31 AND `se_users`.`user_wh_privacy` = 'N' AND `se_blogentries`.`blogentry_user_id` <> 70695 AND `se_users`.`user_enabled` = 1
|
||
|
|
ORDER BY
|
||
|
|
`se_blogentries`.`blogentry_date` DESC,
|
||
|
|
`se_blogentries`.`blogentry_comments` DESC,
|
||
|
|
`se_blogentries`.`blogentry_views` DESC
|
||
|
|
LIMIT 8";
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$result=$database->database_query($sql) or $em.= $database->database_error();
|
||
|
|
//echo error_reporting();
|
||
|
|
|
||
|
|
|
||
|
|
while ($row = $database->database_fetch_assoc($result)) {
|
||
|
|
|
||
|
|
$blocklist = explode(",", $row["user_blocklist"]);
|
||
|
|
if(!isset($_GET["uid"])){$_GET["uid"]=-1;}
|
||
|
|
if(!isset($_GET["ubl"])){$_GET["ubl"]="";}
|
||
|
|
$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["blogentry_user_id"]/1000))*1000)+1000;
|
||
|
|
$bimage="/uploads_user/".$weirdnumber."/".$row["blogentry_user_id"]."/".$row["user_photo"];
|
||
|
|
|
||
|
|
$chkbimage=$_SERVER["DOCUMENT_ROOT"].$bimage;
|
||
|
|
if(!is_file($chkbimage))
|
||
|
|
{
|
||
|
|
$bimage="/images/nophoto.png";
|
||
|
|
}
|
||
|
|
|
||
|
|
echo $chkbimage;
|
||
|
|
|
||
|
|
$buname=$row["user_username"];
|
||
|
|
$bid=$row["blogentry_id"];
|
||
|
|
$btitle=strip_tags(html_entity_decode($row["blogentry_title"]));
|
||
|
|
$htmlfreecontent = strip_tags(html_entity_decode($row["blogentry_body"]));
|
||
|
|
$htmlfreecontent = str_replace(' ','',$htmlfreecontent);
|
||
|
|
$bsdesc = myTruncate($htmlfreecontent, 70);
|
||
|
|
$bviews=$row["blogentry_views"];
|
||
|
|
$bcomments=$row["blogentry_totalcomments"];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
$bsdesc="";
|
||
|
|
$arr = array ('error'=>$em, 'uimg'=>$bimage, 'uname'=>$buname, 'bid'=>$bid, 'btitle'=>$btitle, 'bdesc'=> $bsdesc, 'bviews'=>$bviews, 'bcom' => $bcomments);
|
||
|
|
|
||
|
|
echo json_encode($arr);
|
||
|
|
?>
|