|
@@ -74,10 +74,12 @@ function getTreeList($array, $id_field = "id", $pid_field = "pid", $value = "0")
|
|
|
* @return type
|
|
|
*/
|
|
|
function getExcelDatas($filepath, $sheetIndex = 0) {
|
|
|
- $reader_type = \PHPExcel_IOFactory::identify($filepath);
|
|
|
- $reader = \PHPExcel_IOFactory::createReader($reader_type);
|
|
|
- $phpexcel = $reader->load($filepath);
|
|
|
- $sheet = $phpexcel->getSheet($sheetIndex);
|
|
|
+ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filepath);
|
|
|
+ $sheet = $spreadsheet->getSheet($sheetIndex);
|
|
|
+ /* $reader_type = \PHPExcel_IOFactory::identify($filepath);
|
|
|
+ $reader = \PHPExcel_IOFactory::createReader($reader_type);
|
|
|
+ $phpexcel = $reader->load($filepath);
|
|
|
+ $sheet = $phpexcel->getSheet($sheetIndex); */
|
|
|
return $sheet->toArray();
|
|
|
}
|
|
|
|
|
@@ -345,16 +347,16 @@ function chkEnterpriseFull($ep) {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
-function generate_password( $length = 8 ) {
|
|
|
+
|
|
|
+function generate_password($length = 8) {
|
|
|
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*?';
|
|
|
$password = '';
|
|
|
- for ( $i = 0; $i < $length; $i++ )
|
|
|
- {
|
|
|
- // 这里提供两种字符获取方式
|
|
|
- // 第一种是使用 substr 截取$chars中的任意一位字符;
|
|
|
- // 第二种是取字符数组 $chars 的任意元素
|
|
|
- // $password .= substr($chars, mt_rand(0, strlen($chars) – 1), 1);
|
|
|
- $password .= $chars[ mt_rand(0, strlen($chars) - 1) ];
|
|
|
+ for ($i = 0; $i < $length; $i++) {
|
|
|
+ // 这里提供两种字符获取方式
|
|
|
+ // 第一种是使用 substr 截取$chars中的任意一位字符;
|
|
|
+ // 第二种是取字符数组 $chars 的任意元素
|
|
|
+ // $password .= substr($chars, mt_rand(0, strlen($chars) – 1), 1);
|
|
|
+ $password .= $chars[mt_rand(0, strlen($chars) - 1)];
|
|
|
}
|
|
|
return $password;
|
|
|
}
|
|
@@ -364,9 +366,7 @@ function generate_password( $length = 8 ) {
|
|
|
* @param $mobile
|
|
|
* @return int
|
|
|
*/
|
|
|
-
|
|
|
-function isCreditNo($vStr)
|
|
|
-{
|
|
|
+function isCreditNo($vStr) {
|
|
|
$vCity = array(
|
|
|
'11', '12', '13', '14', '15', '21', '22',
|
|
|
'23', '31', '32', '33', '34', '35', '36',
|
|
@@ -374,8 +374,10 @@ function isCreditNo($vStr)
|
|
|
'50', '51', '52', '53', '54', '61', '62',
|
|
|
'63', '64', '65', '71', '81', '82', '91'
|
|
|
);
|
|
|
- if (!preg_match('/^([\d]{17}[xX\d]|[\d]{15})$/', $vStr)) return false;
|
|
|
- if (!in_array(substr($vStr, 0, 2), $vCity)) return false;
|
|
|
+ if (!preg_match('/^([\d]{17}[xX\d]|[\d]{15})$/', $vStr))
|
|
|
+ return false;
|
|
|
+ if (!in_array(substr($vStr, 0, 2), $vCity))
|
|
|
+ return false;
|
|
|
$vStr = preg_replace('/[xX]$/i', 'a', $vStr);
|
|
|
$vLength = strlen($vStr);
|
|
|
if ($vLength == 18) {
|
|
@@ -383,14 +385,16 @@ function isCreditNo($vStr)
|
|
|
} else {
|
|
|
$vBirthday = '19' . substr($vStr, 6, 2) . '-' . substr($vStr, 8, 2) . '-' . substr($vStr, 10, 2);
|
|
|
}
|
|
|
- if (date('Y-m-d', strtotime($vBirthday)) != $vBirthday) return false;
|
|
|
+ if (date('Y-m-d', strtotime($vBirthday)) != $vBirthday)
|
|
|
+ return false;
|
|
|
if ($vLength == 18) {
|
|
|
$vSum = 0;
|
|
|
for ($i = 17; $i >= 0; $i--) {
|
|
|
$vSubStr = substr($vStr, 17 - $i, 1);
|
|
|
$vSum += (pow(2, $i) % 11) * (($vSubStr == 'a') ? 10 : intval($vSubStr, 11));
|
|
|
}
|
|
|
- if ($vSum % 11 != 1) return false;
|
|
|
+ if ($vSum % 11 != 1)
|
|
|
+ return false;
|
|
|
}
|
|
|
return true;
|
|
|
-}
|
|
|
+}
|