Marius Cramer
2014-02-17 ebbe6374fc9c308daf729d2ad1b2f8007ed771ce
interface/lib/classes/remoting.inc.php
@@ -180,37 +180,14 @@
      $session_id = $app->db->quote($session_id);
      $sql = "DELETE FROM remote_session WHERE remote_session = '$session_id'";
      $app->db->query($sql);
      return $app->db->affectedRows() == 1;
      if($app->db->query($sql) != false) {
         return true;
      } else {
         return false;
      }
   }
   //* Add mail domain
   public function mail_user_add($session_id, $client_id, $params){
      global $app;
      if (!$this->checkPerm($session_id, 'mail_user_add')){
         $this->server->fault('permission_denied','You do not have the permissions to access this function.');
         return false;
      }
      //* Check if mail domain exists
      $email_parts = explode('@',$params['email']);
      $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
      if($tmp['domain'] != $email_parts[1]) {
         $this->server->fault('mail_domain_does_not_exist','Mail domain - '.$email_parts[1].' - does not exist.');
         return false;
      }
      //* Set a few params to non empty values that will be overwritten by mail_plugin
      if (!isset($params['uid'])) $params['uid'] = 999989999;
      if (!isset($params['gid'])) $params['gid'] = 999989999;
      $affected_rows = $this->insertQuery('../mail/form/mail_user.tform.php', $client_id, $params);
      return $affected_rows;
   }
   //** protected functions -----------------------------------------------------------------------------------
   protected function klientadd($formdef_file, $reseller_id, $params)
   {
@@ -505,17 +482,50 @@
      }
   }
   // needed from inside the remoting plugins
   public function server_get($session_id, $server_id, $section ='') {
   public function server_get($session_id, $server_id = null, $section ='') {
      global $app;
      if(!$this->checkPerm($session_id, 'server_get')) {
         throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
         $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
         return false;
      }
      if (!empty($session_id) && !empty($server_id)) {
         $app->uses('remoting_lib , getconf');
         $section_config =  $app->getconf->get_server_config($server_id, $section);
         return $section_config;
      if (!empty($session_id)) {
         if(!empty($server_id)) {
            $app->uses('remoting_lib , getconf');
            $section_config =  $app->getconf->get_server_config($server_id, $section);
            return $section_config;
         } else {
            $servers = array();
            $sql = "SELECT server_id FROM server WHERE 1";
            $all = $app->db->queryAllRecords($sql);
            foreach($all as $s) {
               $servers[$s['server_id']] = $app->getconf->get_server_config($s['server_id'], $section);
            }
            unset($all);
            unset($s);
            return $servers;
         }
      } else {
         return false;
      }
   }
   /**
       Gets a list of all servers
       @param int session_id
       @param int server_name
       @author Marius Cramer <m.cramer@pixcept.de> 2014
    */
   public function server_get_all($session_id)
    {
        global $app;
      if(!$this->checkPerm($session_id, 'server_get')) {
           $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
      }
      if (!empty($session_id)) {
         $sql = "SELECT server_id, server_name FROM server WHERE 1";
         $servers = $app->db->queryAllRecords($sql);
         return $servers;
      } else {
         return false;
      }