Commit c3eec448 authored by Danny SMc's avatar Danny SMc

added fixes

parent 93c4cf1f
ewogIENvbmZpZyA9IHsKICAgIEF1dG9VcGRhdGUgPSB0cnVlLAogICAgUGx1Z2luc0RpcmVjdG9yeSA9ICIvREFfUGx1Z2lucyIsCiAgICBFbmFibGVQbHVnaW5zID0gdHJ1ZSwKICAgIENvbmZpZ0ZpbGVQYXRoID0gIi5EaXNjb3ZlckNvbmZpZyIsCiAgICBCbG9ja1Rlcm1pbmF0ZSA9IGZhbHNlLAogICAgRXhhbXBsZVNldHRpbmcgPSBmYWxzZSwKICAgIFBsdWdpbkNvbmZpZ0ZpbGUgPSAiLkRpc2NvdmVyQXBwUGx1Z2lucyIsCiAgfSwKICBBY2NvdW50ID0ge30sCn0=
\ No newline at end of file
ewogIENvbmZpZyA9IHsKICAgIEF1dG9VcGRhdGUgPSB0cnVlLAogICAgUGx1Z2luc0RpcmVjdG9yeSA9ICIvREFfUGx1Z2lucyIsCiAgICBFbmFibGVQbHVnaW5zID0gdHJ1ZSwKICAgIENvbmZpZ0ZpbGVQYXRoID0gIi5EaXNjb3ZlckNvbmZpZyIsCiAgICBCbG9ja1Rlcm1pbmF0ZSA9IGZhbHNlLAogICAgUGx1Z2luQ29uZmlnRmlsZSA9ICIuRGlzY292ZXJBcHBQbHVnaW5zIiwKICB9LAogIEFjY291bnQgPSB7CiAgICBQYXNzd29yZCA9ICJhZDRmYWEyNTYzNjdjYTNlNzlkZmI0MDAwZDIxZDdlMjgzNDAwYmJmMjhjZjMyOGE3MDUxZGJiZmE0NThiN2Q4IiwKICAgIFVzZXJuYW1lID0gImRhbm55c21jOTUiLAogIH0sCn0=
\ No newline at end of file
{
{
"L",
"o",
"r",
"e",
"m",
" ",
"i",
"p",
"s",
"u",
"m",
" ",
"d",
"o",
"l",
"o",
"r",
" ",
"s",
"i",
"t",
" ",
"a",
"m",
"e",
"t",
",",
" ",
"c",
"o",
"n",
"s",
"e",
"c",
"t",
"e",
},
{
"t",
"u",
"r",
" ",
"a",
"d",
"i",
"p",
"i",
"s",
"c",
"i",
"n",
"g",
" ",
"e",
"l",
"i",
"t",
",",
" ",
"s",
"e",
"d",
" ",
"d",
"o",
" ",
"e",
"i",
"u",
"s",
"m",
"o",
"d",
" ",
},
{
"t",
"e",
"m",
"p",
"o",
"r",
" ",
"i",
"n",
"c",
"i",
"d",
"i",
"d",
"u",
"n",
"t",
" ",
"u",
"t",
" ",
"l",
"a",
"b",
"o",
"r",
"e",
" ",
"e",
"t",
" ",
"d",
"o",
"l",
"o",
"r",
},
{
"e",
" ",
"m",
"a",
"g",
"n",
"a",
" ",
"a",
"l",
"i",
"q",
"u",
"a",
".",
" ",
"U",
"t",
" ",
"e",
"n",
"i",
"m",
" ",
"a",
"d",
" ",
"m",
"i",
"n",
"i",
"m",
" ",
"v",
"e",
"n",
},
{
"i",
"a",
"m",
",",
" ",
"q",
"u",
"i",
"s",
" ",
"n",
"o",
"s",
"t",
"r",
"u",
"d",
" ",
"e",
"x",
"e",
"r",
"c",
"i",
"t",
"a",
"t",
"i",
"o",
"n",
".",
},
}
\ No newline at end of file
......@@ -62,8 +62,8 @@ function program.account.login()
program.account.register()
elseif (args[3] >= 46 and args[3] <= 50) and (args[4] == 19) then
DiscoverApp.Callbacks.Run("Login")
local status = Discover.User:Login(username, password)
if status then
local login_status = Discover.User:Login(username, password)
if login_status then
if status then
-- Create Config
local f = fs.open(Internal.Config.ConfigFilePath, "w")
......
......@@ -82,7 +82,7 @@ function program.apps.owned()
if ev == "key" then
if nk == 28 then
base.screen.colour("white")
store.draw.menu("Apps: Owned")
program.draw.menubar("Apps: Owned")
base.colour.set("cyan", "white")
term.setCursorPos(1, 4)
print("Deleting...")
......@@ -94,7 +94,7 @@ function program.apps.owned()
sleep(0.5)
program.apps.owned()
else
base.gui.alert(discover.data.errormsg)
base.gui.alert(Discover.User.Data.ErrorMsg)
sleep(1.5)
program.apps.owned()
end
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ Internal = {
Details = {
Name = "Discover App";
Description = "Discover Network Application.";
Version = 7.3;
Version = 7.4;
Build = 114;
ReleaseKey = "47e748dcf1759597ddc91855f0e95673648d172bb72fdb820679735ca9ea5d47293ca7e5b26e91eb0e3dce660905d75c7617e12121306c4f79190cfef45fe7cd";
};
......
......@@ -29,9 +29,9 @@ Discover = {
};
Core = {
Internal = {
Version = "0.7";
Build = "78";
Release = "Beta";
Version = "1.0";
Build = "178";
Release = "Release";
};
Report = function( self, data )
local query = "cmd=report_bug&data=" .. tostring(textutils.serialize(data));
......@@ -225,8 +225,6 @@ 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)
......@@ -499,8 +497,6 @@ 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
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -30,7 +30,7 @@ if fs.exists(path) then
end
print("Installing, please wait...");
local url = 'https://discoverapi.xyz/files/download/discoverapp/lua';
local url = 'http://discoverapi.xyz/files/download/discoverapp/lua';
local d = http.get(url)
local data = d.readAll()
local f = fs.open(path, "w")
......
......@@ -53,7 +53,7 @@ function program.main.settings(screen)
base.draw.textr("Exit ", 19, false, "red", "grey")
base.draw.textl(" About", 19, false, "lightBlue", "grey")
base.draw.textc("Refresh", 19, false, "orange", "grey")
base.draw.textl(" Setting Names | Value / Enabled | Edit |", 3, false, "lightGrey", "white")
base.draw.textl("| Setting Name | Value / Enabled | Edit |", 3, false, "lightGrey", "white")
local scroll = 0; local options = {};
for k,v in pairs(Internal.Config) do table.insert(options, k); end
......
......@@ -2,6 +2,10 @@ function program.main.updates(name)
tData = {
{
["name"] = "Update: 7.4.0 (Release)";
["content"] = "This is the start of a slow re-working series; where I shall re-build each screen into a better UX. I am starting slow but I plan to create updates for each upgrade for you to check and tell me what you think. This time I have re-build the list view for the tickets, due to them not having very much information on the list page, so this may be better? If you have any better UX ideas, please tell me, would love to create something you guys would prefer.";
};
{
["name"] = "Update: 7.3.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.";
};
{
......
......@@ -7,21 +7,23 @@ function program.tickets.create()
base.screen.colour("white")
program.draw.menubar("Tickets: Create")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Back ", 19, false, "red", "grey")
base.draw.textl(" List Tickets", 19, false, "lightBlue", "grey")
base.draw.textc("Reset Form", 19, false, "orange", "grey")
base.draw.textl(" Back", 19, false, "red", "grey")
base.draw.textr("Create ", 19, false, "orange", "grey")
local text = "When creating a ticket, make sure to explain yourself clearly, any bugs, please tell me the steps you took so I can reproduce the error. Also include any error messages given."
local text = "Explain the problem in detail, and make sure to include any error messages, and steps to reproduce the bug."
for k,v in ipairs(base.data.wordwrap(text, 49)) do
base.draw.textc(v, k+3, false, "cyan", "white")
end
base.draw.texta("Title:", 8, 9, false, "lightGrey", "white")
base.draw.box(8, 36, 10, 1, " ", "cyan", "cyan")
base.draw.texta("Message:", 8, 12, false, "lightGrey", "white")
base.draw.texta("Title:", 8, 8, false, "lightGrey", "white")
base.draw.box(8, 36, 9, 1, " ", "cyan", "cyan")
base.draw.texta("Message:", 8, 11, false, "lightGrey", "white")
base.draw.box(8, 36, 12, 1, " ", "cyan", "cyan")
base.draw.box(8, 36, 13, 1, " ", "cyan", "cyan")
base.draw.textc(" Create Ticket ", 16, false, "white", "cyan")
base.draw.box(8, 36, 14, 1, " ", "cyan", "cyan")
base.draw.box(8, 36, 15, 1, " ", "cyan", "cyan")
base.draw.box(8, 36, 16, 1, " ", "cyan", "cyan")
base.draw.box(8, 36, 17, 1, " ", "cyan", "cyan")
while true do
local args = { os.pullEvent() }
......@@ -30,25 +32,7 @@ function program.tickets.create()
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Tickets: Create", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
program.tickets.main()
elseif (args[3] >= 2 and args[3] <= 13) and args[4] == 19 then
program.tickets.list()
elseif (args[3] >= 18 and args[3] <= 32) and args[4] == 19 then
program.tickets.create()
elseif (args[3] >= 8 and args[3] <= 43) and args[4] == 10 then
base.draw.box(8, 36, 10, 1, " ", "cyan", "cyan")
base.colour.set("white", "cyan")
term.setCursorPos(8, 10)
write(": ")
title = tostring(base.io.limitRead(34))
elseif (args[3] >= 8 and args[3] <= 43) and args[4] == 13 then
base.draw.box(8, 36, 13, 1, " ", "cyan", "cyan")
base.colour.set("white", "cyan")
term.setCursorPos(8, 13)
write(": ")
message = tostring(base.io.limitRead(34))
elseif (args[3] >= 16 and args[3] <= 34) and args[4] == 16 then
elseif (args[3] >= 45 and args[3] <= 50) and args[4] == 19 then
if title and message then
local ok, err = Discover.Tickets:Create(title, message)
if not ok then
......@@ -65,6 +49,20 @@ function program.tickets.create()
sleep(1)
base.draw.box(1, 51, 18, 1, " ", "white", "white")
end
elseif (args[3] >= 2 and args[3] <= 5) and args[4] == 19 then
program.tickets.main()
elseif (args[3] >= 8 and args[3] <= 43) and args[4] == 9 then
base.draw.box(8, 36, 9, 1, " ", "cyan", "cyan")
base.colour.set("white", "cyan")
term.setCursorPos(8, 9)
write(": ")
title = tostring(base.io.limitRead(34))
elseif (args[3] >= 8 and args[3] <= 43) and (args[4] >= 12 and args[4] <= 17) then
if (message) then
message = base.gui.textbox(8, 12, 43, 17, 'white', 'cyan', message);
else
message = base.gui.textbox(8, 12, 43, 17, 'white', 'cyan');
end
end
end
end
......
......@@ -11,6 +11,7 @@ function program.tickets.list()
base.draw.textc("Refresh", 19, false, "orange", "grey")
base.draw.textl(" Create", 19, false, "lightBlue", "grey")
local scroll = 0;
local platform = base.core.getPlatform();
base.draw.textc("Download tickets list...", 10, false, "red", "white")
local ok, tickets = Discover.Tickets:List()
......@@ -23,19 +24,43 @@ function program.tickets.list()
end
local function render()
for i=1, 14 do
if i+scroll <= #tickets then
base.draw.box(1, 51, i+3, 1, " ", "white", "white")
base.draw.texta(i+scroll .. ": " ..tostring(tickets[i+scroll]['title']:sub(1, 40)), 2, i+3, false, "cyan", "white")
if (tickets[i+scroll]['status'] == "true") then
base.draw.textr("Fixed ", i+3, false, "green", "white")
else
base.draw.textr("Pending ", i+3, false, "red", "white")
end
if (#tickets > 0) then
base.draw.box(1, 51, 12, 1, ' ', 'white', 'white');
local positions = {4, 9, 14};
local scrollpos = scroll;
for k,v in ipairs(positions) do
base.draw.box(2, 49, v, 2, ' ', 'white', 'white');
base.draw.box(2, 49, v+2, 2, ' ', 'white', 'white');
if (k+scrollpos <= #tickets) then
base.draw.textr('Ticket ID: ' .. tostring(tickets[k+scrollpos]['token']) .. ' ', v, false, 'lightBlue', 'white');
base.draw.textl(' ' .. k+scrollpos .. '.', v, false, 'grey', 'white')
base.draw.box(2, 49, v+1, 2, ' ', 'lightGrey', 'lightGrey');
base.draw.box(2, 49, v+3, 1, ' ', 'orange', 'orange');
local offset = (platform.Dimensions.Width - 4);
local titles = base.data.wordwrap(tostring(tickets[k+scrollpos]['title']), 47);
base.draw.texta(titles[1], 3, v+1, false, 'white', 'lightGrey');
if (type(titles[2]) == 'string') then
base.draw.texta(titles[2]:sub(1, 32), 3, v+2, false, 'white', 'lightGrey');
end
base.draw.texta('- ' .. tostring(tickets[k+scrollpos]['ntime']), (offset + 1) - tostring(tickets[k+scrollpos]['ntime']):len(), v+2, false, 'grey', 'lightGrey');
base.draw.texta('By ' .. tostring(tickets[k+scrollpos]['author']), offset - tostring(tickets[k+scrollpos]['author']):len(), v+3, false, 'white', 'orange');
if (tostring(tickets[k+scrollpos]['status']) == true) then
base.draw.texta('Fixed', 3, v+3, false, 'lightGrey', 'orange');
else
base.draw.texta('In-Progress', 3, v+3, false, 'red', 'orange');
end
end
end
end
if #tickets < 1 then
base.draw.textc("No tickets to show! Good sign right? ;)", 10, false, "red", "white")
else
base.draw.box(1, 51, 12, 1, ' ', 'white', 'white');
base.draw.textc('No tickets to show', 10, false, 'red', 'white');
end
end
......@@ -54,9 +79,32 @@ function program.tickets.list()
elseif (args[3] >= 2 and args[3] <= 7) and args[4] == 19 then
program.tickets.create()
elseif (args[3] >= 2 and args[3] <= 50) and (args[4] >= 4 and args[4] <= 17) then
local key = args[4] - 3 + scroll
if key <= #tickets then
program.tickets.view(tickets[key].id, tickets[key])
-- Ticket Click
if (args[3] >= 2 and args[3] <= 50) and (args[4] >= 4 and args[4] <= 7) then
-- First Tile
local key = 1 + scroll;
if key <= #tickets then
program.tickets.view(tickets[key].id, tickets[key])
end
elseif (args[3] >= 2 and args[3] <= 50) and (args[4] >= 4 and args[4] <= 7) then
-- Second Tile
local key = 2 + scroll;
if key <= #tickets then
program.tickets.view(tickets[key].id, tickets[key])
end
elseif (args[3] >= 2 and args[3] <= 50) and (args[4] >= 4 and args[4] <= 7) then
-- Third Tile
local key = 3 + scroll;
if key <= #tickets then
program.tickets.view(tickets[key].id, tickets[key])
end
end
end
elseif args[1] == "mouse_scroll" then
......@@ -66,11 +114,37 @@ function program.tickets.list()
render()
end
elseif args[2] == 1 then
if scroll+14 < #tickets then
if scroll+3 < #tickets then
scroll = scroll + 1
render();
end
end
end
end
end
\ No newline at end of file
end
--[[
---------------------------------------------------
---------------------------------------------------
--]]
\ No newline at end of file
<?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
This diff is collapsed.