Commit d7ced2e3 authored by Danny SMc's avatar Danny SMc

Updated to 7.3

parent 6598160b
ewogIENvbmZpZyA9IHsKICAgIEF1dG9VcGRhdGUgPSB0cnVlLAogICAgUGx1Z2luc0RpcmVjdG9yeSA9ICIvREFfUGx1Z2lucyIsCiAgICBFbmFibGVQbHVnaW5zID0gdHJ1ZSwKICAgIENvbmZpZ0ZpbGVQYXRoID0gIi5EaXNjb3ZlckNvbmZpZyIsCiAgICBCbG9ja1Rlcm1pbmF0ZSA9IGZhbHNlLAogICAgRXhhbXBsZVNldHRpbmcgPSBmYWxzZSwKICAgIFBsdWdpbkNvbmZpZ0ZpbGUgPSAiLkRpc2NvdmVyQXBwUGx1Z2lucyIsCiAgfSwKICBBY2NvdW50ID0ge30sCn0=
\ No newline at end of file
alsfhsdkg
\ No newline at end of file
......@@ -108,7 +108,7 @@ function base.net.request(url, query, headers)
end
end
function base.net.post()
function base.net.post(url, query, headers)
if url and (type(url) == "string") then
local tHead = Internal.Headers;
if headers then
......@@ -130,7 +130,7 @@ function base.net.post()
end
end
function base.net.get()
function base.net.get(url, query, headers)
if url and (type(url) == "string") then
local tHead = Internal.Headers;
if headers then
......
......@@ -12,8 +12,8 @@ Internal = {
Details = {
Name = "Discover App";
Description = "Discover Network Application.";
Version = 7.0;
Build = 054;
Version = 7.3;
Build = 114;
ReleaseKey = "47e748dcf1759597ddc91855f0e95673648d172bb72fdb820679735ca9ea5d47293ca7e5b26e91eb0e3dce660905d75c7617e12121306c4f79190cfef45fe7cd";
};
Config = {
......
......@@ -16,11 +16,11 @@
Discover = {
Data = {
Urls = {
Store = "http://api.dannysmc.com/store.php";
User = "http://api.dannysmc.com/user.php";
Projects = "http://api.dannysmc.com/projects.php";
Distribution = "http://api.dannysmc.com/distribution.php";
Pastebin = "https://api.dannysmc.com/pastebin.php";
Store = "https://discoverapi.xyz/api/store";
User = "https://discoverapi.xyz/api/user";
Projects = "https://discoverapi.xyz/api/projects";
Distribution = "https://discoverapi.xyz/api/distribution";
Pastebin = "https://discoverapi.xyz/api/pastebin";
};
Headers = {
["User-Agent"] = "DiscoverAPI";
......@@ -29,9 +29,9 @@ Discover = {
};
Core = {
Internal = {
Version = "0.1";
Build = "1";
Release = "Alpha";
Version = "0.7";
Build = "78";
Release = "Beta";
};
Report = function( self, data )
local query = "cmd=report_bug&data=" .. tostring(textutils.serialize(data));
......@@ -145,6 +145,16 @@ Discover = {
GetRank = function( self )
return tostring(self.Data.Rank);
end;
CheckIP = function( self )
local query = "cmd=check-ip";
local res = http.post(Discover.Data.Urls.User, query, Discover.Data.Headers)
res = textutils.unserialize(res.readAll())
if res.status == true then
return unpack({true, tostring(res.error)});
elseif res.status == false then
return unpack({false, tostring(res.error)});
end
end;
Reset = function( self )
self.Data.Username = nil;
self.Data.Password = nil;
......@@ -215,6 +225,8 @@ Discover = {
end
local query = "cmd=register&username="..textutils.urlEncode(tostring(username)).."&password="..textutils.urlEncode(tostring(password)).."&email="..textutils.urlEncode(tostring(email))
local req = http.post(Discover.Data.Urls.User, query, Discover.Data.Headers)
print(req.readAll());
sleep(100000);
req = textutils.unserialize(req.readAll())
if req.status then
self.Data.CMessage = tostring(req.message)
......@@ -487,6 +499,8 @@ Discover = {
end
local query = "cmd=upload&authkey="..textutils.urlEncode(tostring(Discover.User.Data.AuthKey)).."&name="..textutils.urlEncode(tostring(appname)).."&desc="..textutils.urlEncode(tostring(appdesc)).."&vers="..textutils.urlEncode(tostring(appvers)).."&cate="..textutils.urlEncode(tostring(appcate)).."&status="..textutils.urlEncode(tostring(appstat)).."&data="..textutils.urlEncode(tostring(appdata))
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
print(req.readAll());
sleep(10000);
req = textutils.unserialize(req.readAll())
if req.status then
Discover.User.Data.CMessage = req.message
......@@ -696,14 +710,14 @@ Discover = {
end
end;
Delete = function( self, id )
local query = "cmd=snippets_delete&id="..textutils.urlEncode(tostring(id)).."&key="..textutils.urlEncode(tostring(Discover.User.Data.Authkey))
local req = http.post(self.data.urls.store, query)
local query = "cmd=snippets_delete&id="..textutils.urlEncode(tostring(id)).."&key="..textutils.urlEncode(tostring(Discover.User.Data.AuthKey))
local req = http.post(Discover.Data.Urls.Store, query);
req = textutils.unserialize(req.readAll())
if req.status then
self.data.cmessage = tostring(req.message)
Discover.User.Data.CMessage = tostring(req.message)
return true
else
self.data.errormsg = req.error
Discover.User.Data.ErrorMsg = req.error
return false
end
end;
......@@ -805,12 +819,6 @@ Discover = {
};
Mail = {
Create = function( self, recipient, subject, message, attachments )
if attachments then
local f = fs.open(attachments, "r")
local d = f.readAll()
f.close()
attachments = d
end
local query = "cmd=mail_send&key=" ..textutils.urlEncode(tostring(Discover.User.Data.AuthKey)) .. "&recipient=" ..textutils.urlEncode(tostring(recipient)) .. "&subject=" ..textutils.urlEncode(tostring(subject)) .. "&message=" ..textutils.urlEncode(tostring(message)) .. "&attachments=" ..textutils.urlEncode(tostring(attachments))
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
req = textutils.unserialize(req.readAll())
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,72 +3,38 @@
Author: DannySMc (dannysmc95)
]]
--// Define Functions
function clear()
term.clear()
term.setCursorPos(1,1)
term.clear();
term.setCursorPos(1,1);
end
function setColour(tc, bc)
term.setTextColor(colours[tc])
term.setBackgroundColour(colours[bc])
term.setTextColor(colours[tc]);
term.setBackgroundColour(colours[bc]);
end
printo = print;
function print(text, skip, wait)
if text then
printo(text);
end
if skip then
local _, y = term.getCursorPos();
term.setCursorPos(1, y+1)
end
if wait then
sleep(wait)
end
end
clear();
setColour("cyan", "black")
print("DiscoverApp Installer", true);
setColour("orange", "black")
print("Please choose the path to install the file to:")
setColour("red", "black")
write("> ")
setColour("white", "black")
--// Start Code
clear(); setColour('cyan', 'black');
print("DiscoverApp Installer");
setColour("orange", "black");
print("Please choose the path to install the file to:");
setColour("red", "black");
write("> ");
setColour("white", "black");
local path = tostring(read());
setColour("orange", "black")
setColour("orange", "black");
print("Checking, please wait...", false, 0.5);
if fs.exists(path) then
error("File already exists in that path...")
error("File already exists in that path...");
end
print("Installing, please wait...", false, 0.5);
local url = "http://api.dannysmc.com/files/programs/DiscoverApp.lua";
local url = 'https://discoverapi.xyz/files/download/discoverapp/lua';
local d = http.get(url)
local data = d.readAll()
local f = fs.open(path, "w")
f.write(data)
f.close();
print("Success!! Discover is installed as: " .. path, true, 0.5)
print("Auto-Running in 3 seconds, click any button to cancel")
local count = 4;
os.startTimer(1)
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
count = count - 1;
setColour("lightBlue", "black")
print("Running in " .. tostring(count) .. " second(s)", true, 1)
if count == 0 then
shell.run(path)
end
os.startTimer(1)
elseif args[1] == "char" then
print("Cancelled, leaving program...", false, 0.5)
break;
end
end
clear();
\ No newline at end of file
print("Success!! Discover is installed as: " .. path, true, 0.5);
\ No newline at end of file
......@@ -68,13 +68,13 @@ function program.main.home()
["thrd_name"] = "Feed";
["req_login"] = true;
};
{
--[[{
["icon_name"] = "chatRooms";
["base_func"] = "chat";
["func_name"] = "main";
["thrd_name"] = "Chat";
["req_login"] = true;
};
};--]]
{
["icon_name"] = "profiles";
["base_func"] = "profile";
......
function program.main.updates(name)
tData = {
{
["name"] = "Update: 7.4.0 (Release)";
["content"] = "Due to some changes to my PHP version on my server and the move over to PHP 7.1 everyone has been experiencing various bugs across the Discover Application, I have made a multitude of bug fixes but due to the changes I need to make to the application I am going to make a few updates to the application and brand it under a new version, so please see 8.0.0 for more information.";
};
{
["name"] = "Update: 7.0.1 (Beta)";
["content"] = "First public release. This is a complete re-code of most of the core inner workings of the store including new task manager, menu bar, and home page, as well as better settings screen and also gives access for better plugin support, allowing you to create plugins to install menu tiles to the home screen. I have also added a new CLI based interface, which is internal to the app, but will come out as an external program, that will link directly into the CraftOS shell.";
......
{
app_uploads = "12",
snippet_downloads = "15",
bio = "A web developer by career and hobbyist programmer.",
app_downloads = "261",
snippet_uploads = "1",
location = "UK/London",
newsfeed_posts = {
{
id = "35",
sent = "14:52 09-08-2016",
message = "So for the newsfeed, I am thinking of having like a small list on the right of posters, allowing you to click and skip to that post due to so many posts being on here? What do you think?",
author = "dannysmc95",
},
{
id = "34",
sent = "02:18 19-07-2016",
message = "Well everyone the first post on my blog has gone up about the beta trial of the DiscoverApp, this is to test the program, get your ideas, and hear about bugs and awesome features you want me to add into the program.",
author = "dannysmc95",
},
{
id = "33",
sent = "23:54 14-07-2016",
message = "This could be that the account name has already been used!! A lot of people run into this issue, in the new store app this is fixed! :D",
author = "dannysmc95",
},
{
id = "31",
sent = "12:40 14-07-2016",
message = "This should be fixed now!",
author = "dannysmc95",
},
{
id = "30",
sent = "12:35 14-07-2016",
message = "I shall remove that post and fix that xD",
author = "dannysmc95",
},
{
id = "27",
sent = "18:29 13-07-2016",
message = "fishtoast, using lots of code ;) If you are interested send me a message on the CCForums! I am DannySMc.",
author = "dannysmc95",
},
{
id = "25",
sent = "12:46 13-07-2016",
message = "Thank you addd84513, I have a new version that is a new redesign on the current version, maybe you could beta test it for me??:D",
author = "dannysmc95",
},
{
id = "22",
sent = "10:46 29-06-2016",
message = "Wilma, check your mail (on the store), have sent you an update :P I have explained the problem, and how you just need to re-upload as I have fixed it now.",
author = "dannysmc95",
},
{
id = "20",
sent = "16:02 24-06-2016",
message = "This does work, please make sure you set the status of the app as public",
author = "dannysmc95",
},
{
id = "18",
sent = "15:01 15-06-2016",
message = "Never mind Wilma, you should be able to upload apps now, it was because I had used the wrong table name, when moving the code to a new database.",
author = "dannysmc95",
},
},
registered = "19/12/2014",
website = "https://dannysmc.com/",
username = "dannysmc95",
name = "Danny SMc",
birthday = "24/04/1995",
}
\ No newline at end of file
......@@ -73,15 +73,13 @@ function program.snippets.owned()
local curid = args[4] - 3 + scroll
if #snippets_list >= curid then
-- Delete
local stat = discover:snippets_delete(snippets_list[curid].id)
local stat = Discover.Snippets:Delete(snippets_list[curid].id)
if stat then
base.gui.alert("Snippet deleted!")
sleep(1)
program.snippets.owned()
else
base.gui.alert("Snippet was unable to be deleted!")
sleep(1)
base.gui.alert(discover.data.errormsg)
sleep(1.5)
program.snippets.owned()
end
......
This diff is collapsed.
<?php
function luasub($text) {
$text = str_replace(array("{","}","\"","\'","\\"), "", $text);
return checkString($text);
}
function getfield($key, $field) {
global $conn;
global $users;
// Get $field with the auth key
$sql1 = "SELECT * FROM `$users` WHERE `authkey` = '$key'";
$result1 = $conn->query($sql1);
$data1 = $result1->fetch_all(MYSQLI_ASSOC);
return $data1[0][$field];
}
function validatekey($akey) {
global $conn;
global $users;
// Check key exists
$sql = "SELECT * FROM `cc__users` WHERE `authkey` = '$akey'";
$res = $conn->query($sql);
$data = $res->fetch_all(MYSQLI_ASSOC);
$authtime = $data[0]['authkey_time'];
$status = $data[0]['status'];
if($status == "blocked") {
echo '{["status"]=false;["error"]="You are blocked from the system";["information"]="To help prevent spam, a automated system will log each time you upload, then store it against your username and IP. If you upload, add a comment, download, or register to the system too many times in a time period you will be automatically blocked. To release your block please contact admin: danny.smc95@gmail.com sorry for any inconvenience this could of caused if you are a genuine user.";}';
die();
}
if ($res->num_rows) {
// So there is a key, make sure it is valid
$current = time();
$age = $current - $authtime;
if ($age < 172800) {
return true;
} else {
echo '{["status"]=false;["error"]="Key has expired, please re-login";}';
die();
}
} else {
echo '{["status"]=false;["error"]="Key not found, please re-login";}';
die();
}
}
function ratelimit($auth) {
global $conn;
$rltable = "cc__ratelimit";
if ($auth === "use_ip") {
// Use IP
} else {
// Use username
$username = getfield($auth, "username");
$sql = "SELECT * FROM `$rltable` WHERE `username` = '$username'";
$result = $conn->query($sql);
$data = $result->fetch_all(MYSQLI_ASSOC);
if ($result->num_rows > 0) {
$then = $data[0]['stamp'];
$now = time();
$diff = $now - $then;
if ($diff <= 3) {
// Check counter
$curcount = $data[0]['count'];
if ($curcount >= 5) {
// Block user
$sql = "UPDATE `$rltable` SET `stamp` = '$now' WHERE `username` = '$username'";
$conn->query($sql);
$sql = "UPDATE `cc__users` SET `status` = 'blocked' WHERE `username` = '$username'";
$result = $conn->query($sql);
if ($result->affected_rows > 0) {
// Worked
} else {
}
} else {
// Add to counter
$sql = "UPDATE `$rltable` SET `stamp` = '$now' WHERE `username` = '$username'";
$conn->query($sql);
$sql = "UPDATE `$rltable` SET `count` = count + 1, `stamp` = '$now' WHERE `username` = '$username'";
$result = $conn->query($sql);
}
} else {
$sql = "UPDATE `$rltable` SET `stamp` = '$now' WHERE `username` = '$username'";
$conn->query($sql);
}
} else {
// No record, so add new:
$stam = time();
$coun = 1;
$addr = $_SERVER['remote_addr'];
$sql = "INSERT INTO `$rltable` (username, ipaddress, stamp, count) VALUES ('$username', '$addr', '$stam', '$count')";
$result = $conn->query($sql);
}
}
}
function rateblocking($postdata) {
global $conn;
$ip = $_SERVER['REMOTE_ADDR'];
$date = new DateTime();
$stamp = $date->getTimestamp();
// Check for IP
$sql = "SELECT * FROM `cc__store_limit` WHERE `ipaddress` = '$ip'";
$res = $conn->query($sql);
$data = $res->fetch_all(MYSQLI_ASSOC);
if ($res->num_rows > 0) {
// Check counter
if ($data[0]['counter'] > 5) {
echo '{["status"]=false;["error"]="Your IP has been banned as spam";["message"]="Your IP has been banned as spam";}';
die();
}
// Get difference
$dif = $stamp - intval($data[0]['stamp']);
// Get ID
$id = $data[0]['id'];
if ($dif < 0) {
// If abusing add to counter
$accsql2 = "UPDATE `cc__store_limit` SET `counter` = counter + 1 WHERE `id` = $id";
$conn->query($accsql2);
}
// Update stamp
$accsql2 = "UPDATE `cc__store_limit` SET `stamp` = '$stamp' WHERE `id` = $id";
$conn->query($accsql2);
} else {
$sql = "INSERT INTO `cc__store_limit` (ipaddress, stamp, counter) VALUES ('$ip','$stamp',1)";
$res = $conn->query($sql);
}
}
function getGravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
$url = 'http://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$s&d=$d&r=$r";
if ( $img ) {
$url = '<img src="' . $url . '"';
foreach ( $atts as $key => $val )
$url .= ' ' . $key . '="' . $val . '"';
$url .= ' />';
}
return $url;
}
function ago($time) {
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
$periods[$j].= "s";
}
return "$difference $periods[$j] ago ";
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment