FoundScripts

Empire

http://www.naarvoren.nl/artikel/hover.html

Pulldown Links with text description underneath

<!--Example drop down menu 1-->

<form name="form1">
<select name="select1" size="1" style="background-color:#FFFFD7" onChange="displaydesc(document.form1.select1, thetext1, 'textcontainer1')">
<option selected value="http://www.javascriptkit.com">JavaScript Kit </option>
<option value="http://freewarejava.com">Freewarejava.com</option>
<option value="http://wired.com" target="newwin">Wired News</option>
<option value="http://www.news.com">News.com</option>
<option value="http://www.codingforums.com" target="newwin">Coding Forums</option>
</select>
 <input type="button" value="Go" 
onClick="jumptolink(document.form1.select1)"><br>
<span id="textcontainer1" align="left" style="font:italic 13px Arial">
</span>
</form>

<!--Example drop down menu 2-->

<form name="form2">
<select name="select2" size="1" style="background-color:#E3FFDF" onChange="displaydesc(document.form2.select2, thetext2, 'textcontainer2')">
<option selected value="http://www.cnn.com">CNN</option>
<option value="http://www.msnbc.com">MSNBC</option>
<option value="http://news.bbc.co.uk">BBC News</option>
<option value="http://www.theregister.com/">The Register</option>
</select>
 <input type="button" value="Go" 
onClick="jumptolink(document.form2.select2)"><br>
<span id="textcontainer2" align="left" style="font:italic 13px Arial">
</span>
</form>



<!--IMPORTANT: Below script should always follow all of your HTML codes above, and never proceed them-->
<!--To be safe, just add below script at the end of your page-->

<script type="text/javascript">

/***********************************************
- Drop down menu w/ description- © Dynamic Drive (www.dynamicdrive.com)
- This notice must stay intact for use
- Visit http://www.dynamicdrive.com/ for full source code
                                                                                            - /

//1) CUSTOMIZE TEXT DESCRIPTIONS FOR LINKS ABOVE
var thetext1=new Array()
thetext1[0]="Comprehensive JavaScript tutorials and over 400+ free scripts"
thetext1[1]="Direct link to hundreds of free Java applets online!"
thetext1[2]="Up to date news on the technology front"
thetext1[3]="News.com- The #1 technology News site."
thetext1[4]="Web Coding and development forums"

/// You may define additional text arrays if you have multiple drop downs:
var thetext2=new Array()
thetext2[0]="CNN- US and World News."
thetext2[1]="MSNBC- NBC News online."
thetext2[2]="BBC News- Updated every minute of every day."
thetext2[3]="TheRegister- Daily IT news."

// Now, see 2) below for final customization step

function displaydesc(which, descriptionarray, container){
if (document.getElementById)
document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
}

function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}

//2) Call function displaydesc() for each drop down menu you have on the page
//   This function displays the initial description for the selected menu item
//   displaydesc(name of select menu, name of corresponding text array, ID of SPAN container tag):
//   Important: Remove the calls not in use (ie: 2nd line below if there's only 1 menu on your page)

displaydesc(document.form1.select1, thetext1, 'textcontainer1')
displaydesc(document.form2.select2, thetext2, 'textcontainer2')

</script>

Pulldown Links to new window

<form name="form1">
    <select name="favs1" onChange="window.open(this.options[this.selectedIndex].value)">
    <option selected>Favourites</option>
    <option>-------------------</option>
    <option value="http://www.yahoo.com">Yahoo!</option>
    <option value="http://www.altavista.com">Altavista</option>
    </select>
</form>

Pulldown Links to sized pop out window

<-- To use this type, copy the following javascript to your pages <HEAD> tags
<SCRIPT language="Javascript">
function spawnWin(options) {
 var url = options[options.selectedIndex].value;
 var winArgs = "top=50,left=50,toolbar=no,location=no,directories=no,
 status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no," ;
  winArgs+= "width=400,height=300";
  var howdy = open(url,"newlinks",winArgs);
 }
</SCRIPT>
//-->
<form name="form2">
        <SELECT NAME="newlinks" onChange="spawnWin(this.options)">
        <option selected>Favourites</option>
        <option>------------------</option>
        <option value="http://www.yahoo.com">Yahoo!</option>
        <option value="http://www.altavista.com">Altavista</option>
        </select>
   </form>

Image Rotator RandomFunction

<?php

/*

        AUTOMATIC IMAGE ROTATOR
        Version 2.2 - December 4, 2003
        Copyright (c) 2002-2003 Dan P. Benjamin, Automatic, Ltd.
        All Rights Reserved.

        http://www.hiveware.com/imagerotator.php
        
        http://www.automaticlabs.com/
        
        
        DISCLAIMER
        Automatic, Ltd. makes no representations or warranties about
        the suitability of the software, either express or
        implied, including but not limited to the implied
        warranties of merchantability, fitness for a particular
        purpose, or non-infringement. Dan P. Benjamin and Automatic, Ltd.
        shall not be liable for any damages suffered by licensee
        as a result of using, modifying or distributing this
        software or its derivatives.
        
        
        ABOUT
        This PHP script will randomly select an image file from a
        folder of images on your webserver.  You can then link to it
        as you would any standard image file and you'll see a random
        image each time you reload.
        
        When you want to add or remove images from the rotation-pool,
        just add or remove them from the image rotation folder.


        VERSION CHANGES
        Version 1.0
                - Release version
        
        Version 1.5
                - Tweaked a few boring bugs
        
        Version 2.0
                - Complete rewrite from the ground-up
                - Made it clearer where to make modifications
                - Made it easier to specify/change the rotation-folder
                - Made it easier to specify/change supported image types
                - Wrote better instructions and info (you're them reading now)
                - Significant speed improvements
                - More error checking
                - Cleaner code (albeit more PHP-specific)
                - Better/faster random number generation and file-type parsing
                - Added a feature where the image to display can be specified
                - Added a cool feature where, if an error occurs (such as no
                  images being found in the specified folder) *and* you're
                  lucky enough to have the GD libraries compiled into PHP on
                  your webserver, we generate a replacement "error image" on
                  the fly.
                
    Version 2.1
        - Updated a potential security flaw when value-matching
          filenames

    Version 2.2
        - Updated a few more potential security issues
        - Optimized the code a bit.
        - Expanded the doc for adding new mime/image types.

        Thanks to faithful ALA reader Justin Greer for
        lots of good tips and solid code contribution!


        INSTRUCTIONS
        1. Modify the $folder setting in the configuration section below.
        2. Add image types if needed (most users can ignore that part).
        3. Upload this file (rotate.php) to your webserver.  I recommend
           uploading it to the same folder as your images.
        4. Link to the file as you would any normal image file, like this:

                        <img src="http://example.com/rotate.php">

        5. You can also specify the image to display like this:

                        <img src="http://example.com/rotate.php?img=gorilla.jpg">
                
                This would specify that an image named "gorilla.jpg" located
                in the image-rotation folder should be displayed.
        
        That's it, you're done.

- /




/* ------------------------- CONFIGURATION -----------------------


        Set $folder to the full path to the location of your images.
        For example: $folder = '/user/me/example.com/images/';
        If the rotate.php file will be in the same folder as your
        images then you should leave it set to $folder = '.';

- /


        $folder = '.';


/*      

        Most users can safely ignore this part.  If you're a programmer,
        keep reading, if not, you're done.  Go get some coffee.

    If you'd like to enable additional image types other than
        gif, jpg, and png, add a duplicate line to the section below
        for the new image type.
        
        Add the new file-type, single-quoted, inside brackets.
        
        Add the mime-type to be sent to the browser, also single-quoted,
        after the equal sign.
        
        For example:
        
        PDF Files:

                $extList['pdf'] = 'application/pdf';
        
    CSS Files:

        $extList['css'] = 'text/css';

    You can even serve up random HTML files:

            $extList['html'] = 'text/html';
            $extList['htm'] = 'text/html';

    Just be sure your mime-type definition is correct!

- /

    $extList = array();
        $extList['gif'] = 'image/gif';
        $extList['jpg'] = 'image/jpeg';
        $extList['jpeg'] = 'image/jpeg';
        $extList['png'] = 'image/png';
        

// You don't need to edit anything after this point.


// --------------------- END CONFIGURATION -----------------------

$img = null;

if (substr($folder,-1) != '/') {
        $folder = $folder.'/';
}

if (isset($_GET['img'])) {
        $imageInfo = pathinfo($_GET['img']);
        if (
            isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
        file_exists( $folder.$imageInfo['basename'] )
    ) {
                $img = $folder.$imageInfo['basename'];
        }
} else {
        $fileList = array();
        $handle = opendir($folder);
        while ( false !== ( $file = readdir($handle) ) ) {
                $file_info = pathinfo($file);
                if (
                    isset( $extList[ strtolower( $file_info['extension'] ) ] )
                ) {
                        $fileList[] = $file;
                }
        }
        closedir($handle);

        if (count($fileList) > 0) {
                $imageNumber = time() % count($fileList);
                $img = $folder.$fileList[$imageNumber];
        }
}

if ($img!=null) {
        $imageInfo = pathinfo($img);
        $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
        header ($contentType);
        readfile($img);
} else {
        if ( function_exists('imagecreate') ) {
                header ("Content-type: image/png");
                $im = @imagecreate (100, 100)
                    or die ("Cannot initialize new GD image stream");
                $background_color = imagecolorallocate ($im, 255, 255, 255);
                $text_color = imagecolorallocate ($im, 0,0,0);
                imagestring ($im, 2, 5, 5,  "IMAGE ERROR", $text_color);
                imagepng ($im);
                imagedestroy($im);
        }
}

?>

Popup window

<!--@frozen:0-->
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
mywindow = window.open(URL, "newwin", 'toolbar=0,scrollbars=,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,top=60,left=60');
}
// End -->
</script>
</head>

<body>
<A HREF="javascript:popUp('http://e8z.org')">Open Popup Window</A>
</body>
<!--@frozen:1-->
<?php

// Select display an image from and array randomly

$imagesArray = array("image1.gif", "http://topsite.com/image2.jpg", "./images/image3.png");
$randomImage = rand(sizeof($imagesArray));
print '<img src="'.$imagesArray[$randomImage].'">';

?>

<table border=0 align="center">
    <tr>
        <td align="center">
        <!-- Javascript function to change the image src -->
        <!-- Menu PHP generated from the directories images -->
<?
// lists directory images and build a numbers lines javascript linked to the pictures
// Coded Gallery by Nicolas d'Haussy

// Lists the images of this directory
$imageNb=0;
$session=opendir(".");
while ($file=readdir($session)) {

    if (is_file($file)) {

        // Check if the file is an image
        $extension = strtolower(substr(strrchr($file,  "." ), 1 ));
        if ($extension == "jpg" || $extension == "jpeg" || $extension == "gif") {

            $imageNb++;
            echo ("        <a href=\"#\" onClick=\"document.images['image'].src='" . $file . "'\">" . $imageNb . "</a>  \n");
        }
    }
}
closedir($session);
?>
        </td>
    </tr>
    <tr>
        <td align="center">
        <IMG NAME="image" src="" BORDER="0">
        </td>
    </tr>
</table> 
<table border=0>
    <tr>
        <td>
        <!-- Select menu PHP generated displaying the folder images -->
        <!-- Javascript function to change the image src -->
        <select onChange="document.images['imageSelectMenu'].src=this.options[this.selectedIndex].value" >
        <option value="" selected> Selection </option>
<?
// selectMenuGallery by Nicolas d'Haussy
// generates a navigation with select menu to display the pictures from the folder where this script is located

// Lists the images of this directory and build the select menu.
$selectMenuItems;
$session=opendir(".");
while ($file=readdir($session)) {

    if (is_file($file)) {

        // Check if the file is an image
        $extension = strtolower(substr(strrchr($file,  "." ), 1 ));
        if ($extension == "jpg" || $extension == "jpeg" || $extension == "gif") {

            // Add an option to the select menu
            $selectMenuItems .= ("        <option value=\"" . $file . "\">" . $file . "</option>\n");
        }
    }
}
closedir($session);
// Then display the dynamic menu items
echo ($selectMenuItems);
?>
        </select>
        </td>
    </tr>
    <tr>
        <td>
        <!-- Image src javascript commanded-->
        <IMG NAME="imageSelectMenu" BORDER="0">
        </td>
    </tr>
</table> 
<?
// This script scans a folder and displays all the images from this folder on the same page in full size.
// Coded Gallery by Nicolas d'Haussy


// Lists the images of this directory
$imageNb=0;
$session=opendir(".");
while ($file=readdir($session)) {

    if (is_file($file)) {

        // Check if the file is an image
        $extension = strtolower(substr(strrchr($file,  "." ), 1 ));
        if ($extension == "jpg" || $extension == "jpeg" || $extension == "JPG" || $extension == "gif") {

            echo ("<img src=\"" . $file . "\" alt=\"" . $file . "\" border=1><br><br>\n");
            $imageNb++;
        }
    }
}
echo("\n<br>" . $imageNb . " images.");
closedir($session);
?> 

http://www.onlinetools.org/articles/creating_thumbnails_all.php

//thumbnail generator

<?php 
$gd2=checkgd();
$pics=directory("pics","jpg,JPG,JPEG,jpeg,png,PNG");
$pics=ditchtn($pics,"tn_");
if ($pics[0]!=""){
	foreach ($pics as $p){
		createthumb("pics/".$p,"thumbs/tn_".$p,150,150);
	}
}
/*
	Function checkgd()
	checks the version of gd, and returns "yes" when it's higher than 2
- /
function checkgd(){
	$gd2="";
	ob_start();
	phpinfo(8);
	$phpinfo=ob_get_contents();
	ob_end_clean();
	$phpinfo=strip_tags($phpinfo);
	$phpinfo=stristr($phpinfo,"gd version");
	$phpinfo=stristr($phpinfo,"version");
	preg_match('/\d/',$phpinfo,$gd);
	if ($gd[0]=='2'){$gd2="yes";}
	return $gd2;
}

/*
	Function ditchtn($arr,$thumbname)
	filters out thumbnails
- /
function ditchtn($arr,$thumbname){
	foreach ($arr as $item){
		if (!preg_match("/^".$thumbname."/",$item)){$tmparr[]=$item;}
	}
	return $tmparr;
}

/*
	Function createthumb($name,$filename,$new_w,$new_h)
	creates a resized image
	variables:
	$name		Original filename
	$filename	Filename of the resized image
	$new_w		width of resized image
	$new_h		height of resized image
- /	
function createthumb($name,$filename,$new_w,$new_h){
	global $gd2;
	$system=explode(".",$name);
	if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);}
	if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);}
	$old_x=imageSX($src_img);
	$old_y=imageSY($src_img);
	if ($old_x > $old_y) {
		$thumb_w=$new_w;
		$thumb_h=$old_y*($new_h/$old_x);
	}
	if ($old_x < $old_y) {
		$thumb_w=$old_x*($new_w/$old_y);
		$thumb_h=$new_h;
	}
	if ($old_x == $old_y) {
		$thumb_w=$new_w;
		$thumb_h=$new_h;
	}
	if ($gd2==""){
			$dst_img=ImageCreate($thumb_w,$thumb_h);
			imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
	}else{
		$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
		imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
	}
	if (preg_match("/png/",$system[1])){
		imagepng($dst_img,$filename); 
	} else {
		imagejpeg($dst_img,$filename); 
	}
	imagedestroy($dst_img); 
	imagedestroy($src_img); 
}

/*
        Function directory($directory,$filters)
        reads the content of $directory, takes the files that apply to $filter 
		and returns an array of the filenames.
        You can specify which files to read, for example
        $files = directory(".","jpg,gif");
                gets all jpg and gif files in this directory.
        $files = directory(".","all");
                gets all files.
- /
function directory($dir,$filters){
	$handle=opendir($dir);
	$files=array();
	if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}}
	if ($filters != "all"){
		$filters=explode(",",$filters);
		while (($file = readdir($handle))!==false) {
			for ($f=0;$f<sizeof($filters);$f++):
				$system=explode(".",$file);
				if ($system[1] == $filters[$f]){$files[] = $file;}
			endfor;
		}
	}
	closedir($handle);
	return $files;
}
?>