[Vtigercrm-commits] [vtiger-commits] r7541 - in /vtigercrm/trunk/modules/Users: add2db.php upload.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Jun 26 10:32:52 EDT 2006


Author: saraj
Date: Mon Jun 26 08:32:48 2006
New Revision: 7541

Log:
put a check to upload only doc file in the mail merge file  - ahmed

Modified:
    vtigercrm/trunk/modules/Users/add2db.php
    vtigercrm/trunk/modules/Users/upload.php

Modified: vtigercrm/trunk/modules/Users/add2db.php
==============================================================================
--- vtigercrm/trunk/modules/Users/add2db.php (original)
+++ vtigercrm/trunk/modules/Users/add2db.php Mon Jun 26 08:32:48 2006
@@ -33,13 +33,31 @@
   $binFile = $_FILES['binFile']['name'];
   $filename = basename($binFile);
   $filetype= $_FILES['binFile']['type'];
+  $filesize = $_FILES['binFile']['size'];
 
-    $filesize = $_FILES['binFile']['size'];
+  $error_flag ="";
+  $filetype_array = explode("/",$filetype);
+
+  $file_type_value = strtolower($filetype_array[1]);
+  
     if($filesize != 0)	
     {
-		$data = base64_encode(fread(fopen($uploaddir.$binFile, "r"), $filesize));
+	    if($file_type_value == "msword" || $file_type_value == "doc" || $file_type_value == "document")
+	    {
+		    if($result!=false)
+	    	    {
+			 $savefile="true";	
+		    }			 
+	    }
+	    else
+	    {
+		    $savefile="false";
+		    $error_flag="1";
+	    }		    
+	    
+ 		$data = base64_encode(fread(fopen($uploaddir.$binFile, "r"), $filesize));
 		//$data = addslashes(fread(fopen($uploaddir.$binFile, "r"), $filesize));
-	   $textDesc = $_REQUEST['txtDescription'];	
+	        $textDesc = $_REQUEST['txtDescription'];	
 		$strDescription = addslashes($textDesc);
 	//    $fileid = create_guid();
 		$date_entered = date('YmdHis');
@@ -66,6 +84,8 @@
 		$genQueryId = $adb->getUniqueID("wordtemplates");
 		if($genQueryId != '')
 		{
+			if($result!=false && $savefile=="true")
+			{
 			$module = $_REQUEST['target_module'];
 			$sql = "INSERT INTO vtiger_wordtemplates ";
 			$sql .= "(templateid,module,date_entered,parent_type,data,description,filename,filesize,filetype) ";
@@ -73,12 +93,15 @@
 			$sql .= "'$filename', '$filesize', '$filetype')";
 
 			$result = $adb->query($sql);
-			if($result!=false)
-			{
 			   $result = $adb->updateBlob('vtiger_wordtemplates','data'," filename='".$filename."'",$data);
 			   deleteFile($uploaddir,$filename);
-			   header("Location: index.php?action=listwordtemplates&module=Users&parenttab=Settings");	
+			   	header("Location: index.php?action=listwordtemplates&module=Users&parenttab=Settings");	
 			}
+		   	   elseif($savefile=="false")
+	                   {
+			   	header("Location: index.php?action=upload&module=Users&parenttab=Settings&flag=".$error_flag);	
+				   
+			   }  			   
 			else
 			{
 				include('themes/'.$theme.'/header.php');

Modified: vtigercrm/trunk/modules/Users/upload.php
==============================================================================
--- vtigercrm/trunk/modules/Users/upload.php (original)
+++ vtigercrm/trunk/modules/Users/upload.php Mon Jun 26 08:32:48 2006
@@ -25,7 +25,19 @@
 require_once($theme_path.'layout_utils.php');
 
 $smarty = new vtigerCRM_Smarty;
-
+//error handling
+if(isset($_REQUEST['flag']) && $_REQUEST['flag'] != '')
+{
+	$flag = $_REQUEST['flag'];
+	switch($flag)
+	{
+		case 1:
+			$smarty->assign("ERRORFLAG","<font color='red'><B>File has to be a Document of type doc/msword</B></font>");
+			break;
+		default:
+			$smarty->assign("ERRORFLAG","");
+	}		
+}
 
 $smarty->assign("MOD", return_module_language($current_language,'Settings'));
 $smarty->assign("IMAGE_PATH",$image_path);





More information about the vtigercrm-commits mailing list