- PLEASE READ -
The login system and the inbox has been taken down while I change the scripts to use the new ccsystems script as this script is more secure and immature users have been abusing the php scripts. I shall post on here and on my profile when it has been updated, I apologise for any problems this may have caused.
A little bit about it ->
It runs of MySQL and PHP to work and uses lua to post and receive the data, it is all on databases so it means you can login and view your inbox no matter where you are as long as your url whitelist is disabled so you can connect to it!
Here is a small documentation I wrote up, it is also included at the top of the API, it is all commented so feel free to read through!
Pastebin code:
pastebin get WVW8j0NS blazeapi
CONTENTS:
———
Login -> Takes a username and password and will return true or false
Register -> Takes a username, password and email and returns true or false
Send -> Takes a username, password, recipient, subject, message and will return true or false
Delete -> Takea a username, password, and msgid, will then return true or false
Inbox -> Will take a username and password and return a nested array
WordWrap -> This will take a string and a character limit and will wrap the string to that character limit, returns a table
SHA256 -> This will take a string and return a hashed sum of it (The hashed sum is the stored password in the database)
How To Use:
———–
Login -> ec.login(username, password)
Simple. Give it a username and password and it will check it against the database, if that user exists then it will return the boolean value of true or false if no user exists. Always tell the user to register if they don't have a user account.
Register -> ec.register(username, password, email)
This will take a username, password and email, the email needs to be real as when someone forgets their password (future update) you can send them a link through email to reset password. It returns a boolean true or false if it worked or not.
Send -> ec.send(username, password, recipient, subject, message)
This needs to take a username, password, recipient, subject and message. The username and password allows it to check you're registered, and then the recipient, message and subject are all for the sending messsage. Make sure the subject is less than 20 characters and the message is less than 300 characters. Will return true or false on whether it worked or not, of course this may sometimes return false, when the message did send, so I wouldn't consider using the true or false values as the PHP script has it's moments.
Delete -> ec.delete(username, password, msgid)
This takes a username and password to check your account and then takes the msgid, which is the first value in the nested array, for example to get the first message's id, (the table of all messages is called inbox): inbox[1][1] and this will return the id, if you want the second messages id then use inbox[2][1], etc. This will of course return true or false as a boolean result on whether it worked or not. Please note sometimes the message will delete but cause of an error it may delete the message but return false, so always make sure first as it is tempermental.
Inbox -> ec.inbox(username, password)
This of course will return your whole inbox for the username and password arguments you give it, this may also be a slow process as the PHP script will loop through every single row of the table and add it to a lua nested array. So depending on internet speed and inbox count, so be wary to make this a function that is ONLY run when needed! Of cours to update the inbox etc. The format is as follows:
{
{
"Message ID",
"Message Sender",
"Recipeint",
"Subject",
"Message",
},
{
"Message 2 ID",
"Message 2 Sender",
"Recipient for message 2",
"Subject for message 2",
"Message for message 2",
},
}
so it is a nested table, so make sure when running through them that you get the right values from each message. Each message is it's own array inside another array, have any questions about this, email me on: danny@xigen.co.uk or PM me on the computercraft forums, my username is dannysmc95. Look at blaze for code snippets to display the contents but it is pretty simple as you can do a straight for loop on that array. for loops for nested tables work as so (this will get the second message in the table):for _, v in ipairs(inbox[2]) do
print(v)
end
Like I said any questions PM me or email me.
SHA256 -> ec.sha256(msg)
This is to be used with the database. All passwords should be hashed using this before they are stored or sent up, as this is what my Blaze Client uses to encrypt passwords and etc. Please use this like the following:
newPassword = ec.sha256(password)
and then use newPassword to send up (of course the variable names can be different if you want).
Word Wrap -> ec.wordwrap(string, limit)
This is something I added which may be useful, in essence it will wrap the string variable to the limit (which should be a number) and return a table, so if you have a string that is like 300 characters and you wish to make it automatically wrap it to a computer you can use (msg being the 300 character string) ec.wordwrap(msg, 51) - always make sure you never send a wordwrapped string up as it will error, or at least if you try and get it back the inbox will be messed up!
QUESTIONS:
———-
Any questions PM me on computercraft forums: dannysmc95, or email me on danny@xigen.co.uk
LICENSE:
——–
This is licensed under the Creative Commons (Attribution 3.0) license.
This declares you can:
Share - Copy and redistribute the material in any medium or format
Adapt - Remix, transform, and build upon the material for any purpose, even commercially.
AS LONG AS you follow the license terms which are as follows:
Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
In other words you can use it as you need, but you have to give credit to me. To do this add me into a credits section as the hoster and creator of the API, or link to my computercraft forums profile or my website: http://dannysmc.com.
I hope this is good and I hope you guys enjoy this, it is made so the email style of client can be standardized using this. So everyone can send emails to and fro without problems, with multiple programs created by many users but follow the same API to allow all the programs to work together!
Thanks Guys! If you used it to make an email program PM me so we can add it under here:
User Created Email Programs:
Blaze Email Client (DannySMc - dannysmc95)
Any questions PM me!
Thanks