Beispiel #1
0
 static function ExecuteCreateFTP($uid, $username, $password, $destination, $domainDestination, $access_type, $home)
 {
     global $zdbh;
     global $controller;
     $currentuser = ctrl_users::GetUserDetail($uid);
     $username = $currentuser['username'] . '_' . $username;
     runtime_hook::Execute('OnBeforeCreateFTPAccount');
     if (fs_director::CheckForEmptyValue(self::CheckForErrors($username, $password))) {
         // Check to see if its a new home directory or use a current one...
         if ($home == 1) {
             $homedirectory_to_use = '/' . str_replace('.', '_', $username);
             $full_path = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . $homedirectory_to_use . '/';
             // Create the new home directory... (If it doesnt already exist.)
             if (!file_exists($full_path)) {
                 @mkdir($full_path, 777);
                 @chmod($full_path, 0777);
             }
         } else {
             if ($home == 3) {
                 $homedirectory_to_use = '/' . $domainDestination;
             } else {
                 $homedirectory_to_use = '/' . $destination;
             }
         }
         // Check if Path is inside user home directory.
         $full_homeDir = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . $homedirectory_to_use . '/';
         $baseDir = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'];
         $realPath = realpath($full_homeDir);
         if (0 !== strpos($realPath, $baseDir)) {
             self::$invalidPath = true;
             return false;
         }
         $sql = $zdbh->prepare("INSERT INTO x_ftpaccounts (ft_acc_fk, ft_user_vc, ft_directory_vc, ft_access_vc, ft_password_vc, ft_created_ts) VALUES (:userid, :username, :homedir, :accesstype, :password, :time)");
         $sql->bindParam(':userid', $currentuser['userid']);
         $sql->bindParam(':username', $username);
         $sql->bindParam(':homedir', $homedirectory_to_use);
         $sql->bindParam(':accesstype', $access_type);
         $sql->bindParam(':password', $password);
         $sql->bindParam(':time', time());
         $sql->execute();
         self::$create = true;
         // Include FTP server specific file here.
         $FtpModuleFile = 'modules/' . $controller->GetControllerRequest('URL', 'module') . '/code/' . ctrl_options::GetSystemOption('ftp_php');
         if (file_exists($FtpModuleFile)) {
             include $FtpModuleFile;
         }
         runtime_hook::Execute('OnAfterCreateFTPAccount');
         return true;
     }
     return false;
 }
 static function ExecuteCreateForwarder($uid, $address, $dname, $ddomain, $keepmessage)
 {
     global $zdbh;
     global $controller;
     $currentuser = ctrl_users::GetUserDetail($uid);
     if (fs_director::CheckForEmptyValue(self::CheckCreateForErrors($address, $dname, $ddomain, $keepmessage))) {
         return false;
     }
     $destination = strtolower(str_replace(' ', '', $dname . '@' . $ddomain));
     runtime_hook::Execute('OnBeforeCreateForwarder');
     self::$create = true;
     // Include mail server specific file here.
     $MailServerFile = 'modules/' . $controller->GetControllerRequest('URL', 'module') . '/code/' . ctrl_options::GetSystemOption('mailserver_php');
     if (file_exists($MailServerFile)) {
         include $MailServerFile;
     }
     $sql = "INSERT INTO x_forwarders (fw_acc_fk,\n\t\t\t\t\t\t\t\t\t\t\t  fw_address_vc,\n\t\t\t\t\t\t\t\t\t\t\t  fw_destination_vc,\n\t\t\t\t\t\t\t\t\t\t\t  fw_keepmessage_in,\n\t\t\t\t\t\t\t\t\t\t\t  fw_created_ts) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t  :userid,\n\t\t\t\t\t\t\t\t\t\t\t  :address,\n\t\t\t\t\t\t\t\t\t\t\t  :destination,\n\t\t\t\t\t\t\t\t\t\t\t  :keepmessage,\n\t\t\t\t\t\t\t\t\t\t\t  :time)";
     $sql = $zdbh->prepare($sql);
     $sql->bindParam(':userid', $currentuser['userid']);
     $sql->bindParam(':address', $address);
     $sql->bindParam(':destination', $destination);
     $sql->bindParam(':keepmessage', $keepmessage);
     $sql->bindParam(':time', time());
     $sql->execute();
     runtime_hook::Execute('OnAfterCreateForwarder');
     self::$ok = true;
     return true;
 }
 static function ExecuteAddDistList($uid, $inAddress, $inDomain)
 {
     global $zdbh;
     global $controller;
     $currentuser = ctrl_users::GetUserDetail($uid);
     $fulladdress = strtolower(str_replace(' ', '', $inAddress . '@' . $inDomain));
     if (fs_director::CheckForEmptyValue(self::CheckCreateForErrors($inAddress, $inDomain))) {
         return false;
     }
     runtime_hook::Execute('OnBeforeAddDistList');
     self::$create = true;
     // Include mail server specific file here.
     $MailServerFile = 'modules/' . $controller->GetControllerRequest('URL', 'module') . '/code/' . ctrl_options::GetSystemOption('mailserver_php');
     if (file_exists($MailServerFile)) {
         include $MailServerFile;
     }
     $sqlStatment = "INSERT INTO x_distlists (dl_acc_fk,\n\t\t\t\t\t\t\t\t\t\t  dl_address_vc,\n\t\t\t\t\t\t\t\t\t\t  dl_created_ts) VALUES (\n\t\t\t\t\t\t\t\t\t\t  :userid,\n\t\t\t\t\t\t\t\t\t\t  :fulladdress,\n\t\t\t\t\t\t\t\t\t\t  :time)";
     $sql = $zdbh->prepare($sqlStatment);
     $sql->bindParam(':userid', $currentuser['userid']);
     $sql->bindParam(':fulladdress', $fulladdress);
     $sql->bindParam(':time', time());
     $sql->execute();
     runtime_hook::Execute('OnAfterAddDistList');
     self::$ok = true;
     return true;
 }
Beispiel #4
0
 static function ExecuteCreateAlias($uid, $address, $domain, $destination)
 {
     global $zdbh;
     global $controller;
     $currentuser = ctrl_users::GetUserDetail($uid);
     if (fs_director::CheckForEmptyValue(self::CheckCreateForErrors($address, $domain, $destination))) {
         return false;
     }
     runtime_hook::Execute('OnBeforeCreateAlias');
     $address = str_replace('*', '', $address);
     $fulladdress = $address . "@" . $domain;
     $destination = strtolower(str_replace(' ', '', $destination));
     self::$create = true;
     // Include mail server specific file here.
     include "modules/" . $controller->GetControllerRequest('URL', 'module') . "/code/" . ctrl_options::GetSystemOption('mailserver_php') . "";
     $bindArray = array(':userid' => $currentuser['userid'], ':fulladdress' => $fulladdress, ':destination' => $destination, ':time' => time());
     $sql = "INSERT INTO x_aliases (al_acc_fk,\n\t\t\t\t\t\t\t\t\t\t\t  al_address_vc,\n\t\t\t\t\t\t\t\t\t\t\t  al_destination_vc,\n\t\t\t\t\t\t\t\t\t\t\t  al_created_ts) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t  :userid,\n\t\t\t\t\t\t\t\t\t\t\t  :fulladdress,\n\t\t\t\t\t\t\t\t\t\t\t  :destination,\n\t\t\t\t\t\t\t\t\t\t\t  :time)";
     if ($zdbh->bindQuery($sql, $bindArray)) {
         runtime_hook::Execute('OnAfterCreateAlias');
         self::$ok = true;
         return true;
     } else {
         return false;
     }
 }
    static function ExecuteAddMailbox($uid, $address, $domain, $password)
    {
        global $zdbh;
        global $controller;
        $currentuser = ctrl_users::GetUserDetail($uid);
        if (fs_director::CheckForEmptyValue(self::CheckCreateForErrors($address, $domain, $password))) {
            return false;
        }
        runtime_hook::Execute('OnBeforeCreateMailbox');
        $address = strtolower(str_replace(' ', '', $address));
        $fulladdress = strtolower(str_replace(' ', '', $address . "@" . $domain));
        self::$create = true;
        // Include mail server specific file here.
        $MailServerFile = 'modules/' . $controller->GetControllerRequest('URL', 'module') . '/code/' . ctrl_options::GetSystemOption('mailserver_php');
        if (file_exists($MailServerFile))
            include($MailServerFile);

        $sql = "INSERT INTO x_mailboxes (mb_acc_fk,
											 mb_address_vc,
											 mb_created_ts) VALUES (
											 :userid,
											 :fulladdress,
											 :time)";
        $time = time();
        $sql = $zdbh->prepare($sql);
        $sql->bindParam(':time', $time);
        $sql->bindParam(':userid', $currentuser['userid']);
        $sql->bindParam(':fulladdress', $fulladdress);
        $sql->execute();
        runtime_hook::Execute('OnAfterCreateMailbox');
        self::$ok = true;
        return true;
    }