SRL Archive - Research & Development Lounge

ReadExternalSCARMessage


MylesMadness

2008-10-11 10:48:24

Well, I always wanted to have to scar send messages over the internet to each other. So I made this:
[PHP]<?php
function str_between($str, $betw, $betw2) //by Ron
{
$str = " " . $str;
$pos = strpos($str, $betw);
if ($pos > 0)
{
$str2 = substr($str, $pos + strlen($betw));
$pos2 = strpos($str2, $betw2);
if ($pos2 == 0)
return '';
return substr($str2, 0, $pos2);
}
else
return '';
}

if(isset($_POST['Content'])){
$Content = $_POST['Content'];
$Id = $_POST['Id'];
$fp = fopen("report.txt", "a");
fwrite($fp, '<'.$Id.'>'.$Content.'</'.$Id.'>');
fclose($fp);
echo 'Done';
}else{
$Id = $_POST['Id'];
$file = fopen("report.txt","r");
echo Str_between(fread($file,filesize("report.txt")), '<'.$Id.'>', '</'.$Id.'>');
fclose($file);
}
?>[/PHP]

program New;
Function SendExternalSCARMessage(ID, Content:String):Boolean;
var
I:Integer;
begin
I:=InitializeHTTPClient(False, False);
AddPostVariable(I, 'Id', ID);
AddPostVariable(I, 'Content', Content);
Result:=True;
Writeln(PostHTTPPageEx(I, 'Url with the php file'));
end;

Function ReadExternalSCARMessage(ID:String):String;
var
I:Integer;
begin
I:=InitializeHTTPClient(False, False);
ClearPostData(I);
AddPostVariable(I, 'Id', ID);
Result:=PostHTTPPageEx(I, 'Url with the php file');
end;

begin
Writeln(ReadExternalSCARMessage('pie'));
end.

Credits to:
mixster:for helping me with between, even though I just used rons after it all

noidea

2008-10-11 10:58:16

Wow, this is cool. Maybe we could use this for some thing like the old bots used to do for the randoms. We tell SCAR what the correct answer is, for example the mouderot random. Good job!

MylesMadness

2008-10-11 13:56:16

So, sleepwalker? Its a start to it, but defiantly not the entire thing