utils cleanup
This commit is contained in:
parent
b2e90d2f42
commit
e76d5314f7
8
www/extern/egg/EGGDatabase.php
vendored
8
www/extern/egg/EGGDatabase.php
vendored
@ -69,9 +69,7 @@ class EGGDatabase
|
||||
|
||||
public function sql_query_assoc(string $query)
|
||||
{
|
||||
$r = $this->pdo->query($query)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $r;
|
||||
return $this->pdo->query($query)->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
public function sql_query_assoc_prep(string $query, array $params)
|
||||
@ -84,9 +82,7 @@ class EGGDatabase
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
$r = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $r;
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
public function sql_exec_prep(string $query, array $params)
|
||||
|
@ -223,7 +223,7 @@ class Programs
|
||||
|
||||
if (strpos($prog['internal_name'], ' ') !== FALSE) return ['result'=>'err', 'message' => 'Internal name contains spaces ' . $prog['name']];
|
||||
|
||||
foreach (explode('|', $prog['ui_language']) as $lang) if ($this->convertLanguageToFlag($lang) === null) return ['result'=>'err', 'message' => 'Unknown ui-lang ' . $prog['name']];;
|
||||
foreach (explode('|', $prog['ui_language']) as $lang) if ($this->convertLanguageToFlag($lang) === null) return ['result'=>'err', 'message' => 'Unknown ui-lang ' . $prog['name']];
|
||||
|
||||
if (!in_array($prog['prog_language'], self::PROG_LANGS)) return ['result'=>'err', 'message' => 'Unknown prog-lang ' . $prog['name']];
|
||||
|
||||
|
@ -1,16 +1,5 @@
|
||||
<?php
|
||||
|
||||
global $CONFIG;
|
||||
$CONFIG = require 'config.php';
|
||||
|
||||
global $CSS_BASE;
|
||||
$CSS_BASE = ($CONFIG['prod']) ? ('/data/css/styles.min.css') : ('/data/css/styles.css');
|
||||
|
||||
global $ADDITIONAL_SCRIPTS;
|
||||
global $ADDITIONAL_STYLESHEETS;
|
||||
$ADDITIONAL_SCRIPTS = [];
|
||||
$ADDITIONAL_STYLESHEETS = [];
|
||||
|
||||
function startsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
@ -23,7 +12,8 @@ function endsWith($haystack, $needle)
|
||||
return $length === 0 || (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
function destructiveUrlEncode($str) {
|
||||
function destructiveUrlEncode($str)
|
||||
{
|
||||
$str = str_replace(' ', '_', $str);
|
||||
$str = str_replace('+', '_', $str);
|
||||
$str = str_replace(':', '_', $str);
|
||||
@ -73,7 +63,7 @@ function formatMilliseconds($millis)
|
||||
* @param string $output - name of the new file (include path if needed)
|
||||
* @return boolean|resource
|
||||
*/
|
||||
function smart_resize_image($file, $width = 0, $height = 0, $proportional, $output)
|
||||
function smart_resize_image($file, $width, $height, $proportional, $output)
|
||||
{
|
||||
if ( $height <= 0 && $width <= 0 ) return false;
|
||||
if ( $file === null) return false;
|
||||
@ -189,43 +179,9 @@ function magick_resize_image($file, $width, $height, $output)
|
||||
shell_exec($cmd);
|
||||
}
|
||||
|
||||
function sendMail($subject, $content, $to, $from) {
|
||||
mail($to, $subject, $content, 'From: ' . $from);
|
||||
}
|
||||
|
||||
function ParamServerOrUndef($idx) {
|
||||
return isset($_SERVER[$idx]) ? $_SERVER[$idx] : 'NOT_SET';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception $e
|
||||
*/
|
||||
function sendExceptionMail($e)
|
||||
function sendMail($subject, $content, $to, $from)
|
||||
{
|
||||
try {
|
||||
$subject = "Server has encountered an Error at " . date("Y-m-d H:i:s") . "] ";
|
||||
|
||||
$content = "";
|
||||
|
||||
$content .= 'HTTP_HOST: ' . ParamServerOrUndef('HTTP_HOST') . "\n";
|
||||
$content .= 'REQUEST_URI: ' . ParamServerOrUndef('REQUEST_URI') . "\n";
|
||||
$content .= 'TIME: ' . date('Y-m-d H:i:s') . "\n";
|
||||
$content .= 'REMOTE_ADDR: ' . ParamServerOrUndef('REMOTE_ADDR') . "\n";
|
||||
$content .= 'HTTP_X_FORWARDED_FOR: ' . ParamServerOrUndef('HTTP_X_FORWARDED_FOR') . "\n";
|
||||
$content .= 'HTTP_USER_AGENT: ' . ParamServerOrUndef('HTTP_USER_AGENT') . "\n";
|
||||
$content .= 'MESSAGE:' . "\n" . $e->getMessage() . "\n";
|
||||
$content .= 'CODE:' . "\n" . $e->getCode() . "\n";
|
||||
$content .= 'TRACE:' . "\n" . $e->getTraceAsString() . "\n";
|
||||
$content .= '$_GET:' . "\n" . print_r($_GET, true) . "\n";
|
||||
$content .= '$_POST:' . "\n" . print_r($_POST, true) . "\n";
|
||||
$content .= '$_FILES:' . "\n" . print_r($_FILES, true) . "\n";
|
||||
|
||||
sendMail($subject, $content, 'virtualadmin@mikescher.de', 'webserver-error@mikescher.com');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
//
|
||||
}
|
||||
mail($to, $subject, $content, 'From: ' . $from);
|
||||
}
|
||||
|
||||
function get_client_ip() {
|
||||
|
@ -65,7 +65,9 @@ if (!array_key_exists($cmd, $API_COMMANDS))
|
||||
print(" ::::::`:::::;' / / `# \n");
|
||||
print(" \n");
|
||||
print(" \n");
|
||||
httpDie(400, 'Wrong command.');
|
||||
|
||||
$FRAME_OPTIONS->forceResult(400, 'Wrong command.');
|
||||
return;
|
||||
}
|
||||
|
||||
$config = $API_COMMANDS[$cmd];
|
||||
@ -73,10 +75,10 @@ $config = $API_COMMANDS[$cmd];
|
||||
|
||||
$secret = isset($_GET['secret']) ? $_GET['secret'] : '';
|
||||
|
||||
if ($config['auth'] === 'webhook_secret' && $secret !== $CONFIG['webhook_secret']) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
if ($config['auth'] === 'ajax_secret' && $secret !== $CONFIG['ajax_secret']) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
if ($config['auth'] === 'upload_secret' && $secret !== $CONFIG['upload_secret']) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
if ($config['auth'] === 'admin' && !$SITE->isLoggedInByCookie()) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
if ($config['auth'] === 'webhook_secret' && $secret !== $SITE->config['webhook_secret']) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
if ($config['auth'] === 'ajax_secret' && $secret !== $SITE->config['ajax_secret']) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
if ($config['auth'] === 'upload_secret' && $secret !== $SITE->config['upload_secret']) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
if ($config['auth'] === 'admin' && !$SITE->isLoggedInByCookie()) { $FRAME_OPTIONS->forceResult(401, "Unauthorized."); return; }
|
||||
|
||||
|
||||
global $API_OPTIONS;
|
||||
|
Loading…
Reference in New Issue
Block a user