Author Topic: [MOD] Top uploaders v1.0  (Read 24393 times)

0 Members and 1 Guest are viewing this topic.

Offline IGC

  • Newbie
  • *
  • Posts: 29
  • http://www.theanimegallery.com
    • View Profile
    • theAnimeGallery.com
[MOD] Top uploaders v1.0
« on: August 16, 2006, 05:48:22 PM »
Hello, this is my first MOD, so I am going to try to explain everything as clearly as possible so there are no confussions.

First of all, I want to note that there is another mod that talks about Top Uploaders, but I looked at it, and it was a little bit outdated and some of the things didn't work, as far as I recall, and the one I'm going to post is more complete.

I'm going to post three versions of this module:
1. Simple version, ads a new horizontal table with the top 3 uploaders (can be changed to whatever number you want).
2. Medium version, ads a vertical table with the top 5 uploaders including avatars (can be changed to whatever number you want).
   - Here is my site with the Medium Version implemented: http://www.anime.igc-web.com/gallery/
3. Complete version, ads a big table with top 10 uploaders including avatar, avg rating for uploaded files with at least 1 vote and # of votes (can be changed to whatever number you want).[/color]
   - You can check it out on my site as well: http://www.anime.igc-web.com/gallery/top_uploaders.php

Here we go.

Simple version
Quote
---------------[Changed / new files]--------------------

Changed files

includes/page_header.php
lang/<your language>/main.php
templates/<your template>/home.html

New files
templates/<your template>/top_uploaders_small.html


---------------[Installation]-----------------------

Step 1

Open includes/page_header.php
At the end just above ?> add:
Code: [Select]
//-----------------------------------------------------
//--- Top Uploaders Small -----------------------------
//-----------------------------------------------------
$top_uploaders_small = "<table width=100% cellpadding=0 cellspacing=0><tr>";
$sql = "SELECT user_name, users.user_id, count( image_id ) uploaded
FROM ".IMAGES_TABLE." img, ".USERS_TABLE." users
WHERE users.user_id = img.user_id
AND user_level = ".USER."
GROUP BY user_id
ORDER BY uploaded DESC
LIMIT 0 , 3"; //CHANGE THIS TO GET MORE USERS
$result = $site_db->query($sql);

while($row = $site_db->fetch_array($result)) {
$top_uploaders_small .= "<td><a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><b>".$row['user_name']."</b></a> (".$row['uploaded']." uploads)</td>";
}

$top_uploaders_small .= "</tr></table>";

$site_template->register_vars(array(
"lang_top_uploaders_small" => $lang['lang_top_uploaders_small'],
"top_uploaders_small" => $top_uploaders_small));
$site_template->register_vars("top_uploaders_small_bit", $site_template->parse_template("top_uploaders_small_bit"));

unset($top_uploaders_small_bit);
unset($top_uploaders_small);



Step 2

Open lang/<your language>/main.php
At the end just above ?> add:
Code: [Select]
//-----------------------------------------------------
//--- Top Uploaders Small -----------------------------
//-----------------------------------------------------
$lang['lang_top_uploaders_small'] = "Top 3 uploaders";



Step 3

Open templates/<your template>/home.html
Wherever you want to place the top upladers information (below new images, below your news, below your list of active users....) add:
Code: [Select]
{top_uploaders_small_bit}
<br />



Step 4

Create a file called top_uploaders_small_bit.html with:
Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="1">
 <tr>
   <td class="head1">
     <table width="100%" border="0" cellspacing="0" cellpadding="3">
       <tr>
         <td valign="top" class="head1">{lang_top_uploaders_small}</td>
       </tr>
       <tr>
         <td valign="top" class="row2">{top_uploaders_small}</td>
       </tr>
     </table>
   </td>
 </tr>
</table>

And upload it to: templates/<your template>/

And we are done!!
You can add {top_uploaders_small_bit} on any of your template files, wherever you want to display the statistics.





Medium version
Quote
---------------[Changed / new files]--------------------

Changed files

includes/page_header.php
lang/<your language>/main.php
templates/<your template>/home.html

New files
templates/<your template>/top_uploaders_medium.html


---------------[Installation]-----------------------

Step 1

Open includes/page_header.php
At the end just above ?> add:
Code: [Select]
//-----------------------------------------------------
//--- Top Uploaders Medium ----------------------------
//-----------------------------------------------------
$top_uploaders_medium= "<table width=100% cellpadding=0 cellspacing=0 style=\"padding-left:3px; padding-right:3px;\">";
$sql = "SELECT user_name, users.user_id, count( image_id ) uploaded, user_avatar
FROM ".IMAGES_TABLE." img, ".USERS_TABLE." users
WHERE users.user_id = img.user_id
AND user_level = ".USER."
GROUP BY user_id
ORDER BY uploaded DESC
LIMIT 0 , 5"; //CHANGE THIS TO GET MORE USERS
$result = $site_db->query($sql);

while($row = $site_db->fetch_array($result)) {
$top_uploaders_medium .= "<tr><td align=center style=\"padding-top:3px; padding-bottom:2px;\">";
if($row['user_avatar'] == "")
$top_uploaders_medium .= "<a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><img src=\"".TEMPLATE_PATH."/avatars/blank.gif\" border=0 /></td></tr>";
else
$top_uploaders_medium .= "<a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><img src=\"".TEMPLATE_PATH."/avatars/".$row['user_avatar']."\" border=0 /></a></td></tr>";
$top_uploaders_medium .= "<tr><td align=center style=\"padding-bottom:2px;\"><a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a></td></tr>";
$top_uploaders_medium .= "<tr><td align=center style=\"border-bottom:1px dashed black; padding-bottom:3px;\"><b>".$row['uploaded']."</b> uploads</td></tr>";
}

$top_uploaders_medium.= "</tr></table>";

$site_template->register_vars(array(
"lang_top_uploaders_medium" => $lang['lang_top_uploaders_medium'],
"top_uploaders_medium" => $top_uploaders_medium));
$site_template->register_vars("top_uploaders_medium_bit", $site_template->parse_template("top_uploaders_medium_bit"));

unset($top_uploaders_medium_bit);
unset($top_uploaders_medium);



Step 2

Open lang/<your language>/main.php
At the end just above ?> add:
Code: [Select]
//-----------------------------------------------------
//--- Top Uploaders Medium ----------------------------
//-----------------------------------------------------
$lang['lang_top_uploaders_medium'] = "Top 5 uploaders";



Step 3

Note: this will add a right panel on your site for the top uploaders section. If you don't want the panel and want to put the table in the middle of the site, you should modify the template file accordingly

Open templates/<your template>/home.html
Find:
Code: [Select]
                <td width="19" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="19" height="19" /></td>
              </tr>
            </table>
for other template files the same code may be shown as:
Code: [Select]
                <td width="20" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="19" height="19" /></td>
              </tr>
            </table>

Replace with:
Code: [Select]
<td width="19" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="19" height="19" /></td>

<td width="150" class="row2" valign="top" style="border-left:1px solid black;">

                  {top_uploaders_medium_bit}

</td>

              </tr>

            </table>



Step 4

Note: Same as for step 3, this part is designed to fill the right panel we created. If you are going to put the table some place else, you will need to change this template accordingly to fit your site's design.

Create a file called top_uploaders_medium_bit.html with:
Code: [Select]
<table width="150" border="0" cellspacing="0" cellpadding="0">

<tr>

    <td class="head2" height="20"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_top_uploaders_medium}</td>

</tr>

<tr>

    <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>

</tr>

<tr>

    <td align="center" class="row1">{top_uploaders_medium}</td>

</tr>

<tr>

    <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>

</tr>

</table>

And upload it to: templates/<your template>/

And we are done!!
You can recreate step 3 on any of: home.html, top.html, search.html, categories.html, lightbox.html, details.html, error.html, member.html, register.html and postcard_create.html (which are the big template files)


My site has this version implemented: http://www.anime.igc-web.com/gallery/

Complete version
Quote
---------------[Changed / new files]--------------------

Changed files

lang/<your language>/main.php
templates/<your template>/home.html

New files
top_uploaders.php
templates/<your template>/top_uploaders.html
templates/<your template>/images/0.png ... 10.png

---------------[Installation]-----------------------

Step 1

Open lang/<your language>/main.php
At the end just above ?> add:
Code: [Select]
//-----------------------------------------------------
//--- Top Uploaders -------------------------------------
//-----------------------------------------------------
$lang['lang_top_uploaders_complete'] = "Top uploaders";
$lang['lang_top_by_uploads'] = "by uploads";
$lang['lang_top_by_rating'] = "by rating";
$lang['lang_top_by_hits'] = "by hits";
$lang['lang_top_by_votes'] = "by votes";



Step 2

Note: this will add an extra link on the top-right part of your main page. Where "Top images" and "New images" are located. If you don't want the extra link or you have changed your layout, you should modify the template file accordingly

Open templates/<your template>/home.html
Find:
Code: [Select]
<a href="{url_top_images}"><b>{lang_top_images}</b></a>&nbsp;
<a href="{url_new_images}"><b>{lang_new_images}</b></a>&nbsp;
Just above add:
Code: [Select]
<a href="top_uploaders.php"><b>{lang_top_uploaders_complete}</b></a>&nbsp;



Step 3

NOTE: This section assumess that you have installed mod avatar and have a rating scale of 0 to 10.
If you do not have either of these, you should modify top_uploaders.php to fit your needs. (It should not be too hard)

Download the attached file top_uploaders.txt, rename it to top_uploaders.php and place it on your 4images root directory, next to index.php, top.php, details.php....

Step 4

Note: Same as for step 2, this part is designed to fill the newly created page and follows the basic layout of 4images. If you have changed your layout, you may need to make some modifications to the following code

Create a file called top_uploaders.html with:

a. Copy the code from templates/<your template>/top.html into the new file.
This will mantain your layout as much possible.

b. Delete all the text in between these two lines (including the two lines):
Code: [Select]
                  <span class="title">{lang_top_images}</span>
Code: [Select]
                  <p>&nbsp;</p>

c. In the part we just deleted, place the text on the attached file: paste_this.txt

And upload it to: templates/<your template>/



Step 5

Upload the following image files (0.png ... 10.png) to templates/<your template>/images/













Of course you can create your own images...

And we are done!!
You can recreate step 3 on any of: home.html, top.html, search.html, categories.html, lightbox.html, details.html, error.html, member.html, register.html and postcard_create.html (which are the big template files)


My site has this version implemented: http://www.anime.igc-web.com/gallery/
« Last Edit: October 12, 2006, 08:30:38 PM by IGC »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Top uploaders v1.0
« Reply #1 on: August 17, 2006, 12:05:10 AM »
Very nice!
Will wait for people's feedback.

I must add, that using page_header.php is not recomended, unless you are planning on displaying this on every page. If its only on one page, then it should be moved into the page file (index.php, details.php, etc), or if you are planning show it on a few selected pages, then a function with the code from page_header.php could be created, and then all you need to do is add one line that would execute the function into each page you were you want it to show

For example in your case the only page it will be showed on, is home page so, the whole code could (or even should) only be moved into index.php.
;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline IGC

  • Newbie
  • *
  • Posts: 29
  • http://www.theanimegallery.com
    • View Profile
    • theAnimeGallery.com
Re: [MOD] Top uploaders v1.0
« Reply #2 on: August 17, 2006, 12:18:50 AM »
Very nice!
Will wait for people's feedback.

I must add, that using page_header.php is not recomended, unless you are planning on displaying this on every page. If its only on one page, then it should be moved into the page file (index.php, details.php, etc), or if you are planning show it on a few selected pages, then a function with the code from page_header.php could be created, and then all you need to do is add one line that would execute the function into each page you were you want it to show

For example in your case the only page it will be showed on, is home page so, the whole code could (or even should) only be moved into index.php.
;)

mmm... thanks for the tip. I only knew of doing it this way. That is why I placed it there.
When I add the complete version, I will make sure I modify the instructions.

Offline ccsakuweb

  • Sr. Member
  • ****
  • Posts: 498
  • Patri
    • View Profile
    • My Art
Re: [MOD] Top uploaders v1.0
« Reply #3 on: September 28, 2006, 01:18:09 AM »
wow this mod is really nice! I hope to install Medium Version, but I need a Horizontal table because my template, please could you help me?
 and i'm waiting the complete mod, good luck with your great mod! my gallery is an anime gallery too (with fanarts and wallpapers) www.myart.es your website is very nice ;)
:arrow: 4images Paid Mods: Links, Blog, Albums, Subdomains for users, Diferent templates for user profile, Related picture in details, Last pictures in details.
And the mod that you request me.   Demo: http://www.myart.es

A website dedicated to artist people who loves drawing, design, writing and more

Offline ccsakuweb

  • Sr. Member
  • ****
  • Posts: 498
  • Patri
    • View Profile
    • My Art
Re: [MOD] Top uploaders v1.0
« Reply #4 on: September 28, 2006, 02:10:20 AM »
to medium version but in a horizontal table and with only 3 users I edited the mod, but it doesn't work... what is wrong?

page_header.php
Code: [Select]
//-----------------------------------------------------
//--- Top Uploaders Medium ----------------------------
//-----------------------------------------------------
$top_uploaders_medium= "<table width=100% cellpadding=0 cellspacing=0><tr>";
$sql = "SELECT user_name, users.user_id, count( image_id ) uploaded, user_avatar
FROM ".IMAGES_TABLE." img, ".USERS_TABLE." users
WHERE users.user_id = img.user_id
AND user_level = ".USER."
GROUP BY user_id
ORDER BY uploaded DESC
LIMIT 0 , 3"; //CHANGE THIS TO GET MORE USERS
$result = $site_db->query($sql);

while($row = $site_db->fetch_array($result)) {
$top_uploaders_medium .= "<td>";
if($row['user_avatar'] == "")
$top_uploaders_medium .= "<a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><img src=\"".TEMPLATE_PATH."/userpic/blank.gif\" border=0 /></td>";
else
$top_uploaders_medium .= "<a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><img src=\"".TEMPLATE_PATH."/userpic/".$row['user_avatar']."\" border=0 /></a><br>";
$top_uploaders_medium .= "<a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a><br>";
$top_uploaders_medium .= "<b>".$row['uploaded']."</b> uploads</td>";
}

$top_uploaders_medium.= "</tr></table>";

$site_template->register_vars(array(
"lang_top_uploaders_medium" => $lang['lang_top_uploaders_medium'],
"top_uploaders_medium" => $top_uploaders_medium));
$site_template->register_vars("top_uploaders_medium_bit", $site_template->parse_template("top_uploaders_medium_bit"));

unset($top_uploaders_medium_bit);
unset($top_uploaders_medium);

top_uploaders_medium_bit.html
Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
   <td class="head1">
     <table width="100%" border="0" cellspacing="0" cellpadding="3">
       <tr>
         <td valign="top" class="head1">{lang_top_uploaders_medium}</td>
       </tr>
       <tr>
         <td valign="top" class="row2">{top_uploaders_medium}</td>
       </tr>
     </table>
   </td>
</tr>
</table>

i have a problem in page_header, then i can't anything from this medium version.. could you help me please?
:arrow: 4images Paid Mods: Links, Blog, Albums, Subdomains for users, Diferent templates for user profile, Related picture in details, Last pictures in details.
And the mod that you request me.   Demo: http://www.myart.es

A website dedicated to artist people who loves drawing, design, writing and more

Offline IGC

  • Newbie
  • *
  • Posts: 29
  • http://www.theanimegallery.com
    • View Profile
    • theAnimeGallery.com
Re: [MOD] Top uploaders v1.0
« Reply #5 on: September 28, 2006, 04:24:01 PM »
If the problem is that it does not work at all or you get an error message, please let me know what it says...

If the problem is just that the table doesn't look nice when it is shown the problem is in this line (on your modification):

Code: [Select]
if($row['user_avatar'] == "")
$top_uploaders_medium .= "<a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><img src=\"".TEMPLATE_PATH."/userpic/blank.gif\" border=0 /></td>";

You have added a </td> at the end, that is supposed to be a <br />
If the user does not have an avatar your modification created an extra row after the avatar and that messed up your table.

It should be:
Code: [Select]

if($row['user_avatar'] == "")
$top_uploaders_medium .= "<a href=\"" .$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><img src=\"".TEMPLATE_PATH."/userpic/blank.gif\" border=0 /><br />";

Let me know if the problem is a different problem, that is all I saw... but since you didn't specify what the problem was I didn't look more deeply into it...

IGC

Offline ccsakuweb

  • Sr. Member
  • ****
  • Posts: 498
  • Patri
    • View Profile
    • My Art
Re: [MOD] Top uploaders v1.0
« Reply #6 on: October 12, 2006, 01:23:17 PM »
thanks!! my problem was that i don't have avatar mod installed, I have userpic mod. Then I replaced user_avatar to userpic XD Now I have medium mod in my website without any problem. Thank you very much. I'm waitting the high version!! ^^ in your website is really great
:arrow: 4images Paid Mods: Links, Blog, Albums, Subdomains for users, Diferent templates for user profile, Related picture in details, Last pictures in details.
And the mod that you request me.   Demo: http://www.myart.es

A website dedicated to artist people who loves drawing, design, writing and more

Offline IGC

  • Newbie
  • *
  • Posts: 29
  • http://www.theanimegallery.com
    • View Profile
    • theAnimeGallery.com
Re: [MOD] Top uploaders v1.0
« Reply #7 on: October 12, 2006, 08:07:44 PM »
I just updated the post with the COMPLETE VERSION...

Since I finished that on my site I have made some other changes so I might have missed a step... but I think everything should work just fine.

Remember that for the Medium and Complete version to work WITHOUT MODIFICATIONS you should have installed mod avatar.

IGC

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] Top uploaders v1.0
« Reply #8 on: October 14, 2006, 03:00:52 PM »
esta muy guapo el mod! gracias por compartirlo nacho! xD

Offline IGC

  • Newbie
  • *
  • Posts: 29
  • http://www.theanimegallery.com
    • View Profile
    • theAnimeGallery.com
Re: [MOD] Top uploaders v1.0
« Reply #9 on: October 14, 2006, 05:10:44 PM »
esta muy guapo el mod! gracias por compartirlo nacho! xD

de nada millonario!! que ya me he enterao que estas ganando una pasta con la pagina!!! que perro!!! jajajaja. yo tb kiero!!

como has exo que vaya tanta gente?? ha sido un poco de suerte o tenias a un grupo de gente para que corriera la voz y la fuera anunciando?

Si kieres contestame por un privado.

Un saludo

Offline ccsakuweb

  • Sr. Member
  • ****
  • Posts: 498
  • Patri
    • View Profile
    • My Art
Re: [MOD] Top uploaders v1.0
« Reply #10 on: October 18, 2006, 06:51:02 PM »
 8O sois españoles! q bien xD yo tb. IGC queria preguntarte si podríamos afiliarnos ya que nuestras webs son de la misma temática!  :lol:
jeje.. mi web es: www.myart.es

sobre el mod, está genial muchas gracias, estoy deseando ponerlo en mi web ^^ lo que pasa que hasta dentro de unas semanitas no podré que me han quitado internet  :cry:

PD:  8) os molestaria compartir el secreto conmigo por fi?  :oops: ya sabeis mi pm xD
:arrow: 4images Paid Mods: Links, Blog, Albums, Subdomains for users, Diferent templates for user profile, Related picture in details, Last pictures in details.
And the mod that you request me.   Demo: http://www.myart.es

A website dedicated to artist people who loves drawing, design, writing and more

Offline IGC

  • Newbie
  • *
  • Posts: 29
  • http://www.theanimegallery.com
    • View Profile
    • theAnimeGallery.com
Re: [MOD] Top uploaders v1.0
« Reply #11 on: October 18, 2006, 11:21:12 PM »
hello IGC,
wow nice mod...
i see on details site the toogle function.
   
where you found this these java script??

greets ivan

I don't remeber where I first saw it, but it is a simple javascript function... I've used so many times since I first saw it that I don't need to look at the first implementation...
I've also added some changes and tweaked it a little bit...

If you want I can create a new post with a step by step explanation on how to implement it...

It's just changing a couple of templates... no .php modifications needed.

IGC

Offline Entropyx

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [MOD] Top uploaders v1.0
« Reply #12 on: November 17, 2006, 10:09:44 PM »
is it possible to include Administrator accounts?

Offline IGC

  • Newbie
  • *
  • Posts: 29
  • http://www.theanimegallery.com
    • View Profile
    • theAnimeGallery.com
Re: [MOD] Top uploaders v1.0
« Reply #13 on: November 18, 2006, 05:25:02 AM »
is it possible to include Administrator accounts?

sure...

just change this line
Code: [Select]
AND user_level = ".USER."
for this
Code: [Select]
AND user_level >= ".USER."
You may need to change it more than once if you are using more than one version of the mode.
The line appears ONE time PER version. So if you installed all three, you will need to make the change 3 times.

IGC

Offline Entropyx

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [MOD] Top uploaders v1.0
« Reply #14 on: November 18, 2006, 06:57:15 PM »
is it possible to include Administrator accounts?

sure...

just change this line
Code: [Select]
AND user_level = ".USER."
for this
Code: [Select]
AND user_level >= ".USER."
You may need to change it more than once if you are using more than one version of the mode.
The line appears ONE time PER version. So if you installed all three, you will need to make the change 3 times.

IGC
thanx :D