4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: trez on February 27, 2007, 04:01:31 PM

Title: [MOD] - Random User Profile for internal/external sites
Post by: trez on February 27, 2007, 04:01:31 PM
Random User Profile for internal/external sites by 2XG MEDIA

NOTE
Thank's for the compliment's I've received on my previous MOD's, that really keeps me motivated to post more MOD's and share them with you,
even if i can make them payed. But yet i decided to make this MOD free, because it's simple ;) Enjoy it.

WHAT DOES THIS MOD
Well, just use it if you have more than 50 users with userpics, otherwise i don't recommend it. The MOD allows you to show anywhere a random user (with userpicture, username and country) - even outside your site, outside your gallery. I use that MOD to advertise my page on other sites.

REQUIRED MOD's
You need to have installed the following MOD's in order to use that one:

[MOD] Member personal photo v1.1.1 by V@no (http://www.4homepages.de/forum/index.php?topic=6797.0)
[MOD] Select country and gender with gif when register (http://www.4homepages.de/forum/index.php?topic=7385.0)

VERSIONS
1.7.X

Installation
Simply follow the steps. No additional SQL fields are required :)


STEP ONE

Make a new file and call it "random_user.php" and upload it into your 4images root.
Insert the following code:

Code: [Select]
<?php

$templates_used 
'';
$main_template 'random_user';

define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');


if (isset(
$HTTP_GET_VARS['template']) || isset($HTTP_POST_VARS['template'])) {
  
$template = (isset($HTTP_POST_VARS['template'])) ? basename(stripslashes($HTTP_POST_VARS['template'])) : basename(stripslashes($HTTP_GET_VARS['template']));
  if (!
file_exists(TEMPLATE_PATH."/".$template.".".$site_template->template_extension)) {
    
$template "";
  }
  else {
    
$main_template $template;
  }
}
else {
  
$template "";
}

// random USER
          
$sql "SELECT ".get_user_table_field("u.""user_id").get_user_table_field(", u.""user_name").", u.user_gender, u.userpic, u.user_country
                  FROM "
.USERS_TABLE." u
              WHERE "
.get_user_table_field("u.""user_id")." > ".GUEST." and u.userpic <> ''
              ORDER BY rand()
                  LIMIT 1"
;
$random_USER_result $site_db->query_firstrow($sql);

$site_template->register_vars(array(
"random_USER" => '<center><a href="member.php?action=showprofile&user_id=' $random_USER_result['user_id'] . '" target="_new"><img src="' ROOT_PATH "data/userpic/" $random_USER_result['userpic'] . '" height="100" border="0"></a><br />' $random_USER_result['user_name'] . '<br>от ' $random_USER_result['user_country'] . '</center>',
));


$site_template->print_template($site_template->parse_template($main_template));  


echo 
$content;
include(
ROOT_PATH.'includes/page_footer.php');
?>


save and close the file.

STEP TWO

Make a new file and call it "random_user.html" and upload it into your 4images template folder (e.g. yoursite.com/4images/templates/default).
Insert the following code:

Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>///</title>

<table width="150" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="your_css_class">
{random_USER}
</td>
</tr>
</table>

</html>

save and close the file.

Thats it.
Now you can use the following code, anywhere on the internet to show the random user:

Code: [Select]
<iframe src="http://www.YOURSITE.com/random_user.php" width="150"
height="135" marginheight="0" marginwidth="0" frameborder="0"
scrolling="no"></iframe>

Greetings,

George

----------------------------------------------------------------------------------------------------------------------


If there are any questions feel free to write in this topic - DON'T send me PM's regarding this MOD.

Feel free to browse another 25 unreleased (payed) MOD's here: http://www.ggrec.com/mods (http://www.ggrec.com/mods)

Title: Re: [MOD] - Random User Profile for internal/external sites
Post by: ccsakuweb on March 14, 2007, 12:06:39 AM
great mod ;)

thank you a lot

but I would like that the mod don't change the user picture size.
Title: Re: [MOD] - Random User Profile for internal/external sites
Post by: ccsakuweb on March 14, 2007, 12:22:49 AM
i changed it in random_user.php the height were 100px

^^ Good mod
But i like more includes :p

Code: [Select]
<?php
include("http://www.yourwebsite.es/random_user.php");
?>
Title: Re: [MOD] - Random User Profile for internal/external sites
Post by: trez on March 14, 2007, 08:31:40 AM
i changed it in random_user.php the height were 100px

^^ Good mod
But i like more includes :p

When you make it by iframe and you put that (for example) on a site with 5000 hits per day, your site gets also 5000 hits per day. That's the reason why i used iframe :)
Title: Re: [MOD] - Random User Profile for internal/external sites
Post by: ccsakuweb on March 15, 2007, 10:41:29 PM
hehe good idea XD
Title: Re: [MOD] - Random User Profile for internal/external sites
Post by: Loda on March 16, 2007, 12:46:33 PM
hello!
great job and nice mod!
i want to modify the mod. is it possible to show the last top user given the most comments at the last day?

my modification looks like this:
insert this
Code: [Select]
$time=time();
$m1 =60;
$h1 =$m1*60;
$T1 =$h1*24;
$T7 =$T1*7;
$T30=$T1*30;
(date("w",$time)==0) ? $date_w = 7 : $date_w = date("w",$time);


$ts_today_at_0           =mktime(0,0,0,date("m",$time),date("d",$time),date("Y",$time));
$ts_yesterday_at_0       =$ts_today_at_0-$T1;
$ts_1st_of_month         =mktime(0,0,0,date("m",$time),1,date("Y",$time));
$ts_1st_of_month_before  =mktime(0,0,0,date("m",$ts_1st_of_month-1),1,date("Y",$ts_1st_of_month-1));
$ts_this_monday          =$ts_today_at_0-$T1*($date_w-1);
$ts_last_monday          =$ts_this_monday-$T7;
$ts_24h_before           =$time-$T1;
$ts_7days_before         =$time-$T7;
$ts_30days_before        =$time-$T30;
and change the order to this:
Code: [Select]
ORDER BY user_comments DESCthe problem is, i don't know where i have to insert the date...
Title: Re: [MOD] - Random User Profile for internal/external sites
Post by: ccsakuweb on March 16, 2007, 09:14:41 PM
I would like to insert the sex image at left from the nick too

I installed [MOD] Select country and gender with gif when register .