Jump to content




[PHP] Please Help with a php script

utility wireless networking

  • You cannot reply to this topic
13 replies to this topic

#1 snoble2022

  • Members
  • 100 posts
  • LocationSomewhere near the local computer store?

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)

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 January 2013 - 05:39 PM

Try over in General. Moved.

#3 Aichan

  • Members
  • 25 posts

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

#4 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 05 January 2013 - 05:48 PM

Good luck getting help here. You'll probably have more luck on a PHP forum.

#5 snoble2022

  • Members
  • 100 posts
  • LocationSomewhere near the local computer store?

Posted 05 January 2013 - 05:59 PM

Alright, thank you so much Aichan!

DLCruze: Where are some good forums

#6 dissy

  • Members
  • 181 posts

Posted 05 January 2013 - 06:03 PM

View PostDlcruz129, on 05 January 2013 - 05:48 PM, said:

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!

#7 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 05 January 2013 - 06:15 PM

View Postsnoble2022, on 05 January 2013 - 05:59 PM, said:

Alright, thank you so much Aichan!

DLCruze: Where are some good forums

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

#8 Aichan

  • Members
  • 25 posts

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.computerc...-web-interface/

#9 Jasonfran

  • Members
  • 148 posts
  • LocationEngland

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.

#10 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 06 January 2013 - 01:40 AM

This is like the simplest thing ever.

#11 Exerro

  • Members
  • 801 posts

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?

#12 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 06 January 2013 - 02:16 AM

View PostDlcruz129, on 05 January 2013 - 06:15 PM, said:

View Postsnoble2022, on 05 January 2013 - 05:59 PM, said:

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!

#13 Someguy123

  • New Members
  • 12 posts

Posted 06 January 2013 - 02:26 AM

View Postawsumben13, on 06 January 2013 - 01:52 AM, said:

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.

#14 Aichan

  • Members
  • 25 posts

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users