OnlineSchoolData
OnlineSchoolData
   
   
Home
Solutions
Tools
Security
Links
Our Philosophy
Our Clients
Contact Us
Share

Free Technology Tools


Dear Visitor:

Feel free to copy and use these tools. All code segments do not rename, delete, or maniputate files and/or directory structures in any way, shape, or form.

Feel free to contact us if you have any questions about these tools. Please, contact us only via e-mail.

Also, if you found any information useful, drop us a note.

 

 

 
   
   

Do You Have the Necessary Tools?


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Some tools shared below use php. Most servers support php. To check if your server supports php you can either contact your webmaster or use a text editor and create a file containing the following three lines:


<?php
echo phpinfo();
?>


The output should be similar to this. If you see the php banner indicating the version ID, you have access to php. Integrating php with html is simple. First, the pages must be named .php instead of .htm or .html. If your page ends with .php, you can embed php commands. Visit the official php site for detailed information.


Also, you would want to make sure that Javascript is enabled. Check your browser's settings for that. Oh, by the way, use Mozilla Firefox as your default browser, especially if you are a Windows user.

 

Display Images Randomly


I wrote this simple script having the need to display images randomly. Works best if the images are the same aspect ratio.

  1. Create a directory/folder that will contain a few images. I will assume that this directory is called images. No other files or directories should be there.
  2. The file where the random images is at the root of the web site.
  3. In the file where you want the random images add the following:
    <?php
      if ($handle = opendir('random')) {
        // Loop over the directory and count the files
        $counter = 0;
        $image_names = array();
        while (false !== ($file = readdir($handle))) {
          if ( ($file != '.') and ($file != '..') ) {
            $image_names[$counter] = $file;
            $counter++;
          }
        }
        $counter--;
        //print_r($image_names);
        //print $counter . "<br>";
        //print "There are " . $counter . " files<br>";
        $pick_image = rand(0, $counter);
        //print "$image_names[$pick_image] = $pick_image<br>";
        closedir($handle);
      }
      print "<img src=\"random/" . $image_names[$pick_image] . "\" width=\"200\" height=\"150\" border=\"0\" alt=\"Random image\" align=\"middle\" title=\"Random image #$pick_image from an array of $counter images ($image_names[$pick_image])\">";
      //print "<br>" . $image_names[$pick_image] . "->" . $pick_image;
    ?>

In this case, the images were 100x150 pixes. You will need to adjust those two numbers to the size of your own images. To help you understand the code, remove the comments (//) to print debug statements.


 

Create An Image Gallery


This implementation uses frames. It requires you to have images in this configuration: the full size image and its thumbnail. I use, irfanview, a nifty MS Windows program to create images in bulk mode.

The thumbnails start with "thumb_" and can be of any type.

You need to create three files: 1) the frame definition, 2) left.php, and 3) right.html. All three files will reside in the same directory as the images.

The file left.php creates two named anchors for the top and the bottom of the left frame. The left.php file itself is created dynamically and its contents will be based the number of images it will find in the directory.


The Frame Definition:

    <HTML>
      <HEAD>
        <TITLE>Show Images</TITLE>
      </HEAD>
      <FRAMESET COLS="20%,*">
        <FRAME SRC="left.php" NAME=left>
        <FRAME SRC="right.html" NAME=right>
      </FRAMESET>
    </HTML>

The file left.php

<?php
    if ($handle = opendir('.')) {
      // Loop over the directory and count the files
      $counter = 0;
      $accumulator = "<html>\n<body>\n<div align=\"center\"><h2>Thumbnails</h2></div><a name=\"top\"></a>\n<p> </p>";
      while (false !== ($file = readdir($handle))) {
        if ( ($file != '.') and ($file != '..') and (stristr($file, 'thumb_')) ) {
          $counter++;
          $accumulator = $accumulator . "Go to: <a href=\"#top\">top</a>/<a href=\"#bottom\"<bottom</a</<a href=\"http://www.this.that.php\" target=\"_top\"<Home Page</a<\n";
          $accumulator = $accumulator . "<p><a href=\"" . substr(stristr($file, '_'), 1) . "\" target=right><img src=\"" . $file . "\" alt=\"" . $file . "\" BORDER=0></a></p>";
        }
      }
      $accumulator = $accumulator . "<a name=\"bottom\"></a>\n</body></html>";
      closedir($handle);
      print $accumulator;
    }
?>

The file right.php

    <html>
      <body>
        <div align="center"><h1>Photographs: Credits Here</h1>
        </div> <p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
        <div align="center"><h1>Click on a thumbnail to view the full image.</h1></div>
      </body>
    </html>