You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

70 lines
1.4 KiB
PHP

<?php
/**
* This file contains global settings and things that should be loaded at the
* top of each file.
*/
ob_start();
header("Access-Control-Allow-Origin: *");
if (strtolower($_GET['format']) == 'plain') {
define("JSON", false);
} else {
define("JSON", true);
}
// Composer
require 'vendor/autoload.php';
// API response formatters
require 'response.php';
// Database settings
// Also inits database and stuff
$database;
try {
$database = new medoo([
'database_type' => 'mysql',
'database_name' => 'c0terranquest',
'server' => 'localhost',
'username' => 'c0terranquest',
'password' => 'qinkifTQ!OMY2',
'charset' => 'utf8'
]);
} catch (Exception $ex) {
header('HTTP/1.1 500 Internal Server Error');
sendError('Database error. Try again later.', true);
}
// Show errors and stuff?
define("DEBUG", false);
// Use POST instead of GET?
if (!is_empty($_GET['post']) && $_GET['post'] == '1') {
define("GET", false);
} else {
define("GET", true);
}
if (!DEBUG) {
error_reporting(0);
} else {
error_reporting(E_ALL);
ini_set('display_errors', 'On');
}
$VARS;
if (GET) {
$VARS = $_GET;
} else {
$VARS = $_POST;
}
/**
* Checks if a string or whatever is empty.
* @param $str The thingy to check
* @return boolean True if it's empty or whatever.
*/
function is_empty($str) {
return (!isset($str) || $str == '' || $str == null);
}