Jump to content

PHP 5.3 issue?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
Pope Viper

Pope Viper

    Newbie

  • Members
  • Pip
  • 5 posts
I've got a forum where I had implemented a snippet of code that will rotate the banner.

There's essentially a pointer in my header template that points to HEADER.PHP I found this code on VBORG.COM, and it looks like the originator isn't supporting it anymore.

It's supposed to read a particular directory, find various image types, and randomly select one for display.

It worked perfectly under PHP 5.2.9, but under 5.3.0, it does not function at all, with no error displayed.

I'm hoping one of you brilliant guys can view the code, and point out the problem, or perhaps show me the correct path to go.

<?php

// DEFINE ACTUAL PATH TO IMAGE DATA FOLDER

	$folder = ".";

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


// DEFINE VALID EXTENSIONS AND CONTENT TYPES

	$extList = array();

	$extList['png'] = 'image/png';

	$extList['gif'] = 'image/gif';

	$extList['jpg'] = 'image/jpg';


// RETRIEVE VARIABLE DATA FROM THE QUERY

	if (isset($_GET['fid'])) { $fid = $_GET['fid']; }

	if (isset($_GET['pid'])) { $pid = $_GET['pid']; }


// VALIDATE CURRENT IMAGE DATA, CHECK FID, CHECK PID

	if (!file_exists($img) && $fid > 0) { $img = $folder . $fid . ".png"; }

	if (!file_exists($img) && $pid > 0) { $img = $folder . $pid . ".png"; }


// VALIDATE CURRENT IMAGE DATA, RANDOMIZE

	if (!file_exists($img)) {

		$fileList = array();

		$handle = opendir($folder);

		while (false != ($file = readdir($handle))) {

			$fileInfo = pathinfo($file);

			if (isset($extList[strtolower($fileInfo['extension'])])) {

				$fileList[] = $file;

			}

		}

		closedir($handle);

		if (count($fileList) > 0) {

			$imageNumber = time() % count($fileList);

			$img = $folder.$fileList[$imageNumber];

		}

	}


// POST CURRENT IMAGE DATA TO QUERY FETCH

	$imageInfo = pathinfo($img);

	$contentType = 'Content-type: '.$extList[$imageInfo['extension']];

	header ($contentType);

	readfile($img);

?>


#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
At the top of the file put:

error_reporting(E_ALL)

Right after <?php. Run it and then tell us if it produces and notices, warnings or errors.

#3
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
You might give my banner rotator a try: http://forum.codecal...d.html#post9265

#4
Pope Viper

Pope Viper

    Newbie

  • Members
  • Pip
  • 5 posts
John -
Your code was very close to what I was running, but I went ahead and created a new page with your code, moved back to PHP 5.3, and boom, it's working great.

THANK YOU!!!

#5
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Huh, you're right - they are indeed VERY similar. Perhaps the real originator is still supporting his code. :)

#6
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Nice work John! +rep

#7
Pope Viper

Pope Viper

    Newbie

  • Members
  • Pip
  • 5 posts
John.

Was wondering if you could help me a bit via PM's?

The site I'm working on is obviously using your header code (now!), but I can't seem to get a portion of it centered like I would like.

WOuld you mind?

#8
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
I would be happy to help you here so everyone can benefit from the discussion.

#9
Pope Viper

Pope Viper

    Newbie

  • Members
  • Pip
  • 5 posts
Perfect, thank you.

I run a forum, using Vbulletin 3.8.4, using a purchased, but very modified skin.


My header, consists of three images:
Header1.gif - building image on the far left.
Header.php - code that rotates the title/slogan images.
header_bg.gif - I believe this is the background that everything in the header resides upon.

The header template, where my banner items are kept is as follows:

<!-- logo -->

<a name="top"></a>


<if condition="$show['popups']">

<!-- NAVBAR POPUP MENUS -->




  <if condition="$notifications_total">

    <!-- notifications menu -->

    <div class="vbmenu_popup" id="notifications_menu" style="display:none">

        <table cellpadding="4" cellspacing="1" border="0">

        <tr><td class="thead" colspan="2">$vbphrase[your_notifications]</td></tr>

        $notifications_menubits

        </table>

    </div>

    <!-- / notifications menu -->

    </if>


  

<!-- / NAVBAR POPUP MENUS -->



</if>



<table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">

<tr>

 <td class="header" align="$stylevar[left]" nowrap="nowrap"><a href="$vboptions[homeurl]/?$session[sessionurl]"><img src="images/armada/header1.gif" alt="" border="0" /><img src="images/armada/header/header.php?" alt="" border="0" /></a>


</td>

<td align="$stylevar[right]" id="header_right_cell">

 

</tr>


<tr>

 <td bgcolor="#100404"><img src="images/armada/spacer.gif" alt="" border="0" /></td>

</tr>

<tr>

 <td bgcolor="#000000"><img src="images/armada/spacer.gif" alt="" border="0" /></td>

</tr>

<tr><td>

<!-- /logo -->



<!-- content table -->

$spacer_open

$_phpinclude_output


The HEADER.PHP, which you will probably recognize:

<?php


$folder = './';


$extList = array();

$extList['gif'] = 'image/gif';

$extList['jpg'] = 'image/jpeg';

$extList['jpeg'] = 'image/jpeg';

$extList['png'] = 'image/png';


$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);

   }

}


?> 



The problem I have is that if you go out to to the site templeofevil.com/testforum, you'll see that the title/slogan is next to the "building" image, with a great swath of emptiness to the right.

I'd like to get it centered between that building image, and the right side of the page.