简体   繁体   English

输入类型提交登录错误

[英]Input type submit login error

Ok, so I have downloaded mibew messenger and I want to customize the buttons, so I go into login.php and the actual submit button for the login is type="image" so I changed to to type="submit" and when I submit the form I get a incorrect username/password error, anyway I was very confused so I was looking through loads of the other files to see if I can find anything that's related to the type="image" just in-case there's something that identifies the type="image" , well I dunno, I didn't find anything but what I did notice is that when I type in admin into the username and click login the submit button it returns the login error but also in the box where I put admin there is now the value of the type="submit" so in this case it says login because the value is value="login" , I'm really confused, I think maybe it is submitting "login" instead of "admin" as the username. 好的,所以我已经下载了mibew Messenger,我想自定义按钮,所以我进入login.php,登录的实际提交按钮为type="image"所以当我更改为type="submit"时,提交表单时,我得到了一个错误的用户名/密码错误,无论如何我都很困惑,所以我正在浏览其他文件的加载,以查看是否可以找到与type="image"相关的任何内容,以防万一标识type="image" ,我不知道,我什么也没找到,但是我注意到的是,当我在用户名中键入admin并单击login提交按钮时,它还会返回登录错误,而且在框中我把admin设置为type="submit"的值,因此在这种情况下它说的是login因为该值为value="login" ,我很困惑,我认为也许是在提交“ login”而不是“ admin”作为用户名。

Here is the before and after submit buttons: 这是提交之前和之后的按钮:

NEW

<input type="submit" name="login" value="login" >

ORIGINAL 原版的

<input type="image" name="login" src='<?php echo $webimroot.getlocal("image.button.login") ?>' alt='<?php echo getlocal("button.enter") ?>'/>

If i change it back to the original it works fine, but i want to use css not images. 如果我将其更改回原始版本,效果很好,但是我想使用CSS而不是图像。

Also, it would be quite hard to make a jsfiddle, otherwise i would have made one. 另外,制作jsfiddle会非常困难,否则我会制作一个。

This is login.php where is posts the data 这是login.php,在其中发布数据

require_once('../libs/common.php');
require_once('../libs/operator.php');

$errors = array();
$page = array('formisRemember' => true, 'version' => $version);

if (isset($_POST['login']) && isset($_POST['password'])) {
    $login = getparam('login');
    $password = getparam('password');
    $remember = isset($_POST['isRemember']) && $_POST['isRemember'] == "on";

    $operator = operator_by_login($login);
    if ($operator && isset($operator['vcpassword']) && $operator['vcpassword'] == md5($password)) {

        $target = isset($_SESSION['backpath'])
                ? $_SESSION['backpath']
                : "$root/agent/index.php";

        login_operator($operator, $remember);
        header("Location: $target");
        exit;
    } else {
        $errors[] = getlocal("page_login.error");
        $page['formlogin'] = $login;
    }
}

$page['localeLinks'] = get_locale_links("$root/agent/login.php");
start_html_output();
require('../display/login.php');

This is the included operator.php in login.php 这是login.php中包含的operator.php

$can_administrate = 0;
$can_takeover = 1;
$can_viewthreads = 2;
$can_modifyprofile = 3;

$can_count = 4;

$permission_ids = array(
    $can_administrate => "admin",
    $can_takeover => "takeover",
    $can_viewthreads => "viewthreads",
    $can_modifyprofile => "modifyprofile"
);

function operator_by_login($login)
{
    global $mysqlprefix;
    $link = connect();
    $operator = select_one_row(
        "select * from ${mysqlprefix}chatoperator where vclogin = '" . mysql_real_escape_string($login) . "'", $link);
    mysql_close($link);
    return $operator;
}

function operator_by_email($mail)
{
    global $mysqlprefix;
    $link = connect();
    $operator = select_one_row(
        "select * from ${mysqlprefix}chatoperator where vcemail = '" . mysql_real_escape_string($mail) . "'", $link);
    mysql_close($link);
    return $operator;
}

function operator_by_id_($id, $link)
{
    global $mysqlprefix;
    return select_one_row(
        "select * from ${mysqlprefix}chatoperator where operatorid = $id", $link);
}

function operator_by_id($id)
{
    $link = connect();
    $operator = operator_by_id_($id, $link);
    mysql_close($link);
    return $operator;
}

function operator_get_all()
{
    global $mysqlprefix;
    $link = connect();

    $query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
             "from ${mysqlprefix}chatoperator order by vclogin";
    $operators = select_multi_assoc($query, $link);
    mysql_close($link);
    return $operators;
}

function operator_is_online($operator)
{
    global $settings;
    return $operator['time'] < $settings['online_timeout'];
}

function operator_is_available($operator)
{
    global $settings;
    return $operator['istatus'] == 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
}

function operator_is_away($operator)
{
    global $settings;
    return $operator['istatus'] != 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
}

function update_operator($operatorid, $login, $email, $password, $localename, $commonname)
{
    global $mysqlprefix;
    $link = connect();
    $query = sprintf(
        "update ${mysqlprefix}chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'" .
        ", vcemail = '%s', vcjabbername= '%s'" .
        " where operatorid = %s",
        mysql_real_escape_string($login),
        ($password ? " vcpassword='" . md5($password) . "'," : ""),
        mysql_real_escape_string($localename),
        mysql_real_escape_string($commonname),
        mysql_real_escape_string($email),
        '',
        $operatorid);

    perform_query($query, $link);
    mysql_close($link);
}

function update_operator_avatar($operatorid, $avatar)
{
    global $mysqlprefix;
    $link = connect();
    $query = sprintf(
        "update ${mysqlprefix}chatoperator set vcavatar = '%s' where operatorid = %s",
        mysql_real_escape_string($avatar), $operatorid);

    perform_query($query, $link);
    mysql_close($link);
}

function create_operator_($login, $email, $password, $localename, $commonname, $avatar, $link)
{
    global $mysqlprefix;
    $query = sprintf(
        "insert into ${mysqlprefix}chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername) values ('%s','%s','%s','%s','%s','%s','%s')",
        mysql_real_escape_string($login),
        md5($password),
        mysql_real_escape_string($localename),
        mysql_real_escape_string($commonname),
        mysql_real_escape_string($avatar),
        mysql_real_escape_string($email), '');

    perform_query($query, $link);
    $id = mysql_insert_id($link);

    return select_one_row("select * from ${mysqlprefix}chatoperator where operatorid = $id", $link);
}

function create_operator($login, $email, $password, $localename, $commonname, $avatar)
{
    $link = connect();
    $newop = create_operator_($login, $email, $password, $localename, $commonname, $avatar, $link);
    mysql_close($link);
    return $newop;
}

function notify_operator_alive($operatorid, $istatus)
{
    global $mysqlprefix;
    $link = connect();
    perform_query("update ${mysqlprefix}chatoperator set istatus = $istatus, dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid", $link);
    mysql_close($link);
}

function has_online_operators($groupid = "")
{
    global $settings, $mysqlprefix;
    loadsettings();
    $link = connect();
    $query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from ${mysqlprefix}chatoperator";
    if ($groupid) {
        $query .= ", ${mysqlprefix}chatgroupoperator where groupid = $groupid and ${mysqlprefix}chatoperator.operatorid = ${mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
    } else {
        $query .= " where istatus = 0";
    }
    $row = select_one_row($query, $link);
    mysql_close($link);
    return $row['time'] < $settings['online_timeout'] && $row['total'] > 0;
}

function is_operator_online($operatorid, $link)
{
    global $settings, $mysqlprefix;
    loadsettings_($link);
    $query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
             "from ${mysqlprefix}chatoperator where operatorid = $operatorid";
    $row = select_one_row($query, $link);
    return $row['time'] < $settings['online_timeout'] && $row['total'] == 1;
}

function get_operator_name($operator)
{
    global $home_locale, $current_locale;
    if ($home_locale == $current_locale)
        return $operator['vclocalename'];
    else
        return $operator['vccommonname'];
}

function append_query($link, $pv)
{
    $infix = '?';
    if (strstr($link, $infix) !== FALSE)
        $infix = '&amp;';
    return "$link$infix$pv";
}

function check_login($redirect = true)
{
    global $root, $mysqlprefix;
    if (!isset($_SESSION["${mysqlprefix}operator"])) {
        if (isset($_COOKIE['webim_lite'])) {
            list($login, $pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2);
            $op = operator_by_login($login);
            if ($op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd) {
                $_SESSION["${mysqlprefix}operator"] = $op;
                return $op;
            }
        }
        $requested = $_SERVER['PHP_SELF'];
        if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
            $requested .= "?" . $_SERVER['QUERY_STRING'];
        }
        if ($redirect) {
            $_SESSION['backpath'] = $requested;
            header("Location: $root/agent/login.php");
            exit;
        } else {
            return null;
        }
    }
    return $_SESSION["${mysqlprefix}operator"];
}

function get_logged_in()
{
    global $mysqlprefix;
    return isset($_SESSION["${mysqlprefix}operator"]) ? $_SESSION["${mysqlprefix}operator"] : FALSE;
}

function login_operator($operator, $remember)
{
    global $root, $mysqlprefix;
    $_SESSION["${mysqlprefix}operator"] = $operator;
    if ($remember) {
        $value = $operator['vclogin'] . "," . md5($operator['vcpassword']);
        setcookie('webim_lite', $value, time() + 60 * 60 * 24 * 1000, "$root/");

    } else if (isset($_COOKIE['webim_lite'])) {
        setcookie('webim_lite', '', time() - 3600, "$root/");
    }
}

function logout_operator()
{
    global $root, $mysqlprefix;
    unset($_SESSION["${mysqlprefix}operator"]);
    unset($_SESSION['backpath']);
    if (isset($_COOKIE['webim_lite'])) {
        setcookie('webim_lite', '', time() - 3600, "$root/");
    }
}

function setup_redirect_links($threadid, $token)
{
    global $page, $root, $settings, $mysqlprefix;
    loadsettings();
    $link = connect();

    $operatorscount = db_rows_count("${mysqlprefix}chatoperator", array(), "", $link);

    $groupscount = 0;
    $groups = array();
    if ($settings['enablegroups'] == "1") {
        foreach (get_groups($link, true) as $group) {
            if ($group['inumofagents'] == 0) {
                continue;
            }
            $groups[] = $group;
        }
        $groupscount = count($groups);
    }

    prepare_pagination(max($operatorscount, $groupscount), 8);
    $p = $page['pagination'];
    $limit = $p['limit'];

    $operators = select_multi_assoc(db_build_select(
                                        "operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time",
                                        "${mysqlprefix}chatoperator", array(), "order by vclogin $limit"), $link);

    $groups = array_slice($groups, $p['start'], $p['end'] - $p['start']);
    mysql_close($link);

    $agent_list = "";
    $params = array('thread' => $threadid, 'token' => $token);
    foreach ($operators as $agent) {
        $params['nextAgent'] = $agent['operatorid'];
        $status = $agent['time'] < $settings['online_timeout']
                ? ($agent['istatus'] == 0
                        ? getlocal("char.redirect.operator.online_suff")
                        : getlocal("char.redirect.operator.away_suff")
                )
                : "";
        $agent_list .= "<li><a href=\"" . add_params($root . "/agent/redirect.php", $params) .
                       "\" title=\"" . topage(get_operator_name($agent)) . "\">" .
                       topage(get_operator_name($agent)) .
                       "</a> $status</li>";
    }
    $page['redirectToAgent'] = $agent_list;

    $group_list = "";
    if ($settings['enablegroups'] == "1") {
        $params = array('thread' => $threadid, 'token' => $token);
        foreach ($groups as $group) {
            $params['nextGroup'] = $group['groupid'];
            $status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout']
                    ? getlocal("char.redirect.operator.online_suff")
                    : ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout']
                            ? getlocal("char.redirect.operator.away_suff")
                            : "");
            $group_list .= "<li><a href=\"" . add_params($root . "/agent/redirect.php", $params) .
                           "\" title=\"" . topage(get_group_name($group)) . "\">" .
                           topage(get_group_name($group)) .
                           "</a> $status</li>";
        }
    }
    $page['redirectToGroup'] = $group_list;
}

$permission_list = array();

function get_permission_list()
{
    global $permission_list, $permission_ids;
    if (count($permission_list) == 0) {
        foreach ($permission_ids as $permid) {
            $permission_list[] = array(
                'id' => $permid,
                'descr' => getlocal("permission.$permid")
            );
        }
    }
    return $permission_list;
}

function is_capable($perm, $operator)
{
    $permissions = $operator && isset($operator['iperm']) ? $operator['iperm'] : 0;
    return $perm >= 0 && $perm < 32 && ($permissions & (1 << $perm)) != 0;
}

function prepare_menu($operator, $hasright = true)
{
    global $page, $settings, $can_administrate;
    $page['operator'] = topage(get_operator_name($operator));
    if ($hasright) {
        loadsettings();
        $page['showban'] = $settings['enableban'] == "1";
        $page['showgroups'] = $settings['enablegroups'] == "1";
        $page['showstat'] = $settings['enablestatistics'] == "1";
        $page['showadmin'] = is_capable($can_administrate, $operator);
        $page['currentopid'] = $operator['operatorid'];
    }
}

function get_all_groups($link)
{
    global $mysqlprefix;
    $query = "select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname, vclocaldescription from ${mysqlprefix}chatgroup order by vclocalname";
    return select_multi_assoc($query, $link);
}

function get_groups($link, $checkaway)
{
    global $mysqlprefix;
    $query = "select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname, vclocaldescription" .
             ", (SELECT count(*) from ${mysqlprefix}chatgroupoperator where ${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid) as inumofagents" .
             ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
             "from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus = 0 and ${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid " .
             "and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseen" .
             ($checkaway
                     ? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
                       "from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus <> 0 and ${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid " .
                       "and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseenaway"
                     : ""
             ) .
             " from ${mysqlprefix}chatgroup order by vclocalname";
    return select_multi_assoc($query, $link);
}

function get_operator_groupids($operatorid)
{
    global $mysqlprefix;
    $link = connect();
    $query = "select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid";
    $result = select_multi_assoc($query, $link);
    mysql_close($link);
    return $result;
}

And it wont let me add any more code if you need common.php let me know 如果您需要common.php,它不会让我添加更多代码。

Without seeing your PHP it's hard to tell, but it could be that image submits "login" as POST/GET variable value array(x, y), where the submit type will just a string value. 没有看到您的PHP很难说,但是可能是图像以POST / GET变量值array(x,y)的形式提交“登录”,其中的提交类型只是一个字符串值。 If you are checking the submission based on that value, you will need to make some changes. 如果您基于该值检查提交,则需要进行一些更改。

EDIT: 编辑:

Looking at your code, it looks like you might be using 'login' as the username and the submit button. 查看您的代码,看来您可能正在使用“登录”作为用户名和提交按钮。 Try changing the submit button name to something else. 尝试将提交按钮名称更改为其他名称。

<input type="submit" name="loginButton" value="login" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM