• [Mod] Photo Of The Day 4 0 5 1
Currently:  

Author Topic: [Mod] Photo Of The Day  (Read 269905 times)

0 Members and 2 Guests are viewing this topic.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Re: POTD reset everyday
« Reply #75 on: May 08, 2003, 03:40:16 PM »
Quote from: batz
My settings are by_votes but if an image in 2 days had more votes than an one day photo the first image is the POTD. Can you fix this SSL?

There's nothing to fix. Date of the vote is not stored in the database, so there's no difference between old and new votes, this MOD shows "absolute champion", with the highest number of voices through the whole gallery.

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[Mod] Photo Of The Day
« Reply #76 on: May 09, 2003, 01:42:04 AM »
Ok, thanks again.

I have to rename it to "Most Voted Photo" or something like that.  :wink:

Offline Omnirayf

  • Pre-Newbie
  • Posts: 5
    • View Profile
So....
« Reply #77 on: May 09, 2003, 02:44:15 AM »
How can we make a Photo of the Day mod that is essentially a database list of pics that get randomly chosen, displayed for 24 hours, and still display the hit/vote/rank data?

What we are talking about is essentially the Random Image mod, but with a 24 hour display timer on it that also keeps track of when it was last displayed and doesn't get displayed again until it runs through the entire database of pics.

Has this been done already?  Am I just missing something? As it is, the POTD mod will only display the top pic of a given category, and that is not a true POTD. :wink:  :D

Offline Omnirayf

  • Pre-Newbie
  • Posts: 5
    • View Profile
Mebbernind!
« Reply #78 on: May 09, 2003, 04:43:29 AM »
Mebbernind!

I think I have it figured out with the help of a couple of friends....

Code: [Select]

<?php

/**************************************************************************
*                                                                        *
*    4images - A Web Based Image Gallery Management System               *
*    ----------------------------------------------------------------    *
*                                                                        *
*             File&#58; potd.php                                           *
*        Copyright&#58; &#40;C&#41; 2002 Jan Sorgalla                                *
*            Email&#58; jan@4homepages.de                                    *
*              Web&#58; http&#58;//www.4homepages.de                             *
*    Scriptversion&#58; 1.0 for 4images 1.7                                *
*                                                                        *
*    Never released without support from&#58; Nicky &#40;http&#58;//www.nicky.net&#41; and SLL &#40;;   *
*                                                                        *
**************************************************************************
*                                                                        *
*    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
*    bedingungen &#40;http&#58;//www.4homepages.de/4images/lizenz.php&#41; für       *
*    weitere Informationen.                                              *
*    ---------------------------------------------------------------     *
*    This script is NOT freeware! Please read the Copyright Notice       *
*    &#40;http&#58;//www.4homepages.de/4images/lizenz_e.php&#41; for further         *
*    information.                                                        *
*                                                                        *
*************************************************************************/
//Based on the Photo of the Day mod by SLL and V@no
//additional tweaking by Omnirayf 9-5-2003

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define&#40;'ROOT_PATH', './4images/'&#41;;
//include&#40;ROOT_PATH.'global.php'&#41;;
include&#40;ROOT_PATH.'config.php'&#41;;
include&#40;ROOT_PATH.'includes/db_mysql.php'&#41;;
include&#40;ROOT_PATH.'includes/constants.php'&#41;;

$site_db = new Db&#40;$db_host, $db_user, $db_password, $db_name&#41;;
function is_remote&#40;$file_name&#41; &#123;
  
return &#40;preg_match&#40;'#^https?\\&#58;\\/\\/[a-z0-9\-&#93;+\.&#40;[a-z0-9\-&#93;+\.&#41;?[a-z&#93;+#i', $file_name&#41;&#41; ? 1 &#58; 0;
&#125;
    
switch &#40;POTD_SELECT_MODE&#41; &#123;
   
case "by_rating"     &#58; $select_mode = "i.image_rating"; $select_mode2 = ", i.image_votes DESC"; break;
   
case "by_votes"      &#58; $select_mode = "i.image_votes"; $select_mode2 = ", i.image_name ASC"; break;
   
case "by_comments"   &#58; $select_mode = "i.image_comments"; $select_mode2 = ", i.image_name ASC"; break;
   
case "by_downloads"  &#58; $select_mode = "i.image_downloads"; $select_mode2 = ", i.image_name ASC"; break;
   
case "by_hits"                &#58; $select_mode = "i.image_hits"; $select_mode2 = ", i.image_name ASC"; break;
   
default                             &#58; $select_mode = "i.image_rating"; $select_mode2 = ", i.image_votes DESC"; break;
&#125;

$sql "SELECT COUNT&#40;*&#41; as total_images
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b 
        WHERE a.image_date<"
.mktime&#40;0, 0, 0, date&#40;"m"&#41;, date&#40;"d"&#41;, date&#40;"y"&#41;&#41;."
AND a.image_active=
        
AND a.cat_id b.cat_id 
        
AND b.auth_viewcat=".AUTH_ALL." 
        
AND b.auth_viewimage=".AUTH_ALL."
        ";
$row = $site_db->query_firstrow&#40;$sql&#41;;
$total_images = $row['total_images'&#93;;

mt_srand&#40;mktime&#40;0, 0, 0, date&#40;"
m"&#41;, date&#40;"d"&#41;, date&#40;"y"&#41;&#41;&#41;;
$number = &#40;$total_images > 1&#41; ? mt_rand&#40;0, $total_images - 1&#41; &#58; 0;

$sql = "SELECT a.image_ida.cat_ida.image_namea.image_activea.image_thumb_filea.image_comments 
        FROM 
".IMAGES_TABLE." a".CATEGORIES_TABLE." 
        WHERE a
.image_date<".mktime&#40;0, 0, 0, date&#40;"m"&#41;, date&#40;"d"&#41;, date&#40;"y"&#41;&#41;."
AND a.image_active=
        
AND a.cat_id b.cat_id 
        
AND b.auth_viewcat=".AUTH_ALL." 
        
AND b.auth_viewimage=".AUTH_ALL." 
        
LIMIT $number1";
$row = $site_db->query_firstrow&#40;$sql&#41;;
$image_id = $row['image_id'&#93;;
$cat_id = $row['cat_id'&#93;;
$image_name = $row['image_name'&#93;;
$image_comments = $row['image_comments'&#93;;
$thumb_src = &#40;is_remote&#40;$row['image_thumb_file'&#93;&#41;&#41; ? $row['image_thumb_file'&#93; &#58; ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'&#93;;

echo "
<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><center><a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";
echo 
"<b>$image_name</b><br>\n";
echo 
"Comments&#58; $image_comments</center></td></tr></table>\n";
?>


Copy this code to Notepad or Homesite or UltraEdit, rename to potd.php, toss it in your root directory, and then test it by direct url call. You should get any old pic in your 4images database, regardless of stats. Refresh, and the pic should remain the same. After midnight of the date you implement the mod, the pic should change to another random pic for another 24 hours.

This mod has been optimized for people who are using Postnuke or PhpNuke and want a Photo of the Day block. Just make a new php script block and put this into it:
Code: [Select]
include("http://www.your-own-site.com/potd.php");
?>
It works, believe me, especially if you are using Postnuke. Otherwise, if you are having problems with it, add the opening <?php tag.

Let me know if it works for you, as it works for me. This way I can go and slap my friends for their help. :wink:

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] Photo Of The Day
« Reply #79 on: May 09, 2003, 08:56:58 AM »
Quote from: batz
I have to rename it to "Most Voted Photo" or something like that.  :wink:

It's really the matter of word definitions, nothing else... From my point of view, the "Photo of the Day" is the most rated (voted, dl'd, etc.) picture through the whole gallery for any particular date. I know, I'm not the brightest guy in the world  :wink:  give me the right definition then?

I'm afraid, if you change this MOD the way you want it, it could happens that some day no one picture get votes. What are you supposed to show as a POTD in this case?

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Re: Mebbernind!
« Reply #80 on: May 09, 2003, 09:02:31 AM »
Quote from: Omnirayf
You should get any old pic in your 4images database, regardless of stats. Refresh, and the pic should remain the same. After midnight of the date you implement the mod, the pic should change to another random pic for another 24 hours.

Hmmm.... sorry, I didn't get the idea  :cry:
This script shows random pic within some time frame, and, as I can see, has nothing to do with votes, ratings, etc... So, why do you call it "true POTD"??

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: Mebbernind!
« Reply #81 on: May 09, 2003, 10:01:58 AM »
Quote from: SLL
Hmmm.... sorry, I didn't get the idea  :cry:
This script shows random pic within some time frame, and, as I can see, has nothing to do with votes, ratings, etc... So, why do you call it "true POTD"??

the main key is "24 hours" ;)
I'd like have something like that too, it should be then some thing like "POTD - random winner", this something like a lottery for images hehe :lol:
And this could be easily done with some cookies, but then it will we different for each visitor, but...who cares? hehe
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 Omnirayf

  • Pre-Newbie
  • Posts: 5
    • View Profile
Semantics... OY!
« Reply #82 on: May 10, 2003, 04:43:21 AM »
For my use, Photo of the Day needs to be a randomly chosen pic to be displayed for 24 hours.

If I was going to chose a pic to display as the Top Voted Pic, Top Rated Pic, and the Pic with Most Hits or Downloads, and it not change every 24 hours, then I would keep the mod the way it originally was written.

If I wanted something that restarted every day according to hits, votes, and downloads, then I would make them separate pics, and write if/else functions into the code that would make them visible in that manner, then every 24 hours, they would reset to zero and become active as soon as someone started voting and hitting them. That would drive traffic, but from what I see, it would also encourage cheating because the prog would change pics to suit the one that gains ground. This could happen several times through the day, like a race. I don't need that, but others may be interested in it.

You can see what I have done with it one my site:
www.airbrushonline.com

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[Mod] Photo Of The Day
« Reply #83 on: May 10, 2003, 02:56:39 PM »
Quote from: SLL
From my point of view, the "Photo of the Day" is the most rated (voted, dl'd, etc.) picture through the whole gallery for any particular date.


From mine is the most voted photo on a specific day  :D

Quote from: SLL
I know, I'm not the brightest guy in the world  :wink:  give me the right definition then?


You are very bright, believe me.  :lol:

Quote from: SLL
I'm afraid, if you change this MOD the way you want it, it could happens that some day no one picture get votes. What are you supposed to show as a POTD in this case?


Until any photo get voted in a day, the photo of the day remains from the day before.

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Semantics... OY!
« Reply #84 on: May 10, 2003, 03:00:16 PM »
Quote from: Omnirayf
For my use, Photo of the Day needs to be a randomly chosen pic to be displayed for 24 hours.


I don't know if i understend your modification MOD.

Your POTD MOD changes every 24 hours, but is based in what stats?

Offline Omnirayf

  • Pre-Newbie
  • Posts: 5
    • View Profile
None...
« Reply #85 on: May 11, 2003, 04:35:35 AM »
It's not based on any stats... The Photo of the Day in my database cold be the worst pic in there, but it would be displayed for 24 hours.

Now if I wanted a pic that was the Top Voted Pic of the database, I would have it that way... which is how the original mod was working for me.

Didn't want that.

Offline helluvaguy

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Exclude Pics from POTD Mod
« Reply #86 on: May 11, 2003, 10:01:50 AM »
I was wondering, if it would be possible to exclude pics from one or two specific categories from being displayed in the POTD mod.

Offline Omnirayf

  • Pre-Newbie
  • Posts: 5
    • View Profile
From what I understand....
« Reply #87 on: May 11, 2003, 11:59:37 AM »
...the mod will only bring up pics from categories that are designated public access. Hide your categories by making them private or admin only, and your pics will be hidden from the POTD as well.

If it works differently from that, let us know!

Offline helluvaguy

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
[Mod] Photo Of The Day
« Reply #88 on: May 11, 2003, 01:47:04 PM »
This is exactly what I didn't wanna do. I want to keep the category public but exclude the pics from appearing in the mod.

I'm not very good at all with SQL, but I thought it could be possible to integrate something that tells the SQL query to get every category, except the ones with 'cat_id xyz'.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Re: Exclude Pics from POTD Mod
« Reply #89 on: May 11, 2003, 02:00:58 PM »
Quote from: helluvaguy
I was wondering, if it would be possible to exclude pics from one or two specific categories from being displayed in the POTD mod.


Easy enough... just add to POTD sql query limiting statements like this:
Code: [Select]
WHERE ..... AND c.cat_id != 2 ..... AND c.cat_id > 4