protected function startRulePlugins() { $config = Zend_Registry::get('config'); $log = Zend_Registry::get('log'); $this->rulePlugins = new PBX_Rule_Plugin_Broker(); // Registrando plugin de tempo limite $this->rulePlugins->registerPlugin(new Snep_Rule_Plugin_TimeLimit()); foreach (Snep_Modules::getInstance()->getRegisteredModules() as $module) { $plugins_dir = $config->system->path->base . "/" . $module->getModuleDir() . "/rule_plugins"; if (file_exists($plugins_dir)) { $plugins = ""; foreach (scandir($plugins_dir) as $filename) { // Todos os arquivos .php devem ser classes de Plugins if (preg_match("/.*\\.php\$/", $filename)) { // Tentar instanciar e Adicionar no array require_once $plugins_dir . "/" . $filename; $classname = basename($filename, '.php'); $plugins .= " " . $classname; if (class_exists($classname)) { $this->rulePlugins->registerPlugin(new $classname()); } } } $log->debug("Plugins de regras: " . trim($plugins)); } } }
public function indexAction() { $this->view->breadcrumb = $this->view->translate("Welcome to Snep version %s", SNEP_VERSION); // Direcionando para o "snep antigo" $config = Zend_Registry::get('config'); $db = Zend_Registry::get('db'); // GOD! $linfoData = new Zend_Http_Client('http://localhost/snep/lib/linfo/index.php?out=xml'); try { $linfoData->request(); $sysInfo = $linfoData->getLastResponse()->getBody(); $sysInfo = simplexml_load_string($sysInfo); } catch (HttpException $ex) { echo $ex; } if (trim($config->ambiente->db->host) == "") { $this->_redirect("/installer/"); } else { $systemInfo = array(); $uptimeRaw = explode(';', $sysInfo->core->uptime); $systemInfo['uptime'] = $uptimeRaw[0]; /* require_once "includes/AsteriskInfo.php"; $astinfo = new AsteriskInfo(); $astVersionRaw = explode('@', $astinfo->status_asterisk("core show version", "", True)); preg_match('/Asterisk (.*) built/', $astVersionRaw[0], $astVersion); */ $systemInfo['asterisk'] = $astVersion[1]; $systemInfo['mysql'] = trim(exec("mysql -V | awk -F, '{ print \$1 }' | awk -F'mysql' '{ print \$2 }'")); $systemInfo['linux_ver'] = $sysInfo->core->os . ' / ' . $sysInfo->core->Distribution; $systemInfo['linux_kernel'] = $sysInfo->core->kernel; $cpuRaw = explode('-', $sysInfo->core->CPU); $systemInfo['hardware'] = $cpuRaw[1]; $cpuNumber = count(explode('<br />', $sysInfo->core->CPU)); $cpuUsageRaw = explode(' ', $sysInfo->core->load); $loadAvarege = ($cpuUsageRaw[0] + $cpuUsageRaw[1] + $cpuUsageRaw[2]) / 3; $systemInfo['usage'] = round($loadAvarege * 100 / ($cpuNumber - 1)); $systemInfo['memory']['ram'] = array('total' => $this->byte_convert(floatval($sysInfo->memory->Physical->total)), 'free' => $this->byte_convert(floatval($sysInfo->memory->Physical->free)), 'used' => $this->byte_convert(floatval($sysInfo->memory->Physical->used)), 'percent' => floatval($sysInfo->memory->Physical->total) > 0 ? round(floatval($sysInfo->memory->Physical->used) / floatval($sysInfo->memory->Physical->total) * 100) : 0); $systemInfo['memory']['swap'] = array('total' => $this->byte_convert(floatval($sysInfo->memory->swap->core->free)), 'free' => $this->byte_convert(floatval($sysInfo->memory->swap->core->total)), 'used' => $this->byte_convert(floatval($sysInfo->memory->swap->core->used)), 'percent' => floatval($sysInfo->memory->swap->core->total) > 0 ? round(floatval($sysInfo->memory->swap->core->used) / floatval($sysInfo->memory->swap->core->total) * 100) : 0); $deviceArray = $sysInfo->mounts->mount; foreach ($deviceArray as $mount) { $systemInfo['space'][] = array('mount_point' => $mount["mountpoint"], 'size' => $this->byte_convert(floatval($mount["size"])), 'free' => $this->byte_convert(floatval($mount["free"])), 'percent' => floatval($mount["size"]) > 0 ? round(floatval($mount["used"]) / floatval($mount["size"]) * 100) : 0); } $netArray = $sysInfo->net->interface; $count = 0; foreach ($netArray as $board) { if ($count < 6) { $systemInfo['net'][] = array('device' => $board["device"], 'up' => $board["state"]); $count++; } } /// @todo tratar isso depois /* $sqlN = "select count(*) from"; $select = $db->query($sqlN . ' peers'); $result = $select->fetch(); $systemInfo['num_peers'] = $result['count(*)']; $select = $db->query($sqlN . ' trunks'); $result = $select->fetch(); $systemInfo['num_trunks'] = $result['count(*)']; $select = $db->query($sqlN . ' regras_negocio'); $result = $select->fetch(); * */ $systemInfo['num_routes'] = $result['count(*)']; $systemInfo['modules'] = array(); $modules = Snep_Modules::getInstance()->getRegisteredModules(); foreach ($modules as $module) { $systemInfo['modules'][] = array("name" => $module->getName(), "version" => $module->getVersion(), "description" => $module->getDescription()); } $this->view->indexData = $systemInfo; // Creates Snep_Inspector Object $objInspector = new Snep_Inspector(); // Get array with status of inspected system requirements $inspect = $objInspector->getInspects(); // Verify errors $this->view->error = false; foreach ($inspect as $log => $message) { if ($message['error'] == 1) { $this->view->error = true; } } // Inspector url $this->view->inspector = $this->getFrontController()->getBaseUrl() . '/inspector/'; } }
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__))); // Add standard library to the include path set_include_path(implode(PATH_SEPARATOR, array(APPLICATION_PATH . '/lib', get_include_path()))); // Initializing Snep Config require_once "Snep/Config.php"; Snep_Config::setConfigFile(APPLICATION_PATH . '/includes/setup.conf'); $config = Snep_Config::getConfig(); defined('SNEP_VENDOR') || define('SNEP_VENDOR', $config->ambiente->emp_nome); defined('SNEP_VERSION') || define('SNEP_VERSION', trim(file_get_contents(APPLICATION_PATH . "/configs/snep_version"))); // Define application environment $snep_env = Snep_Config::getConfig()->system->debug ? "development" : "production"; defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : $snep_env); if (APPLICATION_ENV === "development") { require_once "Zend/Debug.php"; } // Adds the modules directory to the snep module system require_once "Snep/Modules.php"; Snep_Modules::getInstance()->addPath(APPLICATION_PATH . "/modules"); /** Zend_Application */ require_once 'Zend/Application.php'; require_once 'Zend/Config/Ini.php'; // Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/application.ini'); // Adding standard lib autoloader capabilities to keep old code running $application->setAutoloaderNamespaces(array("Asterisk_", "PBX_", "Snep_")); // Keeping old links to avoid rework in too much stuff. require_once "Zend/Registry.php"; Zend_Registry::set("config", $config); Zend_Registry::set("db", Snep_Db::getInstance()); /* Fight! */ $application->bootstrap()->run();
protected function startModules() { Snep_Modules::getInstance()->addPath(Snep_Config::getConfig()->system->path->base . "/modules"); }
protected function startActions() { $config = Zend_Registry::get('config'); $actions_dir = $config->system->path->base . "/lib/PBX/Rule/Action"; $actions = PBX_Rule_Actions::getInstance(); foreach (scandir($actions_dir) as $filename) { // Todos os arquivos .php devem ser classes de Actions if (preg_match("/.*\\.php\$/", $filename)) { // Tentar instanciar e Adicionar no array $classname = 'PBX_Rule_Action_' . basename($filename, '.php'); if (class_exists($classname)) { $actions->registerAction($classname); } } } foreach (Snep_Modules::getInstance()->getRegisteredModules() as $module) { if ($module->getModuleId() != null) { $actions_dir = $config->system->path->base . "/modules/" . $module->getModuleDir() . "/actions"; } else { $actions_dir = $config->system->path->base . "/" . $module->getModuleDir() . "/actions"; } if (file_exists($actions_dir)) { foreach (scandir($actions_dir) as $filename) { // Todos os arquivos .php devem ser classes de Actions if (preg_match("/.*\\.php\$/", $filename)) { // Tentar instanciar e Adicionar no array require_once $actions_dir . "/" . $filename; $classname = basename($filename, '.php'); if (class_exists($classname)) { $actions->registerAction($classname); } } } } } }