Page 1 of 1

Please Help: PHP code problem

Posted: Tue Oct 19, 2004 11:13 am
by nishant
Sami | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Hello,

This is regarding a problem, which has stalled our website migration on a new server. We need some assistance in our 
code which is working perfectly on our old server but isn't on the new server. It will be a great help, if you can solve this problem.

This is a php code which calls an swf file from a directory. The directory variable is $dir[0] while $image is variable for 

swf file.

I am only giving here the line of code which isn't working. The rest of the code in the file 450.php3, i am pasting below my 

mail for reference.

My original code is -
<param name="Movie" value="./<?php echo $dir[0];?>/cards/<?php echo $image;?>">

The source code of the uploaded page, on my new server (sendlovecards.com) when i open in IE
<param name="Movie" value=".//cards/">
This is the url where i am getting this problem - http://www.sendlovecards.com/450.php3?image=70_10.swf

It actually should be something like
<param name="Movie" value="./70/cards/70_10.swf">

The url where it works perfectly (my old server)
http://www.greetingstudio.com/450.php3?image=70_10.swf

Both servers are different. The sendlovecards.com server has Red Hat Enterprise Linux,
whereas the greetingstudio.com server has Red Hat 7.x

For PHP version on sendlovecards.com server- http://sendlovecards.com/test.php3
For PHP version on greetingstudio.com server- http://greetingstudio.com/test.php3

The original code is working perfectly. I can't make any changes on the server since my hosting provider won't allow it.
I can make changes to my code below. Please suggest me the easiest way. 


Thank you very much in advance.

Regards,

Nishant


--------------------------------------450.php3 code----------------------------------------

Code: Select all

<?php
$img=0;
$swf=0;
$dir=explode("_",$image);
$file=explode(".",$dir[1]);

if($file[1]=="gif" || $file[1]=="jpg" || $file[1]=="png")
{
$img=1;
}
if($file[1]=="swf")
{
$swf=1;
}
?>
<html>
<head>
<title>GreetingStudio.com: Flash Ecards Preview</title>
</head>
<body bgcolor="#000000" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<center><br><br>

<table border="0" width="780" cellspacing="0" bgcolor="#FFFFFF" background="/images/450.gif" cellpadding="0">
<tr><td height="65" valign="top">
</td></tr>
<tr><td height="100"><center>

<a href="javascript:history.back()"><img border="0" src="../images/buttons/back.gif"></a></center></td></tr>
<tr>
<td>
<p align="center">
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" 

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="450" height="300" 

border="0" vspace="0" hspace="0" name="sjoy">
<param name="_cx" value="20373">
<param name="_cy" value="14023">
<param name="FlashVars" value="-1">
<param name="Movie" value="./<?php echo $dir[0];?>/cards/<?php echo $image;?>">
<param name="Src" value="./<?php echo $dir[0];?>/cards/<?php echo $image;?>">
<param name="WMode" value="Opaque">
<param name="Play" value="-1">
<param name="Loop" value="-1">
<param name="Quality" value="High">
<param name="SAlign" value>
<param name="Menu" value="-1">
<param name="Base" value>
<param name="AllowScriptAccess" value="always">
<param name="Scale" value="ShowAll">
<param name="DeviceFont" value="0">
<param name="EmbedMovie" value="0">
<param name="BGColor" value>
<param name="SWRemote" value><embed src="./<?php echo $dir[0];?>/cards/<?php echo $image;?>" quality="best" 

pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" 

type="application/x-shockwave-flash" width="450" height="300" border="0" name="sjoy" vspace="0" hspace="0">
</object>

</p>
</td>
</tr><tr><td height="100"></td></tr>
</table>

<!-- ########## MAIN FOOTER PAGE ENDS HERE ############### -->
</body>
</html>

Posted: Tue Oct 19, 2004 11:49 am
by John Cartwright

Code: Select all

//change $image to $_GET['image'] eg. 

<param name="Src" value="./<?php echo $dir[0];?>/cards/<?php echo $_GET['image'] ?>">
This problem is most likely because you have register globals off.

Posted: Tue Oct 19, 2004 11:50 am
by Weirdan
classical register_globals problem. Here is solution:

Code: Select all

$dir=explode("_", $_REQUEST&#1111;'image']);
$file=explode(".",$dir&#1111;1]);

Register Globals

Posted: Tue Oct 19, 2004 1:13 pm
by sternobread
I agree with their assessment of it being a register_globals problem. There is a line in your php.ini file which reads Register_Globals = Off. On your old server you probably had this value set to On.

By registering globals, php will register any variables passed along with methods such as GET, POST, or on the query string in the URL. Most people recommend that you leave this off as it opens a potential security hole where someone could pass unsolicited data to your php script.

The alternative is to use the global php vars $_POST['varname'] or $_GET['varname'] (depending on the method used) to retrieve those values.

Posted: Wed Oct 20, 2004 4:24 am
by nishant
Thanks for your help.

I am trying this out and if anything goes wrong, I will get back to you.

Thanks once again.

Nishant