Exemplo n.º 1
0
                $civ = $_SESSION['civ'];
            } else {
                $civ = $_USER->getCiv();
            }
            $cat = new CSRCategory($open, $_USER->getRace(), $cult, $civ);
            if ($_REQUEST['grant'] != "") {
                $cat->grantNode($_REQUEST['grant'], $_USER->getID());
            }
            if ($_REQUEST['deny'] != "") {
                $cat->denyNode($_REQUEST['deny'], $_USER->getID());
            }
        }
        $c .= "<center><table>\n\t\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='left'>" . csr_render_yubopoints($user['id']) . "</td>\n\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
        $c .= csr_render_menu($menu);
        $c .= "</div></td>\n\t\t\t\t\t\t<td width='645px' valign='top'>";
        if ($open != 0) {
            $c .= csr_render_category($cat);
        } else {
            $cat = new AchSummary($menu, 3);
            $c .= ach_render_summary_header();
        }
        if ($open == 0) {
            $c .= ach_render_summary_footer($cat);
        }
        $c .= "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table></center>";
    }
}
$c .= "</td>\n\t</tr>\n</table></center>";
#$c = var_export($_USER).$c;
echo ryzom_app_render("achievements admin", $c, $_ADMIN->isIG());
Exemplo n.º 2
0
     *
     * #code taken from facebook tutorial
     *
     * // Get the url to redirect for login to facebook
     * // and request permission to write on the user's wall.
     * $login_url = $facebook->getLoginUrl(
     * array('scope' => 'publish_stream')
     * );
     *
     * // If not authenticated, redirect to the facebook login dialog.
     * // The $login_url will take care of redirecting back to us
     * // after successful login.
     * if (! $facebook->getUser()) {
     * $c .= '<script type="text/javascript">
     * top.location.href = "'.$login_url.'";
     * </script>;';
     * }
     * else {
     * $DBc->sqlQuery("INSERT INTO ach_fb_token (aft_player,aft_token,aft_date,aft_allow) VALUES ('".$_USER->getID()."','".$DBc->sqlEscape($facebook->getAccessToken())."','".time()."','1') ON DUPLICATE KEY UPDATE aft_token='".$DBc->sqlEscape($facebook->getAccessToken())."', aft_date='".time()."'");
     * }
     */
}
if (!$_USER->isIG && $_CONF['enable_webig'] == false) {
    $c .= ach_render_forbidden(false);
} elseif ($_USER->isIG && $_CONF['enable_offgame'] == false) {
    $c .= ach_render_forbidden(true);
} else {
    $c .= ach_render();
}
echo ryzom_app_render(strtoupper(get_translation('ach_app_name', $_USER->getLang())), $c, $_USER->isIG());
Exemplo n.º 3
0
function ryzom_app_authenticate(&$user, $ask_login = true, $welcome_message = '', $webprivs = true)
{
    $name = ryzom_get_param('name');
    $urluser = ryzom_get_param('user');
    // user serialization send by auth server
    $urlusercheksum = ryzom_get_param('checksum');
    // user serialization checksum
    $authkey = ryzom_get_param('authkey');
    // InGame authkey
    $lang = ryzom_get_param('lang');
    $cid = intval(ryzom_get_param('cid'));
    $is_auth_ingame = false;
    // we have to set the $user['lang'] even for anonymous user or we cannot display the test in the right langage
    if ($lang == '') {
        if (!isset($_SESSION['lang'])) {
            $l = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : 'en';
            if ($l == 'fr' || $l == 'en' || $l == 'de' || $l == 'ru' || $l == 'es') {
                $lang = $l;
            } else {
                $lang = 'en';
            }
        } else {
            $lang = $_SESSION['lang'];
        }
    }
    if ($lang != 'fr' && $lang != 'en' && $lang != 'de' && $lang != 'ru' && $lang != 'es') {
        $lang = 'en';
    }
    $user['message'] = '';
    $user['lang'] = $lang;
    $user['groups'] = array();
    if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Ryzom') || ryzom_get_param('ig')) {
        $user['ig'] = true;
    } else {
        $user['ig'] = false;
    }
    if (isset($_SESSION['user'])) {
        if (ryzom_get_param('action') == 'logout') {
            unset($_SESSION['user']);
        } else {
            $_SESSION['user']['ig'] = $user['ig'];
            define('RYZOM_IG', $user['ig']);
            $user = $_SESSION['user'];
            return true;
        }
    }
    if ($urluser && $urlusercheksum) {
        // Check $authuser (used to test app from another server ingame)
        if (hash_hmac('sha1', $urluser, RYAPI_AUTH_KEY) == $urlusercheksum) {
            $ig = $user['ig'];
            $user = array_merge($user, unserialize(base64_decode($urluser)));
            $user['ig'] = $ig;
            if (!isset($user['groups'])) {
                $user['groups'] = array();
            }
            define('RYZOM_IG', $user['ig']);
            $_SESSION['user'] = $user;
            return true;
        }
    }
    if ($user['ig']) {
        // Ingame
        $shardid = ryzom_get_param('shardid');
        $error_message = '';
        if (ryzom_authenticate_ingame($shardid, $cid, $name, $authkey) || ryzom_authenticate_with_session($name, $cid, $error_message)) {
            $is_auth_ingame = true;
        }
    } else {
        // Outgame or bad ingame auth (external server) : Use session
        $error_message = '';
        if (!ryzom_authenticate_with_session($name, $cid, $error_message)) {
            define('RYZOM_IG', false);
            if ($ask_login) {
                if ($error_message) {
                    $c = '<h3>' . _t($error_message) . '</h3>';
                } else {
                    $c = '';
                }
                if (!$welcome_message) {
                    $welcome_message = '<span style="font-size:11pt; color: #AAAAFF">The application <strong style="color: #99FFFF">' . _t(APP_NAME) . '</strong> require authentication. Please enter your credentials</span>';
                }
                $c .= '<div style="text-align: center">' . $welcome_message . '</div><br />';
                if ($user['message']) {
                    $c .= '<div style="text-align: center"><strong style="color: #FF5555">' . _t($user['message']) . '</strong></div><br />';
                }
                $c .= ryzom_render_login_form($name, false);
                echo ryzom_app_render(_t('app_' . APP_NAME), $c);
                die;
            }
            return false;
        }
    }
    $_SESSION['lang'] = $lang;
    define('RYZOM_IG', $user['ig']);
    // get user informations
    $ig = $user['ig'];
    $user = ryzom_user_get_info($cid, $webprivs, RYAPI_USE_PLAYER_STATS);
    if (isset($user['creation_date'])) {
        $user['id'] = ryzom_get_user_id($cid, $user['char_name'], $user['creation_date'], $user);
    }
    $user['gender'] = ryzom_get_user_gender($user['id']);
    $user['ig'] = $ig;
    $user['lang'] = $_SESSION['lang'];
    if (!isset($user['groups'])) {
        $user['groups'] = array();
    }
    if ($is_auth_ingame && $user['last_played_date'] != '0') {
        $user['auth_ig'] = true;
    } else {
        $user['auth_ig'] = false;
    }
    if (!isset($_SESSION['translater_mode']) || ryzom_get_param('translate_this') == '0') {
        $_SESSION['translater_mode'] = false;
    }
    // Set/unset translation mode
    if (in_array('WTRS', $user['groups']) && ryzom_get_param('translate_this') == '1') {
        $_SESSION['translater_mode'] = true;
    }
    $user['translation_mode'] = $_SESSION['translater_mode'];
    //	$user['after_merge'] = $user['uid'] >= 671686;
    ryzom_unset_url_param('translate_this');
    if (isset($user['last_played_date'])) {
        $_SESSION['last_played_date'] = $user['last_played_date'];
    }
    // don't send this informations to external apps
    unset($user['last_played_date']);
    unset($user['creation_date']);
    return true;
}
Exemplo n.º 4
0
<?php

define('APP_NAME', 'app_test');
include_once '../config.php';
include_once '../lang.php';
include_once 'lang.php';
// Ask to authenticate user (using ingame or session method) and fill $user with all information
ryzom_app_authenticate($user, true);
// Enable debug logs only for DEVS
if (in_array('DEV', $user['groups'])) {
    ryLogger::getInstance()->enable = true;
}
// Debug log
p($user);
// Update user acces on Db
$db = ryDB::getInstance(APP_NAME);
$db->setDbDefs('test', array('id' => SQL_DEF_INT, 'num_access' => SQL_DEF_INT));
$num_access = $db->querySingleAssoc('test', array('id' => $user['id']));
if ($num_access) {
    $db->update('test', array('num_access' => ++$num_access['num_access']), array('id' => $user['id']));
} else {
    $db->insert('test', array('num_access' => $num_access['num_access'] = 1, 'id' => $user['id']));
}
// Content
$c = _t('access', $num_access['num_access']) . '<br/>';
echo ryzom_app_render(APP_NAME, $c, $user['ig']);
Exemplo n.º 5
0
<?php

include_once 'config.php';
include_once 'lang.php';
// List of apps
$apps = array('app_test');
$c = '';
// Ask to authenticate user (using ingame or session method) and fill $user with all information
$logged = ryzom_app_authenticate($user, false);
if ($logged) {
    $c .= '<h1>' . _t('welcome', $user['char_name']) . '</h1>';
} else {
    if (!$user['ig']) {
        if ($user['message']) {
            $c .= '<div style="text-align: center"><strong style="color: #FF5555">' . _t($user['message']) . '</strong></div><br />';
        }
        $c .= ryzom_render_login_form(ryzom_get_param('name'));
    }
}
foreach ($apps as $app) {
    $c .= '<a href="' . RYAPP_URL . '/' . $app . '/index.php"><img src="' . RYAPP_URL . '/' . $app . '/favicon.png" />' . _t($app) . '</a><br />';
}
if ($logged && !$user['ig']) {
    $c .= '<br /><a href="' . RYAPP_URL . '/index.php?action=logout">' . _t('logout') . '</a>';
}
// Print GET values on debug view
p($_GET);
echo ryzom_app_render('Ryzom', $c, $user['ig']);