Author Topic: New Pics in Category  (Read 34395 times)

0 Members and 1 Guest are viewing this topic.

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
New Pics in Category
« Reply #15 on: January 22, 2003, 01:50:43 PM »
I think u dont need to change anything, just use exact same code with .CATEGORIES_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 ChrisTTian

  • Newbie
  • *
  • Posts: 29
    • View Profile
New Pics in Category
« Reply #16 on: January 22, 2003, 02:03:02 PM »
I tried the same scrpt but now I get the following error:

DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name FROM 4images_images i, 4images_categories c LEFT JOIN phpbb_users u ON u.user_id = i.user_id WHERE i.image_active = 1 AND i.image_date >= 1043153567 AND c.cat_id = i.cat_id AND i.cat_id = 0 ORDER BY i.image_date DESC LIMIT 15
Unknown column 'u.user_name' in 'field list'

DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name FROM 4images_images i, 4images_categories c LEFT JOIN phpbb_users u ON u.user_id = i.user_id WHERE i.image_active = 1 AND i.image_date >= 1043153567 AND c.cat_id = i.cat_id AND i.cat_id = 1 ORDER BY i.image_date DESC LIMIT 15
Unknown column 'u.user_name' in 'field list'

DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name FROM 4images_images i, 4images_categories c LEFT JOIN phpbb_users u ON u.user_id = i.user_id WHERE i.image_active = 1 AND i.image_date >= 1043153567 AND c.cat_id = i.cat_id AND i.cat_id = 2 ORDER BY i.image_date DESC LIMIT 15
Unknown column 'u.user_name' in 'field list'
Show all new images?

So what is wrong now?  :roll:

Thank you again for your help

Offline ChrisTTian

  • Newbie
  • *
  • Posts: 29
    • View Profile
New Pics in Category
« Reply #17 on: January 22, 2003, 02:09:05 PM »
I guess it is because I use 4images together with phpBB forum.

The table "phpbb_users" is in the same database as all other tables of 4images

Christian

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
New Pics in Category
« Reply #18 on: January 22, 2003, 03:04:51 PM »
Quote from: ChrisTTian
I guess it is because I use 4images together with phpBB forum. The table "phpbb_users" is in the same database as all other tables of 4images

oh yesss... you almost right. i've spent few days trying to understand, why "random images" doesn't work together with "fetch phpbb stats"

the reason is that both of them using the same table names. http://www.4homepages.de/forum/viewtopic.php?t=1020&postdays=0&postorder=asc&start=135
the solution is: define table names directly in this script, using different names
Code: [Select]
define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');
define('PIC_USERS_TABLE', '4images_images');


and add this PIC_ to the queries... this should help

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
New Pics in Category
« Reply #19 on: January 22, 2003, 03:08:54 PM »
Quote from: gti-the-sexy
I PUT THIS SCRIPT TO MY ROOT DIRECTORY which is /vhosts/mydomain.com/http/ AND CHANGED ROOT PATH DEFINITION but only I see "Show all new images?"
could't you add linking images in this code?
Code: [Select]
define('ROOT_PATH', './');
because this code runs exactly withour any problems


hey hey! open your eyes!  :evil:
the root for you should be
Code: [Select]
define('ROOT_PATH', './mngpicturesX/');
and image links are there, btw...

Offline gti-the-sexy

  • Newbie
  • *
  • Posts: 33
    • View Profile
New Pics in Category
« Reply #20 on: January 22, 2003, 04:02:52 PM »
Quote from: SLL
Quote from: ChrisTTian
I guess it is because I use 4images together with phpBB forum. The table "phpbb_users" is in the same database as all other tables of 4images

oh yesss... you almost right. i've spent few days trying to understand, why "random images" doesn't work together with "fetch phpbb stats"

the reason is that both of them using the same table names. http://www.4homepages.de/forum/viewtopic.php?t=1020&postdays=0&postorder=asc&start=135
the solution is: define table names directly in this script, using different names
Code: [Select]
define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');
define('PIC_USERS_TABLE', '4images_images');


and add this PIC_ to the queries... this should help


I added PIC_ and defines but I got the same error which Christ. got

Offline ChrisTTian

  • Newbie
  • *
  • Posts: 29
    • View Profile
New Pics in Category
« Reply #21 on: January 22, 2003, 04:11:16 PM »
Well I am finally getting closer  :wink:

On my test system only the user name is missing yet. Maybe the productive environment will solve my problem

Found 2 new images in category Sternfahrt    ...view category

PIC00025 uploaded by     ...view image
PIC00023 uploaded by     ...view image
Show all new images?


Maybe a little bug:

If $number_of_new_pics is been set to "1" and there has been no picture uploaded I get the following code and I can't click the link like mentioned in a thread before:

Show all new images?

It seems that the variable

Code: [Select]
$allnew_link

will be ignored because the html code shows only

Show all new images? </a>

with the missing http:.... string.

Can you include a "if...else question"

If there are new pics in the last x day show me:

Found 2 new images in category Sternfahrt    ...view category
PIC00025 uploaded by     ...view image
PIC00023 uploaded by     ...view image
Show all new images?


If there are no pics in the last days show me

There are no New pics. Klick here to surf the image gallery.

This should make the circle round if there were no new pics. I tried to add an "else" somewhere in your code but I couldn't figure out where to put it.


Below is the code with the included "define" lines and the added "PIC_" for people like me using phpBB and 4images together. I hope that the user name problem can be fixed.

Once again a big thank you to SSL  :!:  :!:  :!:
Christian

Code: [Select]
<?php 

define
&#40;'ROOT_PATH', './4images/'&#41;;
define&#40;'PIC_CATEGORIES_TABLE', '4images_categories'&#41;; 
define&#40;'PIC_IMAGES_TABLE', '4images_images'&#41;; 
define&#40;'PIC_USERS_TABLE', '4images_users'&#41;; 
include&#40;ROOT_PATH.'global.php'&#41;; 
require&#40;ROOT_PATH.'includes/sessions.php'&#41;; 
$user_access get_permission&#40;&#41;; 

$number_of_new_pics 1
$days_to_be_new 100

$new_cutoff time&#40;&#41; - 60 * 60 * 24 * $days_to_be_new; 
$cat_id_sql get_auth_cat_sql&#40;"auth_viewcat", "NOTIN"&#41;; 

   
$sql "SELECT MAX&#40;cat_id&#41; as max_id FROM ".PIC_CATEGORIES_TABLE
   
$row $site_db->query_firstrow&#40;$sql&#41;; 
   
$cat_max_id = &#40;!empty&#40;$row['max_id'&#93;&#41;&#41; ? $row['max_id'&#93; &#58; 0; 

for &#40;$i = 0; $i <= $cat_max_id; $i++&#41;&#123; 

  
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name 
          FROM "
.PIC_IMAGES_TABLE." i,  ".PIC_CATEGORIES_TABLE." c 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i"
   
$result $site_db->query&#40;$sql&#41;; 
   
$row $site_db->fetch_array&#40;$result&#41;; 
    
$images_in_category $site_db->get_numrows&#40;$result&#41;; 

   
$category_name = &#40;$row['cat_name'&#93;&#41;; 
   
$category_id = &#40;$row['cat_id'&#93;&#41;; 
    
$category_link = &#40;"<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">"&#41;; 

if &#40;$images_in_category&#41; &#123; echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b>&nbsp;&nbsp;&nbsp;$category_link ...view category </a><br>"; &#125; 

  
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name 
          FROM "
.PIC_IMAGES_TABLE." i,  ".PIC_CATEGORIES_TABLE." c 
          LEFT JOIN "
.PIC_USERS_TABLE." u ON u.user_id = i.user_id 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i 
          ORDER BY i.image_date DESC 
          LIMIT 
$number_of_new_pics"

   
$result $site_db->query&#40;$sql&#41;; 
  
while &#40;$row = $site_db->fetch_array&#40;$result&#41;&#41; &#123; 
   
$image_name = &#40;$row['image_name'&#93;&#41;; 
   
$image_id = &#40;$row['image_id'&#93;&#41;; 
   
$category_name = &#40;$row['cat_name'&#93;&#41;; 
   
$user_name = &#40;$row['user_name'&#93;&#41;; 
   
$media_path = &#40;$row['image_media_file'&#93;&#41;; 
   
$image_link = &#40;"<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">"&#41;; 
   
$allnew_link = &#40;"<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">"&#41;; 

   
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b>&nbsp;&nbsp;&nbsp;$image_link ...view image </a></ul>"
  &
#125; 
&#125; 
   
echo "$allnew_link Show all new images? </a>"
?>

Offline gti-the-sexy

  • Newbie
  • *
  • Posts: 33
    • View Profile
New Pics in Category
« Reply #22 on: January 22, 2003, 08:13:28 PM »
THANKSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS


SLL & CHRIST :)

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
New Pics in Category
« Reply #23 on: January 22, 2003, 10:29:20 PM »
Quote from: ChrisTTian
On my test system only the user name is missing yet. Maybe the productive environment will solve my problem
Not exactly.. Since I have no phpBB integration, I can't check it myself, but I believe you should define phpBBusers (or whatever it's name is) as 'PIC_USERS_TABLE' and get user name out of it.

Quote from: ChrisTTian
If $number_of_new_pics is been set to "1" and there has been no picture uploaded
$number_of_new_pics variable stands for maximum number of pics found to show under the category info.
Get the code with all (I believe  :lol: ) corrections you asked for:
Code: [Select]
<?php
define
&#40;'ROOT_PATH', './4images/'&#41;;
define&#40;'PIC_CATEGORIES_TABLE', '4images_categories'&#41;;
define&#40;'PIC_IMAGES_TABLE', '4images_images'&#41;;
define&#40;'PIC_USERS_TABLE', '4images_users'&#41;;
include&#40;ROOT_PATH.'global.php'&#41;;
require&#40;ROOT_PATH.'includes/sessions.php'&#41;;
$user_access get_permission&#40;&#41;;

$number_of_new_pics 5;
$days_to_be_new 3;

$new_cutoff time&#40;&#41; - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql get_auth_cat_sql&#40;"auth_viewcat", "NOTIN"&#41;;

   
$sql "SELECT MAX&#40;cat_id&#41; as max_id FROM ".PIC_CATEGORIES_TABLE;
   
$row $site_db->query_firstrow&#40;$sql&#41;;
   
$cat_max_id = &#40;!empty&#40;$row['max_id'&#93;&#41;&#41; ? $row['max_id'&#93; &#58; 0;

$total_images_found 0;
for &
#40;$i = 0; $i <= $cat_max_id; $i++&#41;&#123;

  
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name
          FROM "
.PIC_IMAGES_TABLE." i,  ".PIC_CATEGORIES_TABLE." c
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i";
   
$result $site_db->query&#40;$sql&#41;;
   
$row $site_db->fetch_array&#40;$result&#41;;
   
$images_in_category $site_db->get_numrows&#40;$result&#41;;
   
$total_images_found $total_images_found $images_in_category;

   
$category_name = &#40;$row['cat_name'&#93;&#41;;
   
$category_id = &#40;$row['cat_id'&#93;&#41;;
   
$category_link = &#40;"<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">"&#41;;

if &#40;$images_in_category&#41; &#123;
echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b>&nbsp;&nbsp;&nbsp;$category_link ...view category </a><br>";&#125;

  
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name
          FROM "
.PIC_IMAGES_TABLE." i,  ".PIC_CATEGORIES_TABLE." c
          LEFT JOIN "
.PIC_USERS_TABLE." u ON u.user_id = i.user_id
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i
          ORDER BY i.image_date DESC
          LIMIT 
$number_of_new_pics";

   
$result $site_db->query&#40;$sql&#41;;
  
while &#40;$row = $site_db->fetch_array&#40;$result&#41;&#41; &#123;
   
$image_name = &#40;$row['image_name'&#93;&#41;;
   
$image_id = &#40;$row['image_id'&#93;&#41;;
   
$image_date format_date&#40;$config['date_format'&#93;." ".$config['time_format'&#93;,$row['image_date'&#93;&#41;;
   
$category_name = &#40;$row['cat_name'&#93;&#41;;
   
$user_name = &#40;$row['user_name'&#93;&#41;;
   
$media_path = &#40;$row['image_media_file'&#93;&#41;;
   
$image_link = &#40;"<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">"&#41;;

   
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> at <b>$image_date</b>&nbsp;&nbsp;&nbsp;$image_link ...view image </a></ul>";
  &
#125;
 
&#125;
if &#40;!$total_images_found&#41; &#123;
   
$gallery_link = &#40;"<a href=\"" . ROOT_PATH . "index.php" . "\">"&#41;;
echo "No new images found within last $days_to_be_new days. Click $gallery_link here</a> to surf the gallery...<br>";
   &
#125; else &#123;
  
$allnew_link = &#40;"<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">"&#41;;
   
echo "$allnew_link Would you like to see all new images? </a>";
&#125;
?>

Offline _Keith_

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • http://www.scikotics-ccc.com
New Pics in Category
« Reply #24 on: January 23, 2003, 01:54:53 AM »
I want this but I would like it to use with IPF (IBF) Forums

heres my site right now. I kind of want to add this into the portal. I have a idea on how to do it and I am gonna play with your code a bit to see what I come up with but any help to put this in would be greatly appreciated.

Offline ChrisTTian

  • Newbie
  • *
  • Posts: 29
    • View Profile
New Pics in Category
« Reply #25 on: January 23, 2003, 11:02:09 AM »
Hi SLL it finally works!!!

aaaaand: I get the username as well  :!:

There is a tiny little difference between the table "users" in 4images and the table "users" in phpBB:

In 4images the filed is called "user_name" but in phpBB the filed is called "username"

So when i changed as you wrote above the code

Code: [Select]
define('PIC_USERS_TABLE', '4images_users');

to the phpbb table

Code: [Select]
define('PIC_USERS_TABLE', 'phpbb_users');

I got the correct error:

Unknown column 'u.user_name' in 'field list'

Of course there is now no field "user_name" in phpBB. But if I change the $sql statement from "u.user_name" to "u.username" it works correct.

So here is the complete code for people who have included 4images and phpbb:

It is up to you SLL to move this code to the final section of the forum because ist is your great work!!! I will send you the link to my news page as soon as I have included it. Hopefully this evening ;-)

Greetings and 1000 Thank you to Russia ;-)

Code: [Select]
<?php 
define
&#40;'ROOT_PATH', './4images/'&#41;; 
define&#40;'PIC_CATEGORIES_TABLE', '4images_categories'&#41;; 
define&#40;'PIC_IMAGES_TABLE', '4images_images'&#41;; 
define&#40;'PIC_USERS_TABLE', 'phpbb_users'&#41;; 
include&#40;ROOT_PATH.'global.php'&#41;; 
require&#40;ROOT_PATH.'includes/sessions.php'&#41;; 
$user_access get_permission&#40;&#41;; 

$number_of_new_pics 5
$days_to_be_new 30

$new_cutoff time&#40;&#41; - 60 * 60 * 24 * $days_to_be_new; 
$cat_id_sql get_auth_cat_sql&#40;"auth_viewcat", "NOTIN"&#41;; 

   
$sql "SELECT MAX&#40;cat_id&#41; as max_id FROM ".PIC_CATEGORIES_TABLE
   
$row $site_db->query_firstrow&#40;$sql&#41;; 
   
$cat_max_id = &#40;!empty&#40;$row['max_id'&#93;&#41;&#41; ? $row['max_id'&#93; &#58; 0; 

$total_images_found 0
for &
#40;$i = 0; $i <= $cat_max_id; $i++&#41;&#123; 

  
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name 
          FROM "
.PIC_IMAGES_TABLE." i,  ".PIC_CATEGORIES_TABLE." c 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i"
   
$result $site_db->query&#40;$sql&#41;; 
   
$row $site_db->fetch_array&#40;$result&#41;; 
   
$images_in_category $site_db->get_numrows&#40;$result&#41;; 
   
$total_images_found $total_images_found $images_in_category

   
$category_name = &#40;$row['cat_name'&#93;&#41;; 
   
$category_id = &#40;$row['cat_id'&#93;&#41;; 
   
$category_link = &#40;"<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">"&#41;; 

if &#40;$images_in_category&#41; &#123; 
   
echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b>&nbsp;&nbsp;&nbsp;$category_link ...view category </a><br>";&#125; 

  
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.username 
          FROM "
.PIC_IMAGES_TABLE." i,  ".PIC_CATEGORIES_TABLE." c 
          LEFT JOIN "
.PIC_USERS_TABLE." u ON u.user_id = i.user_id 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i 
          ORDER BY i.image_date DESC 
          LIMIT 
$number_of_new_pics"

   
$result $site_db->query&#40;$sql&#41;; 
  
while &#40;$row = $site_db->fetch_array&#40;$result&#41;&#41; &#123; 
   
$image_name = &#40;$row['image_name'&#93;&#41;; 
   
$image_id = &#40;$row['image_id'&#93;&#41;; 
   
$image_date format_date&#40;$config['date_format'&#93;." ".$config['time_format'&#93;,$row['image_date'&#93;&#41;; 
   
$category_name = &#40;$row['cat_name'&#93;&#41;; 
   
$user_name = &#40;$row['user_name'&#93;&#41;; 
   
$media_path = &#40;$row['image_media_file'&#93;&#41;; 
   
$image_link = &#40;"<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">"&#41;; 

   
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> at <b>$image_date</b>&nbsp;&nbsp;&nbsp;$image_link ...view image </a></ul>"
  &
#125; 
&#125; 
if &#40;!$total_images_found&#41; &#123; 
   
$gallery_link = &#40;"<a href=\"" . ROOT_PATH . "index.php" . "\">"&#41;; 
   
echo "No new images found within last $days_to_be_new days. Click $gallery_link here</a> to surf the gallery...<br>"
   &
#125; else &#123; 
  
$allnew_link = &#40;"<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">"&#41;; 
   
echo "$allnew_link Would you like to see all new images? </a>"
   &
#125; 
?>

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
New Pics in Category
« Reply #26 on: January 23, 2003, 11:59:43 AM »
Quote from: _Keith_
I want this but I would like it to use with IPF (IBF) Forums

I believe you don't have to change anything in this code to make it work with your forum. Just make right table definitions.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
New Pics in Category
« Reply #27 on: January 23, 2003, 12:05:55 PM »
Quote from: ChrisTTian
It is up to you SLL to move this code to the final section of the forum because ist is your great work!!!
I don't think it's a MOD, we're not modifying anything in 4images  :)
In order to publish it, at least the output of this script shouldn't be so ugly  :wink:  
What about this? http://www.dalnet.ru/get_new_pics.php

Offline ChrisTTian

  • Newbie
  • *
  • Posts: 29
    • View Profile
New Pics in Category
« Reply #28 on: January 23, 2003, 12:50:47 PM »
SLL

this looks really great! Was ist hard to make?

Btw: Didn't know that Russia has so many beautyful women ;-)

Just too bad that i cant read kyrillic and don't understand russian. What do you use your image gallery for?
 
Greetings
Christian

P.S.: The link to my web site is http://www.tt-owners.de. A Page about a car from Aud called "Audi TT"

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
New Pics in Category
« Reply #29 on: January 23, 2003, 01:26:09 PM »
Quote from: ChrisTTian
Was ist hard to make?

5 more minutes :)  http://sll.blood.ru/for_chris.zip
Quote from: ChrisTTian
Btw: Didn't know that Russia has so many beautyful women ;-)  Just too bad that i cant read kyrillic and don't understand russian. What do you use your image gallery for?

Then make yourself happy - spend some week in Moscow with Russian girls  :wink: And there's not much to read in this gallery, just look at photos. This is a gallery for Russian IRC network DalNet(ru), so the people you see there are wasting best part of their life chatting  8O I've started this gallery two weeks ago, so there are still not too many photos...
Quote from: ChrisTTian
The link to my web site is http://www.tt-owners.de. A Page about a car from Aud called "Audi TT"

Very nice desing!  I used to drive TT once, nice car, but I'm a big fan of another German manufacturer :) http://sll.blood.ru/tmp/sll-525.jpg