ip

PowerShell force [int] to wrap (IP to Long conversion)

这一生的挚爱 提交于 2019-12-24 15:23:03
问题 Just a quick question as I'm kind of new to math in PowerShell I need to make a converter in PowerShell that converts IP to Long. It works fine for lower values, but on higher ones it is causing an Integer Overflow. [int]$a = Read-Host "First bit of IP address" [int]$b = Read-Host "2nd bit of IP address" [int]$c = Read-Host "3rd bit of IP address" [int]$d = Read-Host "4th bit of IP address" $a *= 16777216 $b *= 65536 $c *= 256 $base10IP = $a + $b + $c + $d Write-Host $base10IP Works fine if I

Display Country Flag by IP

时光总嘲笑我的痴心妄想 提交于 2019-12-24 11:37:47
问题 I want to be able to display the Country Flag image by the IP. The IPs are stored in Mysql in a column, each page has it's own row with IP like so: TABLE: PAGEID INFO IP 12340 abc 120.120.120.120 12341 fgh 121.121.121.121 12342 ert 122.122.122.122 12343 bvn 120.120.120.120 12344 hjk 123.123.123.123 So when a user open it will get the IP by the page id from mysql and then decide what country flag to display based on the IP. Is there such a script like this besides the one below? This is a

Communicating between two different computers with TCP/IP

流过昼夜 提交于 2019-12-24 10:40:19
问题 I've been studying how to use sockets to make two java programs communicate. Now, on each example I've gone through, they've always placed the "server side program" on the same computer on which the "client side program" was, and of course the IP set was either 127.0.0.1 , or simply "localhost". Now, my question is: how do I get to communicate the two programs if one is on a computer, and one on another? I've tried to set the IP as the one my computer has when connected to internet (the one I

$_SERVER headers are missing in PHP but present in Python

一笑奈何 提交于 2019-12-24 09:57:56
问题 I'm behind a transparent proxy which always adds the HTTP_X_FORWARDED_FOR header. When I dump the headers out using PHP the header is missing. But Python works.. lol Python: remote_addr = os.environ.get('HTTP_X_FORWARDED_FOR', os.environ.get('REMOTE_ADDR', '')) PHP: print_r($_SERVER['HTTP_X_FORWARDED_FOR']); print_r($_SERVER['REMOTE_ADDR']); ---- EDIT: Added more info on configs below ------ PHP Version: 5.2.16 PHP Configure Command: './configure' '--enable-bcmath' '--enable-calendar' '-

Failing to set cookies in PHP

做~自己de王妃 提交于 2019-12-24 08:16:11
问题 I have written a PHP script which takes information about visitors IP and browser from a website and stores it in a table in my database. This script is included in the header and runs every time each page is loaded, google analytics type thing. survey.php I want this code to run only for each new visitor of the website, so that I only log each new visitor. I guess this is done by setting a cookie so I wrote this other code to set a cookie and then include the survey.php only when there is no

Clean solution for lookup if extern IP is in own subnet range in objective-c

╄→尐↘猪︶ㄣ 提交于 2019-12-24 07:58:10
问题 Hi all, I am looking for a better solution for checking / calculating if an IP-address is in the same subnet like your iPhone. The background: I am looking up devices by the Zeroconf / Bonjour and this devices can have multiple IP-addresses. So I want to check which of them can be reached by my device. I Thought the easiest way is to take the extern IP and connect it with my subnet-mask, but I havenot found any way to do it directly (need both as int), so I made a workaround. The code:

Checking if string is web address or ip on android

北战南征 提交于 2019-12-24 05:31:25
问题 I need to validate if string entered in TextEdit is a web address eg. "www.stackoverflow.com" or an ip address eg. "64.34.119.12". I have tried this two methods without success. I have private class variable named ip. Method 1: public boolean isAdress(){ boolean isaddr = true; try { ip = new NetTask().execute(""+textEdit1.getText()).get(); } catch (Exception ex) { isaddr = false; } return isaddr; } Method 2 is the one were I check string before sending it to NetTask. public boolean isAdress()

ip range and port scanner

混江龙づ霸主 提交于 2019-12-24 05:28:05
问题 Can someone help me to checking a port scanner with specific range of IP addresses using command line. How can i make sure that the port scan with that IP's range. args[0] and args[1] for IP Address range, while args[2] and args[3] for a port scanner. For example I run "java Test 1.1.1.1 5 0 10" the program will check IP's from 1.1.1.1 to 1.1.1.5 on ports 0 - 10 Here my code: import java.util.concurrent.*; import java.util.*; import java.net.*; // source http://stackoverflow.com/questions

Get public IP using DynDNS and WebRequest C#

时光怂恿深爱的人放手 提交于 2019-12-24 04:33:50
问题 I Use this code to get the public IP-address (thanks to this post How to get the IP address of the server on which my C# application is running on?): public static string GetPublicIP() { try { String direction = ""; WebRequest request = WebRequest.Create("http://checkip.dyndns.org/"); using (WebResponse response = request.GetResponse()) { using (StreamReader stream = new StreamReader(response.GetResponseStream())) { direction = stream.ReadToEnd(); } } //Search for the ip in the html int first

MYSQL - SELECT IP v4/v6, inet_pton & bin2hex

有些话、适合烂在心里 提交于 2019-12-24 04:08:08
问题 I'm having bit of a trouble selecting correct values from my mysql sql server. The ip can be ipv6 and v4. Table: User{ ... ip binary(16) } $ip = '192.168.10.115'; $ip = bin2hex(inet_pton($ip)); // Returns c0a80a73 $result = $this->db->select("SELECT * FROM User WHERE HEX(ip) = $ip"); // $result empty because in db its stored as: // HEX(ip) = C0A80A73000000000000000000000000 How can I get a viable match to the * 00000 * ? If input was a ipv6 match this would be ok, but ip v4 not. 回答1: Can you