<div>Hi All</div>
<div> </div>
<div>1. I debugged further, looks line "$directory = opendir("himg");" is taking lot of time. The himg folder is in same path as that of page.tpl.php.</div>
<div>Not sure why ths problem is coming. Any input?</div>
<div> </div>
<div> </div>
<div>2. I just commented line "$directory = opendir("himg");" and declared an array and harcoded file names.</div>
<div>3. After that I faced the problem with below two lines.</div>
<div> </div>
<div>header('Content-Type: image/jpeg');<br>imagejpeg($image);</div>
<div> </div>
<div>With this it is printing some junk characters in screen and after that it is printing page.tpl.php file.</div>
<div> </div>
<div>Any suggestions how to get-rid of this problem.</div>
<div> </div>
<div>Regards,</div>
<div>Austin</div>
<div>----------------------</div>
<div> </div>
<div>Hi All<br>Thanks for your input.<br> <br>Out of curosity, I just put some PHP code (as shown below in blue and red color) , and independently it is rotating images present in folder "himg" properly.<br>I have a sub-theme myzen (based on Zen theme). I have put page.tpl.php in myzen\templates folder.<br>
I added same code to page.tpl.php in head section. When I access site, it takes more time and gets error "Time exceeds" and "SQL server gone away".<br> <br>Can somebody point out whats gooing wrong here?<br>
<br> <?php</div>
<p> <br>function endswith($string, $test) <br>{ </p>
<p> $strlen1 = strlen($string); <br> $testlen = strlen($test); <br> if($strlen1 < $testlen) <br> return FALSE;<br> $diff = $strlen1 - $testlen;<br> $strend = substr($string, $diff);<br> return ($strend == $test); <br>
} <br> <br>$directory = opendir("himg");</p>
<p>while ( FALSE !== ($file = readdir( $directory )) ) <br>{</p>
<p> if(endswith($file, "jpg"))<br> {<br> $files[] = $file; <br> }<br>}</p>
<p>//Calculate a random value</p>
<p>$which = rand(0,sizeof($files)-1) ;<br> <br>$imagepath="himg/" . $files[$which];</p>
<p>//print $which;<br>$image=imagecreatefromjpeg($imagepath);<br>$imgheight = imagesy($image);<br>$imgcolor = imagecolorallocate($image, 255, 255, 55);</p>
<p>imagestring($image, 30, 110, $imgheight - ($imgheight - 65), "Example Text..", $imgcolor);<br>header('Content-Type: image/jpeg');<br>imagejpeg($image);<br>?><br> </p>
<p>Regards,<br>Austin</p>