Hello Radioact,
Below is in header template.
{random_profile:members=8,online=1}
Below is ext.random_profile.php file .
Is there a way to only have 1 pic per person online .
At the moment I am seeing 3 to 5 picture per person that comes online. ( That is if they have uploaded 3 to 5 picture to there account.
<?php
$data = array(
'name' => 'Show random profile',
'about' => 'This extension allows you to display radnom profiles on your website.',
'author' => 'Radioact',
'email' => 'ramil@zhunussov.com',
'help' => 'NA',
'website' => 'http://www.mahabbat.kz',
);
function vldext_random_profile ($params = array())
{
global $DB, $SESSION, $CACHE, $PREFS,$TEMPLATE;
$members = isset($params['members']) && $params['members'] ? intval($params['members']) : 1;
$cachetime = isset($params['cachetime']) && $params['cachetime'] ? intval($params['cachetime']) : 1;
$gender = isset($params['gender']) && $params['gender'] ? $params['gender'] : '';
$adult = isset($params['adult']) && $params['adult'] ? intval($params['adult']) : 0;
$online = isset($params['online']) && $params['online'] ? 1 : 0;
$region = isset($params['region']) ? $params['region'] : '';
$fields = isset($fields)? $fields:'';
//------------------------------------------------
// Get member
//------------------------------------------------
if ( ($fields = $CACHE->get("ext", "randomprofile". $gender .$members.$region.$adult)) === false ) {
$result = $DB->query("SELECT p.member_id, p.filename, m.username, m.screenname, d.field_5, d.field_6
FROM " . DB_PREFIX . "pictures as p, " . DB_PREFIX . "members_data as d, " . DB_PREFIX . "members as m
WHERE d.data_id=p.member_id AND d.data_id=m.member_id
AND p.active='1'
AND p.adult='" . ($adult ? 1 : 0) . "' " . ($gender ? " AND d.field_1='" . mysql_real_escape_string($gender) . "'" : ""). ($region ? "
AND d.field_4='" . mysql_real_escape_string($region) . "'" : "") . "
" . ($online ? "AND m.lastvisit > " . ( time() - $PREFS->conf['user_timeout']*60 ) : "") . "
ORDER BY RAND() LIMIT $members");
//------------------------------------------------
// Check if resultset contains any rows
//------------------------------------------------
if ($DB->num_rows($result))
{
//------------------------------------------------
// Fetch resultset
//------------------------------------------------
$i = 0;
while($obj = $DB->fetch_object($result)) {
//------------------------------------------------
// Display image tag
//------------------------------------------------
$fields[$i]['member_id'] = $obj->member_id;
$fields[$i]['screenname'] = htmlentities2utf8($obj->screenname);
$fields[$i]['city'] = $obj->field_5 ? $obj->field_5 : '';
$fields[$i]['picture'] = $obj->filename ? $PREFS->conf['thumbnail_prefix'] . 'picture_' . $obj->filename : "";
$fields[$i]['member_link'] = $PREFS->conf['fancy_urls'] ? ($PREFS->conf['fancy_homepages'] ? $obj->username : "member/".$obj->member_id."/index.html") : "index.php?m=member&p=profile&id=" . $obj->member_id;
$fields[$i]['member_title'] = htmlentities2utf8($obj->field_6);
$i++;
}
}
$CACHE->put("ext", "randomprofile". $gender .$members.$region.$adult, $cachetime, $fields);
}
$TEMPLATE->assign("randomprofile", $fields);
$TEMPLATE->output('ext.random_profile.tpl');
//------------------------------------------------
// Clean up
//------------------------------------------------
unset($result);
unset($obj);
}
?>
Last edited by newcastle (2007-10-30 05:51:18)