How to find client's IP Address using Javascript code [duplicate] - javascript

This question already has answers here:
How to get client's IP address using JavaScript? [closed]
(31 answers)
Closed 9 years ago.
I want to find client's IP Address when accessing my app..How to find using javascript code..kindly provide help with sample code..I tried wit tis code but m not getting
function getip(json){
alert(json.ip); // alerts the ip address
}

You can't using ONLY JavaScript on it's own. You need to use a server side script ans call it using Ajax to perform this task.
For example in PHP script, you can do the following to get the client's ip address:
echo $_SERVER["REMOTE_ADDR"];
Next call this script using Ajax and display/use it in your page.

At least there used to be a way using Java to do this, but Javascript alone cannot find a machines IP.

Related

Is it possible to read/write to a file using Javascript? [duplicate]

This question already has answers here:
Using Node.JS, how do I read a JSON file into (server) memory?
(13 answers)
Closed 2 years ago.
This is not for a browser.
I intend to make a "blacklist" array for my bot, which will prevent users from running commands. However, I can only seem to do this on the actual bot file as I haven't found a way to do an external method.
What I'd want to do is have my main bot file as normal, but have a blacklist.txt with an array including their username, discord account ID and extra notes which can be accessed at any time by admins using a command.
This is what I'm using:
var blacklist=[
{username:'',userid:'',notes:''},
]
It's possible with node.js(a platform based on javascript)
Here is an example how to do that Using Node.JS, how do I read a JSON file into (server) memory?

Ping send with PHP [duplicate]

This question already has answers here:
Creating a ping uptime service with PHP
(3 answers)
Closed 4 years ago.
I have an application to develop for the university. Something simple. But I'm inexperienced on how to do it. It's exactly what I want to do; If I send ping 50 IP addresses at 3 minute intervals, I would like the IP address to write on the admin panel off if it is turned off and open if it is turned on. (red and green button maybe ) How ı can do it exactly? Since the servers belong to us, I want the commands to work correctly. What exactly do I want to show on the screen if Ping is successful?
You can quickly use the hostsystems ping-command by using shell-execution, if available. So you don't have to implement your own php-ping-service as described in the other solution. This can be done if easier solutions don't work. In my opinion less code is always better.
<?php
$output = shell_exec('ping www.stackoverflow.com');
echo "<pre>$output</pre>";
?>

get data from mysql using php and javascript [duplicate]

This question already has answers here:
Using Jquery Ajax to retrieve data from Mysql
(5 answers)
Updating a MySql database using PHP via an onClick javascript function
(2 answers)
How to update a web page without reloading the web page using AJAX?
(4 answers)
Closed 5 years ago.
I am new to javascript. I have one label, What I am doing is to get id using javascript which I am saving in a variable.
What I want is to send that variable to php page, where it will compare that id with mysql database id and returns it's data(some text) to javascript, it will then set it to label.
I would have used text file which is easiest way but some says this isn't a secure way to do this.
So how can I achieve this ?
Any help is appreciated, Thanks in advance.

Encrypt javascript file [duplicate]

This question already has answers here:
How can I hide or encrypt JavaScript code? [duplicate]
(7 answers)
Closed 4 years ago.
I don't find any info about that,so asking here.
Is somebody ever used some tool to protect javascript files? And totaly encrypt them?
Because I found this tool that seems like can totaly encrypt JS?
What do you think?
http://webtools.securitygeeks.net/p/blog-page_26.html?
That tool is useless. It declares a global variable called teksasli which contains your original script in a plain string. just look at the value of that variable in any console to see the original source.
There is no point in trying to encrypt Javascript, because the user/browser needs to decrypt it in order to run it.
If you want to obfuscate the source code, You could try GWT http://mojo.codehaus.org/gwt-maven-plugin/ (The Google Web Toolkit ).

Retrieve the complete URL from an iFrame [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How do I get the current location of an iframe?
Hi i want to get the complete URL, and with the methods i know i get the full url but of the iframe, and i want the 'final' document.location.href,
how can i get it?
i don't care if its php or js, but i'm guessing by my experiments that with PHp it's not possible...
If you want to know where you currently are:
Client side - javascript - you can use alert(window.location).
Server side - php - .$_SERVER["REQUEST_URI"] or $_SERVER['PATH_INFO'] depending on what you want.
Take a look at the top answer from this question.
It's important to note that it's (luckily!) not possible to get the URL of an iframe if the iframe's URL is from a different domain than the parent page. If you're trying to do that, you're probably out of luck.

Categories

Resources