>>  Site Map >>  Forums >>  PHP-Nuke Newbie

Forum module - topics in forum:



PHP-Nuke Newbie - Complete phpnuke newbie? want to ask a question before installing? or have installed and are now confused? this is the place.



Code for photo of the week

I created a block for displaying a thumbnail size of a photo on the bottom right side of my website www.wenhui.ch. When the thumbnail is clicked, a large size photo is supposed to be displayed.

However, the thumbnail does not show up at all in the block. The code is shown below. I would be grateful if someone can help me edit the codes:
Code: :

<?PHP
if (eregi("block-pic2.php", $_SERVER['PHP_SELF']))
  {
  header("Location: index.php");
  }
$content  = "";
$content  = "<A HREF='http://www.wenhui.ch/pics/misc/big.jpg'>\n";
$content .= "<IMG SRC='http://www.wenhui.ch/pics/misc/small.jpg'></A>\n";

$content = "-- Test photo --";
?>



The file name of the block is "block-pic2.php". Pls see www.wenhui.ch for a real example.






Here is the code for a random picture: http://www.phpnuke-nederland.com/ftopicp-4201.html#4201 (yes, it's dutch)

Example can be seen here: http://test.preservingfidelitysquad.nl/index.php

If this is what you want I'll translate it for you.


BL






Thanks for the offer. For the moment I need a block that shows photos with a fixed file name.

One of my friends is a photographic fan and has agreed to supply Photo of the Week for my website. He will put his photos on his website and regularly rename one of the photos as "big.jpg" and its thumnail "small.jpg". The block on my website points to the thumnail size photo (small.jpg) on his website and will show the fullsize photo when thumnail is clicked. There will be no need for me to intervene.

Could you check the codes in my block to see what goes wrong?

I will try your random block. The example looks quite impressive.




Random photo

I just had a try at your block Random Photo. I renamed the file block-randomphotos.php. My jpg photos are located in the directory "http://www.wenhui.ch/pics/random". Here are the codes:

Code: :
<?php

/************************************************************************/
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/* please credit me, it's my only block                                 */
/* Copyright Robert J. Sori, Las Vegas Nevada                           */
/************************************************************************/

if (stristr($_SERVER['SCRIPT_NAME'], "block-randomphotos.php")) {
    Header("Location: index.php");
    die();
}

mt_srand((double)microtime()*1000000);
$imgs = dir('pics/random');
while ($file = $imgs->read()) {
    if (eregi("gif", $file) || eregi("jpg", $file)) {
    $imglist .= "$file ";
    }
}
closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$a = sizeof($imglist)-2;
$random = mt_rand(0, $a);
$image = $imglist[$random];
$asin = explode(".", $image);
$content .= "<center><a href=\"picshow.php?show=pics/random/$image\">";
$content .= "<img src=\"http://www.wenhui.ch/pics/random/$image\" border=\"0\" width=\"120\" alt=\"\"><br><br></center>";

?>


After activating the block, I go this message:

Quote: :

Warning: dir(pictures): failed to open dir: No such file or directory in /home/www/a19681cb40e9cccbf716f537e7798dce/web/blocks/block-randomphotos.php on line 17

Fatal error: Call to a member function on a non-object in /home/www/a19681cb40e9cccbf716f537e7798dce/web/blocks/block-randomphotos.php on line 18


This is the problematic line 17
Code: :

$imgs = dir('pics/random');
 


I would be grateful if you could fix the problem in the codes.






Save following code as block-RandomPicture.php

Code: :
<?php

/************************************************************************/
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/* please credit me, it's my only block                                 */
/* Copyright Robert J. Sori, Las Vegas Nevada                           */
/************************************************************************/

if (stristr($_SERVER['SCRIPT_NAME'], "block-RandomPicture.php")) {
    Header("Location: index.php");
    die();
}

mt_srand((double)microtime()*1000000);
$imgs = dir('pictures');
while ($file = $imgs->read()) {
    if (eregi("gif", $file) || eregi("jpg", $file)) {
    $imglist .= "$file ";
    }
}
closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$a = sizeof($imglist)-2;
$random = mt_rand(0, $a);
$image = $imglist[$random];
$asin = explode(".", $image);
$content .= "<center><a href=\"picshow.php?show=pictures/$image\">";
$content .= "<img src=\"pictures/$image\" border=\"0\" width=\"120\" alt=\"\"><br><br></center>";

?>



Upload the file to root/blocks


Save following code as picshow.php
Code: :

<?php

if (!isset($mainfile)) {
include("mainfile.php");
}

$index = 0;
include("header.php");
OpenTable();
$sl = $show;
echo "
<center><h3><a href=\"javas c r i p t:history.back()\">Go back!<br><br>
<img src=$sl border=\"2\" width=\"100%\"></a></h3>
</center>";
Closetable();
include("footer.php");

?>



Upload picshow.php to root/

Create a folder called "pictures" and upload an empty index.html to this folder. In this folder you upload all your photos to create a randomizer.
If you only want to display 1 picture, then upload just 1 photo into that folder.

Activate the block in the admin panel.


BL






I have succeeded in creating a random picture block following your instruction. It is a very nice addition to my website.
I removed "Go back" link since it does not work.
One thing: how to center the thumbnail image inside the block?

(The picture is now vertically centered after I removed an extra <br> at the end of the code for the picture link.
--- 21/9/2005 )


Many thanks, BL, for your help.




Attention! You are currently viewing sitemap page!
We strongly suggest to look at original content

Search from web

Valid HTML 4.01 Valid CSS