/** * * @param object $poComposerLoader */ public static function autoload($poComposerLoader) { $laModules = Config::getOptions('modules'); if (is_array($laModules)) { foreach ($laModules as $lsNamespace => $laPath) { $poComposerLoader->set($lsNamespace, $laPath); } } }
public static function hasAccess() { $lsIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ""; $lsClient = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; $lsToken = isset($_SERVER['HTTP_TOKEN']) ? $_SERVER['HTTP_TOKEN'] : ""; $lbReturn = false; $lsStatus = "DENIED"; Debug::debug(array($lsIp, $lsClient, $lsToken)); $laAccess = Config::getOptions('access'); Debug::debug($laAccess); if (isset($laAccess[$lsIp])) { Debug::debug('1'); if (isset($laAccess[$lsIp]['user-agent'][$lsClient])) { Debug::debug('1.1'); if ($laAccess[$lsIp]['user-agent'][$lsClient] == $lsToken) { Debug::debug('1.1.1'); $lbReturn = true; } } elseif (isset($laAccess[$lsIp]['user-agent']['*'])) { Debug::debug('1.2'); if ($laAccess[$lsIp]['user-agent']['*'] == $lsToken) { Debug::debug('1.2.1'); $lbReturn = true; } } } elseif (isset($laAccess['*'])) { Debug::debug('2'); if (isset($laAccess['*']['user-agent'][$lsClient])) { Debug::debug('2.1'); if ($laAccess['*']['user-agent'][$lsClient] == $lsToken) { Debug::debug('2.1.1'); $lbReturn = true; } } elseif (isset($laAccess['*']['user-agent']['*'])) { Debug::debug('2.2'); if ($laAccess['*']['user-agent']['*'] == $lsToken) { Debug::debug('2.2.2'); $lbReturn = true; } } } if ($lbReturn) { $lsStatus = "PERMITED"; } Event::log(array("ip:[{$lsIp}]", "user-agent:[{$lsClient}]", "token:[{$lsToken}]", "status:[{$lsStatus}]"), 'access'); return $lbReturn; }
/** * */ public function getParamsfilters() { if (is_file($this->_sConfigPath . DS . 'srv-validate.php')) { return include $this->_sConfigPath . DS . 'srv-validate.php'; } else { return Config::getOptions('params'); } }
/** * * @param string $psFile * @param int $pnChmod * @param string $pnChown * @param string $pnChown */ public static function setCHMOD($psFile, $pnChmod = null, $psChown = null, $psChgrp = null) { $laLogConf = Config::getOptions('system'); if ($pnChmod === null && isset($laLogConf['chmod'])) { $pnChmod = $laLogConf['chmod']; } if ($psChown === null && isset($laLogConf['chown'])) { $psChown = $laLogConf['chown']; } if ($psChgrp === null && isset($laLogConf['chgrp'])) { $psChgrp = $laLogConf['chgrp']; } Debug::debug("chmod {$pnChmod} {$psFile}"); @chmod($psFile, $pnChmod); Debug::debug("chown {$psChown} {$psFile}"); @chown($psFile, $psChown); Debug::debug("chgrp {$psChgrp} {$psFile}"); @chgrp($psFile, $psChgrp); }
/** * * @param string $psFile * @param number $pnChmod * @param number $pnChown * @param number $pnChown */ public static function setCHMOD($psFile, $pnChmod = 0664, $pnChown = 'root', $pnChown = 'root') { $laLogConf = Config::getOptions('log'); if (isset($laLogConf['chmod'])) { $pnChmod = $laLogConf['chmod']; } if (isset($laLogConf['chown'])) { $pnChown = $laLogConf['chown']; } if (isset($laLogConf['chgrp'])) { $pnChgrp = $laLogConf['chgrp']; } chmod($psFile, $pnChmod); chown($psFile, $pnChown); chgrp($psFile, $pnChgrp); }
$gbPhpError = true; } if (isset($_GET['debug'])) { $gbDebug = true; $gbTime = true; } if (isset($_GET['time'])) { $gbTime = true; } if (isset($_GET['test'])) { $gbTest = true; } } use OnionSrv\Config; Config::setDebugMod($gbDebug, $gbPhpError, $gbTime, $gbTest, $gbPrompt); Config::setTimeZone(); OnionSrv\Autoload::autoload($goLoader); use OnionSrv\Debug; Debug::debugTimeStart("init"); if (PHP_SAPI == "cli") { $goService = new OnionSrv\LineService(); $goService->serviceRoute(); } else { if (OnionSrv\Access::hasAccess()) { $goService = new OnionSrv\HttpService(); $goService->serviceRoute(); } else { header('HTTP/1.1 403 Forbidden'); exit(403); } }