87 lines
2.8 KiB
PHP
87 lines
2.8 KiB
PHP
<?php header('Content-type: application/json');
|
|
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/');
|
|
include_once(PATHTOINCLUDES."bebop/regular.php");
|
|
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;
|
|
}
|
|
|
|
function truncateWords($input, $numwords, $padding="")
|
|
{
|
|
$output = strtok($input, " \n");
|
|
while(--$numwords > 0) $output .= " " . strtok(" \n");
|
|
if($output != $input) $output .= $padding;
|
|
return $output;
|
|
}
|
|
//date_default_timezone_set('UTC'); // don't know
|
|
$offset=0;
|
|
$varhour = date('H');
|
|
if($varhour >= 0){$offset=0;}
|
|
if($varhour >= 4){$offset=1;}
|
|
if($varhour >= 8){$offset=2;}
|
|
if($varhour >= 12){$offset=3;}
|
|
if($varhour >= 18){$offset=1;}
|
|
$em="";
|
|
// only groups that upload a photo are include in selection..
|
|
$sql="SELECT
|
|
`se_groups`.`group_id`,
|
|
`se_groups`.`group_user_id`,
|
|
`se_groups`.`group_groupcat_id`,
|
|
`se_groups`.`group_datecreated`,
|
|
`se_groups`.`group_dateupdated`,
|
|
`se_groups`.`group_views`,
|
|
`se_groups`.`group_title`,
|
|
`se_groups`.`group_desc`,
|
|
`se_groups`.`group_photo`,
|
|
`se_groups`.`group_search`,
|
|
`se_groups`.`group_privacy`,
|
|
`se_groups`.`group_comments`,
|
|
`se_groups`.`group_approval`,
|
|
`se_groups`.`group_totalcomments`,
|
|
`se_groups`.`group_totalmembers`,
|
|
`se_groups`.`group_totaltopics`,
|
|
`se_groups`.`group_discussion`,
|
|
`se_groups`.`group_invite`,
|
|
`se_groups`.`group_upload`
|
|
FROM
|
|
`se_groups`
|
|
WHERE
|
|
`se_groups`.`group_dateupdated` > UNIX_TIMESTAMP()-(60*60*1000) AND `se_groups`.`group_totalcomments` > 0 AND `se_groups`.`group_photo` <> ''
|
|
ORDER BY
|
|
RAND()
|
|
LIMIT 1";
|
|
|
|
$dbhost = "localhost";
|
|
$dbuser = "db.bateworldcom";
|
|
$dbname = "bateworldcom";
|
|
$dbpass = "sDIE8U8!5n*4%Ue_x.Pq";
|
|
|
|
|
|
$result=$database->database_query($sql) or $em.=$database->database_error();
|
|
while ($row = $database->database_fetch_assoc($result)) {
|
|
$weirdnumber = (((int)($row["group_id"]/1000))*1000)+1000;
|
|
$groupimage="/uploads_group/".$weirdnumber."/".$row['group_id']."/".$row['group_photo'];
|
|
$gtitle=strip_tags(html_entity_decode($row["group_title"]));
|
|
$gtitle=strtolower($gtitle);
|
|
$gtitle=ucwords($gtitle);
|
|
$htmlfreecontent = strip_tags(html_entity_decode($row["group_desc"]));
|
|
$htmlfreecontent = str_replace(' ','',$htmlfreecontent);
|
|
$gsdesc = myTruncate($htmlfreecontent, 20);
|
|
$gsdesc = truncateWords($htmlfreecontent, 20, '...');
|
|
$gsdesc = ucfirst($gsdesc);
|
|
$gid=$row["group_id"];
|
|
break;
|
|
}
|
|
$arr = array ('error'=>$em,'gtitle'=>$gtitle, 'gdesc'=>$gsdesc, 'gimg'=>$groupimage, 'gid' => $gid);
|
|
echo json_encode($arr);
|
|
?>
|