[Vtigercrm-commits] [vtiger-commits] r7702 - /vtigercrm/trunk/modules/Settings/Save.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Jun 30 07:52:57 EDT 2006
Author: saraj
Date: Fri Jun 30 05:52:47 2006
New Revision: 7702
Log:
proxy server settings integrated
Modified:
vtigercrm/trunk/modules/Settings/Save.php
Modified: vtigercrm/trunk/modules/Settings/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/Save.php (original)
+++ vtigercrm/trunk/modules/Settings/Save.php Fri Jun 30 05:52:47 2006
@@ -10,13 +10,12 @@
********************************************************************************/
require_once("include/database/PearDatabase.php");
-
$server=$_REQUEST['server'];
$port=$_REQUEST['port'];
$server_username=$_REQUEST['server_username'];
$server_password=$_REQUEST['server_password'];
$server_type = $_REQUEST['server_type'];
-
+$db_update = true;
if($_REQUEST['smtp_auth'] == 'on' || $_REQUEST['smtp_auth'] == 1)
$smtp_auth = 'true';
else
@@ -25,16 +24,37 @@
$sql="select * from vtiger_systems where server_type = '".$server_type."'";
$id=$adb->query_result($adb->query($sql),0,"id");
+if($server_type == 'proxy')
+{
+ $action = 'ProxyServerConfig&proxy_server_mode=edit';
+ if (!$sock =@fsockopen($server, $port, $errno, $errstr, 30))
+ {
+ $error_str = 'error=Unable connect to "'.$server.':'.$port.'"';
+ $db_update = false;
+ }else
+ {
+ $url = "http://www.google.co.in";
+ $proxy_cont = '';
+ $sock = fsockopen($server, $port);
+ if (!$sock) {return false;}
+ fputs($sock, "GET $url HTTP/1.0\r\nHost: $server\r\n");
+ fputs($sock, "Proxy-Authorization: Basic " . base64_encode ("$server_username:$server_password") . "\r\n\r\n");
+ while(!feof($sock)) {$proxy_cont .= fread($sock,4096);}
+ fclose($sock);
+ $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);
+
+ if(substr_count($proxy_cont, "Cache Access Denied") > 0)
+ {
+ $error_str = 'error=Proxy Authentication Required';
+ $db_update = false;
+ }
+ else
+ {
+ $action = 'ProxyServerConfig';
+ }
+ }
+}
-if($id=='')
-{
- $id = $adb->getUniqueID("vtiger_systems");
- $sql="insert into vtiger_systems values(" .$id .",'".$server."','".$port."','".$server_username."','".$server_password."','".$server_type."','".$smtp_auth."')";
-}
-else
- $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;
-
-$adb->query($sql);
if($server_type == 'backup')
{
$conn_id = @ftp_connect($server);
@@ -42,11 +62,13 @@
if(!$conn_id)
{
$error_str = 'error=Unable connect to "'.$server.'"';
+ $db_update = false;
}else
{
if(!@ftp_login($conn_id, $server_username, $server_password))
{
$error_str = 'error=Couldn\'t connect to "'.$server.'" as user "'.$server_username.'"';
+ $db_update = false;
}
else
{
@@ -56,17 +78,17 @@
}
}
-if($server_type == 'proxy')
+if($db_update)
{
- $action = 'ProxyServerConfig&proxy_server_mode=edit';
- if (!$sock = fsockopen($server, $port, $errno, $errstr, 30))
+ if($id=='')
{
- $error_str = $errstr.' : '.$errno ;
- }else
- {
- $action = 'ProxyServerConfig';
- fclose($sock);
+ $id = $adb->getUniqueID("vtiger_systems");
+ $sql="insert into vtiger_systems values(" .$id .",'".$server."','".$port."','".$server_username."','".$server_password."','".$server_type."','".$smtp_auth."')";
}
+ else
+ $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;
+
+ $adb->query($sql);
}
//Added code to send a test mail to the currently logged in user
More information about the vtigercrm-commits
mailing list