Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a option to define the egg settings! #93

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/admin/redeem/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/redeem/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find the code in our database!"
"message" => "We cannot find the code in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -41,7 +41,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/redeem/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find the code in our database!"
"message" => "We cannot find the code in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -58,7 +58,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
2 changes: 1 addition & 1 deletion api/admin/settings/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
2 changes: 1 addition & 1 deletion api/admin/statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
ErrorHandler::Critical("Statistics ",$e);
Expand Down
4 changes: 2 additions & 2 deletions api/admin/user/ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
"message" => "We cannot find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -57,7 +57,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/user/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
"message" => "We cannot find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -80,7 +80,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/user/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -65,7 +65,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/user/reset-password.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
"message" => "We cannot find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -47,7 +47,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/user/resources/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
"message" => "We cannot find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -153,7 +153,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/user/resources/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
"message" => "We cannot find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -137,7 +137,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions api/admin/user/unban.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
"message" => "We cannot find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand All @@ -51,7 +51,7 @@
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
"message" => "We are sorry, but our server cannot handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Expand Down
54 changes: 54 additions & 0 deletions app/EggManagerConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace MythicalDash;

use MythicalDash\Database\Connect;

class EggManagerConfig
{
public static function getConfig($settingName)
{
$connect = new Connect();
$conn = $connect->connectToDatabase();
$sql = "SELECT setting_value FROM mythicaldash_eggs_config WHERE setting_name = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $settingName);
$stmt->execute();
$result = $stmt->get_result();
if ($row = $result->fetch_assoc()) {
return $row["setting_value"];
}
return null;
}

public static function updateConfig($settingName, $settingValue)
{
$connect = new Connect();
$conn = $connect->connectToDatabase();
$sql = "INSERT INTO mythicaldash_eggs_config (setting_name, setting_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $settingName, $settingValue);
return $stmt->execute();
}

public static function deleteConfig($settingName)
{
$connect = new Connect();
$conn = $connect->connectToDatabase();
$sql = "DELETE FROM mythicaldash_eggs_config WHERE setting_name = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $settingName);
return $stmt->execute();
}

public static function addConfig($settingName, $settingValue)
{
$connect = new Connect();
$conn = $connect->connectToDatabase();
$sql = "INSERT INTO mythicaldash_eggs_config (setting_name, setting_value) VALUES (?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $settingName, $settingValue);
return $stmt->execute();
}
}
?>
17 changes: 17 additions & 0 deletions app/SettingsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,21 @@ public static function getSetting($settingName) {
return null;
}
}
public static function updateSetting($settingName, $settingValue) {
$connect = new Connect();
$conn = $connect->connectToDatabase();
$safeSettingName = $conn->real_escape_string($settingName);
$safeSettingValue = $conn->real_escape_string($settingValue);

$query = "UPDATE mythicaldash_settings SET `$safeSettingName` = '$safeSettingValue'";

if ($conn->query($query)) {
$conn->close();
return true;
} else {
$conn->close();
return false;
}
}

}
Loading