Commit a29dc848 authored by Derrick Sobodash's avatar Derrick Sobodash

Added licensing and copyright info. Cleaned up the formatting

of the PHP server files.
parent 2beb8b79
Copyright (c) 2008, 2012 Derrick Sobodash
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
openshiren
==========
=========
Open source server for the Web edition of Chunsoft's Shiren the Wanderer
\ No newline at end of file
Open source server for the Web edition of Chunsoft's Shiren the Wanderer
<?php
$action = $_GET["Action"];
$fp = @fopen("authori-log.txt", "ab");
if($action == "chg")
{
fwrite($fp, "\r\nPassword change from $REMOTE_ADDR@" . date("H:i:s") . " ...\r\n");
fwrite($fp, " " . str_pad("Serial:", 10, " ", STR_PAD_RIGHT) . "{$_GET["Serial"]}\r\n");
fwrite($fp, " " . str_pad("oldPass:", 10, " ", STR_PAD_RIGHT) . "{$_GET["oldPass"]}\r\n");
fwrite($fp, " " . str_pad("newPass:", 10, " ", STR_PAD_RIGHT) . "{$_GET["newPass"]}\r\n");
do_ok_out();
}
else if($action == "reg")
{
fwrite($fp, "\r\nRegistration from $REMOTE_ADDR@" . date("H:i:s") . " ...\r\n");
fwrite($fp, " " . str_pad("yourName:", 10, " ", STR_PAD_RIGHT) . "{$_GET["yourName"]}\r\n");
fwrite($fp, " " . str_pad("yourPass:", 10, " ", STR_PAD_RIGHT) . "{$_GET["yourPass"]}\r\n");
fwrite($fp, " " . str_pad("Serial:", 10, " ", STR_PAD_RIGHT) . "{$_GET["Serial"]}\r\n");
do_ok_out();
}
else if($action == "aut")
{
fwrite($fp, "\r\nAuthentication from $REMOTE_ADDR@" . date("H:i:s") . " ...\r\n");
fwrite($fp, " " . str_pad("yourName:", 10, " ", STR_PAD_RIGHT) . "{$_GET["yourName"]}\r\n");
fwrite($fp, " " . str_pad("counter:", 10, " ", STR_PAD_RIGHT) . "{$_GET["counter"]}\r\n");
fwrite($fp, " " . str_pad("Serial:", 10, " ", STR_PAD_RIGHT) . "{$_GET["Serial"]}\r\n");
fwrite($fp, " " . str_pad("check1:", 10, " ", STR_PAD_RIGHT) . "{$_GET["check1"]}\r\n");
fwrite($fp, " " . str_pad("check2:", 10, " ", STR_PAD_RIGHT) . "{$_GET["check2"]}\r\n");
do_aut_out();
}
fwrite($fp, "\r\n-------------------------------------------------------------------------------\r\n");
fclose($fp);
function do_ok_out()
{
/*
openShiren Authorization Server
Authorization server.
Version: 0.6
Author: Derrick Sobodash <derrick@sobodash.com>
Copyright: (c) 2008, 2012 Derrick Sobodash
Web site: https://github.com/sobodash/openshiren/
License: BSD License <http://opensource.org/licenses/bsd-license.php>
*/
$action = $_GET["Action"];
$fp = @fopen("authori-log.txt", "ab");
if($action == "chg") {
fwrite($fp, "\nPassword change from $REMOTE_ADDR@" . date("H:i:s") . "...\n");
fwrite($fp, " " . str_pad("Serial:", 10, " ", STR_PAD_RIGHT) . "{$_GET["Serial"]}\n");
fwrite($fp, " " . str_pad("oldPass:", 10, " ", STR_PAD_RIGHT) . "{$_GET["oldPass"]}\n");
fwrite($fp, " " . str_pad("newPass:", 10, " ", STR_PAD_RIGHT) . "{$_GET["newPass"]}\n");
do_ok_out();
}
else if($action == "reg") {
fwrite($fp, "\nRegistration from $REMOTE_ADDR@" . date("H:i:s") . "...\n");
fwrite($fp, " " . str_pad("yourName:", 10, " ", STR_PAD_RIGHT) . "{$_GET["yourName"]}\n");
fwrite($fp, " " . str_pad("yourPass:", 10, " ", STR_PAD_RIGHT) . "{$_GET["yourPass"]}\n");
fwrite($fp, " " . str_pad("Serial:", 10, " ", STR_PAD_RIGHT) . "{$_GET["Serial"]}\n");
do_ok_out();
}
else if($action == "aut") {
fwrite($fp, "\nAuthentication from $REMOTE_ADDR@" . date("H:i:s") . "...\n");
fwrite($fp, " " . str_pad("yourName:", 10, " ", STR_PAD_RIGHT) . "{$_GET["yourName"]}\n");
fwrite($fp, " " . str_pad("counter:", 10, " ", STR_PAD_RIGHT) . "{$_GET["counter"]}\n");
fwrite($fp, " " . str_pad("Serial:", 10, " ", STR_PAD_RIGHT) . "{$_GET["Serial"]}\n");
fwrite($fp, " " . str_pad("check1:", 10, " ", STR_PAD_RIGHT) . "{$_GET["check1"]}\n");
fwrite($fp, " " . str_pad("check2:", 10, " ", STR_PAD_RIGHT) . "{$_GET["check2"]}\n");
do_aut_out();
}
fwrite($fp, "\n-------------------------------------------------------------------------------\n");
fclose($fp);
function do_ok_out() {
?><HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT=0>
......@@ -61,11 +61,9 @@ Shiren authentication system 89a0uKT2
OK<BR>
</BODY>
</HTML><?php
}
function do_aut_out()
{
}
function do_aut_out() {
?><HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT=0>
......@@ -82,6 +80,5 @@ result=success
OK<BR>
</BODY>
</HTML><?php
}
?>
\ No newline at end of file
}
?>
This diff is collapsed.
<?php
$fp = @fopen("rescue-log.txt", "ab");
fwrite($fp, "Shiren Data from $REMOTE_ADDR...\r\n");
$fd = @fopen("php://input", "rb");
$fddump = @fread($fd, $CONTENT_LENGTH);
fclose($fd);
$fields = explode("&", $fddump);
for($i=0; $i<count($fields); $i++) {
list($var, $val) = explode("=", $fields[$i]);
if($var == "character_name"||$var == "mail_address"||$var == "player_name")
fwrite($fp, " " . str_pad("$var:", 16, " ", STR_PAD_RIGHT) . pack("H*", $val) . "\r\n");
else
fwrite($fp, " " . str_pad("$var:", 16, " ", STR_PAD_RIGHT) . "$val\r\n");
}
while(list($key1, $value1) = each($_GET)) {
fwrite($fp, " " . str_pad("$key1:", 16, " ", STR_PAD_RIGHT) . "$value1\r\n");
}
while(list($key1, $value1) = each($_POST)) {
fwrite($fp, " " . str_pad("$key1:", 16, " ", STR_PAD_RIGHT) . "$value1\r\n");
}
fwrite($fp, "-------------------------------------------------------------------------------\r\n");
fclose($fp);
/*
openShiren Rescue Server
Rescue server.
Version: 0.6
Author: Derrick Sobodash <derrick@sobodash.com>
Copyright: (c) 2008, 2012 Derrick Sobodash
Web site: https://github.com/sobodash/openshiren/
License: BSD License <http://opensource.org/licenses/bsd-license.php>
*/
$fp = @fopen("rescue-log.txt", "ab");
fwrite($fp, "Shiren Data from $REMOTE_ADDR...\n");
$fd = @fopen("php://input", "rb");
$fddump = @fread($fd, $CONTENT_LENGTH);
fclose($fd);
$fields = explode("&", $fddump);
for($i=0; $i<count($fields); $i++) {
list($var, $val) = explode("=", $fields[$i]);
if($var == "character_name"||$var == "mail_address"||$var == "player_name")
fwrite($fp, " " . str_pad("$var:", 16, " ", STR_PAD_RIGHT) . pack("H*", $val) . "\n");
else
fwrite($fp, " " . str_pad("$var:", 16, " ", STR_PAD_RIGHT) . "$val\r\n");
}
while(list($key1, $value1) = each($_GET)) {
fwrite($fp, " " . str_pad("$key1:", 16, " ", STR_PAD_RIGHT) . "$value1\r\n");
}
while(list($key1, $value1) = each($_POST)) {
fwrite($fp, " " . str_pad("$key1:", 16, " ", STR_PAD_RIGHT) . "$value1\r\n");
}
fwrite($fp, "-------------------------------------------------------------------------------\n");
fclose($fp);
?><!-- \225\227\227\210\202\314\203V\203\214\203\223 -->
<!-- result=success -->
\ No newline at end of file
<!-- result=success -->
<?php
/*
openShiren Download
Work in progress download server
Version: 0.1
Author: Derrick Sobodash <derrick@sobodash.com>
Copyright: (c) 2008, 2012 Derrick Sobodash
Web site: https://github.com/sobodash/openshiren/
License: BSD License <http://opensource.org/licenses/bsd-license.php>
*/
// Which file contains the rankings log?
$log = "download-log.txt";
// Which file contains the rankings log?
$log = "download-log.txt";
/**
* parse_raw_packet()
* Parses raw post data off the input stream and returns it as a clean
* associative array.
*/
function parse_raw_packet()
{
global $CONTENT_LENGTH;
/**
* parse_raw_packet()
* Parses raw post data off the input stream and returns it as a clean
* associative array.
*/
function parse_raw_packet()
{
global $CONTENT_LENGTH;
// Read the full packet payload into a variable.
$fd = fopen("php://input", "rb");
$packet = fread($fd, $CONTENT_LENGTH);
fclose($fd);
// Break it up by "&" symbols.
// No, don't be mislead, this is data that is not available as
// $_GET or $_POST. They really did send a raw packet like this.
$fields = explode("&", $packet);
// Next, break apart each field by "=" and set it in an array.
$vars = array();
foreach($fields as $field)
{
$pair = explode("=", $field);
$name = $pair[0];
$vars[$name] = $pair[1];
}
return($vars);
}
// Read the full packet payload into a variable.
$fd = fopen("php://input", "rb");
$packet = fread($fd, $CONTENT_LENGTH);
fclose($fd);
// Break it up by "&" symbols.
// No, don't be mislead, this is data that is not available as
// $_GET or $_POST. They really did send a raw packet like this.
$fields = explode("&", $packet);
/**
* decode()
* Function by byuu which decodes the payload to hex for further parsing.
* Currently supports both known encoded blocks, "spaw" and "toke."
*/
function decode($str, $type = "spaw")
// Next, break apart each field by "=" and set it in an array.
$vars = array();
foreach($fields as $field)
{
if($type == "spaw")
$salt = "BCDEFGHIJKSTUVWX";
else if($type == "toke")
$salt = "ABCDEFGHIJRSTUVW";
$str = strtr($str, $salt, "0123456789ABCDEF");
return $str;
}
// Open the log file for rankings
$fp = @fopen($log, "ab");
// Record where the submission came from and the local time recieved
fwrite($fp, "\r\nData from $REMOTE_ADDR@" . date("H:i:s") . " ...\r\n");
// Fetch the contents of the raw packet
$packet = parse_raw_packet();
$pair = explode("=", $field);
$name = $pair[0];
$vars[$name] = $pair[1];
}
return($vars);
}
/**
* decode()
* Function by byuu which decodes the payload to hex for further parsing.
* Currently supports both known encoded blocks, "spaw" and "toke."
*/
function decode($str, $type = "spaw")
{
if($type == "spaw")
$salt = "BCDEFGHIJKSTUVWX";
else if($type == "toke")
$salt = "ABCDEFGHIJRSTUVW";
$str = strtr($str, $salt, "0123456789ABCDEF");
return $str;
}
// Open the log file for rankings
$fp = @fopen($log, "ab");
// Record where the submission came from and the local time recieved
fwrite($fp, "\r\nData from $REMOTE_ADDR@" . date("H:i:s") . " ...\r\n");
// Fetch the contents of the raw packet
$packet = parse_raw_packet();
while(list($var, $val) = each($packet))
fwrite($fp, " " . str_pad("$var:", 12, " ", STR_PAD_RIGHT) . "$val\r\n");
while(list($var, $val) = each($_GET))
fwrite($fp, " " . str_pad("$var:", 12, " ", STR_PAD_RIGHT) . "$val\r\n");
while(list($var, $val) = each($_POST))
fwrite($fp, " " . str_pad("$var:", 12, " ", STR_PAD_RIGHT) . "$val\r\n");
fwrite($fp, "\r\n-------------------------------------------------------------------------------\r\n");
fclose($fp);
while(list($var, $val) = each($packet))
fwrite($fp, " " . str_pad("$var:", 12, " ", STR_PAD_RIGHT) . "$val\r\n");
while(list($var, $val) = each($_GET))
fwrite($fp, " " . str_pad("$var:", 12, " ", STR_PAD_RIGHT) . "$val\r\n");
while(list($var, $val) = each($_POST))
fwrite($fp, " " . str_pad("$var:", 12, " ", STR_PAD_RIGHT) . "$val\r\n");
fwrite($fp, "\r\n-------------------------------------------------------------------------------\r\n");
fclose($fp);
?><!--
\225\227\227\210\202\314\203V\203\214\203\223
-->
......@@ -94,4 +94,4 @@ article2=00084600000000800055300000000100056700020000000055D00000000000054000000
player2=8345838B838B8393
memo2=
-->
\ No newline at end of file
-->
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment