• [Mod] Random image / Zufallsbild 5 0 5 1
Currently:  

Author Topic: [Mod] Random image / Zufallsbild  (Read 869102 times)

0 Members and 2 Guests are viewing this topic.

Rembrandt

  • Guest
Re: [Mod] Random image / Zufallsbild
« Reply #615 on: October 02, 2009, 09:24:48 PM »
Hallo!

Ich habe noch eine kurze Frage bezüglich Sicherheit:

Sollte bei "$image_name = $row['image_name'];" nicht eine Sicherheits-Funktion, ........ eingebaut/berücksichtigt werden?..


$row['image_name'] kommt aus der datenbank, ich denke da braucht man so etwas nicht, und dort sollte der image name schon bereinigt sein.
sollte der image name nicht bereinigt hinneingeschrieben werden, können man mit einer sql injektion die DB manipulieren.

mfg Andi

Offline ahsancharming

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #616 on: October 03, 2009, 07:50:00 AM »
Hallo!

Ich habe noch eine kurze Frage bezüglich Sicherheit:

Sollte bei "$image_name = $row['image_name'];" nicht eine Sicherheits-Funktion, wie "format_text(..." oder "safe_htmlspecialchars(..." oder so änlich eingebaut/berücksichtigt werden?

Danke & Gruss

i dont understand this language ..please explain me in english
thnx

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #617 on: October 03, 2009, 03:23:07 PM »
@ ahsancharming

1. this language is German ( you are on a .de-domain ) ...
2. for this case we have the translation feature on the top on each site ...
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 Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #618 on: October 03, 2009, 08:17:40 PM »
well thanx alot but i still want it to be perfect

1) i want a hyperlink of category on category name.
2) i wont the font in "CENTER" , "VERDENA" and "Size.2".
3) is it possile to use friendly urls ?


1.) i will create an query for you
2.) use html codes like for the background color in my previons post
3.) no, it is not possible rightnow

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: random_more_pics.php                                 *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.0 for 4images 1.6.1                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    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.                                                        *
 *                                                                        *
 *************************************************************************/

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH''./');

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

define('SCRIPT_URL''http://www.wallpaperspecial.com/wallzz/');

$site_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 
"<body bgcolor=\"#5D8FB5\" topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n";

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images 1;

$sql "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_hits, b.cat_name 
        FROM ("
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b) 
        WHERE a.image_active=1 
        AND a.cat_id = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        ORDER BY RAND() 
        LIMIT 
$num_images";
$result $site_db->query($sql);

echo 
"<table border='0' width='133' bgcolor='#5D8FB5' align='left'>\n";

while (
$row $site_db->fetch_array($result)){
  
$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'];
  
$image_hits $row['image_hits'];
  
$cat_name $row['cat_name'];


  echo 
"<tr>\n";
  echo 
"<td><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\" target=\"_blank\"> <img src=\"".SCRIPT_URL.$thumb_src."\" border=\"0\" alt=\"$image_name\"></a></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td><font face='Verdana' size='2'><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\" target=\"_blank\"><b>$image_name</b></a></font></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td><font face='Verdana' size='2'>Views: $image_hits</font></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td><font face='Verdana' size='2'><a href=\"".SCRIPT_URL."categories.php?cat_id=$cat_id\" target=\"_blank\">$cat_name</a></font></td>\n";
  echo 
"</tr>\n";
}
  echo 
"</table>\n";
?>
« Last Edit: October 03, 2009, 08:47:36 PM by Nicky »
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 ahsancharming

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #619 on: October 04, 2009, 12:34:24 AM »
well thanx alot but i still want it to be perfect

1) i want a hyperlink of category on category name.
2) i wont the font in "CENTER" , "VERDENA" and "Size.2".
3) is it possile to use friendly urls ?


1.) i will create an query for you
2.) use html codes like for the background color in my previons post
3.) no, it is not possible rightnow

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: random_more_pics.php                                 *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.0 for 4images 1.6.1                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    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.                                                        *
 *                                                                        *
 *************************************************************************/

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH''./');

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

define('SCRIPT_URL''http://www.wallpaperspecial.com/wallzz/');

$site_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 
"<body bgcolor=\"#5D8FB5\" topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n";

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images 1;

$sql "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_hits, b.cat_name 
        FROM ("
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b) 
        WHERE a.image_active=1 
        AND a.cat_id = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        ORDER BY RAND() 
        LIMIT 
$num_images";
$result $site_db->query($sql);

echo 
"<table border='0' width='133' bgcolor='#5D8FB5' align='left'>\n";

while (
$row $site_db->fetch_array($result)){
  
$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'];
  
$image_hits $row['image_hits'];
  
$cat_name $row['cat_name'];


  echo 
"<tr>\n";
  echo 
"<td><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\" target=\"_blank\"> <img src=\"".SCRIPT_URL.$thumb_src."\" border=\"0\" alt=\"$image_name\"></a></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td><font face='Verdana' size='2'><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\" target=\"_blank\"><b>$image_name</b></a></font></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td><font face='Verdana' size='2'>Views: $image_hits</font></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td><font face='Verdana' size='2'><a href=\"".SCRIPT_URL."categories.php?cat_id=$cat_id\" target=\"_blank\">$cat_name</a></font></td>\n";
  echo 
"</tr>\n";
}
  echo 
"</table>\n";
?>


sorry iam asking u small small things..im not gud into php ..
i tried 2-3 times to to make the text in center.. :)

may i know where to add this "p align='center"</p> ?

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #620 on: October 04, 2009, 09:08:39 AM »
Code: [Select]
<td align='center'>
those are NOT PHP basic  :P
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

Rembrandt

  • Guest
Re: [Mod] Random image / Zufallsbild
« Reply #621 on: October 04, 2009, 09:27:33 AM »
Hi!
..
sorry iam asking u small small things..im not gud into php ..
i tried 2-3 times to to make the text in center.. :)

may i know where to add this "p align='center"</p> ?
its not valide.

test it:

echo "<table style=\"background-color:#5D8FB5;border-style:none;width:133px;text-align:center;\" summary=\"randomtable\">\n";

while (
$row $site_db->fetch_array($result)){
  
$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'];
  
$image_hits $row['image_hits'];
  
$cat_name $row['cat_name'];

  echo 
"<tr>\n";
  echo 
"<td><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\" onclick=\"void(window.open(this.href, '', '')); return false;\"><img src=\"".SCRIPT_URL.$thumb_src."\" style=\"border-style:none;\" alt=\"$image_name\"></a></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td style=\"font-family:Verdana,Arial;font-size:12px;font-weight:bold;\"><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\" onclick=\"void(window.open(this.href, '', '')); return false;\">$image_name</a></td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td style=\"font-family:Verdana,Arial;font-size:12px;\">Views: $image_hits</td>\n";
  echo 
"</tr>\n";
  echo 
"<tr>\n";
  echo 
"<td style=\"font-family:Verdana,Arial;font-size:12px;\"><a href=\"".SCRIPT_URL."categories.php?cat_id=$cat_id\" onclick=\"void(window.open(this.href, '', '')); return false;\">$cat_name</a></td>\n";
  echo 
"</tr>\n";
}
  echo 
"</table>\n";
?>


mfg Andi

Offline ahsancharming

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #622 on: October 04, 2009, 04:11:11 PM »
Code: [Select]
<td align='center'>
those are NOT PHP basic  :P

ok thx alot..finally it works all the way right that i want.

Offline UdoB

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #623 on: November 25, 2009, 07:03:03 PM »
Ich bekomme nun folgende Fehlermeldung wenn ich meine exterene index.php aufrufe.....Warning: include(4images/random.php) [function.include]: failed to open stream: No such file or directory in /var/www/web58/html/index.php on line 23

Warning: include() [function.include]: Failed opening '4images/random.php' for inclusion (include_path='.') in /var/www/web58/html/index.php on line 23


Rembrandt

  • Guest
Re: [Mod] Random image / Zufallsbild
« Reply #624 on: November 25, 2009, 08:25:24 PM »
Ich bekomme nun folgende Fehlermeldung wenn ich meine exterene index.php aufrufe.....Warning: include(4images/random.php) [function.include]: failed to open stream: ....
hast du die random.txt im eingangspost, auch als random.php in deinem  root abgespeichert?

Offline jmschwoerer

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #625 on: December 13, 2009, 03:21:55 PM »
Moin,

wollte diese Modifikation gerade mal angehen ... leider kommt bei mir ne hässliche Fehlermeldung - http://galerie.jmsfoto.net/random.php

Wo liegt der Fehler? Kann mir jemand weiterhelfen?

Grüße jms

PS: das ganze soll in ein wordpress-Blog eingebunden werden: http://blog.jmsfoto.net

Rembrandt

  • Guest
Re: [Mod] Random image / Zufallsbild
« Reply #626 on: December 13, 2009, 03:50:27 PM »
...
wollte diese Modifikation gerade mal angehen ... leider kommt bei mir ne hässliche Fehlermeldung - ...
dein provider, oder du selbst wenn du zugriff auf die php.ini hast, hat in der php.ini "allow_url_include" auf off gestellt.
das heist es ist nicht erlaubt über eine URL eine datei einzubinden.

mfg Andi

Offline jmschwoerer

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #627 on: December 13, 2009, 04:18:00 PM »
Bin einen Schritt weiter ....
der erste link funktioniert nun http://galerie.jmsfoto.net/random.php


Wenn ich das aber in wordpress einfüge (mit diesem Code):
Code: [Select]
<?php
 
include("../4images/random.php");
?>

Dann kommt immer noch die Fehlermeldung :(

(wo würde ich denn die php.ini finden? Ich finde keine ;(


ABER: ich habe das ganze nun etwas anders gelöst ... und zwar mit dem Plugin iFrame ;)

Grüße jms
« Last Edit: December 13, 2009, 04:30:46 PM by jmschwoerer »

Offline Sun

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #628 on: March 10, 2010, 12:44:26 PM »
If i look in page http://www.mydomain.ru/gallery/random.php  then i see random picture.
But what i need to do if i want see random picture in http://www.mydomain.ru/index.html ?  I try to add this in index.html , but i didn't see anything:
Code: [Select]
<SCRIPT language='JavaScript'  src='http://www.mydomain.ru/gallery/random.php'></SCRIPT>My random.php:
Code: [Select]
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', './');

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

define('SCRIPT_URL', 'http://www.mydomain.ru/gallery/');

$site_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 "<body bgcolor=\"#5D8FB5\" topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n";

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images = 1;

$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_hits, b.cat_name
        FROM (".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b)
        WHERE a.image_active=1
        AND a.cat_id = b.cat_id
        AND b.auth_viewcat=".AUTH_ALL."
        AND b.auth_viewimage=".AUTH_ALL."
        ORDER BY RAND()
        LIMIT $num_images";
$result = $site_db->query($sql);

echo "<table border='0' bgcolor='#5D8FB5' align='center'>\n";
echo "<tr>\n";

while ($row = $site_db->fetch_array($result)){
  $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'];
  $image_hits = $row['image_hits'];
  $cat_name = $row['cat_name'];

  echo "<td width='133' align='center'><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\" target=\"_blank\"> <img src=\"".SCRIPT_URL.$thumb_src."\" border=\"0\" alt=\"$image_name\"></a></td>\n";
}
  echo "</tr>\n";
  echo "</table>\n";
Please, help me
Tatyana.
I use 4images v.1.7.6
You can answer me in English and Russian languages.
Sorry, my English is not very good.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #629 on: March 10, 2010, 01:19:34 PM »
@ Sun ...

... for random images on your own index.php trying better this ...
... http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 ...
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) ...