Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse Error

Status
Not open for further replies.

deecee

Technical User
Aug 25, 2001
1,678
0
0
US
Ok here is what im trying to do --

Im trying to protect my files from being downloaded by anyone so i have a file called download.php (a script i got off the net) that holds any domains that can download my files. It also hides the locations of the files. problem is when i go to enter the urls that can download i have an issue Some of the urls are dynamic and change and i dont want to enter 500 urls. For example i have

the id could be anynumber so in my link for the download i use

Code:
<a href=&quot;[URL unfurl="true"]http://www.mysite.com/new/home/download.php?site=1&file=<?php[/URL] echo $row_recordset1['logo hi-res']; ?>&dl=<?php echo $id; ?>&quot; class=&quot;default&quot;>[code]

where $id is :  $id = $_GET['brand'];

so now i pass that over to download.php

here is the line for accepted urls to donwload

[code]$okaysites = array(&quot;[URL unfurl="true"]http://mysite.com&quot;,&quot;http://www.mysite.com&quot;,&quot;http://www.mysite.com/new/brands/logos.php&quot;,&quot;http://www.mysite.com/new/brands/detail.php?brand=$_GET[/URL]['dl']&quot;);

the last url is annoying me -- i have tried everything from echo to &quot;&quot; to '' to \&quot; and i dont know how to get that variable to process into the download.php file.

My error that i get is

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /usr/local/psa/home/vhosts/brandsupplier.com/httpdocs/new/home/download.php on line 26

I gave you line 26 above -- its the one with array

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
You can't use an associative array reference inside a string. You must use explicit string concatentation.

Instead of something like:

$a = &quot;foo: $foo['foo']&quot;;

(whith will cause the parse error), do something like:

$a = &quot;foo: &quot; . $foo['foo'];


Want the best answers? Ask the best questions: TANSTAAFL!!
 
now i get this error

Parse error: parse error, expecting `')'' in /usr/local/psa/home/vhosts/brandsupplier.com/httpdocs/new/home/download.php on line 28


hers line 28

Code:
$okaysites = array(&quot;[URL unfurl="true"]http://mysite.com&quot;,&quot;http://www.mysite.com&quot;,&quot;http://www.mysite.com/new/brands/logos.php&quot;,&quot;http://www.mysite.com/new/brands/detail.php?brand=&quot;[/URL] .$_GET['id'];);

i also tried just $id instead of $_GET['id']

i am defining $id = $_GET['dl']; so id is good

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
Try taking out a ;

so

.$_GET['id'];);


looks like

.$_GET['id']);

HTH

NigeB
 
that didnt work

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
well it got rid of the error but the file wont download -- i go the the denied page for leeching

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
here is the whole code

Code:
$dl = $_GET['dl'];

$ADMIN[defaulturl] = &quot;[URL unfurl="true"]http://www.brandsupplier.com/new&quot;;[/URL]

$okaysites = array(&quot;[URL unfurl="true"]http://brandsupplier.com&quot;,&quot;http://www.brandsupplier.com&quot;,&quot;http://www.brandsupplier.com/new/brands/logos.php&quot;,&quot;http://www.brandsupplier.com/new/brands/detail.php?brand=[/URL] &quot;.$_GET['dl']);

$ADMIN[url_1] = &quot;[URL unfurl="true"]http://www.brandsupplier.com/new/logos/Hi-Res/&quot;;[/URL]

//////////////////////////////////////////////////////

$reffer = $HTTP_REFERER;
if($reffer) {
$yes = 0;
while(list($domain, $subarray) = each($okaysites)) {
if (ereg(&quot;$reffer&quot;,$subarray)) {
$yes = 1;
}
}
$theu = &quot;url&quot;.&quot;_&quot;.&quot;$site&quot;;
if ($ADMIN[$theu] AND $yes == 1) {
header(&quot;Location: $ADMIN[$theu]/$file&quot;);
} else {
header(&quot;Location: $ADMIN[defaulturl]&quot;);
}
} else {
header(&quot;Location: $ADMIN[defaulturl]&quot;);
}

the issues is by $okaysites -- these are sites that can download from the script i need to get $id from the top of the script into a url in $okaysites

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
There twop problems I can see with your script.

there is no guaranty that [ignore]$HTTP_REFERER[/ignor] will be available. Most browsers allow the user to turn on and off referer reporting. Also, if your user points his browser to your script, even with referer reporting turned on, there will not be a referer to have sent him to your site.

It is more appropriate to use &quot;&&&quot; than &quot;AND&quot; in a condition. They are logically equivalent, but &quot;AND&quot; has a much higher precedence than &quot;&&&quot;. This can cause problems sometimes.




Want the best answers? Ask the best questions: TANSTAAFL!!
 
I ended up using this script to protect my downloads

Code:
<?php
$dir=&quot;../logos/Hi-Res/&quot;;
if (isset($_REQUEST[&quot;file&quot;])) {
   $file=$dir.$_REQUEST[&quot;file&quot;];
   header(&quot;Content-type: application/force-download&quot;);
   header(&quot;Content-Transfer-Encoding: Binary&quot;);
   header(&quot;Content-length: &quot;.filesize($file));
   header(&quot;Content-disposition: attachment; filename=\&quot;&quot;.basename($file).&quot;\&quot;&quot;);
   readfile(&quot;$file&quot;);
} else {
   echo &quot;<a href=\&quot;[URL unfurl="true"]http://www.mystie.com/new\&quot;>You[/URL] Do Not Have Access To This Page!!!</a>&quot;;
}
?>

Are there any drawbacks to this? (im sure there are but what are the major ones)

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top