[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/cron/ -> MailScanner.service (source)

   1  <?php
   2  /*********************************************************************************

   3   ** The contents of this file are subject to the vtiger CRM Public License Version 1.0

   4   * ("License"); You may not use this file except in compliance with the License

   5   * The Original Code is:  vtiger CRM Open Source

   6   * The Initial Developer of the Original Code is vtiger.

   7   * Portions created by vtiger are Copyright (C) vtiger.

   8   * All Rights Reserved.

   9   *

  10   ********************************************************************************/
  11  
  12  require_once ('include/utils/utils.php');
  13  require_once ('include/logging.php');
  14  require_once ('include/database/PearDatabase.php');
  15  
  16  require_once ('modules/Settings/MailConverter/handlers/MailScannerInfo.php');
  17  require_once ('modules/Settings/MailConverter/handlers/MailBox.php');
  18  require_once ('modules/Settings/MailConverter/handlers/MailScanner.php');
  19  
  20  //Added as sometimes the php.ini file used for command line php and

  21  //for Apache php is different.

  22  if(!function_exists('imap_open')) {
  23      echo $installationStrings['LBL_NO'].' '.$installationStrings['LBL_IMAP_SUPPORT'];
  24  } elseif(!function_exists('openssl_encrypt')) {
  25      echo $installationStrings['LBL_NO'].' '.$installationStrings['LBL_OPENSSL_SUPPORT'];
  26  }
  27  
  28  /**

  29   * Helper function for triggering the scan.

  30   */
  31  function service_MailScanner_performScanNow($scannerinfo, $debug) {
  32      /** If the scanner is not enabled, stop. */

  33      if($scannerinfo->isvalid) { 
  34          echo "Scanning " . $scannerinfo->server . " in progress\n";
  35  
  36          /** Start the scanning. */

  37          $scanner = new Vtiger_MailScanner($scannerinfo);
  38          $scanner->debug = $debug;
  39          $status = $scanner->performScanNow();
  40          
  41                  if($status && is_bool($status))
  42                      echo "\nScanning " . $scannerinfo->server . " completed\n";
  43                  else
  44                      echo "\nScanning Failed. Error ".$status."\n";
  45          
  46      } else {
  47          echo "Failed! [{$scannerinfo->scannername}] is not enabled for scanning!";
  48      }
  49  }
  50  
  51  /** 

  52   * Execution of this is based on number of emails and connection to mailserver.

  53   * So setting infinite timeout.

  54   */
  55  @set_time_limit(0);
  56  
  57  /** Turn-off this if not required. */

  58  $debug = true;
  59  
  60  /** Pick up the mail scanner for scanning. */

  61  if(isset($_REQUEST['scannername'])) {
  62      
  63      // Target scannername specified?    

  64      $scannername = vtlib_purify($_REQUEST['scannername']);
  65      $scannerinfo = new Vtiger_MailScannerInfo($scannername);
  66      
  67      service_MailScanner_performScanNow($scannerinfo, $debug);
  68      
  69  } else {
  70      
  71      // Scan all the configured mailscanners?

  72      
  73      $scannerinfos = Vtiger_MailScannerInfo::listAll();
  74      if(empty($scannerinfos)) {
  75          
  76          echo "No mailbox configured for scanning!";
  77          
  78      } else {
  79          foreach($scannerinfos as $scannerinfo) {
  80              service_MailScanner_performScanNow($scannerinfo, $debug);
  81          }
  82      }    
  83  }
  84  
  85  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1