1
|
|
|
<?php |
2
|
|
|
require '../config.local.php'; |
3
|
|
|
require_once 'Ilib/ClassLoader.php'; |
4
|
|
|
require_once 'konstrukt/konstrukt.inc.php'; |
5
|
|
|
require_once 'bucket.inc.php'; |
6
|
|
|
|
7
|
|
|
set_error_handler('k_exceptions_error_handler'); |
8
|
|
|
|
9
|
|
|
class MyIdentityLoader extends k_BasicHttpIdentityLoader |
10
|
|
|
{ |
11
|
|
|
function selectUser($username, $password) |
12
|
|
|
{ |
13
|
|
|
$users = array( |
14
|
|
|
'[email protected]' => '7f5c04fb811783c71d951302e3314d62', |
15
|
|
|
'[email protected]' => 'e9127ee5efd3a78a5837f22a5bc4ef10' |
16
|
|
|
); |
17
|
|
|
if (isset($users[$username]) && $users[$username] == md5($password)) { |
18
|
|
|
return new k_AuthenticatedUser($username); |
19
|
|
|
} |
20
|
|
|
} |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
require_once 'MDB2.php'; |
24
|
|
|
|
25
|
|
|
class ToolsFactory |
26
|
|
|
{ |
27
|
|
|
public $db_dsn; |
28
|
|
|
public $error_log; |
29
|
|
|
|
30
|
|
|
function new_MDB2_Driver_Common($db) |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
$db = MDB2::singleton($this->db_dsn, array("persistent" => true)); |
33
|
|
|
if (PEAR::isError($db)) { |
34
|
|
|
throw new Exception($db->getMessage()); |
35
|
|
|
} |
36
|
|
|
$db->setFetchMode(MDB2_FETCHMODE_ASSOC); |
37
|
|
|
$db->setOption("portability", MDB2_PORTABILITY_NONE); |
38
|
|
|
return $db; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
function new_DB_Sql() |
42
|
|
|
{ |
43
|
|
|
return new DB_Sql; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
View Code Duplication |
function new_Translation2_Admin() |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
$driver = "mdb2"; |
49
|
|
|
$options = array( |
50
|
|
|
"hostspec" => DB_HOST, |
51
|
|
|
"database" => DB_NAME, |
52
|
|
|
"phptype" => "mysql", |
53
|
|
|
"username" => DB_USER, |
54
|
|
|
"password" => DB_PASS |
55
|
|
|
); |
56
|
|
|
$params = array( |
57
|
|
|
"langs_avail_table" => "core_translation_langs", |
58
|
|
|
"strings_default_table" => "core_translation_i18n" |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
$translation = Translation2_Admin::factory($driver, $options, $params); |
62
|
|
|
if (PEAR::isError($translation)) { |
63
|
|
|
exit($translation->getMessage()); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
return $translation; |
66
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
View Code Duplication |
function new_Translation2() |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
$driver = "mdb2"; |
72
|
|
|
$options = array( |
73
|
|
|
"hostspec" => DB_HOST, |
74
|
|
|
"database" => DB_NAME, |
75
|
|
|
"phptype" => "mysql", |
76
|
|
|
"username" => DB_USER, |
77
|
|
|
"password" => DB_PASS |
78
|
|
|
); |
79
|
|
|
$params = array( |
80
|
|
|
"langs_avail_table" => "core_translation_langs", |
81
|
|
|
"strings_default_table" => "core_translation_i18n" |
82
|
|
|
); |
83
|
|
|
|
84
|
|
|
$translation = Translation2::factory($driver, $options, $params); |
85
|
|
|
if (PEAR::isError($translation)) { |
86
|
|
|
throw new Exception($translation->getMessage()); |
87
|
|
|
} |
88
|
|
|
$translation->setLang("dk"); |
89
|
|
|
return $translation; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
function new_k_TemplateFactory($c) |
|
|
|
|
93
|
|
|
{ |
94
|
|
|
return new Tools_TemplateFactory(null); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
function new_Ilib_ErrorHandler_Observer_File_ErrorList() |
98
|
|
|
{ |
99
|
|
|
return new Ilib_ErrorHandler_Observer_File_ErrorList($this->error_log); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
View Code Duplication |
class Tools_TemplateFactory extends k_DefaultTemplateFactory |
|
|
|
|
105
|
|
|
{ |
106
|
|
|
function create($filename) |
107
|
|
|
{ |
108
|
|
|
$filename = $filename . '.tpl.php'; |
109
|
|
|
$__template_filename__ = k_search_include_path($filename); |
110
|
|
|
if (!is_file($__template_filename__)) { |
111
|
|
|
throw new Exception("Failed opening '".$filename."' for inclusion. (include_path=".ini_get('include_path').")"); |
112
|
|
|
} |
113
|
|
|
return new k_Template($__template_filename__); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
function create_container() |
119
|
|
|
{ |
120
|
|
|
$factory = new ToolsFactory(); |
121
|
|
|
$container = new bucket_Container($factory); |
122
|
|
|
$factory->db_dsn = 'mysql://' . DB_USER . ':' . DB_PASS . '@' . DB_HOST . '/' . DB_NAME; |
123
|
|
|
$factory->error_log = ERROR_LOG; |
124
|
|
|
return $container; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
if (realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) { |
129
|
|
|
k() |
130
|
|
|
->setIdentityLoader(new MyIdentityLoader()) |
131
|
|
|
->setComponentCreator(new k_InjectorAdapter(create_container())) |
132
|
|
|
->run('Intraface_Tools_Controller_Root')->out(); |
133
|
|
|
} |
134
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.