Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3229688
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:50:23+00:00 2026-05-17T16:50:23+00:00

For come reason my login does not work I am using PHP and JavaScript

  • 0

For come reason my login does not work I am using PHP and JavaScript to do so.

PHP:

$users = sql("SELECT * FROM USERS WHERE SITE_ID='${CONFIG["ID"]}'");
if($_REQUEST["logindata"]){
    $logindata = $_REQUEST["logindata"];
    $now = array_shift(explode(" ",microtime()));
    if($_REQUEST["time"] < strtotime("+10 sec",$now) && $_REQUEST["time"] > strtotime("-10 sec",$now))
        exit(json_encode(array("TYPE"=>"FUNCTION","FUNCTION"=>"(\$login.failed(\"Time out for this request.. (Go away bots)\"))")));
    foreach($users as $user){
        if(hash_hmac("sha1",$user["LOGIN_SALT"],hash_hmac("sha1",$_SERVER["REMOTE_ADDR"],$_REQUEST["time"])) == $logindata){
            $_SESSION = $user;
            $_SESSION["ACTIVE_IP"] = $IP;
            sql("UPDATE USERS SET ACTIVE_IP='${IP}' WHERE LOGIN_SALT='${user["LOGIN_SALT"]}'",0);
            $result = json_encode(array("TYPE"=>"FUNCTION","FUNCTION"=>"(\$login.success())"));
        }
    }
    !$result ? $result = json_encode(array("TYPE"=>"FUNCTION","FUNCTION"=>"(\$login.failed())")) : void;
}

JavaScript:

    login: (function () {
        $("#ajax_loading").fadeIn("fast");
        $("[type=submit]").fadeOut("fast");
        $tmp.time = "" + (new Date()).valueOf();
        return $functions.request({
            type: "plugin",
            plugin: "login",
            time: $tmp.time,
            logindata: $.sha1($.sha1($.sha1($("#username").val(),$("#password").val()),$client.domain),$.sha1($client.IP,$tmp.time))
        });
    }),

The $.sha1 function, if one string is given it is a sha1 of it and if two it will give a hmac_sha1 result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:50:23+00:00Added an answer on May 17, 2026 at 4:50 pm

    First of all: take a look at the times and compare them.

    (new Date()).valueOf();
    

    -will give you microseconds, while

    array_pop(explode(" ",microtime()));
    

    -will return only the seconds.
    So your comparison will never match.

    But at all it’s no good idea to compare client-time and the serversided time, because you assume, that both have the same correct time set, and are located in the same timezone.

    If you really like to do that comparision, provide a serverside timestamp to javascript at the begin, and add before submitting the seconds elapsed to that timestamp and use this as $tmp.time

    However you will do it, things like time, domain or IP are almost useless if you send them, while they are not reliable and can be faked very easy.

    What else: you better use hashes that your DBMS can handle on it’s own, so you can fetch the 1 user you like to find directly with the Query and dont have to loop through all users

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I come into ASP.NET from php so the reason why i ask my question
I've come across a problem with modifying XML within SQL Server that doesn't seem
After reading around, I've realized that SQL ( MySQL in my case ) does
I have read somewhere that the C++ standard does not allow something like enum
Since where I work force me to use stored procedures and I haven't been
1) Where does the homepage of your website fit into controllers? I've seen some
Just started working with the Zend Framework Zf Tool and I've already come across
Does Mathematica support hidden line removal for wire frame images? If this isn't the
Note This is not a question about how to implement or emulate duck typing
I think there is something that I'm just not yet getting about how these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.