Initial Commit

This commit is contained in:
Victor Giers
2019-11-19 11:09:22 +01:00
parent 3b8589a917
commit 746e9b4a92
59 changed files with 29837 additions and 0 deletions

107
server/debug.php Normal file
View File

@@ -0,0 +1,107 @@
<?php
/**
* debug.php
*
* Debug-Data Collection And Window Display
*
* @category Debug
* @author Victor Giers <vgiers@web.de>
* @copyright 2019 Victor Giers
* @license https://www.gnu.org/licenses/gpl.txt GPLv3
* @version Permanent Beta
* @link https://www.victorgiers.com/
*/
if(!isset($_SESSION)) session_start();
?>
<style>
.debug{
padding:20px;
position: fixed;
background-color: rgba(0,0,0,0.7);
color:rgba(255,255,255,1);
text-shadow: 1px 1px rgba(0,0,0,1);
font-size: 11px;
font-family: 'Lucida Grande', Verdana, Helvetica, sans-serif;
max-height:700px;
overflow: hidden;
right:40px;
top:85px;
z-index: 1000;
/*pointer-events: none;*/
border-radius: 7px;
}
.debug hr{
color:white;
box-shadow: 1px 1px rgba(0,0,0,1);
}
.debug span{
display: block;
white-space: nowrap;
}
.debug.m{
min-width:4em;
}
.debug table{
padding-top:10px;
border:none;
}
.debug table td{
padding:20px;
vertical-align:top;
border-right: 1px solid #dedede;
box-shadow: 1px 0px #333;
max-height: 600px;
}
.debugcell{
max-height:inherit;
max-width:400px;
overflow: auto;
}
</style>
<script>
var maxed = <?=(isset($_SESSION['debugMaxed']))? $_SESSION['debugMaxed'] : 'false' ?>;
function minimDebug(){
$(".debug").prop("hidden", (_, val) => !val);
$.ajax({url:'server/server.php',method:'POST',data:{debugMaxed:!maxed}});
maxed = !maxed;
}
</script>
<div class="debug"<?=(($_SESSION['debugMaxed'] == 'true') ? '' : ' hidden') ?>>
<h2>Debug</h2><div><a style="position:absolute;right:25px;color:white;top:1em;" href="#" onClick="minimDebug()">Minimieren</a></div><hr>
<table>
<tr>
<?php
if($GLOBALS['phpErrors'] != null || $GLOBALS['sqlErrors'] != null){
echo ("<td><div class='debugcell'>");
if($GLOBALS['sqlErrors'] != null) echo ("<b>SQL-Errors:</b><br>".$GLOBALS['sqlErrors']);
if($GLOBALS['phpErrors'] != null) echo ("<b>PHP-Errors:</b><br>".$GLOBALS['phpErrors']);
echo ("</div></td>");
}
if($GLOBALS['debugData'] != null){
echo ("<td><div class='debugcell'><b>Variables:</b><br/>".$GLOBALS['debugData']."</div></td>");
}
?>
<td>
<div class='debugcell'>
<b>$_SESSION:</b> <pre><?php echo(print_r($_SESSION));?></pre>
</div>
</td>
<td style="border:none;box-shadow: none;">
<div class='debugcell'>
<b>$_GET:</b> <pre><?php echo(print_r($_GET));?></pre>
<b>$_POST:</b> <pre><?php echo(print_r($_POST));?></pre>
<b>$GLOBALS:</b> <pre><?php echo(print_r($GLOBALS));?></pre>
</div>
</td>
</tr>
</table>
</div>
<div class="debug m"<?=(($_SESSION['debugMaxed'] == 'true') ? ' hidden' : '') ?>>
<div id="debugMaxLink"><a style="position:absolute;right:25px;color:white;top:1em;" href="#" onClick="minimDebug()">Debug</a></div>
</div>

84
server/debugfunctions.php Normal file
View File

@@ -0,0 +1,84 @@
<?php
function errorhandler($errno, $errstr, $errfile, $errline, $errcontext){
$fp = explode(dirname(__DIR__, 1), $errfile);
$constants = array(
"E_ERROR",
"E_WARNING",
"E_PARSE",
"E_NOTICE",
"E_CORE_ERROR",
"E_CORE_WARNING",
"E_COMPILE_ERROR",
"E_COMPILE_WARNING",
"E_USER_ERROR",
"E_USER_WARNING",
"E_USER_NOTICE",
"E_STRICT",
"E_RECOVERABLE_ERROR",
"E_DEPRECATED",
"E_USER_DEPRECATED",
"E_ALL"
);
$included = array();
foreach ($constants as $constant) {
$value = constant($constant);
if (($errno & $value) === $value) {
$included[] = $constant;
}
}
$description = implode(", ", $included);
if(strpos($errstr, "sql")){
$GLOBALS['sqlErrors'].="<span>[$description] in <b>".$fp[1]."</b> line <b>$errline</b></span>$errstr<br><br>";
} else {
$GLOBALS['phpErrors'].="<span>[$description] in <b>".$fp[1]."</b> line <b>$errline</b></span>$errstr<br><br>";
}
}
function alert($string){
echo("<script>alert('" .((isset($string)) ? addslashes($string) : 'parameter not set') . "');</script>");
}
function debug($var, $mode = null){
$bt = debug_backtrace();
$file = file($bt[0]['file']);
$src = $file[$bt[0]['line']-1];
$pat = '#(.*)'.__FUNCTION__.' *?\( *?(.*) *?\)(.*)#i';
$varName = preg_replace($pat, '$2', $src);
if($mode == null){
$mode = "print_r";
$varName .= ', "'.$mode.'" ';
}
switch($mode){
case "print_r":
ob_start();
print_r($var);
$result = ob_get_clean();
if($result == strip_tags($result)){
if(strpos($result, ('(')) !== false)
$result = strstr($result, "(");
} else {
$result = htmlspecialchars($result);
}
$GLOBALS['debugData'] .= '<b>' . $varName . '</b>:<pre>'.$result.'</pre>';
break;
case "var_dump":
ob_start();
var_dump($var);
$result = ob_get_clean();
$result = ($result != strip_tags($result))? htmlspecialchars($result) : $result;
$GLOBALS['debugString'] .= '<b>' . $varName . '</b>:<pre>'.$result.'</pre>';
break;
case "var_export":
ob_start();
var_export($var);
$result = ob_get_clean();
$result = ($result != strip_tags($result))? htmlspecialchars($result) : $result;
$GLOBALS['debugString'] .= '<b>' . $varName . '</b>:<pre>'.$result.'</pre>';
break;
case "alert":
$result = print_r($var, true);
$GLOBALS['debugString'] .= alert(json_encode($result));
break;
}
}
?>

0
server/functions.php Normal file
View File

57
server/server.php Normal file
View File

@@ -0,0 +1,57 @@
<?php
if(!isset($_SESSION)) session_start();
include('/home/giers/Web/db_settings.php'); //declares $db_server, $db_password and $db_password
$db_name = 'hori';
$db = mysqli_connect($db_server, $db_user, $db_password, $db_name);
mysqli_set_charset($db, "utf8");
if (isset($_POST['name']) && isset($_POST['loc']) && isset($_POST['typ'])){
$typNo = 0;
if ($_POST['typ'] == 'galerie') { $typNo = 1; }
if ($_POST['typ'] == 'akademie') { $typNo = 2; }
if ($_POST['typ'] == 'venue') { $typNo = 3; }
if ($_POST['typ'] == 'stiftung') { $typNo = 4; }
if ($_POST['typ'] == 'festival') { $typNo = 5; }
if ($_POST['typ'] == 'kunstler') { $typNo = 6; }
$query = "INSERT INTO `institut`(`name`, `location`, `facebook`, `twitter`, `instagram`, `web`, `typ`) VALUES (\"".$_POST['name']."\",\"".$_POST['loc']."\",\"".$_POST['fb']."\",\"".$_POST['twitter']."\",\"".$_POST['insta']."\",\"".$_POST['web']."\",".$typNo.");";
//echo("<script>console.log('".$query."');</script>");
mysqli_query($db, $query);
//header("location: #");
}
if (isset($_GET['delete'])){
$query = "DELETE FROM `institut` WHERE `institut`.`id` = " . $_GET['delete'] . ";";
mysqli_query($db, $query);
//echo $_GET['delete'];
header("location: ../index.php");
}
function fetch_object($db, $query){
$result = mysqli_query($db, $query);
return mysqli_fetch_object($result);
}
function fetch_all($db, $query){
$result = mysqli_query($db, $query);
return mysqli_fetch_all($result);
}
function clean_url($url){
if (0 !== strpos($url, 'http://') && 0 !== strpos($url, 'https://')) {
return "http://{$url}";
} else { return $url; }
}
function nullOrColon($str){
return !empty($str) ? "'".$str."'" : "NULL";
}
function nullOrInt($int){
return !empty($int) ? $int : "NULL";
}
function nullOrTrue($bool){
return !empty($bool) ? "TRUE" : "NULL";
}
?>