HTTP/Web Server Source
This is the source code for a web server. It isn't quite finished, and at the moment I haven't got time to finish it (I start my GCSE exams in 2 weeks) so I thought it might be of benefit to people who want to write one. The server runs in the system tray and supports the resume feature (which some servers such as Xitami don't). At present, the server doesn't save the settings you type in, so you'll have to reset them every time you run it. But anybody with a good knowlage of file I/O should be able to add this. Please Please rate this server, your comments would be appreciated, though I won't be working on the project again until the end of June. If you want to make any changes, please contact me first, and please don't use the code in a commercial product. To get it working, put your pages/files in the 'root' directory which should be in the same directory as the executable. If you like it PLEASE PLEASE PLEASE vote.
KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Upload
<?PHP
##################################################################
## ##
## THIS IS AN UNFINISHED SCRIPT FOR LEARNING PURPOSES ##
## YOU MAY USE AND DISTRIBUTE IT AS LONG AS THIS ##
## COMMENT FIELD IS IN IT OR YOU LINK TO SOURCESHOCK.COM ##
## ##
## the main thing it does is connecting to the msn ##
## server and then connect to the password nexus ##
## when done all that it gets your msn list and changes ##
## your status, the rest is up to you :) ##
## ##
##################################################################
$startcomm = 0;
$username = "username";
$password = "password";
function getData() {
$socket = $GLOBALS["socket"];
$buffer="";
while (!feof($socket)) {
$buffer .= fread($socket,1024);
if (preg_match("/\r/",$buffer)) {
break;
}
}
echo "<font color=green><< $buffer</font><br>";
checkData($buffer);
}
function getData2() {
$socket = $GLOBALS["socket"];
$buffer="";
while (!feof($socket)) {
$buffer .= fread($socket,1024);
if (preg_match("/\r\n\r\n/",$buffer)) {
break;
}
}
//$buffer = str_replace("\n","<br>",$buffer);
echo "<font color=green><< $buffer</font><br>";
checkData($buffer);
}
function checkData($buffer) {
if (preg_match("/lc\=(.+?)/Ui",$buffer,$matches)) {
$GLOBALS["challenge"] = "lc=" . $matches[1];
}
if (preg_match("/(XFR 3 NS )([0-9\.\:]+?) (.*) ([0-9\.\:]+?)/is",$buffer,$matches)) {
$split = explode(":",$matches[2]);
$GLOBALS["startcomm"] = 1;
msn_connect($split[0],$split[1]);
}
if (preg_match("/tpf\=([a-zA-Z0-9]+?)/Ui",$buffer,$matches)) {
nexus_connect($matches[1]);
}
$split = explode("\n",$buffer);
for ($i=0;$i<count($split);$i++) {
$detail = explode(" ",$split[$i]);
if ($detail[0] == "LST") {
//echo "<div OnMouseOver=\"style.cursor='hand';showTooltip('show','$detail[1]-$detail[3]')\" OnMouseMove=\"followTooltip('show')\" OnMouseOut=\"showTooltip('hide')\">" . urldecode($detail[2]) . "</div>";
}
}
//echo $buffer;
}
function msn_connect($server,$port) {
if (IsSet($GLOBALS["socket"])) {
fclose($GLOBALS["socket"]);
}
$GLOBALS["socket"] = fsockopen($server,$port);
if (!$GLOBALS["socket"]) {
return "Could not connect";
} else {
$GLOBALS["startcomm"]++;
send_command("VER " . $GLOBALS["startcomm"] . " MSNP8 CVR0",1);
send_command("CVR " . $GLOBALS["startcomm"] . " 0x0409 win 4.10 i386 MSNMSGR 6.2 MSMSGS " . $GLOBALS["username"] . "@hotmail.com",1);
send_command("USR " . $GLOBALS["startcomm"] . " TWN I " . $GLOBALS["username"] . "@hotmail.com",1);
}
}
function send_command($command) {
$GLOBALS["startcomm"]++;
$socket = $GLOBALS["socket"];
echo "<font color=blue> >> $command<br>";
fwrite($socket,$command . "\r\n");
getData();
}
function nexus_connect($tpf) {
echo "<font color=#a5a5a5>";
$arr[] = "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://nexus.passport.com:443/rdr/pprdr.asp");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_HEADER,1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arr);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = curl_exec($curl);
curl_close($curl);
preg_match("/DALogin=(.+?),/",$data,$matches);
$data = str_replace("\n","<br>",$data);
echo $data;
echo "<br><br>";
$split = explode("/",$matches[1]);
$headers[0] = "GET /$split[1] HTTP/1.1\r\n";
$headers[1] = "Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in=" . $GLOBALS["username"] . "%40hotmail.com,pwd=" . $GLOBALS["password"] . ", " . trim($GLOBALS["challenge"]) . "\r\n";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://" . $split[0] . ":443/". $split[1]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_HEADER,1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = curl_exec($curl);
$data = str_replace("\n","<br>\n",$data);
echo $data;
curl_close($curl);
echo "</font>";
preg_match("/t=(.+?)'/",$data,$matches);
send_command("USR " . $GLOBALS["startcomm"] . " TWN S t=" . trim($matches[1]) . "",2);
send_command("CHG " . $GLOBALS["startcomm"] . " HDN",2);
send_command("SYN " . $GLOBALS["startcomm"] . " 0",2);
getData2();
send_command("SYN " . $GLOBALS["startcomm"] . " 1 46 2",2);
getData2();
send_command("CHG ". $GLOBALS["startcomm"] . " BSY");
getData();
}
msn_connect("messenger.hotmail.com",1863);
?>