<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 函數參考 * * * * * ### 應用公共函數文件 ~~~ <?php // +---------------------------------------------------------------------+ // | OneBase | [ WE CAN DO IT JUST THINK ] | // +---------------------------------------------------------------------+ // | Licensed | http://www.apache.org/licenses/LICENSE-2.0 ) | // +---------------------------------------------------------------------+ // | Author | Bigotry <3162875@qq.com> | // +---------------------------------------------------------------------+ // | Repository | https://gitee.com/Bigotry/OneBase | // +---------------------------------------------------------------------+ /** * 應用公共(函數)文件 */ use think\Db; use think\Response; use think\exception\HttpResponseException; // +---------------------------------------------------------------------+ // | 系統相關函數 // +---------------------------------------------------------------------+ /** * 檢測用戶是否登錄 * @return integer 0-未登錄,大于0-當前登錄用戶ID */ function is_login() { $member = session('member_auth'); if (empty($member)) { return DATA_DISABLE; } else { return session('member_auth_sign') == data_auth_sign($member) ? $member['member_id'] : DATA_DISABLE; } } /** * 系統非常規MD5加密方法 * @param string $str 要加密的字符串 * @return string */ function data_md5($str, $key = 'OneBase') { return '' === $str ? '' : md5(sha1($str) . $key); } /** * 使用上面的函數與系統加密KEY完成字符串加密 * @param string $str 要加密的字符串 * @return string */ function data_md5_key($str, $key = '') { return empty($key) ? data_md5($str, SYS_ENCRYPT_KEY) : data_md5($str, $key); } /** * 數據簽名認證 * @param array $data 被認證的數據 * @return string 簽名 */ function data_auth_sign($data) { // 數據類型檢測 if (!is_array($data)) : $data = (array)$data; endif; // 排序 ksort($data); // url編碼并生成query字符串 $code = http_build_query($data); // 生成簽名 $sign = sha1($code); return $sign; } /** * 檢測當前用戶是否為管理員 * @return boolean true-管理員,false-非管理員 */ function is_administrator($member_id = null) { $return_id = is_null($member_id) ? is_login() : $member_id; return $return_id && (intval($return_id) === SYS_ADMINISTRATOR_ID); } /** * 獲取單例對象 */ function get_sington_object($object_name = '', $class = null) { $request = request(); $request->__isset($object_name) ?: $request->bind($object_name, new $class()); return $request->__get($object_name); } /** * 獲取插件類的類名 * @param strng $name 插件名 */ function get_addon_class($name = '') { $lower_name = strtolower($name); $class = SYS_ADDON_DIR_NAME. SYS_DS_CONS . $lower_name . SYS_DS_CONS . $name; return $class; } /** * 鉤子 */ function hook($tag = '', $params = []) { \think\Hook::listen($tag, $params); } /** * 插件顯示內容里生成訪問插件的url * @param string $url url * @param array $param 參數 */ function addons_url($url, $param = array()) { $parse_url = parse_url($url); $addons = $parse_url['scheme']; $controller = $parse_url['host']; $action = $parse_url['path']; /* 基礎參數 */ $params_array = array( 'addon_name' => $addons, 'controller_name' => $controller, 'action_name' => substr($action, 1), ); $params = array_merge($params_array, $param); //添加額外參數 return url('addon/execute', $params); } /** * 插件對象注入 */ function addon_ioc($this_class, $name, $layer) { !str_prefix($name, $layer) && exception('邏輯與模型層引用需前綴:' . $layer); $class_arr = explode(SYS_DS_CONS, get_class($this_class)); $sr_name = sr($name, $layer); $class_logic = SYS_ADDON_DIR_NAME . SYS_DS_CONS . $class_arr[DATA_NORMAL] . SYS_DS_CONS . $layer . SYS_DS_CONS . $sr_name; return get_sington_object(SYS_ADDON_DIR_NAME . '_' . $layer . '_' . $sr_name, $class_logic); } /** * 獲得瀏覽器 */ function browser_info() { if (!empty($_SERVER['HTTP_USER_AGENT'])) { $br = $_SERVER['HTTP_USER_AGENT']; if (preg_match('/MSIE/i', $br)) { $br = 'MSIE'; } else if (preg_match('/Firefox/i', $br)) { $br = 'Firefox'; } else if (preg_match('/Chrome/i', $br)) { $br = 'Chrome'; } else if (preg_match('/Safari/i', $br)) { $br = 'Safari'; } else if (preg_match('/Opera/i', $br)) { $br = 'Opera'; } else { $br = 'Other'; } return $br; } else { return 'unknow'; } } /** * 拋出響應異常 */ function throw_response_exception($data = [], $type = 'json') { $response = Response::create($data, $type); throw new HttpResponseException($response); } /** * 寫入執行信息記錄 */ function write_exe_log($begin = 'app_begin', $end = 'app_end', $type = 0) { if(empty(config('is_write_exe_log'))) : return false; endif; $source_url = empty($_SERVER["HTTP_REFERER"]) ? '未知來源' : $_SERVER["HTTP_REFERER"]; $exe_log['ip'] = request()->ip(); $exe_log['exe_url'] = request()->url(); $exe_log['exe_time'] = debug($begin, $end); $exe_log['exe_memory'] = debug($begin, $end, 'm'); $exe_log['exe_os'] = get_os(); $exe_log['source_url'] = $source_url; $exe_log['session_id'] = session_id(); $exe_log['browser'] = browser_info(); $exe_log['status'] = DATA_NORMAL; $exe_log['create_time'] = TIME_NOW; $exe_log['update_time'] = TIME_NOW; $exe_log['type'] = $type; $exe_log['login_id'] = is_login(); $exe_log_path = "../log/exe_log.php"; file_exists($exe_log_path) && $now_contents = file_get_contents($exe_log_path); $arr = var_export($exe_log, true); empty($now_contents) ? $contents = "<?php\nreturn array (".$arr.");\n" : $contents = str_replace(');', ','. $arr . ');', $now_contents); file_put_contents($exe_log_path, $contents); } /** * 獲得操作系統 */ function get_os() { if (!empty($_SERVER['HTTP_USER_AGENT'])) { $os = $_SERVER['HTTP_USER_AGENT']; if (preg_match('/win/i', $os)) { $os = 'Windows'; } else if (preg_match('/mac/i', $os)) { $os = 'MAC'; } else if (preg_match('/linux/i', $os)) { $os = 'Linux'; } else if (preg_match('/unix/i', $os)) { $os = 'Unix'; } else if (preg_match('/bsd/i', $os)) { $os = 'BSD'; } else { $os = 'Other'; } return $os; } else { return 'unknow'; } } /** * 獲取訪問token */ function get_access_token() { return md5('OneBase' . date("Ymd") . API_KEY); } /** * 格式化字節大小 * @param number $size 字節數 * @param string $delimiter 數字和單位分隔符 * @return string 格式化后的帶單位的大小 */ function format_bytes($size, $delimiter = '') { $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); for ($i = 0; $size >= 1024 && $i < 5; $i++) : $size /= 1024; endfor; return round($size, 2) . $delimiter . $units[$i]; } // +---------------------------------------------------------------------+ // | 數組相關函數 // +---------------------------------------------------------------------+ /** * 把返回的數據集轉換成Tree * @param array $list 要轉換的數據集 * @param string $pid parent標記字段 * @param string $level level標記字段 * @return array */ function list_to_tree($list, $pk='id', $pid = 'pid', $child = '_child', $root = 0) { // 創建Tree $tree = []; if (!is_array($list)): return false; endif; // 創建基于主鍵的數組引用 $refer = []; foreach ($list as $key => $data) { $refer[$data[$pk]] =& $list[$key]; } foreach ($list as $key => $data) { // 判斷是否存在parent $parentId = $data[$pid]; if ($root == $parentId) { $tree[] =& $list[$key]; } else if(isset($refer[$parentId])){ is_object($refer[$parentId]) && $refer[$parentId] = $refer[$parentId]->toArray(); $parent =& $refer[$parentId]; $parent[$child][] =& $list[$key]; } } return $tree; } /** * 分析數組及枚舉類型配置值 格式 a:名稱1,b:名稱2 * @return array */ function parse_config_attr($string) { $array = preg_split('/[,;\r\n]+/', trim($string, ",;\r\n")); if (strpos($string, ':')) { $value = []; foreach ($array as $val) { list($k, $v) = explode(':', $val); $value[$k] = $v; } } else { $value = $array; } return $value; } /** * 解析數組配置 */ function parse_config_array($name = '') { return parse_config_attr(config($name)); } /** * 將二維數組數組按某個鍵提取出來組成新的索引數組 */ function array_extract($array = [], $key = 'id') { $count = count($array); $new_arr = []; for($i = 0; $i < $count; $i++) { if (!empty($array) && !empty($array[$i][$key])) { $new_arr[] = $array[$i][$key]; } } return $new_arr; } /** * 根據某個字段獲取關聯數組 */ function array_extract_map($array = [], $key = 'id'){ $count = count($array); $new_arr = []; for($i = 0; $i < $count; $i++) { $new_arr[$array[$i][$key]] = $array[$i]; } return $new_arr; } /** * 頁面數組提交后格式轉換 */ function transform_array($array) { $new_array = array(); $key_array = array(); foreach ($array as $key=>$val) { $key_array[] = $key; } $key_count = count($key_array); foreach ($array[$key_array[0]] as $i => $val) { $temp_array = array(); for( $j=0;$j<$key_count;$j++ ){ $key = $key_array[$j]; $temp_array[$key] = $array[$key][$i]; } $new_array[] = $temp_array; } return $new_array; } /** * 頁面數組轉換后的數組轉json */ function transform_array_to_json($array) { return json_encode(transform_array($array)); } /** * 關聯數組轉索引數組 */ function relevance_arr_to_index_arr($array) { $new_array = []; foreach ($array as $v) { $temp_array = []; foreach ($v as $vv) { $temp_array[] = $vv; } $new_array[] = $temp_array; } return $new_array; } /** * 數組轉換為字符串,主要用于把分隔符調整到第二個參數 * @param array $arr 要連接的數組 * @param string $glue 分割符 * @return string */ function arr2str($arr, $glue = ',') { return implode($glue, $arr); } // +---------------------------------------------------------------------+ // | 字符串相關函數 // +---------------------------------------------------------------------+ /** * 字符串轉換為數組,主要用于把分隔符調整到第二個參數 * @param string $str 要分割的字符串 * @param string $glue 分割符 * @return array */ function str2arr($str, $glue = ',') { return explode($glue, $str); } /** * 字符串替換 */ function sr($str = '', $target = '', $content = '') { return str_replace($target, $content, $str); } /** * 字符串前綴驗證 */ function str_prefix($str, $prefix) { return strpos($str, $prefix) === DATA_DISABLE ? true : false; } // +---------------------------------------------------------------------+ // | 文件相關函數 // +---------------------------------------------------------------------+ /** * 獲取目錄下所有文件 */ function file_list($path = '') { $file = scandir($path); foreach ($file as $k => $v) { if (is_dir($path . SYS_DS_PROS . $v)) : unset($file[$k]); endif; } return array_values($file); } /** * 將數據保存為PHP文件,用于調試,默認將調試數據輸出到log目錄下 */ function sf($arr = [], $fpath = 'debug') { $data = "<?php\nreturn ".var_export($arr, true).";\n?>"; $obj = get_sington_object('obIdWork', \ob\IdWork::class); file_put_contents('../log/' . $fpath . '_' . $obj->nextId() . EXT, $data); } /** * 獲取目錄列表 */ function get_dir($dir_name) { $dir_array = []; if (false != ($handle = opendir($dir_name))) { $i = 0; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".."&&!strpos($file,".")) { $dir_array[$i] = $file; $i++; } } closedir($handle); } return $dir_array; } /** * 獲取圖片url */ function get_picture_url($id = 0) { return action(SYS_COMMON_DIR_NAME . SYS_DS_PROS . 'FileBase' . SYS_DS_PROS . 'getPictureUrl', ['id' => $id]); } /** * 獲取文件url */ function get_file_url($id = 0) { return action(SYS_COMMON_DIR_NAME . SYS_DS_PROS . 'FileBase' . SYS_DS_PROS . 'getFileUrl', ['id' => $id]); } /** * 刪除所有空目錄 * @param String $path 目錄路徑 */ function rm_empty_dir($path) { if (!(is_dir($path) && ($handle = opendir($path))!==false)) : return false; endif; while(($file = readdir($handle))!==false) { if(!($file != '.' && $file != '..')) : continue; endif; $curfile = $path . SYS_DS_PROS . $file;// 當前目錄 if(!is_dir($curfile)) : continue; endif; rm_empty_dir($curfile); if(count(scandir($curfile)) == 2) : rmdir($curfile); endif; } closedir($handle); } // +---------------------------------------------------------------------+ // | 時間相關函數 // +---------------------------------------------------------------------+ /** * 時間戳格式化 * @param int $time * @return string 完整的時間顯示 */ function format_time($time = null, $format='Y-m-d H:i:s') { if (null === $time) : $time = TIME_NOW; endif; return date($format, intval($time)); } /** * 獲取指定日期段內每一天的日期 * @param Date $startdate 開始日期 * @param Date $enddate 結束日期 * @return Array */ function get_date_from_range($startdate, $enddate) { $stimestamp = strtotime($startdate); $etimestamp = strtotime($enddate); // 計算日期段內有多少天 $days = ($etimestamp-$stimestamp)/86400+1; // 保存每天日期 $date = []; for($i=0; $i<$days; $i++) : $date[] = date('Y-m-d', $stimestamp+(86400*$i)); endfor; return $date; } // +---------------------------------------------------------------------+ // | 其他函數 // +---------------------------------------------------------------------+ /** * 通過類創建邏輯閉包 */ function create_closure($class = null, $method_name = '', $parameter = []) { $func = function() use($class, $method_name, $parameter) { $object = get_sington_object($class, $class); return call_user_func_array([$object, $method_name], $parameter); }; return $func; } /** * 通過閉包列表控制事務 */ function closure_list_exe($list = []) { Db::startTrans(); try { foreach ($list as $closure) : $closure(); endforeach; Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); throw $e; } } /** * 獲取頁面范圍 */ function get_page_number_scope($current_page = 0, $last_page = 0, $offset = 3, $page_number = 7) { $init = DATA_SUCCESS; $max = $last_page; if($last_page > $page_number) { if($current_page <= $offset){ $max = $page_number; }else if($current_page + $offset >= $last_page){ $init = $last_page - $page_number + $init; $max = $last_page; } else { $init = $current_page - $offset; $max = $current_page + $offset; } } return ['init' => $init, 'max' => $max]; } /** * 獲取分頁HTML */ function get_page_html($current_page = 0, $last_page = 0, $offset = 3, $page_number = 7) { $data = get_page_number_scope($current_page, $last_page, $offset, $page_number); $spans = ''; for($i = $data['init']; $i <= $data['max']; $i++) : $spans .= $i == $current_page ? "<span class='current'>".$i."</span>" : "<a href='?page=$i'><span>$i</span></a>"; endfor; $next = ''; $current_page_next = $current_page + DATA_SUCCESS; if ($current_page < $last_page) : $next = "<a class='next' href='?page=$current_page_next'>下一頁</a>"; endif; $prev = ''; $current_page_prev = $current_page - DATA_SUCCESS; if ($current_page > DATA_SUCCESS) : $prev = "<a class='prev' href='?page=$current_page_prev'>上一頁</a>"; endif; $tmpl = "<div class='onebase pagination pagination-right pagination-large'> <div> $prev $spans $next </div> </div>"; return $tmpl; } ~~~ * * * * * ### 應用公共擴展函數文件 ~~~ <?php // +---------------------------------------------------------------------+ // | OneBase | [ WE CAN DO IT JUST THINK ] | // +---------------------------------------------------------------------+ // | Licensed | http://www.apache.org/licenses/LICENSE-2.0 ) | // +---------------------------------------------------------------------+ // | Author | Bigotry <3162875@qq.com> | // +---------------------------------------------------------------------+ // | Repository | https://gitee.com/Bigotry/OneBase | // +---------------------------------------------------------------------+ /** * 應用公共擴展(函數)文件 */ /** * 導出excel信息 * @param string $titles 導出的表格標題 * @param string $keys 需要導出的鍵名 * @param array $data 需要導出的數據 * @param string $file_name 導出的文件名稱 */ function export_excel($titles = '', $keys = '', $data = [], $file_name = '導出文件' ) { $objPHPExcel = get_excel_obj($file_name); $y = 1; $s = 0; $titles_arr = str2arr($titles); foreach ($titles_arr as $k => $v) : $objPHPExcel->setActiveSheetIndex($s)->setCellValue(string_from_column_index($k). $y, $v); endforeach; $keys_arr = str2arr($keys); foreach ($data as $k => $v) { is_object($v) && $v = $v->toArray(); foreach ($v as $kk => $vv) { $num = array_search($kk, $keys_arr); false !== $num && $objPHPExcel->setActiveSheetIndex($s)->setCellValue(string_from_column_index($num) . ($y + $k + 1), $vv ); } } $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); exit; } /** * 獲取excel */ function get_excel_obj($file_name = '導出文件') { set_time_limit(0); vendor('phpoffice/phpexcel/Classes/PHPExcel'); header("Pragma: public"); header("Expires: 0"); header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header("Content-Type:application/force-download"); header("Content-Type:application/vnd.ms-execl"); header("Content-Type:application/octet-stream"); header("Content-Type:application/download"); header('Content-Disposition:attachment;filename='.iconv("utf-8", "gb2312", $file_name).'.xlsx'); header("Content-Transfer-Encoding:binary"); return new PHPExcel(); } /** * 讀取excel返回數據 */ function get_excel_data($file_url = '', $start_row = 1, $start_col = 0) { vendor('phpoffice/phpexcel/Classes/PHPExcel'); $objPHPExcel = PHPExcel_IOFactory::load($file_url); $objWorksheet = $objPHPExcel->getActiveSheet(); $highestRow = $objWorksheet->getHighestRow(); $highestColumn = $objWorksheet->getHighestColumn(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $excel_data = []; for ($row = $start_row; $row <= $highestRow; $row++) { for ($col = $start_col; $col < $highestColumnIndex; $col++) { $excel_data[$row][] =(string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); } } return $excel_data; } /** * 數字轉字母 */ function string_from_column_index($pColumnIndex = 0) { static $_indexCache = []; if(!isset($_indexCache[$pColumnIndex])) { if($pColumnIndex < 26){ $_indexCache[$pColumnIndex] = chr(65 + $pColumnIndex); }elseif($pColumnIndex < 702){ $_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)).chr(65 + $pColumnIndex % 26); }else{ $_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676 )).chr(65 + ((($pColumnIndex - 26) % 676) / 26 )). chr( 65 + $pColumnIndex % 26); } } return $_indexCache[$pColumnIndex]; } /** * 發送郵件 */ function send_email($address, $title, $message) { $mail = new \ob\PHPMailer(); $mail->isSMTP(); $mail->Host="smtp.exmail.qq.com"; $mail->SMTPAuth = true; $mail->Username=""; $mail->Password=""; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->CharSet='UTF-8'; $mail->setFrom('', ''); $mail->addAddress($address); $mail->isHTML(true); $mail->Subject = $title; $mail->Body = $message; $mail->AltBody = 'OneBase'; if (!$mail->send()) : return $mail->ErrorInfo; endif; return true; } /** * 生成條形碼 * @param string $text 寫入內容 * @param string $file_name 文件名稱 * @param string $path 條形碼保存路徑 * @param string $codebar 條形碼類型 * 'BCGcodabar','BCGcode11','BCGcode39','BCGcode39extended','BCGcode93', * 'BCGcode128','BCGean8','BCGean13','BCGisbn','BCGi25','BCGs25','BCGmsi', * 'BCGupca','BCGupce','BCGupcext2','BCGupcext5','BCGpostnet','BCGothercode' */ function create_barcode($text = '', $file_name = '', $path = '', $codebar = 'BCGcode39') { $class_path = EXTEND_PATH . 'barcode' . DS . 'class' . DS; include_once $class_path . 'BCGFont.php'; include_once $class_path . 'BCGColor.php'; include_once $class_path . 'BCGDrawing.php'; include_once $class_path . $codebar . '.barcode.php'; // The arguments are R, G, B for color. $color_black = new BCGColor(0, 0, 0); $color_white = new BCGColor(255, 255, 255); $code = new $codebar(); $code->setScale(2); // Resolution $code->setThickness(25); // Thickness $code->setForegroundColor($color_black); // Color of bars $code->setBackgroundColor($color_white); // Color of spaces $code->setFont(new BCGFont($class_path . 'font/Arial.ttf', 10)); // Font (or 0) $code->parse($text); /* * Here is the list of the arguments * 1 - Filename (empty : display on screen) * 2 - Background color */ // $drawing = new BCGDrawing($_REQUEST['file_name'], $color_white); $save_path = empty($path) ? PATH_UPLOAD . 'extend' . DS . 'barcode' . DS : $path; $drawing = new BCGDrawing($save_path . $file_name . '.png', $color_white); $drawing->setBarcode($code); $drawing->draw(); // Header that says it is an image (remove it if you save the barcode to a file) // header('Content-Type: image/png'); // Draw (or save) the image into PNG format. $drawing->finish(BCGDrawing::IMG_FORMAT_PNG); return ['name' => $file_name . '.png', 'path' => $save_path . $file_name . '.png']; } /** * 生成二維碼 * @param string $data 寫入數據 * @param string $path 二維碼保存路徑 * @param string $ecc 錯誤修正水平 'L','M','Q','H' * @param int $size 二維碼大小 1 - 10 */ function create_qrcode($data = '', $path = '', $ecc = 'H', $size = 10) { $save_path = empty($path) ? PATH_UPLOAD . 'extend' . DS . 'qrcode' . DS : $path; include_once EXTEND_PATH . 'qrcode' . DS . 'qrlib.php'; if (!file_exists($save_path)) : mkdir($save_path); endif; $filename = $save_path.'.png'; $errorCorrectionLevel = 'L'; if (isset($ecc) && in_array($ecc, array('L','M','Q','H'))) : $errorCorrectionLevel = $ecc; endif; $matrixPointSize = 4; if (isset($size)) : $matrixPointSize = min(max((int)$size, 1), 10); endif; if (isset($data)) { if (trim($data) == '') : exception("qrcode data cannot be empty"); endif; $filename = $save_path.md5($data.'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png'; QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); }else{ QRcode::png('PHP QR Code :)', $filename, $errorCorrectionLevel, $matrixPointSize, 2); } $name = basename($filename); $return_data['name'] = $name; $return_data['path'] = $save_path . $name; return $return_data; } ~~~ * * * * * ### admin模塊函數文件 ~~~ <?php // +---------------------------------------------------------------------+ // | OneBase | [ WE CAN DO IT JUST THINK ] | // +---------------------------------------------------------------------+ // | Licensed | http://www.apache.org/licenses/LICENSE-2.0 ) | // +---------------------------------------------------------------------+ // | Author | Bigotry <3162875@qq.com> | // +---------------------------------------------------------------------+ // | Repository | https://gitee.com/Bigotry/OneBase | // +---------------------------------------------------------------------+ use app\admin\logic\Log as LogicLog; /** * 記錄行為日志 */ function action_log($name = '', $describe = '') { $logLogic = get_sington_object('logLogic', LogicLog::class); $logLogic->logAdd($name, $describe); } /** * 清除登錄 session */ function clear_login_session() { session('member_info', null); session('member_auth', null); session('member_auth_sign', null); } ~~~ * * * * * ### api模塊函數文件 ~~~ <?php // +---------------------------------------------------------------------+ // | OneBase | [ WE CAN DO IT JUST THINK ] | // +---------------------------------------------------------------------+ // | Licensed | http://www.apache.org/licenses/LICENSE-2.0 ) | // +---------------------------------------------------------------------+ // | Author | Bigotry <3162875@qq.com> | // +---------------------------------------------------------------------+ // | Repository | https://gitee.com/Bigotry/OneBase | // +---------------------------------------------------------------------+ use \Firebase\JWT\JWT; // 解密user_token function decoded_user_token($token = '') { $decoded = JWT::decode($token, API_KEY . JWT_KEY, array('HS256')); return (array) $decoded; } // 獲取解密信息中的data function get_member_by_token($token = '') { $result = decoded_user_token($token); return $result['data']; } // 數據驗簽時數據字段過濾 function sign_field_filter($data = []) { $data_sign_filter_field_array = config('data_sign_filter_field'); foreach ($data_sign_filter_field_array as $v) { if (array_key_exists($v, $data)) { unset($data[$v]); } } return $data; } // 過濾后的數據生成數據簽名 function create_sign_filter($data = [], $key = '') { $filter_data = sign_field_filter($data); return empty($key) ? data_md5_key($filter_data, API_KEY) : data_md5_key($filter_data, $key); } ~~~ * * * * * ### index模塊函數文件 ~~~ <?php // +---------------------------------------------------------------------+ // | OneBase | [ WE CAN DO IT JUST THINK ] | // +---------------------------------------------------------------------+ // | Licensed | http://www.apache.org/licenses/LICENSE-2.0 ) | // +---------------------------------------------------------------------+ // | Author | Bigotry <3162875@qq.com> | // +---------------------------------------------------------------------+ // | Repository | https://gitee.com/Bigotry/OneBase | // +---------------------------------------------------------------------+ // 解析字符串中的{$變量} function parse_string_val($string, $vars) { $taglib_begin = '{'; $taglib_end = '}'; $pattern = '/('.$taglib_begin.').*?('.$taglib_end.')/is'; $results = []; preg_match_all($pattern, $string, $results); foreach ($results[0] as $v) { $del_start = substr($v, 2); $del_end = substr($del_start, 0, strlen($del_start) - 1); $string = isset($vars[$del_end]) ? str_replace($v, $vars[$del_end], $string) : sr($string, $v); } return $string; } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看