<?php

// 应用公共文件

/**
 * 
 * @param type $algo
 * @param type $password
 * @param type $salt
 * @param type $hash_iterations
 * @return type
 */
function simple_hash($algo = 'md5', $password = '', $salt = '', $hash_iterations = 2) {
    $res = '';
    $pass = $salt . $password;
    $encoded = hash($algo, $pass, true);
    $iteration = $hash_iterations - 1;
    if ($iteration > 0) {
        for ($i = 0; $i < $iteration; $i++) {
            $encoded = hash($algo, $encoded, true);
        }
    }
    $tmp = unpack('H*', $encoded);
    if (!empty($tmp) && !empty($tmp[1])) {
        $res = $tmp[1];
    }
    return $res;
}

/**
 * 检查权限
 * @param type $url
 * @param type $old_url
 * @return type
 */
function chkCommission($url, $old_url) {
    return app\common\api\MenuApi::chkPermission($url, $old_url);
}
