Пример #1
0
$mail_server_password = $adb->query_result($result, 0, 'server_password');
$smtp_auth = $adb->query_result($result, 0, 'smtp_auth');
$from_email_field = $adb->query_result($result, 0, 'from_email_field');
$servername = vtlib_purify($_REQUEST['server_name']);
$username = vtlib_purify($_REQUEST['server_user']);
if (!empty($servername)) {
    $validInput = validateServerName($servername);
    if (!$validInput) {
        $servername = '';
    }
    $smarty->assign("MAILSERVER", $servername);
} elseif (isset($mail_server)) {
    $smarty->assign("MAILSERVER", $mail_server);
}
if (!empty($username)) {
    $validInput = validateEmailId($username);
    if (!$validInput) {
        $username = '';
    }
    $smarty->assign("USERNAME", $username);
} elseif (isset($mail_server_username)) {
    $smarty->assign("USERNAME", $mail_server_username);
}
if (isset($mail_server_password)) {
    $smarty->assign("PASSWORD", $mail_server_password);
}
if (isset($_REQUEST['from_email_field'])) {
    $smarty->assign("FROM_EMAIL_FIELD", vtlib_purify($_REQUEST['from_email_field']));
} elseif (isset($from_email_field)) {
    $smarty->assign("FROM_EMAIL_FIELD", $from_email_field);
}
Пример #2
0
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *
 ********************************************************************************/
require_once 'modules/Settings/MailScanner/core/MailScannerInfo.php';
require_once 'modules/Settings/MailScanner/core/MailBox.php';
$scannername = vtlib_purify(trim($_REQUEST['mailboxinfo_scannername']));
if (!empty($scannername) && !validateAlphanumericInput($scannername)) {
    $scannername = '';
}
$server = vtlib_purify(trim($_REQUEST['mailboxinfo_server']));
if (!empty($server) && !validateServerName($server)) {
    $server = '';
}
$username = vtlib_purify(trim($_REQUEST['mailboxinfo_username']));
if (!empty($username) && !validateEmailId($username) && !validateAlphanumericInput($username)) {
    $username = '';
}
$newscannerinfo = new Vtiger_MailScannerInfo(false, false);
$newscannerinfo->scannername = $scannername;
$newscannerinfo->server = $server;
$newscannerinfo->protocol = vtlib_purify(trim($_REQUEST['mailboxinfo_protocol']));
$newscannerinfo->username = $username;
$newscannerinfo->password = vtlib_purify(trim($_REQUEST['mailboxinfo_password']));
$newscannerinfo->ssltype = vtlib_purify(trim($_REQUEST['mailboxinfo_ssltype']));
$newscannerinfo->sslmethod = vtlib_purify(trim($_REQUEST['mailboxinfo_sslmethod']));
$newscannerinfo->searchfor = vtlib_purify(trim($_REQUEST['mailboxinfo_searchfor']));
$newscannerinfo->markas = vtlib_purify(trim($_REQUEST['mailboxinfo_markas']));
$newscannerinfo->isvalid = $_REQUEST['mailboxinfo_enable'] == 'true' ? true : false;
// Rescan all folders on next run?
$rescanfolder = $_REQUEST['mailboxinfo_rescan_folders'] == 'true' ? true : false;
Пример #3
0
 /**
  * Function to save this record
  * @return <Boolean> true/false (Saved/Not Saved)
  */
 public function save()
 {
     vimport('~~modules/Settings/MailConverter/handlers/MailScannerInfo.php');
     $scannerLatestInfo = new Vtiger_MailScannerInfo(false, false);
     $fieldsList = $this->getModule()->getFields();
     foreach ($fieldsList as $fieldName => $fieldModel) {
         $scannerLatestInfo->{$fieldName} = $this->get($fieldName);
     }
     $scannerId = $this->getId();
     if (!empty($scannerId)) {
         $scannerLatestInfo->scannerid = $this->getId();
     }
     //Checking Scanner Name
     $scannerName = $this->getName();
     if ($scannerName && !validateAlphanumericInput($scannerName)) {
         return false;
     }
     //Checking Server
     $server = $this->get('server');
     if ($server && !validateServerName($server)) {
         return false;
     }
     //Checking User Name
     $userName = $this->get('username');
     if ($userName && !validateEmailId($userName) && !validateAlphanumericInput($userName)) {
         return false;
     }
     $isConnected = true;
     $scannerOldInfo = new Vtiger_MailScannerInfo($this->get('scannerOldName'));
     if (!$scannerOldInfo->compare($scannerLatestInfo)) {
         vimport('~~modules/Settings/MailConverter/handlers/MailBox.php');
         $mailBox = new Vtiger_MailBox($scannerLatestInfo);
         $isConnected = $mailBox->connect();
     }
     if ($isConnected) {
         $scannerLatestInfo->connecturl = $mailBox->_imapurl;
         //$scannerLatestInfo->isvalid = $scannerOldInfo->isvalid = $isConnected;
         if (!empty($scannerId)) {
             $scannerOldInfo->scannerid = $scannerId;
         }
         $mailServerChanged = $scannerOldInfo->update($scannerLatestInfo);
         if (empty($scannerId)) {
             $this->set('scannerid', $scannerOldInfo->scannerid);
         }
         $rescanFolder = false;
         if ($this->get('searchfor') === 'all') {
             $rescanFolder = true;
         }
         $scannerOldInfo->updateAllFolderRescan($rescanFolder);
         // Update lastscan on all the available folders.
         if ($mailServerChanged && $mailBox) {
             //only for inbox
             $folders = array('INBOX');
             foreach ($folders as $folder) {
                 $scannerOldInfo->updateLastscan($folder);
             }
         }
     }
     return $isConnected;
 }