Can"t hide javascript with PHP :(

Can"t hide javascript with PHP :(

am 04.04.2008 19:08:29 von jaehwang

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;
}
?>



..
..


"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="

Re: Can"t hide javascript with PHP :(

am 04.04.2008 22:18:23 von webmasterNOSPAMTHANKS

*** jh3an escribió/wrote (Fri, 4 Apr 2008 10:08:29 -0700 (PDT)):
> session_start();
> if(!session_is_registered('allow_script'))
> {
> session_register('allow_script');
> $allow_script = true;
> }

First, you store in session data the value of (non-existant) variable
$allow_script. Then you asign a value to $allow_script. You should do it
the other way round.


> register_globals = on

It seems you are following the typical PHP tutorial written a gazillion
years ago. There's not point in using all thouse overcomplicated
session_blah() functions. Just do session_start() and then read and write
values from the $_SESSION associative array:

$_SESSION['allow_script'] = TRUE;
....
if($_SESSION['allow_script']){
...
}

And I suggest you disable register_globals. Apart from being a potential
security hole, it just makes PHP programming more complicated than it
should. Variables pop in from nowhere, they interfere each other... That's
pure chaos IMHO.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--

Re: Can"t hide javascript with PHP :(

am 05.04.2008 23:36:54 von "quian[dot]xu"

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;
> }
> ?>
>
>
>
> .
> .
>
>
> "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 ' 2. Use ob_start() when you generate /raw/ contents


--
Best regards
Xu, Qian (stanleyxu)
http://stanleyxu2005.blogspot.com/

Re: Can"t hide javascript with PHP :(

am 06.04.2008 01:54:18 von Tim Roberts

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

What does that mean? You can't "hide" Javascript. In order for Javascript
to be executed by a browser, the browser has to be able to fetch the
Javascript. If it can be fetched, it can be read.

Perhaps you could be more specific about what you're trying to do.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: Can"t hide javascript with PHP :(

am 06.04.2008 03:24:17 von Jerry Stuckle

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;
>> }
>> ?>
>>
>>
>>
>> .
>> .
>>
>>
>> "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 ' > 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@attglobal.net
==================