Aaron Parecki

Contact Me
 
 

PHP source code for website interface

(Sorry for the lack of comments)
  1. <h1>Multimedia Tools Projects</h1> 
  2. <p></p> 
  3.  
  4. <?php 
  5.     $numcols 28
  6.     $numrows 16
  7.     $size 560 $numcols
  8.  
  9.     $rndinterval 7000
  10.     $rndminimum 3000
  11.  
  12. //    $ReservedCells[cell/img/link][id] 
  13.     $ReservedCells["cell"][0] = "13-17"
  14.     $ReservedCells["img"] [0] = "link1.gif"
  15.     $ReservedCells["link"][0] = "2p1"
  16.     $ReservedCells["cell"][1] = "14-14"
  17.     $ReservedCells["img"] [1] = "link2.gif"
  18.     $ReservedCells["link"][1] = "2p2a"
  19.     $ReservedCells["cell"][4] = "14-15"
  20.     $ReservedCells["img"] [4] = "link2.gif"
  21.     $ReservedCells["link"][4] = "2p2b"
  22.     $ReservedCells["cell"][2] = "13-12"
  23.     $ReservedCells["img"] [2] = "link3.gif"
  24.     $ReservedCells["link"][2] = "2p3"
  25.     $ReservedCells["cell"][3] = "13-10"
  26.     $ReservedCells["img"] [3] = "link4.gif"
  27.     $ReservedCells["link"][3] = "2p4"
  28.  
  29.  
  30.     // cell color distribution 
  31.     $cellcolor[] = "blue.gif"
  32.     $cellcolor[] = "blue.gif"
  33.     $cellcolor[] = "blue.gif"
  34.     $cellcolor[] = "blue.gif"
  35.     $cellcolor[] = "green.gif"
  36.     $cellcolor[] = "green.gif"
  37.     $cellcolor[] = "green.gif"
  38.     $cellcolor[] = "green.gif"
  39.     $cellcolor[] = "lgrey.gif"
  40.  
  41.  
  42. // pull out all "link"s and generate image array 
  43. //   for rollover images based on link name (2p1) 
  44.  
  45. //    $ImgData[link][cell/img][id] 
  46.  
  47.     $path "img/"
  48.     $file = new File(); 
  49.     $tmp_array = array(); 
  50.     $tmp_array $file->get_files("$path","gif"); 
  51.  
  52.     foreach( $ReservedCells["link"] as $link ) { 
  53.         $cnt 0
  54.         while ( list( $key$filename ) = each$tmp_array ) ) { 
  55.             if( substr($filename,0,strlen($link)) == $link ) { 
  56.                 $cellid str_replace($link."_","",$filename); 
  57.                 $cellid str_replace(".gif","",$cellid); 
  58.                 $ImgData[$link][$cnt]["cell"] = $cellid
  59.                 $ImgData[$link][$cnt]["img"] = $filename
  60.                 $cnt++; 
  61.             } 
  62.         } 
  63.         reset($tmp_array); 
  64.     } 
  65.  
  66. // now there is an array of all the 20x20 images, still have to 
  67. //   transfer it to javascript though 
  68.  
  69. ?> 
  70. <style type="text/css"> 
  71.     table.grid 
  72.     { 
  73.       border-spacing: 0px; 
  74.       border-collapse: collapse; 
  75.     } 
  76.     td.grid 
  77.     { 
  78.       border: 1px #FFFFFF solid; 
  79.       padding:0px; 
  80.       font-size:10pt; 
  81.     } 
  82. </style> 
  83. <script language="javascript" type="text/javascript"> 
  84. <!-- 
  85.  
  86. Array.prototype.inArray = function (value) 
  87. // Returns true if the passed value is found in the 
  88. // array.  Returns false if it is not. 
  89.     var i; 
  90.     for (i=0; i < this.length; i++) { 
  91.         // Matches identical (===), not just similar (==). 
  92.         if (this[i] === value) { 
  93.             return true; 
  94.         } 
  95.     } 
  96.     return false; 
  97. }; 
  98.  
  99. var cellcolor = new Array(); 
  100. <?php 
  101.     for( $i=0$i count($cellcolor); $i++ ) { 
  102.         echo "cellcolor[$i] = '".$cellcolor[$i]."';\n"
  103.     } 
  104. ?> 
  105.  
  106. <?php 
  107. // print javascript array for reserved cells for links 
  108.     echo "var ReservedCells = new Array();\n"
  109.     for( $i=0$i count($ReservedCells["cell"]); $i++ ) { 
  110.         echo "ReservedCells[$i] = '".$ReservedCells["cell"][$i]."';\n"
  111.     } 
  112. // end reserved cells 
  113.  
  114. // copy 20x20 image array to javascript array 
  115.     echo "var ImgData = new Array();\n"
  116.     $cnt 0
  117.     while( list($link$value) = each($ImgData) ) { 
  118.         echo "ImgData['$link'] = new Array();\n"
  119.         $id 0
  120.         while( list($null$value2) = each($ImgData[$link]) ) { 
  121.             $linkn $value2["cell"]; 
  122.             echo "ImgData['$link'][$id] = new Array();\n"
  123.             echo "ImgData['$link'][$id]['cell'] = '".$linkn."';\n"
  124.             echo "ImgData['$link'][$id]['img'] = '".$value2["img"]."';\n"
  125.             $id++; 
  126.         } 
  127.         $cnt++; 
  128.     } 
  129. // end image data cells 
  130. ?> 
  131.  
  132. var rndinterval = <?php echo $rndinterval?>
  133. var rndminimum = <?php echo $rndminimum?>
  134.  
  135. function StartTimers() { 
  136. var rndTime = 0; 
  137.     timerPause = 0; 
  138.     for(i=1; i<=<?php echo $numrows?>; i++) { 
  139.         for(j=1; j<=<?php echo $numcols?>; j++) { 
  140.             rndTime = Math.floor(Math.random()*rndinterval)+rndminimum; 
  141.             setTimeout('ChangeBkg("'+i+"-"+j+'")',rndTime); 
  142.         } 
  143.     } 
  144.  
  145. function ChangeBkg(cellid) { 
  146.     if( !ReservedCells.inArray(cellid) ) { 
  147.         document.images[cellid].src=cellcolor[Math.floor(Math.random()*cellcolor.length)]; 
  148.         rndTime = Math.floor(Math.random()*rndinterval)+rndminimum; 
  149.         setTimeout("ChangeBkg('"+cellid+"')",rndTime); 
  150.     } 
  151.  
  152. function ShowBigPic(link) { 
  153.     path = '<?php echo $path?>'; 
  154.     obj = ImgData[link]; 
  155.     for( var cells in obj ) { 
  156.         cellid = ImgData[link][cells]["cell"]; 
  157.         cellimg = ImgData[link][cells]["img"]; 
  158.         document.images[cellid].src = path + cellimg; 
  159.     } 
  160.  
  161. StartTimers(); 
  162. //--> 
  163. </script> 
  164.  
  165. <table class="grid"> 
  166. <?php 
  167. for( $row=1$row<=$numrows$row++ ) { 
  168.     echo "<tr>\n"
  169.     for( $col=1$col<=$numcols$col++ ) { 
  170.         if( in_array("$row-$col"$ReservedCells["cell"]) ) { 
  171.             $index array_search("$row-$col"$ReservedCells["cell"]); 
  172.             $ahref_open "<a href=\"".$ReservedCells["link"][$index]."\" onMouseOver=\"ShowBigPic('".$ReservedCells["link"][$index]."');\">"
  173.             $ahref_close "</a>"
  174.             $src $ReservedCells["img"][$index]; 
  175.         } else { 
  176.             $src $cellcolor[rand(0,count($cellcolor)-1)]; 
  177.             $ahref_open ""
  178.             $ahref_close ""
  179.         } 
  180.         echo "<td class=\"grid\">$ahref_open<img src=\"$src\" width=\"$size\" height=\"$size\" id=\"$row-$col\" name=\"$row-$col\">$ahref_close</td>\n"
  181.     } 
  182.     echo "</tr>\n"
  183. ?> 
  184. </table>