-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.php
More file actions
85 lines (70 loc) · 2.28 KB
/
Copy pathcommon.php
File metadata and controls
85 lines (70 loc) · 2.28 KB
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
<?
require "smarty/Smarty.class.php";
spl_autoload_register(function ($class) {
/* Workaround for cwd changing on script shutdown */
static $cwd = false;
if(!$cwd) $cwd = getcwd();
/* Try including classes/<class>.php */
$file = $cwd . '/classes/' . $class . '.php';
if(file_exists($file))
include($file);
else
{
/* Try including classes/<family>/<class>.php */
$m = array();
if(preg_match('/^([a-z]+)_([^_]+)(_.*)?$/', $class, $m))
{
$file = $cwd . '/classes/' . $m[1] . '/' . $m[2] . '.php';
if(!file_exists($file))
{
/* Cannot include this class. Fail. */
header("Content-type: text/plain; charset=utf-8");
print_r(debug_backtrace());
}
else
include($file);
/* Call initialization function */
$fname = "__" . $m[1] . "_init";
if(is_callable("{$class}::{$fname}"))
$class::$fname();
}
}
});
function get_Smarty()
{
$S = new Smarty;
$S->setTemplateDir("templates");
$S->setCompileDir("../templates_c");
$S->addPluginsDir("plugins");
$S->left_delimiter = "{{";
$S->right_delimiter = "}}";
$S->compile_check = true;
$S->force_compile = true;
return $S;
}
function fail($status, $message)
{
header("Content-type: text/plain; charset=utf-8");
die($status . " " . $message);
}
/* NCC6 samodzielnie escape-uje ciągi wstawiane do zapytań SQL, jeśli zatem w PHP
jest włączona opcja magic_quotes, escape-owanie wykonane automatycznie przez PHP
musi zostać cofnięte */
if(get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
// todo pamiętać, żeby usunąć ten środek tymczasowy
/* Środek tymczasowy */
/*
ob_start(function($content) {
return str_replace("http://pza.org.pl/", "http://test.jaszczur.org/", $content);
});
*/