This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
rickydaan's profile picture

[Question] How to make a website response to a CC Computer?

Started by rickydaan, 31 March 2012 - 08:10 AM
rickydaan #1
Posted 31 March 2012 - 10:10 AM
Hello, I want to make a site for my OS, so u can login & Register in the terminal. Passwords, registering, banning ect will be on the site.

Can someone tell me how to send a signal, and how the server responses to?
(I got: PhP, HTML, CSS (For layouts…), and more)
Xtansia #2
Posted 31 March 2012 - 10:36 AM
http.get and http.post return a file handle for a temp file containing the source code for what ever address it called,
IE:
html page returns html code,
txt file returns text in the file,
php script returns what ever was echoed by it,

basically whatever you see when you go to a page and do view page source.

So you can make a php script respond to get and post requests and echo an answer.

Take this php script:


<?php
$text = $_GET['text'];
$result = sha1($text);
echo $result;
?>

It echos the sha1 hash of the get field "text"

You can then use a program to get the sha1 hash,


local str = "Hello World" --String to hash
local file = http.get("hostname/sha1script.php?text="..str) --Make get request making field "text" = str
local hash = file:readAll() --Read all text from file
print(hash) --Print the resultant hash

That is a simple example,
You can make way more complicated things,
rickydaan #3
Posted 03 April 2012 - 11:55 AM
Well, I mean more like:

Me logging in on ComputerCraft OS — Site responses if pass is good
Session is being started (Able to make in PhP)
Im admin, I promote someone, PhP page gets the signal; Opens a file, cheanges level.
I logout, Session being stopped.

How do i make the page response
Advert #4
Posted 03 April 2012 - 11:57 AM
Any way you want. You just need to be able to tell the difference on the computer.
rickydaan #5
Posted 03 April 2012 - 03:08 PM
Yeah, i was doing stupid; Some if vars, a new GET value and done!