SRL Archive - SRL Snippets

Simple Online Progress Report


Mark

2013-09-23 20:30:00

A simple guide to setup your own hosted online progress report


While i was out today i thought it would be cool if we could check the progress our scripts without the need to setup teamviewer or other Remote clients you may use which can easily cause unwated lag to your system.

So here we go.

1: Step one your going to have to signup to a freehost (or use your own if you have one)
i used this one www.000webhost.com.

2:Creating the php files needed.
First open up notepad then copy the code below and save as CreateLog.php
remember to change the Save as type to All Files when saving.
[PHP]<?php
file_put_contents($_GET["ProgFileName"], '');
?>[/PHP]
Now upload that file to your server.
after that you can test the code from your browser like so
Replace YourSite with your hosted sites address then YourName with the file name you want to create.
http://www.YourSite.com/CreateLog.php?ProgFileName=YourName
what this does is when called it creates a new file on the server with the name specified under ProgFileName and overwrites existing if present make sure this is all working before you continue.

save this code as WriteProg.php like before remember to save the file correctly then upload.
[PHP]<?php
$current = file_get_contents($_GET["ProgFileName"]);
$current .= $_GET["TextToPrint"]."\n";
file_put_contents($_GET["ProgFileName"], $current);
?>[/PHP]
What this does is gets the current content of the ProgFileName Specified then writes the text held in TextToPrint to the next line.
You can test code again from the browser like so
http://www.YourSite.com/WriteProg.php?TextToPrint=YourTextGoesHere&ProgFileName=YourFileName
for text with spaces for example if you wanted your porggy to print
Cru1z1ns Online Prog.
it would actually only read out*
Cru1z1ns
as the browser url reads spaces as end of line you would have to replace the spaces with %20 which is ascii for space which the url bar can understand.
Now if your new file now contains your printed text then your good to go if not recheck your steps.

3:Creating simba code needed

First thing we need is a procedure to Create/Clean our log file we use simba's GetPage(url:string); Function to communicate with our hosted CreateLog.php we use the link we use to test creating a file earlier i wrote this.

//if you wanted you could create a Constant to hold your file name will make name changing easier
const
LogFileName = 'YourNameHere';

procedure CreateCleanLog;
begin
GetPage('www.YourSite.com/CreateLog.php?ProgFileName='+LogFileName);// smalls alterations to include LogFileName constant
end
test this procedure make sure it does wat is says on the tin then continue.

The next procedure we need is something to write the progress report to our log file


procedure PrintOnlineProg(ProggyLines:TStringArray);
var i:integer;
begin
CreateCleanLog;//creates/cleans log before writing.
SetLength(ProggyLines,High(ProggyLines)+1);
for i:= 0 to high(ProggyLines) do
GetPage('www.YourSite.com/WriteProg.php?TextToPrint='+ProggyLines[i]+'&ProgFileName='+LogFileName);
end;

this procedure takes a array of string and prints them in ascending order to your hosted report file.

Now to test this procedure.

this is just an example ive wrote to give you an idea.
     PrintOnlineProg(['Cru1z1ns%20Online%20Prog','Time-Running:%20'+IntToStr(GetTimeRunning),'mined:%20'+IntToStr(OresMined),'Fished:%20'+IntToStr(Fished),'blah:%20'+IntToStr(blah)]);
if done correct your file should look like this.
Cru1z1ns Online Prog
Time-Running: 562
mined: 24
Fished: 125
blah: 1366

now you can view your progress report from any browser like so
http//www.YourSite.com/LogFileName

Well thats it hope someone finds it useful.

Itankbots

2013-09-23 21:09:27

Nvm i mis read it lol

Looks pretty helpfull :) ima try this once i get my accs going on my dedi server

Mark

2013-09-24 10:21:05

From: Itankbots
Nvm i mis read it lol

Looks pretty helpfull :) ima try this once i get my accs going on my dedi server


im glad someone will find it useful.
while writing it i thought of creating a kind of Web UI (User Interface) so you could sends commands back to your bot to perform i might see how it goes later this evening.

if anybody has any ideas let me know.