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

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

0 Members and 1 Guest are viewing this topic.

Offline fermachado

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #210 on: March 19, 2009, 02:03:03 PM »
Absolut GREAT
here the full mod - thx to sll and v@no!!!
Quote
<?php
define('ROOT_PATH', './4images/');
define('SITE_URL', 'http://www.yourdomain.de/');

include_once(ROOT_PATH.'config.php');
include_once(ROOT_PATH.'includes/db_mysql.php');
include_once(ROOT_PATH.'includes/constants.php');

define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');

$pics_db = new Db($db_host, $db_user, $db_password, $db_name);

function is_remote($file_name) {
  return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}

echo "<table width=\"100%\" border=\"0\" cellspacing=\"10\" cellpadding=\"1\"><tr>\n";

# -----------------------------------------------------------------------------------------------------------------------------------

$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_comments, a.image_downloads, a.image_votes, a.image_rating, a.image_hits, a.user_id, u.user_name, u.user_id
        FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b, ".USERS_TABLE." u
        WHERE a.image_active=1 AND a.cat_id = b.cat_id AND u.user_id = a.user_id
        ORDER BY a.image_rating DESC
        LIMIT 1";

$row = $pics_db->query_firstrow($sql);
$image_id = $row['image_id'];
$user_name = $row['user_name'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo "<td align=\"center\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"><br>\n";
echo "<b>$image_name</b><br>\n";
echo "uploaded by <b>$user_name</b><br>\n";
echo "Top Rates</td>\n";

# -----------------------------------------------------------------------------------------------------------------------------------

$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_comments, a.image_downloads, a.image_votes, a.image_rating, a.image_hits, a.user_id, u.user_name, u.user_id
        FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b, ".USERS_TABLE." u
        WHERE a.image_active=1 AND a.cat_id = b.cat_id AND u.user_id = a.user_id
        ORDER BY a.image_votes DESC
        LIMIT 1";

$row = $pics_db->query_firstrow($sql);
$image_id = $row['image_id'];
$user_name = $row['user_name'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo "<td align=\"center\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"><br>\n";
echo "<b>$image_name</b><br>\n";
echo "uploaded by <b>$user_name</b><br>\n";
echo "Top Votes</td>\n";

# -----------------------------------------------------------------------------------------------------------------------------------

$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_comments, a.image_downloads, a.image_votes, a.image_rating, a.image_hits, a.user_id, u.user_name, u.user_id
        FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b, ".USERS_TABLE." u
        WHERE a.image_active=1 AND a.cat_id = b.cat_id AND u.user_id = a.user_id
        ORDER BY a.image_comments DESC
        LIMIT 1";

$row = $pics_db->query_firstrow($sql);
$image_id = $row['image_id'];
$user_name = $row['user_name'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo "<td align=\"center\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"><br>\n";
echo "<b>$image_name</b><br>\n";
echo "uploaded by <b>$user_name</b><br>\n";
echo "Top Kommentare</td>\n";

# -----------------------------------------------------------------------------------------------------------------------------------

$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_comments, a.image_downloads, a.image_votes, a.image_rating, a.image_hits, a.user_id, u.user_name, u.user_id
        FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b, ".USERS_TABLE." u
        WHERE a.image_active=1 AND a.cat_id = b.cat_id AND u.user_id = a.user_id
        ORDER BY a.image_downloads DESC
        LIMIT 1";

$row = $pics_db->query_firstrow($sql);
$image_id = $row['image_id'];
$user_name = $row['user_name'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo "<td align=\"center\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"><br>\n";
echo "<b>$image_name</b><br>\n";
echo "uploaded by <b>$user_name</b><br>\n";
echo "Top Downloads</td>\n";

# -----------------------------------------------------------------------------------------------------------------------------------

$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_comments, a.image_downloads, a.image_votes, a.image_rating, a.image_hits, a.user_id, u.user_name, u.user_id
        FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b, ".USERS_TABLE." u
        WHERE a.image_active=1 AND a.cat_id = b.cat_id AND u.user_id = a.user_id
        ORDER BY a.image_hits DESC
        LIMIT 1";

$row = $pics_db->query_firstrow($sql);
$image_id = $row['image_id'];
$user_name = $row['user_name'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo "<td align=\"center\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"><br>\n";
echo "<b>$image_name</b><br>\n";
echo "uploaded by <b>$user_name</b><br>\n";
echo "Top Hits</td>\n";

# -----------------------------------------------------------------------------------------------------------------------------------

echo "</tr></table>\n";

?>

I use this code to test and I have a error in line 12

$pics_db = new Db($db_host, $db_user, $db_password, $db_name);

Need put information about the database?

Thso works with the 1.7.6

Tanks and sorry my english

www.globalfoto.net

Sintra - Portugal

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] Photo Of The Day
« Reply #211 on: March 19, 2009, 02:10:50 PM »
What error?

just in case check out this post and the next reply:
http://www.4homepages.de/forum/index.php?topic=3529.msg110432#msg110432
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 fermachado

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #212 on: March 19, 2009, 03:13:55 PM »
What error?

just in case check out this post and the next reply:
http://www.4homepages.de/forum/index.php?topic=3529.msg110432#msg110432


Hi,

Thanks,

I have the photo of the day from the original code from SLL in my site and works.

But, the code of Balu is different no?
www.globalfoto.net

Sintra - Portugal

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] Photo Of The Day
« Reply #213 on: March 19, 2009, 03:55:19 PM »
I guess it is different...
why did you use Balu's code?
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 fermachado

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #214 on: March 19, 2009, 06:44:33 PM »
I want the Balu code just for test to see what is different.

I think the Balu code wok with the real 24 hours. :?
www.globalfoto.net

Sintra - Portugal

Offline adamnorth

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #215 on: March 25, 2009, 10:13:39 PM »
Hi,

I did all of the instructions as asked but on my page it keeps giving a 404 image not found. Looked around this topic for a solution, found 1 but did not fix it. I'm sure I did not make an error on replacing the required codes and uploading the potd file to the templates directory...anyone else having this problem?


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] Photo Of The Day
« Reply #216 on: March 26, 2009, 01:47:21 AM »
Try use this modifications over the originals:
Re: [Mod] Photo Of The Day
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 adamnorth

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #217 on: March 27, 2009, 10:30:38 PM »
The first post on this forum for the download and demo of POTD mod, the links are dead. Any idea where I can find it elsewhere?

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] Photo Of The Day
« Reply #218 on: March 28, 2009, 06:30:44 AM »
download and demo links work for me. as a backup the package also attached to the first post.
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 amboutwe

  • Pre-Newbie
  • Posts: 5
    • View Profile
    • Tim And Angi
Re: [Mod] Photo Of The Day
« Reply #219 on: March 30, 2009, 02:13:25 AM »
:D
SSL: Thank you for creating this wonderful addition.
V@no : Thank you for your additions.
:D

At first install, it didn't work but I used V@no's updates and it works wonderfully now.

 :idea: Now, I'm working on adding this to my non gallery pages to drive traffic to the gallery. Thanks again.
--
Angi

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #220 on: July 14, 2009, 02:54:11 PM »
Thx for this mod, but actually it is no "Photo of the day"  8O

In my imagination a 'photo of the DAY' would be

- a selection of the admin (who has chosen the best photos for each day), or the picture has

- the most hits, comments, downloads etc. (in your case they are the total hits, and not of the past 24h)

...or am I wrong?  :|

Offline varoon

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #221 on: July 16, 2009, 11:11:19 AM »
Thx for this mod, but actually it is no "Photo of the day"  8O

In my imagination a 'photo of the DAY' would be

- a selection of the admin (who has chosen the best photos for each day), or the picture has

- the most hits, comments, downloads etc. (in your case they are the total hits, and not of the past 24h)

...or am I wrong?  :|

ya ur right... but now a days many admin cannot update these small options regularly. so they have created it random.  :mrgreen:

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #222 on: July 16, 2009, 02:07:06 PM »
Maybe there is a possibility to "take a look" only of the past 24hours  :?:

Offline daymos

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Photo Of The Day
« Reply #223 on: September 29, 2009, 07:48:15 PM »
Code: [Select]
DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name, u.user_name FROM 4images_images i, 4images_categories c LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND i.cat_id NOT IN (0) AND c.cat_id = i.cat_id ORDER BY i.image_comments DESC LIMIT 1
Unknown column 'i.user_id' in 'on clause'
How can I fix that? Please help me!
Regards,
Code: [Select]
 $sql = "SELECT DISTINCT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")."
            FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id



How to show TOP 3 images by 'rating'?
« Last Edit: September 29, 2009, 08:17:48 PM by daymos »

Rembrandt

  • Guest
Re: [Mod] Photo Of The Day
« Reply #224 on: September 29, 2009, 08:38:43 PM »
Hi!
..
How to show TOP 3 images by 'rating'?

Code: [Select]
$sql = "SELECT DISTINCT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")."
            FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id
           ORDER BY i.image_votes DESC
           LIMIT 3";

mfg Andi

[EDIT by V@no]
added ";
« Last Edit: January 09, 2011, 05:54:29 PM by V@no »