コード例 #1
0
function generateMojangAccount($mojangResponse)
{
    $accessToken = $mojangResponse['accessToken'];
    $clientToken = $mojangResponse['clientToken'];
    $mojandProfile = $mojangResponse['selectedProfile'];
    $licenseUUID = $mojandProfile['id'];
    $licenseName = $mojandProfile['name'];
    // Обновление в БД
    $insert = registerLicenseUUID($licenseUUID, $licenseName);
    $uuid = $insert['uuid'];
    $name = $insert['name'];
    replaceToken($uuid, $clientToken, $accessToken);
    return array("uuid" => $uuid, "name" => $name, "clientToken" => $clientToken, "accessToken" => $accessToken, "provider" => "mojang", "role" => "player");
}
コード例 #2
0
ファイル: basic.php プロジェクト: kix23/GetSimpleCMS
/**
 * generate permalink url from tokenized permalink structure
 * uses a very basic str_replace based token replacer, not a parser
 * TOKENS (%tokenid%)
 *  %path% - path heirarchy to slug
 *  %slug% - slug
 *  %parent% - direct parent of slug
 *
 * supports prettyurl or any other permalink structure
 * eg. ?id=%slug%&parent=%parent%&path=%path%
 * 
 * @param  (str) $slug      slug to resolve permalink for	
 * @param  (str) $permalink (optional) permalink structure
 * @return (str)            	
 */
function generate_permalink($slug, $permalink = null)
{
    global $PERMALINK;
    $slug = (string) $slug;
    if (!isset($permalink)) {
        $plink = $PERMALINK;
        if (empty($PERMALINK)) {
            $plink = getDef('GSDEFAULTPERMALINK');
        }
    } else {
        $plink = $permalink;
    }
    // replace PATH token
    if (containsToken('path', $plink)) {
        // remove PARENT tokens if path, since it would be pointless and probably accidental
        // leaving in for now lets not make assumptions
        // $plink = replaceToken('parent','',$plink);
        $pagepath = getParents($slug);
        if ($pagepath) {
            $pagepath = implode('/', array_reverse($pagepath));
            $plink = replaceToken('path', $pagepath, $plink);
        } else {
            // page has no parents, remove token
            $plink = replaceToken('path', '', $plink);
        }
    }
    // replace PARENT token
    if (containsToken('parent', $plink)) {
        $parent = getParent($slug);
        $plink = replaceToken('parent', $parent, $plink);
    }
    // replace SLUG token
    $plink = replaceToken('slug', $slug, $plink);
    $plink = str_replace('//', '/', $plink);
    // clean up any double slashes
    // debugLog($url);
    // debugLog($plink);
    return no_lsl($plink);
}