// now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2"))
if ($arr["sort"] == "yes") {
usort($os, "srt");
} needs to be called as a string, not a constant it seems. Just wrap srt in quotes. It only sets a warning, not the end of the world, but if you wanna make it correct, this is it. I been slowly in my free time trying to get this script fully working on php 8+, so I been fixing these errors along the way best I can lol function sqlerr($file = __FILE__, $line = __LINE__) {
global $DBconnector; // $DBconnector mysqli connection TTv3
$error = $DBconnector->error;
error_log("SQL error in $file on line $line: $error");
die("An error occurred while executing the query. Please try again later.");
}
// Enable error reporting for development
ini_set('display_errors', 1); // Display errors on the screen
ini_set('display_startup_errors', 1); // Display errors during PHP startup
error_reporting(E_ALL); // Report all errors, warnings, and notices declare(strict_types=1);
class BEncode
{
// Sort dictionary keys
private function makeSorted(array $array): array
{
ksort($array);
return $array;
}
// Encode a single entry
private function encodeEntry($entry, string &$fd): void
{
if (is_int($entry) || is_float($entry)) {
$fd .= "i{$entry}e";
} elseif (is_string($entry)) {
$fd .= strlen($entry) . ":{$entry}";
} else {
throw new InvalidArgumentException("Unsupported entry type.");
}
}
// Encode a list
private function encodeList(array $list, string &$fd): void
{
$fd .= "l";
foreach ($list as $item) {
$this->decideEncode($item, $fd);
}
$fd .= "e";
}
// Encode a dictionary
private function encodeDict(array $dict, string &$fd): void
{
$fd .= "d";
$sortedDict = $this->makeSorted($dict);
foreach ($sortedDict as $key => $value) {
$this->encodeEntry($key, $fd);
$this->decideEncode($value, $fd);
}
$fd .= "e";
}
// Decide what to encode
private function decideEncode($data, string &$fd): void
{
if (is_array($data)) {
if (array_keys($data) === range(0, count($data) - 1)) {
$this->encodeList($data, $fd);
} else {
$this->encodeDict($data, $fd);
}
} else {
$this->encodeEntry($data, $fd);
}
}
// Public method to encode data
public function encode($data): string
{
$fd = "";
$this->decideEncode($data, $fd);
return $fd;
}
}
// Usage example:
function BEncode($data): string
{
return (new BEncode())->encode($data);
}
declare(strict_types=1);
class BDecode
{
public function numberDecode(string $wholefile, int $start): array
{
$ret = [0];
$offset = $start;
$negative = false;
if ($wholefile[$offset] === '-') {
$negative = true;
$offset++;
}
if ($wholefile[$offset] === '0') {
$offset++;
if ($negative) {
return [false];
}
if ($wholefile[$offset] === ':' || $wholefile[$offset] === 'e') {
$ret[0] = 0;
$ret[1] = $offset + 1;
return $ret;
}
return [false];
}
while (isset($wholefile[$offset]) && ctype_digit($wholefile[$offset])) {
$ret[0] = $ret[0] * 10 + (int)$wholefile[$offset];
$offset++;
}
if ($wholefile[$offset] === 'e' || $wholefile[$offset] === ':') {
$ret[1] = $offset + 1;
if ($negative) {
if ($ret[0] === 0) {
return [false];
}
$ret[0] = -$ret[0];
}
return $ret;
}
return [false];
}
public function decodeEntry(string $wholefile, int $offset = 0): array
{
switch ($wholefile[$offset]) {
case 'd':
return $this->decodeDict($wholefile, $offset);
case 'l':
return $this->decodeList($wholefile, $offset);
case 'i':
return $this->numberDecode($wholefile, $offset + 1);
default:
$info = $this->numberDecode($wholefile, $offset);
if ($info[0] === false) {
return [false];
}
$ret[0] = substr($wholefile, $info[1], $info[0]);
$ret[1] = $info[1] + strlen($ret[0]);
return $ret;
}
}
public function decodeList(string $wholefile, int $start): array
{
if ($wholefile[$start] !== 'l') {
return [false];
}
$offset = $start + 1;
$ret = [];
while ($wholefile[$offset] !== 'e') {
$value = $this->decodeEntry($wholefile, $offset);
if ($value[0] === false) {
return [false];
}
$ret[] = $value[0];
$offset = $value[1];
}
return [$ret, $offset + 1];
}
public function decodeDict(string $wholefile, int $start = 0): array
{
if ($wholefile[$start] !== 'd') {
return [false];
}
$offset = $start + 1;
$ret = [];
while ($wholefile[$offset] !== 'e') {
$keyInfo = $this->decodeEntry($wholefile, $offset);
if ($keyInfo[0] === false) {
return [false];
}
$key = $keyInfo[0];
$offset = $keyInfo[1];
$valueInfo = $this->decodeEntry($wholefile, $offset);
if ($valueInfo[0] === false) {
return [false];
}
$ret[$key] = $valueInfo[0];
$offset = $valueInfo[1];
}
return [$ret, $offset + 1];
}
}
// Use this function, e.g., BDecode("d8:announce44:http://www...");
function BDecode(string $wholefile)
{
$decoder = new BDecode();
$result = $decoder->decodeEntry($wholefile);
return $result[0];
}
<?php
$tzs = array();
$tzs["-720"] = array("(GMT - 12:00 hours) Enitwetok, Kwajalien", "Pacific/Kwajalein");
$tzs["-660"] = array("(GMT - 11:00 hours) Midway Island, Samoa", "Pacific/Samoa");
$tzs["-600"] = array("(GMT - 10:00 hours) Hawaii", "Etc/GMT+10");
$tzs["-540"] = array("(GMT - 9:00 hours) Alaska", "America/Anchorage");
$tzs["-480"] = array("(GMT - 8:00 hours) Pacific Time (US & Canada)", "America/Los_Angeles");
$tzs["-420"] = array("(GMT - 7:00 hours) Mountain Time (US & Canada)", "America/Denver");
$tzs["-360"] = array("(GMT - 6:00 hours) Central Time (US & Canada), Mexico City", "America/Chicago");
$tzs["-300"] = array("(GMT - 5:00 hours) Eastern Time (US & Canada), Bogota, Lima, Quito", "America/New_York");
$tzs["-240"] = array("(GMT - 4:00 hours) Atlantic Time (Canada), Caracas, La Paz", "America/Guadeloupe");
$tzs["-210"] = array("(GMT - 3:30 hours) Newfoundland", "America/St_Johns");
$tzs["-180"] = array("(GMT - 3:00 hours) Brazil, Buenos Aires, Georgetown, Falkland Isl.", "Etc/GMT+3");
$tzs["-120"] = array("(GMT - 2:00 hours) Mid-Atlantic, Ascention Isl., St Helena", "Atlantic/St_Helena");
$tzs["-60"] = array("(GMT - 1:00 hour) Azores, Cape Verde Islands", "Atlantic/Azores");
$tzs["0"] = array("(GMT) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia", "Europe/London");
$tzs["60"] = array("(GMT + 1:00 hour) Amsterdam, Berlin, Copenhagen, Madrid, Paris, Rome", "Europe/Rome");
$tzs["120"] = array("(GMT + 2:00 hours) Kaliningrad, South Africa, Warsaw", "Europe/Kaliningrad");
$tzs["180"] = array("(GMT + 3:00 hours) Baghdad, Riyadh, Moscow, Nairobi", "Africa/Nairobi");
$tzs["210"] = array("(GMT + 3:30 hours) Tehran", "Asia/Tehran");
$tzs["240"] = array("(GMT + 4:00 hours) Adu Dhabi, Baku, Muscat, Tbilisi", "Asia/Tbilisi");
$tzs["270"] = array("(GMT + 4:30 hours) Kabul", "Asia/Kabul");
$tzs["300"] = array("(GMT + 5:00 hours) Ekaterinburg, Islamabad, Karachi, Tashkent", "Asia/Tashkent");
$tzs["330"] = array("(GMT + 5:30 hours) Bombay, Calcutta, Madras, New Delhi", "Asia/Calcutta");
$tzs["360"] = array("(GMT + 6:00 hours) Almaty, Dhaka, Khulna", "Asia/Dhaka");
$tzs["420"] = array("(GMT + 7:00 hours) Bangkok, Hanoi, Jakarta", "Asia/Bangkok");
$tzs["480"] = array("(GMT + 8:00 hours) Beijing, Hong Kong, Perth, Singapore, Taipei", "Asia/Taipei");
$tzs["540"] = array("(GMT + 9:00 hours) Osaka, Sapporo, Seoul, Tokyo, Yakutsk", "Asia/Tokyo");
$tzs["570"] = array("(GMT + 9:30 hours) Adelaide, Darwin", "Australia/Adelaide");
$tzs["600"] = array("(GMT + 10:00 hours) Melbourne, Papua New Guinea, Sydney, Vladivostok", "Australia/Sydney");
$tzs["660"] = array("(GMT + 11:00 hours) Magadan, New Caledonia, Solomon Islands", "Asia/Magadan");
$tzs["720"] = array("(GMT + 12:00 hours) Auckland, Wellington, Fiji, Marshall Island", "Pacific/Auckland");
?>
function addData($name,$text,$uid) {
require_once("backend/functions.php"); # getting table prefix
$now = get_date_time();
$sql = "INSERT INTO ajshoutbox (date,name,text,uid) VALUES ('".$now."','".$name."','".$text."','".$uid."')";
$conn = getDBConnection();
$results = SQL_Query_exec($sql, $conn);
if (!$results || empty($results)) {
# echo 'There was an error creating the entry';
end;
}
}function addData($name, $text, $uid) {
require_once "backend/functions.php";
$now = get_date_time();
$conn = getDBConnection();
$sql = "INSERT INTO ajshoutbox (date, name, text, uid) VALUES (?, ?, ?, ?)";
if ($stmt = $conn->prepare($sql)) {
$stmt->bind_param("ssss", $now, $name, $text, $uid);
if (!$stmt->execute()) {
echo 'There was an error creating the entry';
}
$stmt->close();
}
echo 'There was an error preparing the query';
$conn->close();
} die("You didn't edit your config correctly."); // You MUST remove this line