FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Disabling other scripts

 


TheGustav
Is there a way to disable certain scripts, such as Javascript and PHP (the <?php and <script language="Javascript">) on a page?

Such as, if a user fills out a form, that form is then displayed using PHP on the next page... If that user put in some javascript, I don't want it processed. I would just want the plain text displayed, or maybe no text at all, as long as the javascript is not processed...

Is there anyway to obtain something like this?

If so, in more detail is there a way to disable specific scripting? Like only Javascript, and allow others?

Thanks for the help in advance, wondering if this is possible somehow.
brokenadvice
You could try using str_replace like so:

Code:
$mycodearay= array("<", ">", "JAVA", "java", "SCRIPT", "script", "JS");
$myfunction = str_replace($mycodearay, "what to replace it with", $thenameoftheform);


(not tested, but should work).
jabapyth
is the user (normally) going to be putting in any html at all? if not, you could replace all '<' with '&lt;' and '>' with '&gt;' (the html escape codes)
MrBlueSky
Use htmlspecialchars. This will convert all special html characters to entities.

Code:

  $text = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);


This will make sure everything (including HTML and javascript) is shown as plain text in the browser.
abcmario
My question is a little bit similar:

Can I disable a specific part of code generated automatically by the host server (not visible by the website owner, only when the page is loaded from the web browser)?

For example, If want to replace the following part of code through PHP:

Code:
<script type="text/javascript" src="http://www.mydomain.net/myjavascript/abc.js"></script>

with:

Code:
<script type="text/javascript" src="http://www.mydomain.net/myjavascript/none.js"></script>


What should I do?

This post is very insteresting.
TheGustav
brokenadvice wrote:
You could try using str_replace like so:

Code:
$mycodearay= array("<", ">", "JAVA", "java", "SCRIPT", "script", "JS");
$myfunction = str_replace($mycodearay, "what to replace it with", $thenameoftheform);


(not tested, but should work).


Thanks to all that helped! I went with brokenadvice's advice, since the users would use other HTML so I couldn't rule it out entirely, just the scripting languages like javascript and PHP.

This worked quite well, and was exactly what I needed. Smile Thanks a ton!
MrBlueSky
abcmario wrote:
My question is a little bit similar:

Can I disable a specific part of code generated automatically by the host server (not visible by the website owner, only when the page is loaded from the web browser)?

For example, If want to replace the following part of code through PHP:

Code:
<script type="text/javascript" src="http://www.mydomain.net/myjavascript/abc.js"></script>

with:

Code:
<script type="text/javascript" src="http://www.mydomain.net/myjavascript/none.js"></script>


What should I do?

This post is very insteresting.


It depends how and when that part is added by the server. I think it probably not possible. Can you give more details or an url?

Maybe it isn't possible to remove the inclusion of "abc.js", but it should be possible to undo what it does by some javascript of your own. For example if "abc.js" ads a banner to the page, you can use javascript to make that banner invisible.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.