当前位置: 首页>>代码示例>>PHP>>正文


PHP createToken函数代码示例

本文整理汇总了PHP中createToken函数的典型用法代码示例。如果您正苦于以下问题:PHP createToken函数的具体用法?PHP createToken怎么用?PHP createToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createToken函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GamePage

function GamePage()
{
    global $base_uri;
    $uid = params('user');
    if (!isset($_SESSION['uid'])) {
        return 0;
    } else {
        createToken($_SESSION['uid']);
    }
    $reg = 0;
    $shit = 0;
    if (!isset($uid) || $uid == "") {
        $uid = $_SESSION['uid'];
    } else {
        if (!check_registration($uid)) {
            $reg = 1;
        }
        $shit = 1;
    }
    $user = getUserInfo($_SESSION['access_token'], $uid, 'photo_max');
    if ($reg) {
        register($uid, $user['first_name'], $user['last_name']);
    }
    echo $user['first_name'] . " " . $user['last_name'];
    echo "<img src=\"" . $user['photo_max'] . "\" /><br><br>";
    if ($shit) {
        echo "<a href=\"/shit/" . $_SESSION['uid'] . "/" . $uid . "/" . getToken($_SESSION['uid']) . "\">shit</a><br>";
    }
    $friends = getUserFriends($_SESSION['access_token'], $uid);
    foreach ($friends as $friend) {
        echo $friend["first_name"] . " " . $friend["last_name"] . "<br>";
        echo "<a href=\"{$base_uri}/game/" . $friend['uid'] . "\"><img src=\"" . $friend["photo_50"] . "\" /></a><hr>";
    }
}
开发者ID:Vladimir-Gerasimov,项目名称:Lavatorium,代码行数:34,代码来源:index.php

示例2: va

 public function va()
 {
     $usr_info = array('Id' => I('post.usrid'), 'psw' => I('post.psw'), 'lastLogin' => date('Y-m-d H:i:s', time()), 'lastIp' => get_client_ip());
     $usrs = M('usr');
     $map = array('Id=' => $usr_info['Id'], 'psw' => $usr_info['psw']);
     $res = array(response => "数据创建失败,请联系管理员以解决问题。错误代码:0。", status => "0");
     if ($usrs->create($usr_info)) {
         if (checkUsr($map)) {
             //创建token
             $token = createToken($usr_info['Id']);
             //清空token
             session(C('SESSION_KEY_TOKEN'), null);
             //写入token(重新密码登录代表重新获取令牌)
             session(C('SESSION_KEY_TOKEN'), $token);
             $usr_info['token'] = $token;
             $usr_info['grantTime'] = date('Y-m-d H:i:s', time());
             $list = $usrs->where($map)->save($usr_info);
             $res = array(response => "登陆成功", status => "1");
             cookie('login', array(id => $usr_info["id"], token => $token), 3600);
         } else {
             $res = array(response => "用户名密码验证信息错误", status => "2");
         }
     }
     $this->ajaxReturn(json_encode($res), 'JSON');
 }
开发者ID:DiscussionGroup,项目名称:PostorManagerSystem,代码行数:25,代码来源:LoginController.class.php

示例3: Login

/**
 * Ask them for their login information. (shows a page for the user to type
 *  in their username and password.)
 *  It caches the referring URL in $_SESSION['login_url'].
 *  It is accessed from ?action=login.
 *  @uses Login template and language file with the login sub-template.
 *  @uses the protocol_login sub-template in the Wireless template,
 *   if you are using a wireless device
 */
function Login()
{
    global $txt, $context, $scripturl, $user_info;
    // You are already logged in, go take a tour of the boards
    if (!empty($user_info['id'])) {
        redirectexit();
    }
    // In wireless?  If so, use the correct sub template.
    if (WIRELESS) {
        $context['sub_template'] = WIRELESS_PROTOCOL . '_login';
    } else {
        loadLanguage('Login');
        loadTemplate('Login');
        $context['sub_template'] = 'login';
    }
    // Get the template ready.... not really much else to do.
    $context['page_title'] = $txt['login'];
    $context['default_username'] =& $_REQUEST['u'];
    $context['default_password'] = '';
    $context['never_expire'] = false;
    // Add the login chain to the link tree.
    $context['linktree'][] = array('url' => $scripturl . '?action=login', 'name' => $txt['login']);
    // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
    if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
        $_SESSION['login_url'] = $_SESSION['old_url'];
    } else {
        unset($_SESSION['login_url']);
    }
    // Create a one time token.
    createToken('login');
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:40,代码来源:LogInOut.php

示例4: login

function login($data, $ip)
{
    //separate data
    if ($obs = json_decode($data, true)) {
        //sanitization
        $user = htmlentities(preg_replace("/[^a-zA-Z ]*/", "", $obs['n']), ENT_QUOTES, "utf-8");
        $pw = htmlentities(preg_replace("/[^a-zA-Z ]*/", "", $obs['p']), ENT_QUOTES, "utf-8");
        //retrieve pass and id from DB
        $res = json_decode(processLogin($user), true);
        $dbPass = $res[0]['password'];
        $id = $res[0]['userId'];
        //hash entered password
        $cPass = hashPass($pw);
        //compare hashed pws
        if ($cPass == $dbPass) {
            //generate token
            $token = createToken($ip, $id);
            //set cookie to token value
            $time = time() + 86400 / 2;
            setcookie("token", $token, $time, "/");
            session_start();
            setLoginData($_SESSION['user_id'], $user);
            return 1;
        } else {
            setcookie("token", " ", time() - 1);
            return -1;
        }
    } else {
        return -1;
    }
}
开发者ID:ans2759,项目名称:battleship,代码行数:31,代码来源:login.php

示例5: signIn

function signIn($username, $password, $name, $dbConn, $id, $module_type)
{
    // never trust data coming from lua
    $username = htmlspecialchars($username);
    $password = htmlspecialchars($password);
    $name = htmlspecialchars($name);
    $id = htmlspecialchars($id);
    $module_type = htmlspecialchars($module_type);
    // hash is created in the lua now
    // $salt = '';
    // $query = "select salt from users where username = '".dbEsc($username). "';";
    // $result = mysql_query($query);
    // $row = mysql_fetch_array($result, MYSQL_ASSOC);
    // $salt = $row['salt'];
    // $hash = sha1($salt.$password);
    $query2 = "select user_id from users where username = '" . dbEsc($username) . "' AND password = '" . dbEsc($password) . "';";
    $result2 = mysql_query($query2);
    $row2 = mysql_fetch_array($result2, MYSQL_ASSOC);
    if ($row2['user_id'] != '') {
        $token = createToken($dbConn, $row2['user_id'], $name, $id, $username, $module_type);
        if ($module_type == '4') {
            createRedstoneEntry($dbConn, $token, $id);
        }
        if ($module_type == '3') {
            createTankEntry($dbConn, $token, $id);
        }
        if ($module_type == '2') {
            createEnergyEntry($dbConn, $token, $id);
        }
        echo $token;
    } else {
        echo 'error';
    }
}
开发者ID:jaranvil,项目名称:CraftNanny,代码行数:34,代码来源:signin.php

示例6: va

 public function va()
 {
     $usr_info = array('id' => I('post.usrid', 0), 'psw' => I('post.psw', 0), 'lastLogin' => date('Y-m-d H:i:s', time()), 'lastIp' => get_client_ip());
     $usrs = M('admin');
     $map = array('id' => $usr_info['id'], 'psw' => $usr_info['psw']);
     $res = array(response => "数据创建失败,请联系管理员以解决问题。错误代码:0。", status => "0");
     if ($usrs->create($usr_info)) {
         if (checkUsr($map)) {
             //创建token
             $token = createToken($usr_info['Id']);
             //清空token
             session(C('SESSION_KEY_TOKEN_ADMIN'), null);
             //写入token(重新密码登录代表重新获取令牌)
             session(C('SESSION_KEY_TOKEN_ADMIN'), $token);
             $usr['token'] = $token;
             $usr['grantTime'] = date('Y-m-d H:i:s', time());
             $usr['lastLogin'] = date('Y-m-d H:i:s', time());
             $usr['lastIp'] = get_client_ip();
             $list = $usrs->field(array('token', 'grantTime', 'lastLogin', 'lastIp'))->where($map)->save($usr);
             $list = $usrs->field(array('id', 'expiretime'))->where($map)->find();
             $res = array(response => "登陆成功", status => "1");
             cookie(C('COOKIE_KEY_TOKEN_ADMIN'), array(id => $list["id"], token => $token), $list['expiretime']);
         } else {
             $res = array(response => "用户名密码验证信息错误", status => "2");
         }
     }
     $this->ajaxReturn(json_encode($res), 'JSON');
     // $this->redirect(Edit/logined);
 }
开发者ID:iceprosurface,项目名称:PostorManagerSystem,代码行数:29,代码来源:IndexController.class.php

示例7: EnableCoreFeatures

function EnableCoreFeatures()
{
    global $context, $smcFunc, $sourcedir, $modSettings, $txt;
    $context['xml_data'] = array();
    // Just in case, maybe we don't need it
    loadLanguage('Errors');
    // We need (at least) this to ensure that mod files are included
    if (!empty($modSettings['integrate_admin_include'])) {
        $admin_includes = explode(',', $modSettings['integrate_admin_include']);
        foreach ($admin_includes as $include) {
            $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
            if (file_exists($include)) {
                require_once $include;
            }
        }
    }
    $errors = array();
    $returns = array();
    $tokens = array();
    if (allowedTo('admin_forum')) {
        $validation = validateSession();
        if (empty($validation)) {
            require_once $sourcedir . '/ManageSettings.php';
            $result = ModifyCoreFeatures();
            if (empty($result)) {
                $id = isset($_POST['feature_id']) ? $_POST['feature_id'] : '';
                if (!empty($id) && isset($context['features'][$id])) {
                    $feature = $context['features'][$id];
                    $returns[] = array('value' => !empty($_POST['feature_' . $id]) && $feature['url'] ? '<a href="' . $feature['url'] . '">' . $feature['title'] . '</a>' : $feature['title']);
                    createToken('admin-core', 'post');
                    $tokens = array(array('value' => $context['admin-core_token'], 'attributes' => array('type' => 'token_var')), array('value' => $context['admin-core_token_var'], 'attributes' => array('type' => 'token')));
                } else {
                    $errors[] = array('value' => $txt['feature_no_exists']);
                }
            } else {
                $errors[] = array('value' => $txt[$result]);
            }
        } else {
            $errors[] = array('value' => $txt[$validation]);
        }
    } else {
        $errors[] = array('value' => $txt['cannot_admin_forum']);
    }
    $context['sub_template'] = 'generic_xml';
    $context['xml_data'] = array('corefeatures' => array('identifier' => 'corefeature', 'children' => $returns), 'tokens' => array('identifier' => 'token', 'children' => $tokens), 'errors' => array('identifier' => 'error', 'children' => $errors));
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:46,代码来源:Xml.php

示例8: check

 public static function check($receivedToken, $receivedData)
 {
     /* Recreate the generic part of token using secretKey and other stuff */
     $tokenGeneric = $REG->secret_key . $_SERVER["SERVER_NAME"];
     // We create a token which should match
     $token = hash('sha256', $tokenGeneric . $receivedData);
     // We check if token is ok !
     if ($receivedToken != $token) {
         echo 'wrong Token !';
         return false;
     }
     list($tokenDate, $userData) = explode("_", $receivedData);
     // here we compare tokenDate with current time using VALIDITY_TIME to check if the token is expired
     // if token expired we return false
     // otherwise it's ok and we return a new token
     return createToken(time() . "#" . $userData);
 }
开发者ID:andrebonner,项目名称:Absotus,代码行数:17,代码来源:Token.php

示例9: action_avatarSettings_display

 /**
  * This action handler method displays and allows to change avatar settings.
  *
  * - Called by index.php?action=admin;area=manageattachments;sa=avatars.
  *
  * @uses 'avatars' sub-template.
  */
 public function action_avatarSettings_display()
 {
     global $txt, $context, $scripturl;
     // Initialize the form
     $this->_initAvatarSettingsForm();
     $config_vars = $this->_avatarSettings->settings();
     // Saving avatar settings?
     if (isset($_GET['save'])) {
         checkSession();
         call_integration_hook('integrate_save_avatar_settings');
         // Disable if invalid values would result
         if (isset($_POST['custom_avatar_enabled']) && $_POST['custom_avatar_enabled'] == 1 && (empty($_POST['custom_avatar_dir']) || empty($_POST['custom_avatar_url']))) {
             $_POST['custom_avatar_enabled'] = 0;
         }
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=manageattachments;sa=avatars');
     }
     // Attempt to figure out if the admin is trying to break things.
     $context['settings_save_onclick'] = 'return document.getElementById(\'custom_avatar_enabled\').value == 1 && (document.getElementById(\'custom_avatar_dir\').value == \'\' || document.getElementById(\'custom_avatar_url\').value == \'\') ? confirm(\'' . $txt['custom_avatar_check_empty'] . '\') : true;';
     // We need this for the in-line permissions
     createToken('admin-mp');
     // Prepare the context.
     $context['post_url'] = $scripturl . '?action=admin;area=manageattachments;save;sa=avatars';
     Settings_Form::prepare_db($config_vars);
     // Add a layer for the javascript.
     Template_Layers::getInstance()->add('avatar_settings');
     $context['sub_template'] = 'show_settings';
 }
开发者ID:scripple,项目名称:Elkarte,代码行数:35,代码来源:ManageAvatars.controller.php

示例10: login

function login($mail, $password)
{
    $db = new MysqliDb();
    $db->where("mail", $mail);
    $results = $db->get("clientes");
    global $jwt_enabled;
    if ($db->count > 0) {
        $hash = $results[0]['password'];
        if (password_verify($password, $hash) && $results[0]['status'] != 0) {
            if ($jwt_enabled) {
                echo json_encode(createToken($results[0]['cliente_id'], $mail, $results[0]['nombre'], $results[0]['rol_id']));
            } else {
                echo json_encode($results);
            }
        } else {
            echo json_encode(-1);
        }
    } else {
        echo json_encode(-1);
    }
}
开发者ID:arielcessario,项目名称:hydrox-V2,代码行数:21,代码来源:cliente.php

示例11: array

    $user = User::whereRaw('email = ? and password = ?', array($email, $password))->get();
    if ($user->isEmpty()) {
        return $response->withHeader('Content-type', 'application/json')->write('{"msg":"Hatalı kullanıcı adı veya parola"}');
    }
    $user = $user->first();
    if ($user->deleted == 1) {
        return $response->withHeader('Content-type', 'application/json')->write('{"msg":"Hesabınız engellendi !"}');
    }
    $token = Token::where('user_id', $user->user_id)->get();
    if ($token->isEmpty()) {
        $token = new Token();
        $token->user_id = $user->user_id;
    } else {
        $token = $token->first();
    }
    $token->token = createToken();
    $token->create_date = date("YmdHi");
    $token->save();
    $user["token"] = $token;
    $user->password = null;
    $response->write(json_encode($user) . '     ');
    return $response->withHeader('Content-type', 'application/json');
});
$app->post('/register', function ($request, $response, $args) {
    $newUser = new User();
    $email = $request->getParsedBody()["email"];
    $password = $request->getParsedBody()["password"];
    if (!isset($email) && !isset($password)) {
        return $response->write('{"msg":"email ve password bilgisi zorunludur"}')->withHeader('Content-type', 'application/json');
    }
    $newUser->email = $request->getParsedBody()["email"];
开发者ID:gokselpirnal,项目名称:WhatTheFood-web,代码行数:31,代码来源:routes.php

示例12: action_log

    /**
     * Show the log of all tasks that have taken place.
     *
     * @uses ManageScheduledTasks language file
     */
    public function action_log()
    {
        global $scripturl, $context, $txt;
        require_once SUBSDIR . '/ScheduledTasks.subs.php';
        // Lets load the language just in case we are outside the Scheduled area.
        loadLanguage('ManageScheduledTasks');
        // Empty the log?
        if (!empty($_POST['removeAll'])) {
            checkSession();
            validateToken('admin-tl');
            emptyTaskLog();
        }
        // Setup the list.
        $listOptions = array('id' => 'task_log', 'items_per_page' => 30, 'title' => $txt['scheduled_log'], 'no_items_label' => $txt['scheduled_log_empty'], 'base_href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'default_sort_col' => 'date', 'get_items' => array('function' => array($this, 'list_getTaskLogEntries')), 'get_count' => array('function' => array($this, 'list_getNumTaskLogEntries')), 'columns' => array('name' => array('header' => array('value' => $txt['scheduled_tasks_name']), 'data' => array('db' => 'name')), 'date' => array('header' => array('value' => $txt['scheduled_log_time_run']), 'data' => array('function' => create_function('$rowData', '
							return standardTime($rowData[\'time_run\'], true);
						')), 'sort' => array('default' => 'lst.id_log DESC', 'reverse' => 'lst.id_log')), 'time_taken' => array('header' => array('value' => $txt['scheduled_log_time_taken']), 'data' => array('sprintf' => array('format' => $txt['scheduled_log_time_taken_seconds'], 'params' => array('time_taken' => false))), 'sort' => array('default' => 'lst.time_taken', 'reverse' => 'lst.time_taken DESC')), 'task_completed' => array('header' => array('value' => $txt['scheduled_log_completed']), 'data' => array('function' => create_function('$rowData', '
							global $settings, $txt;

							return \'<img src="\' . $settings[\'images_url\'] . \'/admin/complete_\' . ($rowData[\'task_completed\'] ? \'success\' : \'fail\') . \'.png" alt="\' . sprintf($txt[$rowData[\'task_completed\'] ? \'maintain_done\' : \'maintain_fail\'], $rowData[\'name\']) . \'" />\';
						')))), 'form' => array('href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'token' => 'admin-tl'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
						<input type="submit" name="removeAll" value="' . $txt['scheduled_log_empty_log'] . '" onclick="return confirm(\'' . $txt['scheduled_log_empty_log_confirm'] . '\');" class="right_submit" />'), array('position' => 'after_title', 'value' => $txt['scheduled_tasks_time_offset'], 'class' => 'windowbg2')));
        createToken('admin-tl');
        require_once SUBSDIR . '/GenericList.class.php';
        createList($listOptions);
        $context['sub_template'] = 'show_list';
        $context['default_list'] = 'task_log';
        // Make it all look tify.
        $context[$context['admin_menu_name']]['current_subsection'] = 'tasklog';
        $context['page_title'] = $txt['scheduled_log'];
    }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:35,代码来源:ManageScheduledTasks.controller.php

示例13: TaskLog

/**
 * Show the log of all tasks that have taken place.
 *
 * @uses ManageScheduledTasks language file
 */
function TaskLog()
{
    global $scripturl, $context, $txt, $smcFunc, $sourcedir;
    // Lets load the language just incase we are outside the Scheduled area.
    loadLanguage('ManageScheduledTasks');
    // Empty the log?
    if (!empty($_POST['removeAll'])) {
        checkSession();
        validateToken('admin-tl');
        $smcFunc['db_query']('truncate_table', '
			TRUNCATE {db_prefix}log_scheduled_tasks', array());
    }
    // Setup the list.
    $listOptions = array('id' => 'task_log', 'items_per_page' => 30, 'title' => $txt['scheduled_log'], 'no_items_label' => $txt['scheduled_log_empty'], 'base_href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'default_sort_col' => 'date', 'get_items' => array('function' => 'list_getTaskLogEntries'), 'get_count' => array('function' => 'list_getNumTaskLogEntries'), 'columns' => array('name' => array('header' => array('value' => $txt['scheduled_tasks_name']), 'data' => array('db' => 'name')), 'date' => array('header' => array('value' => $txt['scheduled_log_time_run']), 'data' => array('function' => create_function('$rowData', '
						return timeformat($rowData[\'time_run\'], true);
					')), 'sort' => array('default' => 'lst.id_log DESC', 'reverse' => 'lst.id_log')), 'time_taken' => array('header' => array('value' => $txt['scheduled_log_time_taken']), 'data' => array('sprintf' => array('format' => $txt['scheduled_log_time_taken_seconds'], 'params' => array('time_taken' => false))), 'sort' => array('default' => 'lst.time_taken', 'reverse' => 'lst.time_taken DESC'))), 'form' => array('href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'token' => 'admin-tl'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
					<input type="submit" name="removeAll" value="' . $txt['scheduled_log_empty_log'] . '" onclick="return confirm(\'' . $txt['scheduled_log_empty_log_confirm'] . '\');" class="button_submit" />', 'style' => 'text-align: right;'), array('position' => 'after_title', 'value' => $txt['scheduled_tasks_time_offset'], 'class' => 'windowbg2')));
    createToken('admin-tl');
    require_once $sourcedir . '/Subs-List.php';
    createList($listOptions);
    $context['sub_template'] = 'show_list';
    $context['default_list'] = 'task_log';
    // Make it all look tify.
    $context[$context['admin_menu_name']]['current_subsection'] = 'tasklog';
    $context['page_title'] = $txt['scheduled_log'];
}
开发者ID:albertlast,项目名称:SMF2.1,代码行数:31,代码来源:ManageScheduledTasks.php

示例14: action_newsSettings_display

    /**
     * Set general news and newsletter settings and permissions.
     *
     * What it does:
     * - Called by ?action=admin;area=news;sa=settings.
     * - Requires the forum_admin permission.
     *
     * @uses ManageNews template, news_settings sub-template.
     */
    public function action_newsSettings_display()
    {
        global $context, $txt, $scripturl;
        // Initialize the form
        $this->_initNewsSettingsForm();
        $config_vars = $this->_newsSettings->settings();
        // Add some javascript at the bottom...
        addInlineJavascript('
			document.getElementById("xmlnews_maxlen").disabled = !document.getElementById("xmlnews_enable").checked;
			document.getElementById("xmlnews_limit").disabled = !document.getElementById("xmlnews_enable").checked;', true);
        $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings'];
        $context['sub_template'] = 'show_settings';
        // Wrap it all up nice and warm...
        $context['post_url'] = $scripturl . '?action=admin;area=news;save;sa=settings';
        $context['permissions_excluded'] = array(-1);
        // Saving the settings?
        if (isset($_GET['save'])) {
            checkSession();
            call_integration_hook('integrate_save_news_settings');
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=news;sa=settings');
        }
        // We need this for the in-line permissions
        createToken('admin-mp');
        Settings_Form::prepare_db($config_vars);
    }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:35,代码来源:ManageNews.controller.php

示例15: entity

/api.php?token=<token>&action=catalog												returns the list with all courses and lessons of the system
/api.php?token=<token>&action=logout												logs out from eFront API
API returns xml corresponding to the action argument. For actions like efrontlogin, activate_user etc it returns a status entity ("ok" or "error").
In case of error it returns also a message entity with description of the error occured.
*/
$path = "../libraries/";
require_once $path . "configuration.php";
$data = eF_getTableData("configuration", "value", "name='api'");
//Read current values
$api = $data[0]['value'];
if ($api == 1) {
    if (isset($_GET['action'])) {
        $action = $_GET['action'];
        switch ($_GET['action']) {
            case 'token':
                $token = createToken(30);
                if (strlen($token) == 30) {
                    $insert['token'] = $token;
                    $insert['status'] = "unlogged";
                    $insert['expired'] = 0;
                    $insert['create_timestamp'] = time();
                    eF_insertTableData("tokens", $insert);
                    echo "<xml>";
                    echo "<token>" . $token . "</token>";
                    echo "</xml>";
                }
                break;
            case 'efrontlogin':
                if (isset($_GET['token']) && checkToken($_GET['token'])) {
                    $token = $_GET['token'];
                    $creds = eF_getTableData("tokens t, users u", "u.login, u.password, u.user_type", "t.users_LOGIN = u.LOGIN and t.token='{$token}'");
开发者ID:bqq1986,项目名称:efront,代码行数:31,代码来源:api.php


注:本文中的createToken函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。