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

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

0 Members and 1 Guest are viewing this topic.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] Photo Of The Day
« Reply #105 on: May 25, 2003, 02:16:05 PM »
Quote from: balu
The whole??? I deleted it but still no pic!
I am a total newbie in php, how must realize this?


 8O   that's what you have to leave in the code, not delete! just compare it to original...

Offline balu

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • http://www.coverengine.de/4images
[Mod] Photo Of The Day
« Reply #106 on: May 25, 2003, 02:22:30 PM »
ok i just fixed it - now a pic is shown! GREAT

i need no link for the pic (details)
now how I must do it for 4 pics in column?
Jürgen
-------------------------------------------------------
Wer Rechtschreibfehler findet, darf sie behalten!


Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Five in a row...
« Reply #107 on: May 25, 2003, 02:32:57 PM »
Code: [Select]
<?php
define
&#40;'ROOT_PATH', './4images/'&#41;;
define&#40;'SITE_URL', 'http&#58;//faces.dalnet.ru/'&#41;;

include_once&#40;ROOT_PATH.'config.php'&#41;;
include_once&#40;ROOT_PATH.'includes/db_mysql.php'&#41;;
include_once&#40;ROOT_PATH.'includes/constants.php'&#41;;

define&#40;'PIC_CATEGORIES_TABLE', '4images_categories'&#41;;
define&#40;'PIC_IMAGES_TABLE', '4images_images'&#41;;

$pics_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;

echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" 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
FROM "
.PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b
WHERE a.image_active=1 AND a.cat_id = b.cat_id
ORDER BY a.image_rating DESC
LIMIT 1"
;

$row $pics_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 "<td><a href=\"".SITE_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"></a><br>\n";
echo 
"<b>$image_name</b><br>\n";
echo 
"Most rated<br></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
FROM "
.PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b
WHERE a.image_active=1 AND a.cat_id = b.cat_id
ORDER BY a.image_votes DESC
LIMIT 1"
;

$row $pics_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 "<td><a href=\"".SITE_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"></a><br>\n";
echo 
"<b>$image_name</b><br>\n";
echo 
"Most voted<br></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
FROM "
.PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b
WHERE a.image_active=1 AND a.cat_id = b.cat_id
ORDER BY a.image_comments DESC
LIMIT 1"
;

$row $pics_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 "<td><a href=\"".SITE_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"></a><br>\n";
echo 
"<b>$image_name</b><br>\n";
echo 
"Most commented<br></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
FROM "
.PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b
WHERE a.image_active=1 AND a.cat_id = b.cat_id
ORDER BY a.image_downloads DESC
LIMIT 1"
;

$row $pics_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 "<td><a href=\"".SITE_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"></a><br>\n";
echo 
"<b>$image_name</b><br>\n";
echo 
"Most downloaded<br></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
FROM "
.PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b
WHERE a.image_active=1 AND a.cat_id = b.cat_id
ORDER BY a.image_hits DESC
LIMIT 1"
;

$row $pics_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 "<td><a href=\"".SITE_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" vspace=\"2\" alt=\"$image_name\"></a><br>\n";
echo 
"<b>$image_name</b><br>\n";
echo 
"Most viewed<br></td>\n";

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

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

?>

Offline balu

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • http://www.coverengine.de/4images
[Mod] Photo Of The Day
« Reply #108 on: May 25, 2003, 02:40:31 PM »
FANTASTIC!!!!

One last question:

how to center this table and columns
Jürgen
-------------------------------------------------------
Wer Rechtschreibfehler findet, darf sie behalten!


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
[Mod] Photo Of The Day
« Reply #109 on: May 25, 2003, 05:12:34 PM »
Quote from: balu
how to center this table and columns

add align=\"center\" in each <td> tag
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 balu

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • http://www.coverengine.de/4images
[Mod] Photo Of The Day
« Reply #110 on: May 25, 2003, 05:30:11 PM »
many many thx - the smallest problem are the greatest  :lol:

btw. is it possible to add "the uploader" under the pics?
Jürgen
-------------------------------------------------------
Wer Rechtschreibfehler findet, darf sie behalten!


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
[Mod] Photo Of The Day
« Reply #111 on: May 25, 2003, 06:04:58 PM »
Quote from: balu
btw. is it possible to add "the uploader" under the pics?

yes, at the end of each $sql = "SELECT ..... line add:
, a.user_id, u.user_name, u.user_id
so for example for the rating part it would be like this:
Quote
$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

now, at the end of next line add: , ".USERS_TABLE." u
so it would looks like:
Quote
FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b, ".USERS_TABLE." u

then, at the end of next line add AND u.user_id = a.user_id
it should looks like this:
Quote
WHERE a.image_active=1 AND a.cat_id = b.cat_id AND u.user_id = a.user_id

then after $image_id = $row['image_id']; add
$user_name = $row['user_name']
then insert $user_name whereever u want ;)


@SLL:
since u have
Quote
include_once(ROOT_PATH.'includes/constants.php');

next two line are not necessery, u could use CATEGORIES_TABLE and USERS_TABLE ;)
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 Yegor

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • http://www.planetboredom.net
[Mod] Photo Of The Day
« Reply #112 on: May 25, 2003, 06:49:59 PM »
Im gonna set this up myself today.

Wow, your amazing skills put me to shame. *bows*

Thanksa lot guys!
PlanetBoredom.net
 - Things to do when you are bored.  [ Advertise ]

Offline balu

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • http://www.coverengine.de/4images
[Mod] Photo Of The Day
« Reply #113 on: May 25, 2003, 06:58:20 PM »
:o  GREAT
some colors possible and fontstyles and then it will be perfect!!!

@ v@no or sll

I have a funny mystic in my memberlist:

all you users ca see it correct - I not - why? I delete the cache.... I always see 0 members at 0 pages - Funny isn´it?
Jürgen
-------------------------------------------------------
Wer Rechtschreibfehler findet, darf sie behalten!


Offline balu

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • http://www.coverengine.de/4images
[Mod] Photo Of The Day
« Reply #114 on: May 25, 2003, 07:21:25 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";

?>
Jürgen
-------------------------------------------------------
Wer Rechtschreibfehler findet, darf sie behalten!


Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] Photo Of The Day
« Reply #115 on: May 25, 2003, 10:03:11 PM »
Quote from: V@no
@SLL:
since u have
Quote
include_once(ROOT_PATH.'includes/constants.php');

next two line are not necessery, u could use CATEGORIES_TABLE and USERS_TABLE ;)

nope  :wink:   long time ago i've got a problem due to this, and almost lost my hairs trying to find it...  i was running two includes in my index.php, for phpbb and 4images, and they're both using USERS_TABLE variable, so one of them didn't work before i've defined different names directly in those included files.

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
[Mod] Photo Of The Day
« Reply #116 on: May 25, 2003, 10:32:16 PM »
Quote from: SLL
nope  :wink:   long time ago i've got a problem due to this, and almost lost my hairs trying to find it...  i was running two includes in my index.php, for phpbb and 4images, and they're both using USERS_TABLE variable, so one of them didn't work before i've defined different names directly in those included files.
I still dont get it...
if u include SPECIFIC constants.php from 4IMAGES dir, then what does it have with phpbb? it would be a mess, if u include global.php and then constants.php or something...
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 SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
v.1.2
« Reply #117 on: May 27, 2003, 10:22:34 PM »
New version posted. Now you can set random selection mode (by votes, hits, comments, etc.)

download: http://faces.dalnet.ru/files.php?l=english

Offline artpapa

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: v.1.2
« Reply #118 on: May 28, 2003, 12:17:55 AM »
Quote from: SLL
New version posted. Now you can set random selection mode (by votes, hits, comments, etc.)


Dear  SLL.

Where you posted ?

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: v.1.2
« Reply #119 on: May 28, 2003, 12:44:59 AM »
Quote from: artpapa
Where you posted ?

First post in this thread. Check the history log.
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)