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

[PHP] Please Help with a php script

Started by snoble2022, 05 January 2013 - 03:34 PM
snoble2022 #1
Posted 05 January 2013 - 04:34 PM
Hey guys, can anyone help me with something? I need someone to write a php script for me! WARNING: I'm completely dumb when it comes to php!

Requirments of the scipt:
- When I type the url it needs to take a paramater ( so heres what that would look like: www.mysite.com/files/script.php&filepath="ThePathToFile" )
- If the given path doesn't exist then it needs to pretend like it doesn't respond ( So when I call http.request(blahblah) it will return the event "http_failure" if the file doesn't exist
- The php script needs to take the information from the file (The text inside a file) and display it as a raw text format, kinda like what pastebin does
- It needs to be restricted to looking in one dir (so it would be the equivalent of fs.exists("TheBaseDirForLooking/"..filename) but thats in lua)
- Doesn't need any security features as long as its restricted to the one directory

Thanks guys, can anyone do this for me? I don't think it should be too hard. If you want hook up with me on skype to talk about it! (Just PM me for my skype)
Lyqyd #2
Posted 05 January 2013 - 05:39 PM
Try over in General. Moved.
Aichan #3
Posted 05 January 2013 - 05:47 PM
Will do it tomorrow as soon as I wake up, I'll edit this post not to spam
Dlcruz129 #4
Posted 05 January 2013 - 05:48 PM
Good luck getting help here. You'll probably have more luck on a PHP forum.
snoble2022 #5
Posted 05 January 2013 - 05:59 PM
Alright, thank you so much Aichan!

DLCruze: Where are some good forums
dissy #6
Posted 05 January 2013 - 06:03 PM
Good luck getting help here. You'll probably have more luck on a PHP forum.

I'd offer, but don't think he would want to pay my going rates ;}
A file upload over http post is not quite as simple as is stated above…

I just last week finished setting up a HasteBin server and writing a CC client to use it. No more pastebin expirations, yeay!
Dlcruz129 #7
Posted 05 January 2013 - 06:15 PM
Alright, thank you so much Aichan!

DLCruze: Where are some good forums

http://lmgtfy.com/?q=PHP+forums
Aichan #8
Posted 05 January 2013 - 06:16 PM
Doesn't look like an file upload but rather a file writing/editing…

I made something very similar there : http://www.computercraft.info/forums2/index.php?/topic/8198-web-editor-edit-your-scripts-through-a-highlighted-web-interface/
Jasonfran #9
Posted 05 January 2013 - 11:33 PM
You can echo a string to the site like


If(!fileexists){
    echo "File not found";
}

Lua

If requestdata == "File not found" or http_failure then
    --do your stuff
End


The file stuff is pretty simple, read the file line by line in Lua. Send the file data in a request and append a splitter character such as "|" or "&split&" something that would never be used. You can then split the post data into an array using PHPs explode function. And then loop through it and do what you want with the data. I don't think computer craft has the ability to properly send files over http, this is a good alternative.
Mads #10
Posted 06 January 2013 - 01:40 AM
This is like the simplest thing ever.
Exerro #11
Posted 06 January 2013 - 01:52 AM
in php…how do you return something to a pc in minecraft? can you use echo to return something?
GravityScore #12
Posted 06 January 2013 - 02:16 AM
Alright, thank you so much Aichan!

DLCruze: Where are some good forums

http://lmgtfy.com/?q=PHP+forums

Ha! I've never seen that before! Laughed so hard at that…. So going to use that in the future!
Someguy123 #13
Posted 06 January 2013 - 02:26 AM
in php…how do you return something to a pc in minecraft? can you use echo to return something?
Using the echo function in PHP will print out data, accessing the page from your turtle should allow it to read what was echo'd.
Aichan #14
Posted 06 January 2013 - 03:54 AM
http://pastebin.com/cMYH7s7A

Is that what you want?

Just forgot : the rmNonAlpha function will remove dots, so you can save file as "hello" but not "hello.txt" if it matters I'll change that