Handle request if java script is enabled

Hi, I want to check the browser of my site visitors, if JavaScript is enabled the browser will be redirected to google[Dot]com, if it is disabled browser show “Empty” word

I try this code but it does not work ( all requests will redirect to google[dot]com , apparently does not check JavaScript :expressionless: )
( All Code : https://oth.sistan.host/ToShow/RedirectCode.txt ) :

<?php header("location: google.com"); ?> Empty

if you can send me a message in telegram : t.me/UnNature

That code does nothing. It is a PHP file and it just redirects to Google every time anyone goes to it.
It should include Javascript to see if it is enabled. The code does not make sense.

check this please : https://oth.sistan.host/ToShow/RedirectCode.txt
in phphelp.com html and javascript codes will not show

Sorry, but, if you want help with your code, post it here and we can help you with your code.
Third party sites are not what we do here to review code at. We do share third-party sites if they have a good solution to your question.

As far as your JS question goes, Javascript is inside the browser only. It does NOT handle anything on the server. ( It can make AJAX calls to PHP files, but, that is another subject! ) Therefore, you can check javascript by using < noscript > tags. Basically, if JS is enabled, it will not run these. In this area you could add a redirect to google. But, you could do it in a more secure way. Just add a NOSCRIPT display to tell the user that JS is NOT enabled and give them a CONTINUE link that would send them to Google. And, if it IS enabled, continue loading the page.

Hope that makes sense to you! Why do you care if JS is enabled or not? You could just use the NOSCRIPT tags to display a notice stating that the site does not work correctly without JS.

Okay thank you, i did it with html code
< meta http-equiv = “refresh” content = “2; url = https://google.com” / >

Well, that does not check anything, just redirects. So, why even have the first page if you just redirect after 2 seconds? Makes no logical sense.

see this code :
< html >
< head >
< noscript >
< meta http-equiv = “refresh” content = “0; url = https://api.sistan.host/OpenSource/Madeline/SimpleTimeBot/Codes” / >
< style >
div { display:none;}
< /style >
< /noscript >
< /head >
< body >
< div >
< /div >
< /body >
< /html >

I do not want users to be able to see the Codes file with the browser
I want users to be able to use this code only:

<?php eval(file_get_contents('https://api.sistan.host/OpenSource/Madeline/SimpleTimeBot/index.php')); ?>

Actually i want my users use codes from my host

My browser javascript is enabled but < noscript > tag will be run !

< html >
< head >
< noscript >

<?php header('location: https://api.sistan.host/OpenSource/Madeline/SimpleTimeBot/Codes'); ?>

< style >
div { display:none;}
</ style >
< /noscript >
< /head >
< body >
< div >
< /div >
< /body >
< /html >

How resolve this problem ?

You do not seem to understand. SERVER code such as PHP is NEVER seen in the browser. so, placing a header ( redirect ) in PHP inside of a NOSCRIPT will never do a thing. It does not exist in the browser !
CLIENT code is only run in the browser. By then, you already have removed all the PHP and it no longer exists.

You have not explained what you are attempting to do. If you are just making sure that the user has Javascript enabled, just use JS to do the redirect. Place a notice inside the NOSCRIPT code. Something that just says “You MUST have Javascript enabled to use this site!”… Then, if they have Javascript turned off, it will show them this notice. I would add a link there that lets them move to Google.
Then, if Javascript is turned on, have it redirect to the live site.

Are you attempting to make sure JS is enabled? Or trying to move to Google if it IS enabled? Please tell us what you are trying to do.

I want if javascript is disabled redirect to ( https://api.sistan.host/OpenSource/Madeline/SimpleTimeBot/Codes ) , if it is enabled only show the “Empty” word

I tested this code : < meta http-equiv = “refresh” content = “0; url = https://api.sistan.host/OpenSource/Madeline/SimpleTimeBot/Codes” / > , but i cant use eval function in my other script , it show this error : Parse error: syntax error, unexpected ‘<’, expecting end of file in /home/sistohzk/public_html/test/T/index.php(3) : eval()'d code on line 1

i want a code almost like this :

if($viewer == ‘server’ and $viewer != ‘browser’ and $viewer != ‘human’){
header(‘location: https://api.sistan[dot]host/OpenSource/Madeline/SimpleTimeBot/Codes’)
echo ‘humans dont have access’;

i’m novice :sweat_smile:

Well, first, an EVAL() function expects the input to be code ending with a semicolon. " ; " …
( Perhaps you do not have that at the end of your input code. )

Next, you can test if JS is enabled like this:

document.getElementsByTagName('body')[0].innerHTML = 'JavaScript is enable.';
JavaScript is disabled.

Test it with a simple test page and try it with JS turned on and off. You should get different values displayed. If not enabled, it will say so. If it is, it also will say so.
Since the javascript would not be working if it is disabled, they you can place a redirect similar to your version inside the noscript tags something loosely like this:

<noscript><meta http-equiv="refresh" content="0; url=Your-webpage-here" /></noscript>

I think that is what you are looking for!

With this code if javascript is enable or disable it will be redirect to the link :
< script >
document.getElementsByTagName( ‘body’ )[0].innerHTML = ‘JavaScript is enable.’;
</ script >
< noscript >

<?php header('location: https://api.sistan[dot]host/OpenSource/Madeline/SimpleTimeBot/Codes'); ?>

< /noscript>

with this code code it work without problem but eval function does not work :
< script >
document.getElementsByTagName(‘body’)[0].innerHTML = ‘JavaScript is enable.’;
< /script >
< noscript >
< noscript >< meta http-equiv=“refresh” content=“0; url=https://api.sistan.host/OpenSource/Madeline/SimpleTimeBot/Codes” / >< /noscript >
< /noscript >

Check this screenshot

I dont know how resolve eval function error , I do not want humans to be redirected, I just want the eval function to work fine

This does not work! PHP is handled on the server only. Therefore, it will always redirect. You did not understand what I told you.
Did you fix the EVAL data? You need to end it with a semi-colon.

What? humans? So, that makes little sense. Any page that a human sees, a robot or web-bot can see. You can not tell which are which unless you use some sort of on-screen option. Like an input field that needs to be erased to move further or a “captcha” code system embedded. No easy way to tell if it is a robot or human. They both can appear to be a human !

i have a telegram bot script writed with MadelineProto library , I want the code to be on my host and run on another host
i create a file without suffix , anyone can see bot codes , but i want other host and servers can see and use that codes and humans cant see codes easily

See this domain : http://f-eh.ir
This is a free hosting provider from ifastnet[dot]com , They somehow blocked http requests being sent from other servers and we could not set cronjob on this domain, this site needs a javascript enabled browser to be displayed

I don’t know what code they use but I want to have that code and use it the other way around

Well, if you have a script already on another host, you can just post to it. Just use cURL and send a post to the other host to handle your request. So, it would be just as though you were on the site.

Or, just make up a telegram bot script for you live host site and then you don’t need the other site.

I want use codes like copy function, but i want they can’t edit codes and just i can edit codes
is this possible ? If is possible how can i do it ?

Well, you can just display them. They can not change your code on your server. So, they can copy and not edit. But, they can edit once they copy them to their machine.

What do you think about this ? I created this files :
sistan.host/test/1/Codes : touch(‘newfile’);
sistan.host/test/2/C.php : <?php eval(file_get_contents(‘https://sistan.host/test/1/Codes’)); >

I opened C.php file and ‘newfile’ was made in sistan.host/2/newfile !

Apparently my thought is possible but I don’t know how to hide the code from humans
Javascript in browser is very good but it does not work i dont know how resolve it

Sponsor our Newsletter | Privacy Policy | Terms of Service