[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/Settings/ -> Save.php (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/database/PearDatabase.php");
  13  $server=$_REQUEST['server'];
  14  $port=$_REQUEST['port'];
  15  $server_username=$_REQUEST['server_username'];
  16  $server_password=$_REQUEST['server_password'];
  17  $server_type = $_REQUEST['server_type'];
  18  $db_update = true;
  19  if($_REQUEST['smtp_auth'] == 'on' || $_REQUEST['smtp_auth'] == 1)
  20      $smtp_auth = 'true';
  21  else
  22      $smtp_auth = 'false';
  23  
  24  $sql="select * from vtiger_systems where server_type = '".$server_type."'";
  25  $id=$adb->query_result($adb->query($sql),0,"id");
  26  
  27  if($server_type == 'proxy')
  28  {
  29      $action = 'ProxyServerConfig&proxy_server_mode=edit';
  30      if (!$sock =@fsockopen($server, $port, $errno, $errstr, 30))
  31      {
  32          $error_str = 'error=Unable connect to "'.$server.':'.$port.'"';
  33          $db_update = false;
  34      }else
  35      {
  36          $url = "http://www.google.co.in";
  37          $proxy_cont = '';
  38          $sock = fsockopen($server, $port);
  39          if (!$sock)    {return false;}
  40          fputs($sock, "GET $url HTTP/1.0\r\nHost: $server\r\n");
  41          fputs($sock, "Proxy-Authorization: Basic " . base64_encode ("$server_username:$server_password") . "\r\n\r\n");
  42          while(!feof($sock)) {$proxy_cont .= fread($sock,4096);}
  43          fclose($sock);
  44          $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);
  45          
  46          if(substr_count($proxy_cont, "Cache Access Denied") > 0)
  47          {
  48              $error_str = 'error=Proxy Authentication Required';
  49              $db_update = false;
  50          }
  51          else
  52          {
  53              $action = 'ProxyServerConfig';
  54          }
  55      }
  56  }
  57  
  58  if($server_type == 'backup')
  59  {
  60      $conn_id = @ftp_connect($server);
  61      $action = 'BackupServerConfig&bkp_server_mode=edit';
  62      if(!$conn_id)
  63      {
  64          $error_str = 'error=Unable connect to "'.$server.'"';
  65          $db_update = false;
  66      }else
  67      {
  68          if(!@ftp_login($conn_id, $server_username, $server_password))
  69          {
  70              $error_str = 'error=Couldn\'t connect to "'.$server.'" as user "'.$server_username.'"';
  71              $db_update = false;
  72          }
  73          else
  74          {
  75              $action = 'BackupServerConfig';
  76          }
  77          ftp_close($conn_id);
  78      }
  79  }
  80  
  81  if($db_update)
  82  {
  83      if($id=='')
  84      {
  85          $id = $adb->getUniqueID("vtiger_systems");
  86          $sql="insert into vtiger_systems values(" .$id .",'".$server."','".$port."','".$server_username."','".$server_password."','".$server_type."','".$smtp_auth."')";
  87      }
  88      else
  89          $sql="update vtiger_systems set server = '".$server."', server_username = '".$server_username."', server_password = '".$server_password."', smtp_auth='".$smtp_auth."', server_type = '".$server_type."',server_port='".$port."' where id = ".$id;
  90  
  91      $adb->query($sql);
  92  }
  93  
  94  //Added code to send a test mail to the currently logged in user
  95  if($server_type != 'backup' && $server_type != 'proxy')
  96  {
  97      require_once ("modules/Emails/mail.php");
  98      global $current_user;
  99  
 100      $to_email = getUserEmailId('id',$current_user->id);
 101      $from_email = $to_email;
 102      $subject = 'Test mail about the mail server configuration.';
 103      $description = 'Dear '.$current_user->user_name.', <br><br> This is a test mail sent to confirm if a mail is actually being sent through the vtiger system. You are free to delete this mail.<br> Thanks  and  Regards<br> Team vTiger <br><br>';
 104      if($to_email != '')
 105      {
 106          $mail_status = send_mail('Users',$to_email,$current_user->user_name,$from_email,$subject,$description);
 107          $mail_status_str = $to_email."=".$mail_status."&&&";
 108      }
 109      else
 110      {
 111          $mail_status_str = "'".$to_email."'=0&&&";
 112      }
 113      $error_str = getMailErrorString($mail_status_str);
 114      $action = 'EmailConfig';
 115      if($mail_status != 1)
 116          $action = 'EmailConfig&emailconfig_mode=edit';
 117  }
 118  header("Location: index.php?module=Settings&parenttab=Settings&action=$action&$error_str");
 119  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7