Plugin urls rewritten in headers?

orionrush / 2010-12-13 13:14:50   

Hey folks, running into a problem I cant get my head around.

here is a link to my testing page on: stillstatic.tv.

I'm creating a plugin which:
queries indexhibit for the section number of the loading page,
then checks to see if there is a corresponding file and subdirectory for it.
If so it loads a bit of js, and html to insert a swf movie into the background.
else posts an error in its place.

However, while the URL string seems to be phrased properly (my error code generates a valid link to the file ie: http://www.stillstatic.tv/files/swfBg/11/18o.swf)

When I look at the source for the rendered page, the URL is correct yet the the response headers Im seeing in firebug show that the browser is going to http://www.stillstatic.tv/18o.swf instead!?

Im new to PHP and writing plugins so I don't know how to tackle this. Any Ideas?
I've got further notes on the test page I've been working on - check it out at
http://www.stillstatic.tv/index.php?/about/test/

Here is the plugin code:

  1. <?php if defined'SITE' exit'No direct script access allowed'
  2. /*
  3. * Plugin swfBg
  4. * @version .02b
  5. * @author Ben Rush 
  6. *
  7. */
  8. /* //use <plug:test_plugin sec_id='<%section_id%>', pg_num='<%id%>', base_url='<%baseurl%>'/> */
  9. function test_plugin$sec_id $pg_num $base_url
  10. $swfBg_name  '18o.swf'
  11. $swfBg_url  $base_url'/files/swfBg/'$sec_id'/'$swfBg_name
  12. //$swfBg_url = 'http://www.stillstatic.tv/files/swfBg/11/18o.swf';// neither work
  13. if  file_exists$swfBg_url
  14. $swfBg_insert  <<< EOH
  15. <script language="javascript">
  16. if (AC_FL_RunContent == 0) {
  17. alert("This page requires AC_RunActiveContent.js.");
  18. } else {
  19. AC_FL_RunContent(
  20. 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
  21. 'width', '100%',
  22. 'height', '100%',
  23. 'src', '$swfBg_url',
  24. 'quality', 'high',
  25. 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
  26. 'align', 'middle',
  27. 'play', 'true',
  28. 'loop', 'true',
  29. 'scale', 'showall',
  30. 'wmode', 'transparent',
  31. 'devicefont', 'false',
  32. 'id', '18o',
  33. 'name', '18o',
  34. 'menu', 'false',
  35. 'allowFullScreen', 'false',
  36. 'allowScriptAccess','always',
  37. 'movie', '18o',
  38. 'salign', ''
  39. ); //end AC code
  40. }
  41. </script>
  42. <noscript>
  43. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="18o" align="middle">
  44. <param name="allowScriptAccess" value="always" />
  45. <param name="allowFullScreen" value="false" />
  46. <param name="movie" value='$swfBg_url' />
  47. <param name="quality" value="high" />
  48. <param name="bgcolor" value="#ffffff" />
  49. <param name="wmode" value="transparent"> 
  50. <param name="bgcolor" value="#ffffff" />
  51. <embed src='$swfBg_url' quality="high" wmode="transparent" bgcolor="#ffffff" width="100%" height="100%" name="18o" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
  52. </object>
  53. </noscript>
  54. EOH
  55. return $swfBg_insert
  56. else$swfBg_insert  <<< EOH
  57. <span class="plugin_error" style='background-color:red; margins:3px; display: inline-block; border-style: dashed;'>Oops! there's been an error!<br/> page details: section id = $sec_id, page number =  $pg_num <br/>
  58. the swf file couldn't be reached, is it there? <a href='$swfBg_url' title='$swfBg_url'>$swfBg_url</a></span>
  59. EOH
  60. return $swfBg_insert
  61. ?>
orionrush / 2010-12-13 13:17:40   

second try at posting the code

  1. <?php if defined'SITE' exit'No direct script access allowed'
  2. /*
  3. * Plugin swfBg
  4. * @version .02b
  5. * @author Ben Rush 
  6. *
  7. */
  8. /* use <plug:test_plugin sec_id='<%section_id%>', pg_num='<%id%>', base_url='<%baseurl%>'/> */

function test_plugin($sec_id, $pg_num, $base_url)
{
$swfBg_name = '18o.swf';

$swfBg_url = $base_url.'/files/swfBg/'.$sec_id.'/'.$swfBg_name;
//$swfBg_url = 'http://www.stillstatic.tv/files/swfBg/11/18o.swf';// neither work

if ( file_exists($swfBg_url)){
$swfBg_insert = <<< EOH
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '100%',
'height', '100%',
'src', '$swfBg_url',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'transparent',
'devicefont', 'false',
'id', '18o',
'name', '18o',
'menu', 'false',
'allowFullScreen', 'false',
'allowScriptAccess','always',
'movie', '18o',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="18o" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="false" />
<param name="movie" value='$swfBg_url' />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent">
<param name="bgcolor" value="#ffffff" />
<embed src='$swfBg_url' quality="high" wmode="transparent" bgcolor="#ffffff" width="100%" height="100%" name="18o" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>
</noscript>
EOH;

return $swfBg_insert;
}
else{$swfBg_insert = <<< EOH
<span class="plugin_error" style='background-color:red; margins:3px; display: inline-block; border-style: dashed;'>Oops! there's been an error!<br/> page details: section id = $sec_id, page number = $pg_num <br/>
the swf file couldn't be reached, is it there? <a href='$swfBg_url' title='$swfBg_url'>$swfBg_url</a></span>
EOH;
return $swfBg_insert;
}

}
?>

orionrush / 2010-12-13 13:18:16   

bah!

Vaska A / 2010-12-13 13:20:56   

Our fourm really needs to renovation to handle code better...soon..

But this...

  1. $swfBg_name  '18o.swf'
  2. $swfBg_url  $base_url'/files/swfBg/'$sec_id'/'$swfBg_name

Can you repost just these two lines?

Vaska A / 2010-12-13 13:21:27   

And, with a simple edit to the root index.php file you can have the section_id...you don't need to make a new query for that.

Vaska A / 2010-12-13 13:24:05   

hey ben, i'm on ichat/aim right now...wanna chat? as 'indexhibit'...

sorry i didn't get back to you...things are kinda busy... ;)

Vaska A / 2010-12-13 13:33:45   

The first place I would look would be the htaccess file...what's in it?

Vaska A / 2010-12-13 13:37:39   

Also, I don't see where you are actually trying to use the plugin...where?

Vaska A / 2010-12-13 13:47:47   

A quick rewrite...

  1. <?php if defined'SITE' exit'No direct script access allowed'
  2. /*
  3. * Plugin swfBg
  4. * @version .02c
  5. * @author Ben Rush 
  6. *
  7. */
  8. /* use <plug:test_plugin /> */
  9. function test_plugin
  10.     global $rs
  11.     $swfBg_name  '18o.swf'
  12.     $swfBg_url  $rs'baseurl'  '/files/swfBg/'  $rs'section_id'  '/'  $swfBg_name
  13.     //$swfBg_url = 'http://www.stillstatic.tv/files/swfBg/11/18o.swf';// neither work    
  14.     // exists
  15.     if file_exists$swfBg_url
  16.     
  17.         $swfBg_insert  <<< EOH
  18.         <script language="javascript">
  19.         if (AC_FL_RunContent == 0) {
  20.         alert("This page requires AC_RunActiveContent.js.");
  21.         } else {
  22.         AC_FL_RunContent(
  23.         'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
  24.         'width', '100%',
  25.         'height', '100%',
  26.         'src', '$swfBg_url',
  27.         'quality', 'high',
  28.         'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
  29.         'align', 'middle',
  30.         'play', 'true',
  31.         'loop', 'true',
  32.         'scale', 'showall',
  33.         'wmode', 'transparent',
  34.         'devicefont', 'false',
  35.         'id', '18o',
  36.         'name', '18o',
  37.         'menu', 'false',
  38.         'allowFullScreen', 'false',
  39.         'allowScriptAccess','always',
  40.         'movie', '18o',
  41.         'salign', ''
  42.         ); //end AC code
  43.         }
  44.         </script>
  45.         <noscript>
  46.         <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="18o" align="middle">
  47.         <param name="allowScriptAccess" value="always" />
  48.         <param name="allowFullScreen" value="false" />
  49.         <param name="movie" value='$swfBg_url' />
  50.         <param name="quality" value="high" />
  51.         <param name="bgcolor" value="#ffffff" />
  52.         <param name="wmode" value="transparent"> 
  53.         <param name="bgcolor" value="#ffffff" />
  54.         <embed src='$swfBg_url' quality="high" wmode="transparent" bgcolor="#ffffff" width="100%" height="100%" name="18o" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
  55.         </object>
  56.         </noscript>
  57.         EOH;
  58.     }
  59.     else // doesn't exist
  60.     {
  61.         $swfBg_insert = <<< EOH
  62.         <span class="plugin_error" style='background-color:red; margins:3px; display: inline-block; border-style: dashed;'>Oops! there's been an error!<br/> page details: section id = $rssection_id, page number = $rsid <br/>
  63.         the swf file couldn't be reached, is it there? <a href='$swfBg_url' title='$swfBg_url'>$swfBg_url</a></span>
  64.         EOH;
  65.     }    
  66.     return $swfBg_insert;
  67. }
Vaska A / 2010-12-13 13:48:11   

Darn...forum is sucky with alot of code...

Vaska A / 2010-12-13 13:52:13   

http://dl.dropbox.com/u/364434/plugin.test_plugin.php.txt

orionrush / 2010-12-13 13:59:30   

wow - fast!
In the test page I posted, the error is generated by the plugin on the test page - so it is in there - I'll move it into the template index once I've got the bugs out.

  1. Another try at those lines of code:
  2. $swfBg_name = '18o.swf';
  3. $swfBg_loc = '/files/swfBg/';

$swfBg_url = $base_url . $swfBg_loc . $sec_id .'/'. $swfBg_name;

I burned the htacess file on a pike in the public square - as an example to all others who might misbehave! - But the cowards are still hiding.

  1. RewriteEngine on 
  2. RewriteCond %{REQUEST_FILENAME} -f [OR]
  3. RewriteCond %{REQUEST_FILENAME} -d
  4. RewriteRule ^(.+) - [PT,L]
  5. RewriteRule ^(.+) index.php
Vaska A / 2010-12-13 14:54:39   

The problem was easy...it was an openbasedir restriction (should have caught it sooner). Meaning, we needed the server path to use with file_exists...an "http" is not sufficient.

The code above has been badly messed up...for future viewers I don't recommend trying to play with it. ;)

orionrush / 2010-12-13 15:08:04   

Once I get a completed version I'll post a link - thanks again Vaska

This thread has been closed, thank you.