forked from kakserpom/phpdaemon
/
phpd
executable file
·54 lines (43 loc) · 1.26 KB
/
phpd
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
#!/usr/bin/php -q
<?php
/**************************************************************************/
/* phpDaemon
/* Web: http://github.com/kakserpom/phpdaemon
/* ===========================
/* @author kak.serpom.po.yaitsam@gmail.com
/* @description Bootstrap init script.
/**************************************************************************/
error_reporting(E_ALL);
foreach (array('/usr/share/phpdaemon', dirname(dirname(__FILE__))) as $d) {
if (@chdir($d)) {
break;
}
}
ini_set('include_path', get_include_path()
. ':' . dirname(dirname(__FILE__))
. ':' . dirname(dirname(__FILE__)).'/conf'
. ':/usr/share/phpdaemon:/etc/phpdaemon'
);
spl_autoload_register(function($classname) {
$parts = explode('\\', $classname);
if (sizeof($parts) > 1) {
// namespaces support (remove first "PHPDaemon\" part)
array_shift($parts);
}
$path = 'lib/' . implode('/', $parts) . '.class.php';
if (@include($path)) {
return;
}
if (
class_exists('Daemon', false)
&& isset(Daemon::$config->autoload->value)
) {
$files = glob($g = sprintf(Daemon::$config->autoload->value, str_replace('_', DIRECTORY_SEPARATOR, $classname)), GLOB_BRACE);
if (isset($files[0])) {
require $files[0];
return;
}
}
});
require 'lib/BinarySubstr.php';
Daemon_Bootstrap::init();