Re: Can't hide javascript with PHP :(



Xu, Qian wrote:
jh3an wrote:
How are you ? I purchased godaddy web hosting service, and tried to
hide my javascript file with PHP.

But it does not work, I don't know what makes it wrong.
index page does not load javascript file, i guess.
Please help..!! what should I do ?

Here is my index.php, and script.php:
"index.php":
<?
session_start();
if(!session_is_registered('allow_script'))
{
session_register('allow_script');
$allow_script = true;
}
?>
<html>
<head>
<script language="JavaScript" src="script.php" ></script>
.
.


"script.php":
<?
session_start();
if($allow_script)
{
header("Content-type:text/javascript");
?>

alert("HIDE");

<?
$allow_script = false;
}
?>

Here is my php.ini contents:
register_globals = on
allow_url_fopen = on

expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
extension_dir = ./
upload_tmp_dir = /tmp
precision = 12
url_rewriter.tags =
"a=href,area=href,frame=src,input=src,form=,fieldset="

I do not understand you question very well.
But some tips might be helpful:
1. Use '<?php' instead of '<?'
2. Use ob_start() when you generate /raw/ contents



There is no need to use ob_start() - and doing so slows down the delivery of pages and has a negative effect on the server.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: [PHP] cache control with javascript
    ... > PHP) to be cached if the user agent allows it? ... make the call to "generate" the javascript file each time. ... Do You Yahoo!? ...
    (php.general)
  • Re: [PHP] cache control with javascript
    ... actually a PHP file that produces the JavaScript that I need. ... The customer database can get potentially large so that this file could take ... >> PHP) to be cached if the user agent allows it? ... This list is written to the javascript file ...
    (php.general)
  • Re: Javascript "require_once()" Equivalent?
    ... > In PHP, there is a require_oncefunction which includes a file only ... > javascript file has been included already? ... But then there is no need for a test as loading client-side scripts ...
    (comp.lang.javascript)
  • cache control with javascript
    ... Does anybody know how I can make force a javascript file (written in PHP) to ... This list is written to the javascript file for the menu. ... force it to be cached (unless of course the user agent doesn't allow it) so ... I have searched through the php.net website and even through the HTTP/1.1 ...
    (php.general)