4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: ChrisTTian on January 17, 2003, 03:22:18 PM
-
Hello
I would like to include a php file in my main page with the following content:
NEWEST PICS in the IMAGE GALLERY!!!
You can find new Pics in Catagory:
- .... (insert name here) (date)
- .... (insert name here) (date)
- ....
No pic should pop up here. Only the category name and the date of the last update should appear.
The category name should be clickable and lead to the category in the image gallery
It would be fine to adjust the time. Lets say I would like to know smething like "list those categories where there has been an upload in the last 3 days" or so.
As I am not very firm with php and sql could you please send me an example or create a mod for that.
I think this might be very useful especially for news pages. See my newspage on http://www.tt-owners.de/php/news/news.php . I display the last threads from phpBB forum on the left side at "Diskussionstreff" and I would like to add the last categories of the image gallery below or on the right side.
WHY?
Especially in news pages you are forced to provide all kind of information just in compressed summarised form to make some appetite for more browsing.
Praying for some helpful people wo initialise a tiny little mod for me and all others. I guess that shouldn't bee to hard. Maybe the random pic mod can be adjusted to my description?
Greetings
Christian
-
It's not a real MOD, it's written right now, in five minutes... I hope you can do what you want out of it...
<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$number_of_news = 5;
$sql = "SELECT i.image_name, i.image_date, c.cat_name, u.user_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
ORDER BY i.image_date DESC
LIMIT $number_of_news";
$result = $site_db->query($sql);
$new_images_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
$new_images_list[$i] = $row;
$i++;
}
$site_db->free_result();
for ($i = 1; $i <= $number_of_news; $i++) {
if (isset($new_images_list[$i])) {
$image_date = format_date($config['date_format']." ".$config['time_format'],$new_images_list[$i]['image_date']);
$news = ("new image <b>" . $new_images_list[$i]['image_name'] . "</b> in the category <b>" . $new_images_list[$i]['cat_name'] . "</b> uploaded by <b>" . $new_images_list[$i]['user_name'] . "</b> on <b>" . $image_date . "</b><br>" );
echo $news;
}
}
?>
As a result of this I see:
new image Gala in the category Girlz uploaded by SLL on 17.01.2003 01:13
new image Natasha in the category Girlz uploaded by SLL on 17.01.2003 01:11
new image Boris in the category Boyz uploaded by SLL on 17.01.2003 00:59
new image Dmitry in the category Boyz uploaded by SLL on 17.01.2003 00:59
new image Sergey in the category Boyz uploaded by SLL on 17.01.2003 00:56
Jost edit your homepage and insert <?php include("this_filename.php"); ?> in the proper place. I hope this is what you wanted :wink:
-
Wow :!:
I didn't expect to have a ready file 8O
Thank you for this fast reply. The result really looks like what I expected. I will try it this evening. Many thanks!!! :P
I will let you know if this is what I was looking for and post my news page as soon as it is included.
Christian
-
Hello
I forgot one little thing. I hope you can help me:
Is there a way to modify the code that the follwing result will appear:
- New image(s) in category A on 01/18/2003
- New image(s) in category B on 01/16/2003
1) I would like to set a time span for the result like:
"Show me those categories where new images have been added the recent 7 days"
Not every image should be listed by name. The category is all I need :-). Otherwise the list will grow too much and be too long for the news page. I would like to display only the category name as in my sample above.
2) If I click on the cateqory I should jump to the category in the image gallery.
May I ask you for another 5 min to write me the code please. Many thanks in advance!!!
Christian
-
thanx a lot SLL
but how could I link the image names??
-
help please for linking
-
May I ask you for another 5 min to write me the code please.
I don't have time to make this code clean, but at least it works... :) feel free clean it up and modify (and post here)
<?php
define('ROOT_PATH', './4images/');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$number_of_new_pics = 15;
$days_to_be_new = 1;
$new_cutoff = time() - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT MAX(cat_id) as max_id FROM ".CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;
for ($i = 0; $i <= $cat_max_id; $i++){
$sql = "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name
FROM ".IMAGES_TABLE." i, ".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($sql);
$row = $site_db->fetch_array($result);
$images_in_category = $site_db->get_numrows($result);
$category_name = ($row['cat_name']);
$category_id = ($row['cat_id']);
$category_link = ("<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">");
if ($images_in_category) { echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b> $category_link ...view category </a><br>"; }
$sql = "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c
LEFT JOIN ".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($sql);
while ($row = $site_db->fetch_array($result)) {
$image_name = ($row['image_name']);
$image_id = ($row['image_id']);
$category_name = ($row['cat_name']);
$user_name = ($row['user_name']);
$media_path = ($row['image_media_file']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
$allnew_link = ("<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">");
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> $image_link ...view image </a></ul>";
}
}
echo "$allnew_link Show all new images? </a>";
?>
-
Warning: Failed opening './4images/global.php' for inclusion (include_path='.:/sys/php-4.2.3/lib/php') in /vhosts/mydomainname.com/http/4images/test.php on line 4
-
I put test.php to my root directory and coming test.php like this:
Show all new images?
that's it. no links and no image lists :) only this sentence appear
the html source of this page:
-----------------------
Show all new images? </a>
-----------------------
did u test it SLL :)
-
Sure I did check it! Don't try to make me more stupid, that I am :wink:
You can also check yourself http://www.dalnet.ru/get_new_pics.php It's in Russian, but in this case it doesn't matter...
Check path in your file!
define('ROOT_PATH', './4images/');
I've also added number of categories check into the code above.
-
path is right
if I change the right path then an error gives
Warning: Failed opening './mngpicturesX/global.php' for inclusion (include_path='.:/sys/php-4.2.3/lib/php') in /vhosts/mydomain.com/http/mngpicturesX/test.php on line 4
I could't find the mistake :((
my script gives me only
--------------
"Show all new images?"
---------------
-
the first code running exactly without any problems, but this code can't give the links of images
could you add image links to this code SLL please?
<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$number_of_news = 5;
$sql = "SELECT i.image_name, i.image_date, c.cat_name, u.user_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
ORDER BY i.image_date DESC
LIMIT $number_of_news";
$result = $site_db->query($sql);
$new_images_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
$new_images_list[$i] = $row;
$i++;
}
$site_db->free_result();
for ($i = 1; $i <= $number_of_news; $i++) {
if (isset($new_images_list[$i])) {
$image_date = format_date($config['date_format']." ".$config['time_format'],$new_images_list[$i]['image_date']);
$news = ("new image <b>" . $new_images_list[$i]['image_name'] . "</b> in the category <b>" . $new_images_list[$i]['cat_name'] . "</b> uploaded by <b>" . $new_images_list[$i]['user_name'] . "</b> on <b>" . $image_date . "</b><br>" );
echo $news;
}
}
?>
-
path is right
if I change the right path then an error gives Warning: Failed opening './mngpicturesX/global.php' for inclusion
no, it's not right :)
let's say, the full path for the of you site homepage is /vhosts/mydomain.com/http/index.html, and the path for 4images startpage is /vhosts/mydomain.com/http/mngpicturesX/index.php
put this script into the root directory of your site, not 4images root! (or include in your main index.html).
then the root path definition in this script should bedefine('ROOT_PATH', './mngpicturesX/');
try harder :wink: as i said (and as you can see with the link to my site) it works....
-
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?
<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$number_of_news = 5;
$sql = "SELECT i.image_name, i.image_date, c.cat_name, u.user_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
ORDER BY i.image_date DESC
LIMIT $number_of_news";
$result = $site_db->query($sql);
$new_images_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
$new_images_list[$i] = $row;
$i++;
}
$site_db->free_result();
for ($i = 1; $i <= $number_of_news; $i++) {
if (isset($new_images_list[$i])) {
$image_date = format_date($config['date_format']." ".$config['time_format'],$new_images_list[$i]['image_date']);
$news = ("new image <b>" . $new_images_list[$i]['image_name'] . "</b> in the category <b>" . $new_images_list[$i]['cat_name'] . "</b> uploaded by <b>" . $new_images_list[$i]['user_name'] . "</b> on <b>" . $image_date . "</b><br>" );
echo $news;
}
}
?>
because this code runs exactly withour any problems
-
Back to your last code ;-)
Hello again
I tried to adjust the file to my table names. My tables are called "4images_categories" and "4images_images". So I changed the code for the table names. But now I get a parse error in line 14. Why? This code is in line 14:
$sql = "SELECT MAX(cat_id) as max_id FROM ".4images_categories;
What I didn't understand ist what the "." in front of the table name means. In the other code you write the table name in quotas (") and have a dot at the beginning and the end of the table name. Is there something wrong? Because for me it didn't work. Maybe a navive question of an amateur ;-)
Below you'll find the complete code with the replaced table names. Is ther anything else to change?
Greetings Christian
<?php
define('ROOT_PATH', './4images/');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$number_of_new_pics = 15;
$days_to_be_new = 1;
$new_cutoff = time() - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT MAX(cat_id) as max_id FROM ".4images_categories;
$row = $site_db->query_firstrow($sql);
$cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;
for ($i = 0; $i <= $cat_max_id; $i++){
$sql = "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name
FROM ".4images_images." i, ".4images_categories." 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($sql);
$row = $site_db->fetch_array($result);
$images_in_category = $site_db->get_numrows($result);
$category_name = ($row['cat_name']);
$category_id = ($row['cat_id']);
$category_link = ("<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">");
if ($images_in_category) { echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b> $category_link ...view category </a><br>"; }
$sql = "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 ".4images_users." 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($sql);
while ($row = $site_db->fetch_array($result)) {
$image_name = ($row['image_name']);
$image_id = ($row['image_id']);
$category_name = ($row['cat_name']);
$user_name = ($row['user_name']);
$media_path = ($row['image_media_file']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
$allnew_link = ("<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">");
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> $image_link ...view image </a></ul>";
}
}
echo "$allnew_link Show all new images? </a>";
?>
-
I think u dont need to change anything, just use exact same code with .CATEGORIES_TABLE;
-
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
-
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
-
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 namesdefine('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 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?
define('ROOT_PATH', './');
because this code runs exactly withour any problems
hey hey! open your eyes! :evil:
the root for you should bedefine('ROOT_PATH', './mngpicturesX/');
and image links are there, btw...
-
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 namesdefine('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
-
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
$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
<?php
define('ROOT_PATH', './4images/');
define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');
define('PIC_USERS_TABLE', '4images_users');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$number_of_new_pics = 1;
$days_to_be_new = 100;
$new_cutoff = time() - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT MAX(cat_id) as max_id FROM ".PIC_CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;
for ($i = 0; $i <= $cat_max_id; $i++){
$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($sql);
$row = $site_db->fetch_array($result);
$images_in_category = $site_db->get_numrows($result);
$category_name = ($row['cat_name']);
$category_id = ($row['cat_id']);
$category_link = ("<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">");
if ($images_in_category) { echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b> $category_link ...view category </a><br>"; }
$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($sql);
while ($row = $site_db->fetch_array($result)) {
$image_name = ($row['image_name']);
$image_id = ($row['image_id']);
$category_name = ($row['cat_name']);
$user_name = ($row['user_name']);
$media_path = ($row['image_media_file']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
$allnew_link = ("<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">");
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> $image_link ...view image </a></ul>";
}
}
echo "$allnew_link Show all new images? </a>";
?>
-
THANKSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
SLL & CHRIST :)
-
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.
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:<?php
define('ROOT_PATH', './4images/');
define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');
define('PIC_USERS_TABLE', '4images_users');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$number_of_new_pics = 5;
$days_to_be_new = 3;
$new_cutoff = time() - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT MAX(cat_id) as max_id FROM ".PIC_CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;
$total_images_found = 0;
for ($i = 0; $i <= $cat_max_id; $i++){
$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($sql);
$row = $site_db->fetch_array($result);
$images_in_category = $site_db->get_numrows($result);
$total_images_found = $total_images_found + $images_in_category;
$category_name = ($row['cat_name']);
$category_id = ($row['cat_id']);
$category_link = ("<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">");
if ($images_in_category) {
echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b> $category_link ...view category </a><br>";}
$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($sql);
while ($row = $site_db->fetch_array($result)) {
$image_name = ($row['image_name']);
$image_id = ($row['image_id']);
$image_date = format_date($config['date_format']." ".$config['time_format'],$row['image_date']);
$category_name = ($row['cat_name']);
$user_name = ($row['user_name']);
$media_path = ($row['image_media_file']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> at <b>$image_date</b> $image_link ...view image </a></ul>";
}
}
if (!$total_images_found) {
$gallery_link = ("<a href=\"" . ROOT_PATH . "index.php" . "\">");
echo "No new images found within last $days_to_be_new days. Click $gallery_link here</a> to surf the gallery...<br>";
} else {
$allnew_link = ("<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">");
echo "$allnew_link Would you like to see all new images? </a>";
}
?>
-
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.
-
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
define('PIC_USERS_TABLE', '4images_users');
to the phpbb table
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 ;-)
<?php
define('ROOT_PATH', './4images/');
define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');
define('PIC_USERS_TABLE', 'phpbb_users');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$number_of_new_pics = 5;
$days_to_be_new = 30;
$new_cutoff = time() - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT MAX(cat_id) as max_id FROM ".PIC_CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;
$total_images_found = 0;
for ($i = 0; $i <= $cat_max_id; $i++){
$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($sql);
$row = $site_db->fetch_array($result);
$images_in_category = $site_db->get_numrows($result);
$total_images_found = $total_images_found + $images_in_category;
$category_name = ($row['cat_name']);
$category_id = ($row['cat_id']);
$category_link = ("<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">");
if ($images_in_category) {
echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b> $category_link ...view category </a><br>";}
$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($sql);
while ($row = $site_db->fetch_array($result)) {
$image_name = ($row['image_name']);
$image_id = ($row['image_id']);
$image_date = format_date($config['date_format']." ".$config['time_format'],$row['image_date']);
$category_name = ($row['cat_name']);
$user_name = ($row['user_name']);
$media_path = ($row['image_media_file']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
echo "<ul><b>$image_name</b> uploaded by <b>$user_name</b> at <b>$image_date</b> $image_link ...view image </a></ul>";
}
}
if (!$total_images_found) {
$gallery_link = ("<a href=\"" . ROOT_PATH . "index.php" . "\">");
echo "No new images found within last $days_to_be_new days. Click $gallery_link here</a> to surf the gallery...<br>";
} else {
$allnew_link = ("<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">");
echo "$allnew_link Would you like to see all new images? </a>";
}
?>
-
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.
-
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
-
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"
-
Was ist hard to make?
5 more minutes :) http://sll.blood.ru/for_chris.zip
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...
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
-
how could I list the "new added images" for all categories, not for one by one category
for example last 20 added images list for all "4images"
thanks to SLL and Christ :)
-
just remove if ($images_in_category) {
echo "Found <b>$images_in_category</b> new images in category <b>$category_name</b> $category_link ...view category </a><br>";}
At the very end you could write something like echo "Total: $total_images_found found";
-
gti-the-sexy
glad that my pm was some help for you ;-)
christian
-
ok then my last question :)
this code gives me last x images for x times
but I want it to give me last x images for 1 time :)
<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$number_of_news = 5;
$sql = "SELECT i.image_name, i.image_id, i.image_date, c.cat_name, u.user_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
ORDER BY i.image_date DESC
LIMIT $number_of_news";
$result = $site_db->query($sql);
$new_images_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
$new_images_list[$i] = $row;
$i++;
}
$site_db->free_result();
for ($i = 1; $i <= $number_of_news; $i++) {
if (isset($new_images_list[$i])) {
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$image_id = ($row['image_id']);
$image_name = ($row['image_name']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
$image_date = format_date($config['date_format']." ".$config['time_format'],$new_images_list[$i]['image_date']);
$news = (":: <b>" . $new_images_list[$i]['image_name'] . "</b> ( <b>" . $new_images_list[$i]['cat_name'] . " </b>) <br>" );
echo "<ul><b>$image_name</b> $image_link ...view image </a></ul>";
}
}
}
?>
this code gives me last 5 images for 5 times :)
I WANT TO LIST LAST 5 IMAGES FOR 1 TIME
please help me with this code , without any other codes
-
please help me with this code , without any other codes
you shouldn't remove sql query, do exactly, what I told you above
-
of course I did, but it removes only "xxx found in xxx category" sentence and list the new X images for X categories
I dont want to list categories by categories
ONLY LIST LAST X IMAGES FOR ALL 4IMAGES
thanks for help
-
hello,
i got the get_new_pics.php working, but now i want to 'load' it in my home.html. i did this through the following code:
<?php include("get_new_pics.php"); ?>
but when i load my page, it gives the following error:
Fatal error: Cannot redeclare addslashes_array() (previously declared in /blablabla/global.php:32) in /blablabla/global.php on line 32
can someone help me with this? when i load the get_new_pics.php from where it's at, it works, but it doesn't when i try loading it up through home.html...
grtz
-
if u want include it into template that way, then u can comment those lines:
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
-
thnx for your reply V@no, but where should i insert this code? in the home.html?
because this code is already in my get_new_pics.php
http://mobile-snapshots.com/Gallery/get_new_pics.php
-
thnx for your reply V@no, but where should i insert this code? in the home.html?
because this code is already in my get_new_pics.php
http://mobile-snapshots.com/Gallery/get_new_pics.php
hum? insert? I didnt say insert, I said comment (delete, erase, destroy) ;)
-
:cry:
it gives me another error after i commented (sorry, didn't know that it ment deleting :lol: ) the codes.
it now says:
Fatal error: Call to a member function on a non-object in /blablabla/get_new_pics.php on line 20
is there any other way to include this in a site?
thnx.
-
I just noticed this post and couldn't help noticing it's very similar to a Mod post I made a little while ago. :?:
http://www.4homepages.de/forum/viewtopic.php?t=5654
My mode does not do any extra Database Calls (slowing your page load time)
You can see it in action on my web page - Left side.
Just thought it may help.
I'll go now :D
-
How is it possible to have a listing without thumbnails extra besides the one with thumbnails? This as a short overview of all or searched pics.