Example #1
0
 public function indexAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("System Status")));
     // Creates Snep_Inspector Object
     $objInspector = new Snep_Inspector();
     // Get array with status of inspected system requirements
     $inspect = $objInspector->getInspects();
     $this->view->inspect = $inspect;
 }
Example #2
0
 /**
  * List all Music on Hold sounds
  */
 public function indexAction()
 {
     $objInspector = new Snep_Inspector('Sounds');
     $this->view->error = array_pop($objInspector->getInspects());
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("Music on Hold Sessions")));
     $this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName();
     $this->view->modes = array('files' => $this->view->translate('Directory'), 'mp3' => $this->view->translate('MP3'), 'quietmp3' => $this->view->translate('Normal'), 'mp3nb' => $this->view->translate('Without buffer'), 'quietmp3nb' => $this->view->translate('Without buffer quiet'), 'custom' => $this->view->translate('Custom application'));
     Snep_SoundFiles_Manager::syncFiles();
     $this->view->sections = Snep_SoundFiles_Manager::getClasses();
     $this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add/", "display" => $this->view->translate("Add Session"), "css" => "include"));
 }
Example #3
0
 /**
  * List all sound files
  */
 public function indexAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("Sound Files")));
     $this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName();
     $db = Zend_Registry::get('db');
     $select = $db->select()->from("sounds")->where("tipo = 'AST'")->order('arquivo');
     if ($this->_request->getPost('filtro')) {
         $field = mysql_escape_string($this->_request->getPost('campo'));
         $query = mysql_escape_string($this->_request->getPost('filtro'));
         $select->where("`{$field}` like '%{$query}%'");
     }
     $objInspector = new Snep_Inspector('Permissions');
     $inspect = $objInspector->getInspects();
     $this->view->error = $inspect['Permissions'];
     $stmt = $db->query($select);
     $files = $stmt->fetchAll();
     foreach ($files as $id => $file) {
         $info = Snep_SoundFiles_Manager::verifySoundFiles($file['arquivo']);
         $_files[] = array_merge($file, $info);
     }
     $page = $this->_request->getParam('page');
     $this->view->page = isset($page) && is_numeric($page) ? $page : 1;
     $this->view->filtro = $this->_request->getParam('filtro');
     $paginatorAdapter = new Zend_Paginator_Adapter_Array($_files);
     $paginator = new Zend_Paginator($paginatorAdapter);
     $paginator->setCurrentPageNumber($this->view->page);
     $paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit);
     $this->view->files = $paginator;
     $this->view->pages = $paginator->getPages();
     $this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
     $opcoes = array("arquivo" => $this->view->translate("Filename"), "descricao" => $this->view->translate("Description"));
     $filter = new Snep_Form_Filter();
     $filter->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $filter->setValue($this->_request->getPost('campo'));
     $filter->setFieldOptions($opcoes);
     $filter->setFieldValue($this->_request->getPost('filtro'));
     $filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/page/{$page}");
     $this->view->form_filter = $filter;
     $this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add/", "display" => $this->view->translate("Add Sound File"), "css" => "include"));
 }
Example #4
0
 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/';
     }
 }
Example #5
0
 public function configureAction()
 {
     $objInspector = new Snep_Inspector('Permissions');
     $inspect = $objInspector->getInspects();
     $this->view->error = $inspect['Permissions'];
     $this->view->hideMenu = true;
     $this->view->breadcrumb = $this->view->translate("Installer » Configuration");
     $form_config = new Zend_Config_Xml("./modules/default/formsinstaller.xml");
     $form = new Snep_Form();
     $form->setAction($this->getFrontController()->getBaseUrl() . '/installer/configure');
     $asterisk_form = new Snep_Form_SubForm($this->view->translate("Asterisk Configuration"), $form_config->asterisk);
     $database_form = new Snep_Form_SubForm($this->view->translate("Database Configuration"), $form_config->database);
     $snep_form = new Snep_Form_SubForm($this->view->translate("Admin Password"), $form_config->snep);
     $form->addSubForm($database_form, "database");
     $form->addSubForm($asterisk_form, "asterisk");
     $form->addSubForm($snep_form, "snep");
     $submit_button = $form->getElement('submit');
     if ($this->view->error['error']) {
         $submit_button->setAttrib('disabled', true);
     }
     if ($this->getRequest()->isPost()) {
         $form_isValid = $form->isValid($_POST);
         $snep_data = $form->getValue("snep");
         if ($snep_data['password'] !== $snep_data['confirmpassword']) {
             $snep_form->getElement('confirmpassword')->addError($this->view->translate("The password confirmation is different from the original"));
             $form_isValid = false;
         }
         if (!$asterisk_form->isErrors()) {
             $asterisk_data = $form->getValue("asterisk");
             $asterisk = new Asterisk_AMI(null, $asterisk_data);
             try {
                 $asterisk->connect();
             } catch (Asterisk_Exception_Auth $ex) {
                 $asterisk_form->getElement('secret')->addError($this->view->translate("User and/or password rejected by Asterisk"));
                 $form_isValid = false;
             } catch (Asterisk_Exception_CantConnect $ex) {
                 $asterisk_form->getElement('server')->addError($this->view->translate("Unable to connect: %s", $ex->getMessage()));
                 $form_isValid = false;
             }
         }
         if (!$database_form->isErrors()) {
             $database_data = $form->getValue('database');
             $db = Zend_Db::factory('Pdo_Mysql', $database_data);
             try {
                 $db->getConnection();
             } catch (Zend_Db_Exception $ex) {
                 $database_form->getElement('hostname')->addError($this->view->translate("Unable to connect: %s", $ex->getMessage()));
                 $form_isValid = false;
             }
         }
         if ($form_isValid) {
             try {
                 $this->install($db);
             } catch (Exception $ex) {
                 $this->view->message = $ex->getMessage();
                 $this->renderScript("installer/error.phtml");
             }
             // Setando usuário do admin.
             $db->update("peers", array('password' => $snep_data['password']), "id = 1");
             // Gravando alterações no arquivo de configuração.
             $config_file = "./includes/setup.conf";
             $config = new Zend_Config_Ini($config_file, null, true);
             $config->ambiente->ip_sock = $_POST['asterisk']['server'];
             $config->ambiente->user_sock = $_POST['asterisk']['username'];
             $config->ambiente->pass_sock = $_POST['asterisk']['secret'];
             $config->ambiente->db->host = $_POST['database']['hostname'];
             $config->ambiente->db->username = $_POST['database']['username'];
             $config->ambiente->db->password = $_POST['database']['password'];
             $config->ambiente->db->dbname = $_POST['database']['dbname'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $config_file));
             // Grava arquivo.
             $writer->write();
             $this->_redirect("installer/installed");
         }
     }
     $this->view->form = $form;
 }