Beispiel #1
0
 /** Sets the LeelabotAdmin object.
  * This function sets the LeelabotAdmin object, which handles all webadmin operations, from page parsing to authentification handling.
  * 
  * \param $obj The LeelabotAadmin object.
  * 
  * \return Nothing.
  */
 public static function setWAObject($obj)
 {
     self::$_WAObject = $obj;
 }
Beispiel #2
0
 /** Web admin page : Reloads the plugin list from the file.
  * This function reload the plugin list from the file set in the config file. 
  * 
  * \param $data The data from the browser
  * 
  * \return The query result, i.e. an error message if an error occured or "ok" if the reload was successful.
  */
 public function WAPageReload($data)
 {
     Webadmin::disableDesign();
     //We disable the design, because of AJAX
     Webadmin::disableCache();
     if ($this->loadBanlist()) {
         return "success:";
     } else {
         return "error:" . Leelabot::lastError();
     }
 }
Beispiel #3
0
 public function WAPageInstallUpdate($data)
 {
     Webadmin::disableDesign();
     //We disable the design, because of AJAX
     Webadmin::disableCache();
     if ($this->doUpdate($data['matches'][1])) {
         return 'success';
     } else {
         return 'error:Version not found/Update already pending';
     }
 }
Beispiel #4
0
 /** Loads the webserver and configures it.
  * This function loads the webserver and configures it from the data given in argument.
  * 
  * \param $config Configuration data
  * 
  * \return TRUE if server loaded successfully, FALSE otherwise.
  */
 public function load($config)
 {
     Leelabot::message('Loading OuterAPI...');
     include 'lib/nginyus/nginyus.php';
     NginyUS_load('lib/nginyus/');
     $this->_server = new NginyUS();
     //Checking validity of the IP/Port couple
     if (!isset($config['BindAddress']) || !isset($config['BindPort']) || !in_array($config['BindPort'], range(0, 65535)) || !filter_var($config['BindAddress'], FILTER_VALIDATE_IP)) {
         Leelabot::message('Bind address/port not found or incorrect', array(), E_WARNING);
         return FALSE;
     }
     $this->_server->setAddress($config['BindAddress'], $config['BindPort']);
     //Getting the SiteManager
     $this->_manager = $this->_server->manageSites();
     //Loading the webservice
     if (isset($config['Webservice']) && (!isset($config['Webservice']['Enable']) || Leelabot::parseBool($config['Webservice']['Enable']))) {
         Leelabot::message('Loading Webservice...');
         $this->_WSEnabled = TRUE;
         $WSConfig = $config['Webservice'];
         //Including the MLPFIM Webservice class
         include 'lib/mlpfim/mlpfimserver.php';
         //If there is aliases, we update them to add the API path to them
         if (!empty($WSConfig['Aliases'])) {
             $newAliases = array();
             foreach (explode(',', $WSConfig['Aliases']) as $alias) {
                 $newAliases[] = trim($alias) . '/api';
             }
             $WSConfig['Aliases'] = join(', ', $newAliases);
         } else {
             $WSConfig['Aliases'] = '';
         }
         //Creating site for that
         $this->_manager->newSite('webservice');
         $site = $this->_manager->getSite('webservice');
         $this->_manager->loadConfig('webservice', array('SiteRoot' => $config['BindAddress'] . '/api', 'Alias' => $WSConfig['Aliases'], 'DocumentRoot' => '.', 'ProcessFiles' => 'core/webservice.class.php'));
         if (isset($WSConfig['Authentication']) && Leelabot::parseBool($WSConfig['Authentication']) == TRUE && isset($WSConfig['AuthFile']) && is_file(Leelabot::$instance->getConfigLocation() . '/' . $WSConfig['AuthFile'])) {
             $this->_WSAuth = TRUE;
             $WSConfig['AuthFile'] = Leelabot::$instance->getConfigLocation() . '/' . $WSConfig['AuthFile'];
             $this->_WSAuthFile = $WSConfig['AuthFile'];
         } else {
             Leelabot::message('Using Webservice without authentication is not secure !', array(), E_WARNING, TRUE);
         }
     }
     //Loading the webadmin
     if (isset($config['Webadmin']) && (!isset($config['Webadmin']['Enable']) || Leelabot::parseBool($config['Webadmin']['Enable']))) {
         Leelabot::message('Loading Webadmin...');
         $this->_WAEnabled = TRUE;
         $WAConfig = $config['Webadmin'];
         //If there is aliases, we update them to add the admin path to them
         if (!empty($WAConfig['Aliases'])) {
             $newAliases = array();
             foreach (explode(',', $WAConfig['Aliases']) as $alias) {
                 $newAliases[] = trim($alias) . '/admin';
             }
             $WAConfig['Aliases'] = join(', ', $newAliases);
         } else {
             $WAConfig['Aliases'] = '';
         }
         //Creating the site in the webserver
         $this->_manager->newSite('webadmin');
         $site = $this->_manager->getSite('webadmin');
         $this->_manager->loadConfig('webadmin', array('SiteRoot' => $config['BindAddress'] . '/admin', 'Alias' => $WAConfig['Aliases'], 'DocumentRoot' => '.', 'ProcessFiles' => 'web/controllers/dispatcher.class.php'));
         if (isset($WAConfig['Authentication']) && Leelabot::parseBool($WAConfig['Authentication']) == TRUE && isset($WAConfig['AuthFile']) && is_file(Leelabot::$instance->getConfigLocation() . '/' . $WAConfig['AuthFile'])) {
             $this->_WAAuth = TRUE;
             $WAConfig['AuthFile'] = Leelabot::$instance->getConfigLocation() . '/' . $WAConfig['AuthFile'];
             $this->_WAAuthFile = $WAConfig['AuthFile'];
         } else {
             Leelabot::message('Using Webadmin without authentication is not secure !', array(), E_WARNING, TRUE);
         }
     }
     $this->_server->connect();
     //Setting InnerAPI classes
     if (!empty($this->_manager->getSite('webadmin')->classes['LeelabotAdmin'])) {
         Webadmin::setWAObject($this->_manager->getSite('webadmin')->classes['LeelabotAdmin']);
     }
     if (!empty($this->_manager->getSite('webadmin')->classes['LeelabotAdmin'])) {
         $this->_manager->getSite('webadmin')->classes['LeelabotAdmin']->setAuthentication($this->_WAAuth, $this->_WAAuthFile);
     }
     if (!empty($this->_manager->getSite('webadmin')->classes['LeelabotAdmin'])) {
         $this->_manager->getSite('webservice')->classes['LeelabotWebservice']->setAuthentication($this->_WSAuth, $this->_WSAuthFile);
     }
 }