I want to get user machine name or any unique code instead of IP.
Two system on same network have same IP but I want unique Code/number/name of each System.
Please tell me How can I do this with php.
Thanks
EDITED......
I am using below code. This is working on localend. But this stop working on live server. May be its getting server mac address but I want local machine Mac address from where my web app is accessing.
ob_start();//Get the ipconfig details using system commond
system('ipconfig /all');
// Capture the output into a variable
$mycom=ob_get_contents();
// Clean (erase) the output buffer
ob_clean();
$findme = "Physical";
//Search the "Physical" | Find the position of Physical text
$pmac = strpos($mycom, $findme);
// Get Physical Address
$mac=substr($mycom,($pmac+36),17);
//Display Mac Address
echo '<h1>demo---> '.$mac.'</h1>';
Edited
If this is not possible in php then javascript can be used for this? How can I use javascript to get client machine Physical Address....
You should try the below code.
$ip = $_SERVER['REMOTE_ADDR'];
// don't miss to use escapeshellarg(). Make it impossible to inject shell code
$mac1 = shell_exec('arp -a ' . escapeshellarg($ip));
// can be that the IP doesn't exist or the host isn't up (spoofed?)
// check if we found an address
if(empty($mac1)) {
die("No mac address for $ip not found");
}
// having it
echo "mac address for $ip: $mac1";
Hope this will work for you.
Related
I was playing with sockets on local machine with no network connection. See below:
IPAddress address = IPAddress.Any; // doesn't work
IPAddress address = IPAddress.Parse("::1"); // works
So what is exactly ::1 IP address ? Is it the default available IP address or it's the loopback address ? what happens to above code (working line) on a machine with dedicated IP address and network connection ?
EDIT:
exact code is used to bind a specific IP address to socket. Here it is:
ServicePoint sp = ServicePointManager.FindServicePoint(uri);
sp.BindIPEndPointDelegate = new BindIPEndPoint(Bind);
// here's the bind delegate:
private IPEndPoint Bind(ServicePoint sp, IPEndPoint ep, int retryCount)
{
return new IPEndPoint(IPAddress.Parse("::1"), 0);
}
::1 is the loopback address in IPv6. Think of it as the IPv6 version of 127.0.0.1.
See http://en.wikipedia.org/wiki/Localhost
Just to add little more info to it, in IPv6 loopback address is represented as 127 zeroes followed by a 1 i.e (0000... 127 times..1).
It's representation should have been like this -> 0000:0000:0000:0000:0000:0000:0000:0001 but we have some short form representation for this. If there are all zeroes in a single block you can replace it by single 0. So it becomes -> 0:0:0:0:0:0:0:0001.
Again we can see that we have runs of zeroes, they can be eliminated and we get
-> ::0001 -> ::1 .
The simple answer is that:
::1 is the compressed format of IPV6 loopback address 0:0:0:0:0:0:0:1. It is the equivalent of the IPV4 address 127.0. 0.1
I am mantaining a VB6 Windows application which digitally signs PDF documents by launching a JS file, located in the Javascripts subfolder of Acrobat 9.0. Now my Customer wants to plug another smart card reader to the PC which hosts the application, with its own smart card containing certificates related to a second person who will sign certain type of documents.
My question is: how can I programmatically choose, from my JavaScript code, the smart card reader I want?
In my JavaScript code I do the following:
//Initialize the signature handler
var myEngine = security.getHandler("Adobe.PPKLite");
//Obtain the available certificates
var ids = myEngine.digitalIDs;
var myCerts = ids.certs;
//Find the certificate I want to use to sign
for(var j=0; j<myCerts.length; j++)
{
if(myCerts[j].subjectCN == "SMITH JOHN")
{
oCert = myCerts[j];
break;
}
}
//Log to the signature engine by passing the certificate I want to use
//and the slot where the corresponding smart card reader is plugged
myEngine.login( { oParams: { cDIPath: ACROSDK.sigDigitalIDPath,
cPassword: ACROSDK.sigUserPwd,
iSlotID: 1,
oEndUserSignCert: oCert
}
} );
//Digitally sign the document with the certificate I chose
sigField.signatureSign({oSig: myEngine,
bUI: false,
oInfo: { password: ACROSDK.sigUserPwd,
location: ACROSDK.sigLocation,
reason: ACROSDK.sigReason,
contactInfo: ACROSDK.sigContactInfo,
appearance: "FirmaRPPR"
}
});
Why do I receive a General Error when executing signatureSign? Which is the correct way to assign the iSlotID parameter when logging to the signature engine or, alternatively, the cTokenLabel parameter?
Thanks in advance for your help and suggestions!
Mind you, I have no experience in using Acrobat scripting, but in PKCS#11 slot id would refer to the id of the smart card reader connected to the computer, and token label would be assigned label to one of the smart carts in that slot/reader, which can vary from PKCS#11 implementation to another.
And the easiest way to find out the label of the PKCS#11 token would be to configure the PKCS#11 DLL you're using as a Security device in Firefox browser and see the label field in the configuration. But that would be just to get you going in the right direction.
You can write a short C program against the PKCS#11 and use C_GetSlotList and C_GetSlotInfo to find out the slot id's and token labels, here is an example of that. It should not be a problem to port that code over to VB. Also there is NCryptoki that you can use to interface the PKCS#11 DLL.
I know that this will seem like a duplicate, but I honestly have not been able to find any answer that solves this.
I have two iPads set up with static IP addresses on a network that can only access www.example.com (network restriction, not iPad restriction). example.com is an eCommerce site and I want to fill in a coupon field whenever either of these two iPads visit the site.
The only way I can think of doing this is getting the local IP addresses of the iPads (e.g. 192.168.0.x) and creating a whitelist array. But my problem is trying to detect the browsing device's local IP.
I cannot use any resources outside of the example.com domain and I can't use the network's public IP as there will be lots of other devices connected.
Also, I've tried WebRTC but it's Chrome and Firefox only, and I am limited to the iPad's native Safari browser.
Help me Overflow Kenobi, you're my only hope!
EDIT
Conditions have changed. I found out that no other devices will be using the checkout service, so I can now target the external IP. Details about how I did this are below.
OK, I've found a solution to my problem.
One correction first to my original question:
I just found out that none of the other devices on the network will actually be used for purchasing on the website, so the iPads are the only two devices that will enter the checkout.
Knowing this now, I am able to target the public IP of the network. I've done this using two scripts, one in an external PHP file (our server isn't setup to run PHP in HTML files) and one in an external JavaScript file (easier management as there are multiple versions of the checkout page, so if I need to change the discount code I just have to update the JS file.)
PHP file:
// Declare content as JavaScript
Header("content-type: application/x-javascript");
// Declare variables for IP adress requests
$http_client_ip = $_SERVER['HTTP_CLIENT_IP'];
$http_x_forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'];
$remote_addr = $_SERVER['REMOTE_ADDR'];
// Request for most accurate IP address
if (!empty($http_client_ip)) {
$ip_address = $http_client_ip;
} else if (!empty($http_x_forwarded_for)) {
$ip_address = $http_x_forwarded_for;
} else {
$ip_address = $remote_addr;
}
// Add results to array - multiple IP addresses may be returned
$list = explode(',', $ip_address, 2);
// Write the first IP address in array as JavaScript
echo 'document.write(\'<div class="myIP" style="display:none;">' . $list[0] . '</div>\')';
JS file:
// Array of allowed IP addresses
var allowedIP = ['x.x.x.x'];
// Coupon code
var couponCode = "CODE001";
// Run script when page is loaded
$(document).ready(function () {
// Get device IP from 'myIP' div loaded by php
var ipAddress = $('.myIP').text();
// Check if device IP matches any of the IPs in the Allowed array
for (var i = 0; i<allowedIP.length;i++) {
if (ipAddress == allowedIP[i]) {
// If it matches, write to console
console.log("Your external IP is allowed");
// Add coupon code to input field
$('input[name="coupon"]').val(couponCode);
} else {
// If it does not match, write to console
console.log("Sorry buddy, you're not on the list.");
}
};
});
I have been researching this for a while. For the site static.etreeblog.com I would like to change a duv's class if a website is offline.
Ways I have researched:
-Using the onerror tag with an image to run a function.
-Problem: One of the sites i want to test uses an external image host, meaning even if the site was offline the image could be.
Example of what I want to do:
function checksite( site, url ){
if url == online {
document.getElementByClass('site').setClass('online')
}
}
checksite('site1', 'www.example.com')
checksite('site2, 'www.example2.com')
Thankyou in advance.
Extra information:
-The divs will be set to offline by default.
-I am using tumblr to host the status tester (If that helps).
Use PHP, Its a solid way to do this.
Host this script on your server (file name say test.php)
<?php
$url = $_REQUEST["url"];
$port = $_REQUESR["port"]; // Or make it default
$fp = fsockopen($url, $port, $errno, $errstr, 0.4); //(line 47)
if (!$fp) {
echo "OFFLINE";
}
else{
echo "ONLINE";
}
?>
Now loop AJAX to open this file and check whether it is echoing ONLINE or OFFLINE.
You will need help on the server side. You could do an AJAX call to your server and it will call the url and return with the site status. If it is that server your monitoring then the AJAX error code will tell you the status.
I have at my disposal Javascript and Classic ASP. Using these two how can I check to see if a user is a member of a particular active directory group? I know VBSCRIPT has memberof function but I can only use javascript. Any help is appreciated
You'll need to ensure that your web server is set to use Windows Authentication. Then you can use Request.ServerVariables("LOGON_USER") to get the current user's domain\username.
You'll then query Active Directory using ADSI to get group membership.
Here's a link to msdn's ADSI pages. http://msdn.microsoft.com/en-us/library/aa772170%28v=vs.85%29.aspx
This page has some sample scripts (in vbscript)
As far as I know there is no possibility to access activeDirectory by using Javascript. Javascript runs within the browser - and may not access anything out of this sandbox.
In case I misunderstood your question und you ment server-side checking - use ASP functions to check for.
You might also try using Javascript to instantialte a WScript.Network object
var WshNetwork = new ActiveXObject("WScript.Network");
From there, you can get
var netWorkUserName = WshNetwork.UserName;
var netWorkDomain = WshNetwork.UserDomain;
A word of warning: I'm pretty sure this is IE only and requires security changes in IE.
You'll need AJAX and a connection to the AD using ADODB.Connection with the "ADsDSOObject" provider.
EDIT: I saw your comment above. Here's a start:
ldapCommand.CommandText = "select sn from '" & _
"LDAP://example.com/DC=example,DC=com" & _
"' WHERE samAccountName=" & "'" & username & "'"
Set ldapRecordSet = ldapCommand.Execute
ldapCommand is an ADODB.Command, and if Execute throws an error, then the user is not in the domain.