<commit_before><?php

if (!defined('ZBP_PATH')) {
    exit('Access denied');
}

/**
 * Z-Blog with PHP.
 *
 * @author  Z-BlogPHP Team
 * @version 1.0 2020-07-01
 */

/**
 * 用户登录接口.
 *
 * @return array
 */
function api_member_login()
{
    global $zbp;

    ApiCheckAuth(false, 'login');

    $member = null;

    $password = trim(GetVars('password', 'POST'));
    $verify_ret = false;
    if ((bool) preg_match("/^[a-z0-9]{32}$/", $password) === true) {
        // 如果格式是 md5，优先直接验证（只是大概猜测是 md5，不保证是，所以如果失败会在下面重新验）
        $verify_ret = $zbp->Verify_MD5(trim(GetVars('username', 'POST')), $password, $member);
    }
    if ($verify_ret === false) {
        // 如果直接验证失败，或者没有验证，再接着验证
        $verify_ret = $zbp->Verify_MD5(trim(GetVars('username', 'POST')), md5($password), $member);
    }

    if ($verify_ret) {
        $zbp->user = $member;
        $sd = (float) GetVars('savedate', 'POST');
        $sd = ($sd < 1) ? 1 : $sd;
        $sdt = (time() + 3600 * 24 * $sd);

        foreach ($GLOBALS['hooks']['Filter_Plugin_VerifyLogin_Succeed'] as $fpname => &$fpsignal) {
            $fpname();
        }

        $member_array = ApiGetObjectArray(
            $zbp->user,
            array('Url', 'Template', 'Avatar', 'StaticName'),
            array('Guid', 'Password', 'IP')
        );

        return array(
            'data' => array(
                'user' => $member_array,
                'token' => $zbp->GenerateApiToken($member, $sdt),
            ),
            'message' => $GLOBALS['lang']['msg']['operation_succeed'],<commit_msg>api 用户登录返回 expire_time<commit_after><?php

if (!defined('ZBP_PATH')) {
    exit('Access denied');
}

/**
 * Z-Blog with PHP.
 *
 * @author  Z-BlogPHP Team
 * @version 1.0 2020-07-01
 */

/**
 * 用户登录接口.
 *
 * @return array
 */
function api_member_login()
{
    global $zbp;

    ApiCheckAuth(false, 'login');

    $member = null;

    $password = trim(GetVars('password', 'POST'));
    $verify_ret = false;
    if ((bool) preg_match("/^[a-z0-9]{32}$/", $password) === true) {
        // 如果格式是 md5，优先直接验证（只是大概猜测是 md5，不保证是，所以如果失败会在下面重新验）
        $verify_ret = $zbp->Verify_MD5(trim(GetVars('username', 'POST')), $password, $member);
    }
    if ($verify_ret === false) {
        // 如果直接验证失败，或者没有验证，再接着验证
        $verify_ret = $zbp->Verify_MD5(trim(GetVars('username', 'POST')), md5($password), $member);
    }

    if ($verify_ret) {
        $zbp->user = $member;
        $sd = (float) GetVars('savedate', 'POST');
        $sd = ($sd < 1) ? 1 : $sd;
        $sdt = (time() + 3600 * 24 * $sd);

        foreach ($GLOBALS['hooks']['Filter_Plugin_VerifyLogin_Succeed'] as $fpname => &$fpsignal) {
            $fpname();
        }

        $member_array = ApiGetObjectArray(
            $zbp->user,
            array('Url', 'Template', 'Avatar', 'StaticName'),
            array('Guid', 'Password', 'IP')
        );

        return array(
            'data' => array(
                'user' => $member_array,
                'token' => $zbp->GenerateApiToken($member, $sdt),
                'expire_time' => $sdt,
            ),
            'message' => $GLOBALS['lang']['msg']['operation_succeed'],
{'fraction_non_alphanumeric': 0.19694072657743786, 'fraction_numerical': 0.017208413001912046, 'mean_word_length': 2.3898488120950323, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2099686', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1213, 'n_words': 197}