[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Settings/ -> add2db.php (source)

   1  <?php
   2  
   3  /*********************************************************************************
   4  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   5   * ("License"); You may not use this file except in compliance with the License
   6   * The Original Code is:  vtiger CRM Open Source
   7   * The Initial Developer of the Original Code is vtiger.
   8   * Portions created by vtiger are Copyright (C) vtiger.
   9   * All Rights Reserved.
  10  * 
  11   ********************************************************************************/
  12  
  13  require_once ('include/database/PearDatabase.php');
  14  require_once ('include/utils/utils.php');
  15  
  16  
  17      $uploaddir = $root_directory ."/test/logo/" ;// set this to wherever
  18      $saveflag="true";
  19      $nologo_specified="true";
  20      $error_flag ="";
  21      $nologo_specified="false";
  22      $binFile = $_FILES['binFile']['name'];
  23      $filename = basename($binFile);
  24      $filetype= $_FILES['binFile']['type'];
  25      $filesize = $_FILES['binFile']['size'];
  26      
  27      $filetype_array=explode("/",$filetype); 
  28  
  29      $file_type_val=strtolower($filetype_array[1]);
  30  
  31      if($filesize != 0)
  32      {
  33          if (($file_type_val == "jpeg" ) || ($file_type_val == "png") || ($file_type_val == "jpg" ) ||  ($file_type_val == "pjpeg" ) || ($file_type_val == "x-png") ) //Checking whether the file is an image or not
  34          {
  35              if(stristr($binFile, '.gif') != FALSE)
  36              {
  37                  $savelogo="false";
  38                  $error_flag ="1";
  39              }        
  40              else if($result!=false)
  41              {
  42                  $savelogo="true";
  43              }
  44          }
  45          else
  46          {
  47              $savelogo="false";
  48              $error_flag ="1";
  49          }
  50          
  51      }
  52      else
  53      {
  54          $savelogo="false";
  55          if($filename != "") 
  56              $error_flag ="2";
  57      }
  58          
  59      $errorCode =  $_FILES['binFile']['error'];
  60      if($errorCode == 4)
  61      {
  62            $savelogo="false";            
  63          $errorcode="";
  64          $error_flag="5";
  65          $nologo_specified="true";
  66      }
  67      else if($errorCode == 2)
  68      {
  69             $error_flag ="3";
  70             $savelogo="false";            
  71          $nologo_specified="false";
  72      }
  73      else if($errorCode == 3 )
  74      {
  75          $error_flag ="4";
  76            $savelogo="false";
  77          $nologo_specified="false";
  78      }
  79      if($savelogo=="true")
  80      {    
  81          move_uploaded_file($_FILES["binFile"]["tmp_name"],$uploaddir.$_FILES["binFile"]["name"]); 
  82      }    
  83  
  84      if($saveflag=="true")
  85      {
  86          $organization_name=$_REQUEST['organization_name'];
  87          $org_name=$_REQUEST['org_name'];
  88          $organization_address=$_REQUEST['organization_address'];
  89          $organization_city=$_REQUEST['organization_city'];
  90          $organization_state=$_REQUEST['organization_state'];
  91          $organization_code=$_REQUEST['organization_code'];
  92          $organization_country=$_REQUEST['organization_country'];
  93          $organization_phone=$_REQUEST['organization_phone'];
  94          $organization_fax=$_REQUEST['organization_fax'];
  95          $organization_website=$_REQUEST['organization_website'];
  96          $organization_logo=$_REQUEST['organization_logo'];
  97  
  98          $organization_logoname=$filename;
  99          if(!isset($organization_logoname))
 100              $organization_logoname="";
 101  
 102          $sql="SELECT * FROM vtiger_organizationdetails WHERE organizationname = ".$adb->quote($org_name);
 103          $result = $adb->query($sql);
 104          $org_name = from_html($adb->query_result($result,0,'organizationname'));
 105          $org_logo = $adb->query_result($result,0,'logoname'); 
 106  
 107  
 108          if($org_name=='')
 109          {
 110              $sql="INSERT INTO vtiger_organizationdetails
 111                  (organizationname, address, city, state, code, country, phone, fax, website, logoname)
 112                  VALUES (".$adb->quote($organization_name).
 113                      ",".$adb->quote($organization_address).
 114                      ",".$adb->quote($organization_city).
 115                      ",".$adb->quote($organization_state).
 116                      ",".$adb->quote($organization_code).
 117                      ",".$adb->quote($organization_country).
 118                      ",".$adb->quote($organization_phone).
 119                      ",".$adb->quote($organization_fax).
 120                      ",".$adb->quote($organization_website).
 121                      ",".$adb->quote($organization_logoname).
 122                  ")";
 123          }
 124          else
 125          {
 126              if($savelogo=="true")
 127              {
 128                  $organization_logoname=$filename;
 129              }
 130              elseif($savelogo=="false" && $error_flag=="")
 131              {
 132                  $savelogo="true";
 133                  $organization_logoname=$_REQUEST['PREV_FILE'];
 134              }
 135              else
 136              {
 137                  $organization_logoname=$_REQUEST['PREV_FILE'];
 138              }    
 139              if($nologo_specified=="true")
 140              {
 141                  $savelogo="true";
 142                  $organization_logoname=$org_logo;
 143              }
 144  
 145              $sql = "UPDATE vtiger_organizationdetails
 146                  SET organizationname = ".$adb->quote($organization_name).",
 147                      address = ".$adb->quote($organization_address).",
 148                      city = ".$adb->quote($organization_city).",
 149                      state = ".$adb->quote($organization_state).",
 150                      code = ".$adb->quote($organization_code).",
 151                      country = ".$adb->quote($organization_country)." ,
 152                      phone = ".$adb->quote($organization_phone)." ,
 153                      fax = ".$adb->quote($organization_fax).",
 154                      website = ".$adb->quote($organization_website).",
 155                      logoname = ".$adb->quote($organization_logoname)."
 156                  WHERE organizationname = ".$adb->quote($org_name);
 157          }
 158          $adb->query($sql);
 159  
 160          if($savelogo=="true")
 161          {
 162              header("Location: index.php?parenttab=Settings&module=Settings&action=OrganizationConfig");
 163          }
 164          elseif($savelogo=="false")
 165          {
 166          
 167              header("Location: index.php?parenttab=Settings&module=Settings&action=EditCompanyDetails&flag=".$error_flag);
 168          }
 169      
 170  
 171      }    
 172  ?>
 173  


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