Author Topic: [MOD] Show best images on extern page  (Read 58046 times)

0 Members and 1 Guest are viewing this topic.

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
[MOD] Show best images on extern page
« on: July 06, 2007, 12:42:55 PM »
Hi,

this is a mod, found by coincedence and some modifications by SLL (http://www.4homepages.de/forum/index.php?topic=3529.msg25302#msg25302)


What this MOD will do:

- Shows the most rated picture
- Shows the most voted picture
- Shows the most commented picture
- Shows the most downloaded picture
- Shows the most viewed picture

on a page outside of 4Images! I have used this mod in Wordpress!


ok, lets go:

1. Create a new .php file and name it something like "bestpictures.php" or something like that. Save it in the root folder of 4images.

  so it would look like that: /4images/bestpictures.php

2. Put the following code in it:


Code: [Select]
<?php
// error_reporting(E_ALL);
define('ROOT_PATH''../4images/');
define('SITE_URL''http://www.yourdomain.de/');

// Bild des Tages: für 24 Stunden wird einer der besten Bilder aus
// Datenbank gelesen und angezeigt. Nach 24 Stunden wechselt das Bild.
/**************************************************************************
*                                                                        *
*    4images - A Web Based Image Gallery Management System               *
*    ----------------------------------------------------------------    *
*                                                                        *
*             File: potd.php                                           *
*        Copyright: (C) 2002 Jan Sorgalla                                *
*            Email: jan@4homepages.de                                    *
*              Web: http://www.4homepages.de                             *
*    Scriptversion: 1.0 for 4images 1.7                                *
*                                                                        *
*    Never released without support from: Nicky (http://www.nicky.net) and SLL (;   *
*                                                                        *
**************************************************************************
*                                                                        *
*    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
*    bedingungen (http://www.4homepages.de/4images/lizenz.php) für       *
*    weitere Informationen.                                              *
*    ---------------------------------------------------------------     *
*    This script is NOT freeware! Please read the Copyright Notice       *
*    (http://www.4homepages.de/4images/lizenz_e.php) for further         *
*    information.                                                        *
*                                                                        *
*************************************************************************/
//Based on the Photo of the Day mod by SLL and V@no
//additional tweaking by Omnirayf 9-5-2003
// and c-bass ( 6. Juli 2007)

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)) ? 0;
}

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($sql);
$image_id $row['image_id'];
$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><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($sql);
$image_id $row['image_id'];
$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><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($sql);
$image_id $row['image_id'];
$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><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($sql);
$image_id $row['image_id'];
$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><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($sql);
$image_id $row['image_id'];
$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><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";

?>



3. EDIT in the first lines of the code the domain and the path to your 4images installlation! It might be, if u have different database table name, that u also have to change them in the code.
If u dont want for example shown the most viewed pictures, comment the sql query in the code.


4. Test the file by calling it directly over your browser like http://www.yourdomain.de/4images/bestpictures.php

5. Put this line of code, where u want to have the pictures.

            
Code: [Select]
<?php include("http://www.yourdomain.de/4images/bestpictures.php"); ?>
« Last Edit: November 03, 2007, 02:18:08 PM by c-bass »
/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] SHOW BEST IMAGES ON EXTERN PAGE
« Reply #1 on: July 06, 2007, 01:07:51 PM »
... einige kurze Anmerkungen ... in deutsch ... ;)

1. um gleich dem Query Problem mit MySQL 5.0.x zu entgehen und weitere Nachfragen zu provozieren, solltest du statt :
Code: [Select]
FROM ".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b
dieses verwenden :
Code: [Select]
FROM (".PIC_IMAGES_TABLE." a, ".PIC_CATEGORIES_TABLE." b)

2. du schreibst :
Quote
5. Put this line of code, where u want to have the pictures.
Code: [Select]
<?php include("http://www.yourdomain.de/4images/bestpictures.php"); ?>
Das funktioniert nur, wenn die Seite in die integriert werden soll (z.B. Wordpress) auf dem gleichen Webspace liegt.
Willst du die Bilder außerhalb deines Webspce zeigen, so bleibt nur die Einbindung über einen "IFRAME" .
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
Re: [MOD] SHOW BEST IMAGES ON EXTERN PAGE
« Reply #2 on: July 06, 2007, 02:14:42 PM »
Du hast natürlich recht!

Mmmh...ich hab aber den MySQl 5 und funzt trotzdem.

habs gleich im original code bearbeitet!
/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/

Offline souwar

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [MOD] SHOW BEST IMAGES ON EXTERN PAGE
« Reply #3 on: August 26, 2007, 08:36:20 AM »
can this script be modified for a facebook application?

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
Re: [MOD] SHOW BEST IMAGES ON EXTERN PAGE
« Reply #4 on: August 26, 2007, 03:44:43 PM »
what exactly u wanna do? would say, it depends on ur skills  :lol:
/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/

Offline souwar

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [MOD] SHOW BEST IMAGES ON EXTERN PAGE
« Reply #5 on: August 29, 2007, 10:44:27 PM »
i wanna be able to do a facebook application and link it to my photogallery.

there is 2 opion:
1- the user will select what category he want to see in his facebook body page ( it's like query search result )

2- or he i will see a mini gallery ( latest pictures )


Offline egyptsons

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Egypt Sons
Re: [MOD] SHOW BEST IMAGES ON EXTERN PAGE
« Reply #6 on: August 29, 2007, 11:26:29 PM »
working fine :D
Thanx God

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [MOD] SHOW BEST IMAGES ON EXTERN PAGE
« Reply #7 on: August 30, 2007, 09:54:54 PM »
hi

nice thing  :)

but no need for that..
Code: [Select]
define('PIC_CATEGORIES_TABLE', '4images_categories');
define('PIC_IMAGES_TABLE', '4images_images');

prefix is in config.php
PIC_CATEGORIES_TABLE & PIC_IMAGES_TABLE
should be changed to
CATEGORIES_TABLE & IMAGES_TABLE
which are in constants.php

user have only to change path & url
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline janaage01

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Show best images on extern page
« Reply #8 on: September 02, 2007, 06:21:40 PM »
Hello,

I wish to chance the color of the background into black or grey und the fontcolor into white.
I think I musst chance something in this script

Code: [Select]
echo "<td><center><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 "<center>\n";
echo "<b>$image_name</b><br>\n";
echo "Most rated<br></td>\n";



and I wish to show a randompic in this script (like this script from Nicky.

Can someone help me?
« Last Edit: September 02, 2007, 06:57:57 PM by janaage01 »

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
Re: [MOD] Show best images on extern page
« Reply #9 on: September 02, 2007, 07:22:04 PM »
wieviel ahnung hast du denn von html etc?

du müsstest nur in den htmltabellen den hintergrund bestimmen. oder du fügt eine css klasse hinzu und änderst sie in deinem css stylesheet.
/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/

Offline janaage01

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Show best images on extern page
« Reply #10 on: September 02, 2007, 07:27:14 PM »
Ich hab leider keine Ahnung davon. Ich nutze nur ein Script für die page wo ich das eingebaut habe.

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
Re: [MOD] Show best images on extern page
« Reply #11 on: September 02, 2007, 07:35:30 PM »
suche

Code: [Select]

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


ersetze mit

Code: [Select]

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


 bgcolor=\"#000000\" <--- da muss dann der farbcode stehen
/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/

Offline janaage01

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Show best images on extern page
« Reply #12 on: September 02, 2007, 09:00:10 PM »
Danke für den Tipp, aber was muss ich im Code ergänzen, wenn ich die Schriftfarbe ändern will?

Code: [Select]
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"#000000\"><tr>\n";

Hast Du event. auch eine Idee, wie das Zufallsbild eingebunden werden kann?

Offline janaage01

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Show best images on extern page
« Reply #13 on: September 02, 2007, 09:24:58 PM »
Ja, aber das klappt leider nicht in dem Code oben. Ich kenn mich zuwenig damit aus, aber kann es sein, dass die html-Anweisungen in php etwas anders lauten?

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
Re: [MOD] Show best images on extern page
« Reply #14 on: September 03, 2007, 09:57:19 AM »
ja dat wird wohl mit der css datei zusammenhängen. ohne die basics, kommst du so nicht weit.
/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/