Top Profiles Mod

18 years 3 days ago #10761 by Red1000
Top Profiles Mod was created by Red1000
Hello all,

I wanted to know how to display an array of 20 images from the comprofiler/tn folder outside of my Joomla installation.

Currently I am using an edited version of mambome’s top profiles module. The script references “_VALID_MOS” in order to get inside the database.

I am new to php and don’t know how to create a file that would display top users from outside my installation directory, and how directly adding the database name and password would hinder the site’s security.

If my url was www.mysite.com/joomla I would want to have a php script that displays the top 20 users based on profile hits at www.mysite.com as a splash page.

I’ve been confused about this issue for a couple months, and can’t seem to get around it… any help would be greatly appreciated!!

I will post the code I have so far below… it seems very long for what I’m trying to do, but I was deleting code from the original module to try and work backwards to get where I wanted… I just want to display the top 20 users in two rows of ten, with their hit count beneath the small image…


[code:1]<?php

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$hits = $params->get( 'hits' ); //choose to show hits or not
$link = "<img src =\"$mosConfig_live_site/images/comprofiler/tn";
$link_gallery = "<img src =\"$mosConfig_live_site/images/comprofiler/";
$border = "0";

$setsize = $params->get( 'setsize' );
$imagewidth = $params->get( 'imagewidth' );
$imageheight = $params->get( 'imageheight' );

if($setsize =='1')
$setwidth = "width=\"$imagewidth\""; //set image width
if($setsize =='1')
$setheight = "height=\"$imageheight\""; // set image height

$display = $params->get( 'display' ); //Do we want Vertical or Horizontal display?

if($display == "1"«»)
$MamboMe = "<td>";
if($display == "1"«»)
$MeMambo = "</td>";

if($display == "2"«»)
$MamboMe = "<div align=\"center\">";
if($display == "2"«»)
$MeMambo = "</div><hr/>";

$limit = $params->get( 'limit' ); //Set the descent limit

if($limit == "1"«»)
$number = " 1";
elseif($limit == "2"«»)
$number = " 2";
elseif($limit == "3"«»)
$number = " 3";
elseif($limit == "4"«»)
$number = " 4";
elseif($limit == "5"«»)
$number = " 5";
elseif($limit == "6"«»)
$number = " 6";
elseif($limit == "7"«»)
$number = " 7";
elseif($limit == "8"«»)
$number = " 8";
elseif($limit == "9"«»)
$number = " 9";
elseif($limit == "10"«»)
$number = " 10";
elseif($limit == "11"«»)
$number = " 11";
elseif($limit == "12"«»)
$number = " 12";
elseif($limit == "13"«»)
$number = " 13";
elseif($limit == "14"«»)
$number = " 14";
elseif($limit == "16"«»)
$number = " 16";
elseif($limit == "17"«»)
$number = " 17";
elseif($limit == "18"«»)
$number = " 18";
elseif($limit == "19"«»)
$number = " 19";
elseif($limit == "20"«»)
$number = " 20";
else $number = " 5";

if($display == "1"«»){echo "<center><table><tr>\n";}

$query = "SELECT user_id,avatar,hits FROM #__comprofiler WHERE avatarapproved=1 AND avatar IS NOT NULL ORDER BY hits DESC LIMIT $number";
$database ->setQuery ($query);
$results = $database->loadObjectList();

foreach($results as $result){

if(preg_match('/(gallery)/',$result->avatar)){
$query_name = "SELECT id,username FROM #__users WHERE id = ".$result->user_id;
$database ->setQuery ($query_name);
$usernames = $database->loadObjectList();
foreach($usernames as $username){
?><?php if($hits =='1'){
$profileName = $link_gallery.$result->avatar."\"border=\"0\" alt=\"member image\"$setwidth$setheight/>\n<br/>$username->username</a>\n<br/>hits $result->hits$MeMambo\n";}
else{?><?php
$profileName = $link_gallery.$result->avatar."\"border=\"0\" alt=\"member image\"$setwidth$setheight/>\n<br/>$username->username</a>.$MeMambo\n";}
$profile .= "$MamboMe<a href=\"index.php?option=com_comprofiler&amp;task=userProfile&amp;user=".$result->user_id."\">$profileName";
}
}

elseif(preg_match('/(jpg)/',$result->avatar)){
$query_name = "SELECT id,username FROM #__users WHERE id = ".$result->user_id;
$database ->setQuery ($query_name);
$usernames = $database->loadObjectList();
foreach($usernames as $username){
?><?php if($hits =='1'){
/*
the below line I modified, the original line is:
$profileName = $link.$result->avatar."\"border=\"0\" alt=\"member image\"$setwidth$setheight/>\n<br/>$username->username</a>\n<br/>hits $result->hits$MeMambo\n";}
*/
$profileName = $link.$result->avatar."\"border=\"0\" alt=\"member image\"$setwidth$setheight/>\n</a>\n<center>$result->hits$MeMambo\n</center>";}
else{?><?php
$profileName = $link.$result->avatar."\"border=\"0\" alt=\"member image\"$setwidth$setheight/>\n<br/>$username->username</a>$MeMambo\n";}
$profile .= "$MamboMe<a href=\"index.php?option=com_comprofiler&amp;task=userProfile&amp;user=".$result->user_id."\">$profileName";
}
}

elseif(preg_match('/(png)/',$result->avatar)){
$query_name = "SELECT id,username FROM #__users WHERE id = ".$result->user_id;
$database ->setQuery ($query_name);
$usernames = $database->loadObjectList();;
foreach($usernames as $username){
?><?php if($hits =='1'){
$profileName = $link.$result->avatar."\"border=\"0\" alt=\"member image\"$setwidth$setheight/>\n</a>\n<center>$result->hits$MeMambo\n</center>";}
else{?><?php
$profileName = $link.$result->avatar."\"border=\"0\" alt=\"member image\"$setwidth$setheight/>\n<br/>$username->username</a>$MeMambo\n";}
$profile .= "$MamboMe<a href=\"index.php?option=com_comprofiler&amp;task=userProfile&amp;user=".$result->user_id."\">$profileName";
}
}
}

echo $profile;
if($display == "1"«»){echo $MamboMe."</table>\n</center>";}
?>[/code:1]

Joomla 1.0.8 + CB Stable

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.143 seconds

Facebook Twitter LinkedIn