// +---------------------------------------------------------------------- use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xls; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Color; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; // 应用公共文件 /** * 删除目录以及其下的文件 * @param $directory * @return bool */ function removeDir($directory) { if (false == is_dir($directory)) { return false; } $handle = opendir($directory); while (false !== ($file = readdir($handle))) { if ('.' != $file && '..' != $file) { is_dir("$directory/$file") ? removeDir("$directory/$file") : @unlink("$directory/$file"); } } if (readdir($handle) == false) { closedir($handle); rmdir($directory); } return true; } function Kfid($uid) { return trim($uid, 'KF'); } function kfUid($id) { return 'KF' . $id; } //数组转为健的数组 function kftoKey($uidArray, $type = 0) { $return = []; foreach ($uidArray as $val) { if ($type == 0) { $return[$val] = 0; } elseif ($type == 1) { $return[$val] = []; } else { $return[$val] = $val; } } return $return; } //保留小数位数 function floatPointDigit($data, $long = 2) { $long = intval($long); $for1 = "%." . $long . "f"; $for2 = "%." . ($long + 1) . "f"; return sprintf($for1, substr(sprintf($for2, $data), 0, -1)); } //秒格式化为 小时分秒 function secendToHourMinit($sec) { $array = ['h' => 0, 'm' => 0, 's' => 0]; $sec = intval($sec); $array['h'] = floor($sec / 3600); $array['m'] = floor(($sec - 3600 * $array['h']) / 60); $array['s'] = $sec - 3600 * $array['h'] - 60 * $array['m']; $return = ''; if ($array['h']) { $return .= $array['h'] . '小时'; } if ($array['m']) { $return .= $array['m'] . '分'; } if ($array['s']) { $return .= $array['s'] . '秒'; } return $return; } //小数转百分比显示 function perDisplay($dit, $xiaos = 2) { return floatPointDigit(floor(100 * $dit), $xiaos) . '%'; } /** * 数据加密 */ function lock_url($txt, $key) { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+"; $nh = rand(0, 64); $ch = $chars[$nh]; $mdKey = md5($key.$ch); $mdKey = substr($mdKey,$nh%8, $nh%8+7); $txt = base64_encode($txt); $tmp = ''; $i = 0; $j = 0; $k = 0; for ($i=0; $i 0) curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $result = curl_exec($ch); $errno = curl_errno($ch); curl_close($ch); return $result; } else { $context = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n" . 'Content-length: ' . strlen($params), 'content' => $params)); if ($timeout > 0) $context['http']['timeout'] = $timeout; $contextid = stream_context_create($context); $sock = @fopen($url, 'r', false, $contextid); if ($sock) { $result = ''; while (!feof($sock)) { $result .= fgets($sock, 8192); } fclose($sock); } else { return 'TimeOut'; } } return $result; }//end make_request()