-
Notifications
You must be signed in to change notification settings - Fork 0
/
htmldocdom.php
87 lines (58 loc) · 2.23 KB
/
htmldocdom.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
set_time_limit(30); //maximum execution time in seconds - just in case of a bug, to save the servers recource
//not working with WSL
function phpAlert($msg) {
echo '<script type="text/javascript">alert("' . $msg . '")</script>';
} //thanks to maqs from stack overflow
function setVar($var, $val) {
echo '<script type="text/javascript">var ' . $var . ' = ' . $val . ' </script>' . "\n";
} //mine
require_once "myconfig.php";
try {
$conf = new MyConfig('config.xml');
$conf->read_or_create();
$LOG = $conf->get_option('log_to_file');
$LOG = intval($LOG);
}
catch (Exception $e) {
echo "Error reading config file!";
}
if (!isset($LOG)) $LOG = false;
function fileLog($msg) {
global $LOG;
if (!$LOG) return;
$logfile = fopen("qlog.txt", "a") or die("Unable to open file!");
fwrite($logfile, date("Y-m-d H:i:s") . ": ");
fwrite($logfile, $msg);
fwrite($logfile, "\n");
fclose($logfile);
}
//reset part
function reset_it($form_get_string) {
//the whole cookie deletion part and session things in this function is Tony Stark's, SOf
$_SESSION = array();
//deleting cookie
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
} //end del c.
session_destroy();
//mine - to start a new session, cookie, etc.
$req_scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
echo '<script type="text/javascript">window.open("' . "$req_scheme://${_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?form=$form_get_string" . '", "_self")</script>';
}
//shut part, thanks to user259973, Manoj Sharma on SOf (very abbreviated)
function shutdown_handler() {
$error = error_get_last();
if($error === NULL || $error['type'] != E_ERROR) return;
error_log("from qcomb - IN SHUTDOWN FUNC - FATAL ERR::" . print_r($error, true));
print_r($error);
phpAlert("Error type: ${error['type']} | Message: ${error['message']} | File: ${error['file']} | Line number: ${error['file']}");
reset_it('generate');
}
register_shutdown_function("shutdown_handler");
//shut
?>