Преглед изворни кода

username过滤特殊字符

shenzhipeng пре 2 година
родитељ
комит
0d0e2b2c89

+ 1 - 1
application/module/ctrl/Customer_list_adminAction.class.php

@@ -307,7 +307,7 @@ class Customer_list_adminAction extends Action{
 				foreach($excel_array as $array){
 
 					if(!empty($array[1])){
-						$data['uname'] = str_replace("'", '', $array[0]);
+						$data['uname'] = preg_replace("/[^a-zA-Z\s]+/", "", $array[0]);
 						$data['email'] = $email_tmp	 = trim($array[1]);
 						$data['tel'] 		 = trim($array[2]);
 						$data['country'] 	= trim($array[3]);

+ 1 - 1
application/module/ctrl/Delete_list_adminAction.class.php

@@ -141,7 +141,7 @@ class Delete_list_adminAction extends Action{
 		//echo $result;
 		if($result) //如果上传文件成功,就执行导入excel操作
 		{
-			$objReader = PHPExcel_IOFactory::createReader('CSV');//use excel2007 for 2007 format
+			$objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
 			$objPHPExcel = $objReader->load($uploadfile);
 			$sheet = $objPHPExcel->getSheet(0);
 			$highestRow = $sheet->getHighestRow();           //取得总行数

+ 13 - 5
application/module/ctrl/Sms_customer_list_adminAction.class.php

@@ -204,7 +204,7 @@ class Sms_customer_list_adminAction extends Action{
         $admin = new AdvertAdminAction();
         if($_POST['tel']){
             $info = '添加失败';
-            $uname = $_POST['username'];
+            $uname = trim($_POST['username']);
             $tel = trim($_POST['tel']);
             $country = trim($_POST['country']);
             $group_name ='黑名单';
@@ -339,7 +339,7 @@ class Sms_customer_list_adminAction extends Action{
 				$values = '';
 				foreach($excel_array as $array){
 					if(!empty($array[2])){
-						$uname = str_replace("’", '', $array[0]);
+						$uname = preg_replace("/[^a-zA-Z\s]+/", "", $array[0]);
 						$tel = trim($array[1]);
 						$country = trim($array[2]);
 						$groupName = trim($array[3]);
@@ -362,7 +362,11 @@ class Sms_customer_list_adminAction extends Action{
 				if($values) {
 					$values = trim($values, ",");
 					$insert = $admin->import_sms_customer($values);
-					$info = '导入数据成功';
+					if ($insert == false) {
+						$info = '导入数据失败';
+					} else {
+						$info = '导入数据成功';
+					}
 				}
 			}
 
@@ -396,7 +400,7 @@ class Sms_customer_list_adminAction extends Action{
 				$values = '';
 				foreach($excel_array as $array){
 					if(!empty($array[1])){
-						$uname = str_replace("'", '', $array[0]);
+						$uname = preg_replace("/[^a-zA-Z\s]+/", "", $array[0]);
 						$tel = trim($array[1]);
 						$country = trim($array[2]);
 						$groupName = trim($array[3]);
@@ -415,7 +419,11 @@ class Sms_customer_list_adminAction extends Action{
 					$result = $admin->deleteSmsCustomerByTel($telsStr);
 					$values = trim($values, ",");
 					$insert = $admin->import_sms_customer($values);
-					$info = '导入数据成功';
+					if ($insert == false) {
+						$info = '导入数据失败';
+					} else {
+						$info = '导入数据成功';
+					}
 				}
 				
 			}

+ 1 - 1
application/module/view/delete_list_admin/index.html

@@ -16,7 +16,7 @@
 			<div id='main' class="form-actions">
 				<form method="post" id="batch_user_group" action="/?a=Delete_list_admin&m=importDelete" enctype="multipart/form-data"  >
 					<input type="hidden"  name="to_import_user" value="yes" />
-					<input type="file" name="inputExcel" style="width:175px;"><span style="color:red;">(excel是.csv格式的)</span>
+					<input type="file" name="inputExcel" style="width:175px;"><span style="color:red;">(excel是.xls格式的)</span>
 					<input type="submit" class="btn btn-success" value="导入并删除用户"   style="cursor:pointer;height: 32px; width: 140px;margin-left:10px;margin-top:20px;" />
 				</form>
 			</div>

+ 1 - 1
application/module/view/sms_customer_list_admin/remove.html

@@ -16,7 +16,7 @@
 			<div id='main' class="form-actions">
 				<form method="post" id="batch_user_group" action="/?a=sms_customer_list_admin&m=deleteByExcel" enctype="multipart/form-data"  >
 					<input type="hidden"  name="to_import_user" value="yes" />
-					<input type="file" name="inputExcel" style="width:175px;"><span style="color:red;">(excel是.csv格式的)</span>
+					<input type="file" name="inputExcel" style="width:175px;"><span style="color:red;">(excel是.xls格式的)</span>
 					<input type="submit" class="btn btn-success" value="导入并删除用户"   style="cursor:pointer;height: 32px; width: 140px;margin-left:10px;margin-top:20px;" />
 				</form>
 			</div>