My question is huge, and it involves cross-server scripting. Basically it involves two files, one hosted on the server someone would be trying to log in from:
login.php:
and validate.php on the other domain:Code:<?php //a <form> would send various input data here if (count($_POST) > 0) { $c = curl_init(); curl_setopt($c, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); curl_setopt($c, CURLOPT_URL, "..somedomain../validate.php"); curl_setopt($c, CURLOPT_POST, count($_POST)); curl_setopt($c, CURLOPT_POSTFIELDS, $_POST); $result = curl_exec($c); curl_close($c); if ($result) // login validate } ?>
However my question is this: is there any way that validate.php can check the domain that the cURL request comes from? Or in this case, the domain that login.php is on?Code:<?php if (count($_POST) > 0) { // evaluate post data, validate login // if login is good: echo "1"; } ?>
I thought of doing it this way, adding an input field with the domain name in it (this would be in login.php):
But obviously anyone could edit this input field and enter in any server name they would want. Therefore it wouldn't exactly be secure.Code:<input name="server" value="<?php echo $_SERVER["SERVER_NAME"]; ?>">
The point:
To only allow cross-domain logins for verified domains, so the domain that would be sent to validate.php would be checked with a database.
I'm trying to learn how to do some cross-server scripting and this is my first attempt at it. Any advice or constructive criticism gladly accepted.
Thanks all



Reply With Quote

Bookmarks