<?php
/**
 * @Author: anchen
 * @Date:   2017-03-01 16:53:07
 * @Last Modified by:   anchen
 * @Last Modified time: 2017-05-20 14:35:11
 */
/*二级分类*/
function SidType($sid){
    $Data=M('category');
    $where['sid']=$sid;
    $list=$Data->where($where)->select();
    return $list;
}


/**
 * 权限
 */
// function auth_check($str)
// {
//     // $_SESSION array(2) {
//     //   ["username"] => string(5) "user1"
//     //   ["auth"] => string(16) "users,order,shop"
//     // }
//     $auth = M('group')->where(array('id' => session('group_id')))->find()['auth'];
//     $admin = session('admin');
//     if ($admin != "admin") {
//         $arr_cur = explode(",", $auth);
//         if (!in_array($str, $arr_cur)) {
//             // echo "<script>alert('权限不足');location.href=history.back();</script>";die;
//             alertMsg('权限不足', U('Index/index'));
//         } elseif (!$auth) {
//             // echo "<script>alert('权限不足');location.href=history.back();</script>";die;
//             alertMsg('权限不足', U('Index/index'));
//         }
//     }
// }
function cmoney($money){
    $money = $money < 0 ? 0 : $money;
    if($money == (int)$money){
        return (int)$money;
    }else{
        return $money;
    }
}
/* 时间戳转时间 */
function cdate($rule = 0,$timestamp = 0){
    switch ($rule) {
        case 0:
            $rule = "Y-m-d H:i";
            break;
        case 1:
            $rule = "Y-m-d";
            break;
        case 2:
            $rule = "Y-m-d H:i:s";
            break;
        default:
            break;
    }
    return $timestamp?date($rule,$timestamp):'';
}

