標籤:一個個 use etc msu log length div 返回 gb2312
今天周五了,這個項目做了五個晚上了,明天周末不用上班有一整天的時間來結束這個項目了,今晚主要把後台介面給弄出來了。
大概的整個後台介面就是這個樣子了,接下來的工作就是搬磚了,一個個菜單功能填上去就是了。
還有補充了下多個公用方法,為後面菜單開發而準備。
<?php/** * JSON資料返回 */function jsonResult($status,$message,$data){$result=array(‘status‘=>$status,‘message‘=>$message,‘data‘=>$data);exit(json_encode($result));}/** * MD5加密密碼 */function getMd5Password($password){return md5($password.C(‘MD5_PRE‘));}/***擷取導覽功能表*/function getMenuType($type){return $type==1?‘後台菜單‘:‘前端導航‘;}/***擷取狀態*/function status($status){if($status==0){$str=‘關閉‘;}elseif($status==1){$str=‘正常‘;}elseif($status==-1){$str=‘刪除‘;}return $str;}/***擷取後台菜單URL地址*/function getAdminMenuUrl($nav){$url=‘/admin.php?c=‘.$nav[‘c‘].‘&a=‘.$nav[‘a‘];if($nav[‘f‘]==‘index‘){$url="/admin.php?c=".$nav[‘c‘];}return $url;}/***擷取控制器*/function getActive($nav_controller){$controller=strtolower(CONTROLLER_NAME);if(strtolower($nav_controller)==$controller){return ‘class="active"‘;}return ‘‘;}/***檔案上傳結果返回*/function showKind($status,$data){header(‘Content-type:application/json;charset=UTF-8‘);if($status==0){exit(json_encode(array(‘error‘=>0,‘url‘=>$data)));}exit(json_encode(array(‘error‘=>1,‘message‘=>‘上傳失敗‘)));}/***擷取登入使用者名稱*/function getLoginUsername(){return $_SESSION[‘adminUser‘][‘username‘]?$_SESSION[‘adminUser‘][‘username‘]:‘‘;}/***擷取菜單名*/function getCatName($navs,$id){foreach($navs as $nav){$navList[$nav[‘menu_id‘]]=$nav[‘name‘];}return isset($navList[$id])?$navList[$id]:‘‘;}function getCopyFromById($id){$copyFrom=C("COPY_FORM");return $copyFrom[$id]?$copyFrom[$id]:‘‘;}function isThumb($thumb){if($thumb){return ‘<span style="color:red">有</span>‘;}return ‘無‘;}/***文章截取預覽*/function msubstr($str,$start=0,$length,$charset=‘utf-8‘,$suffix=true){$len=strlen($str);if(function_exists(‘mb_substr‘)){if($suffix){return mb_substr($str,$start,$length,$charset).‘...‘;}else{return mb_substr($str,$start,$length,$charset);}}elseif(function_exists(‘iconv_substr‘)){if($suffix && $len>$length){return mb_substr($str,$start,$length,$charset).‘...‘;}else{return mb_substr($str,$start,$length,$charset);}}$re[‘utf-8‘] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";$re[‘gb2312‘] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";$re[‘gbk‘] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";$re[‘big5‘] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";preg_match_all($re[$charset],$str,$match);$slice=join("",array_slice($match[0],$start,$length));if($suffix){return $slice.‘...‘;}return $slice;}?>
就到這裡了,明天早起,把這個項目趕起進度來!
源碼地址:https://github.com/YoZiLin/TP-CMS
前端到後台ThinkPHP開發整站(5)