Ruzy

Members
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Ruzy

  • Rank
    Square
  • Birthday 11/09/1927

Details

  • Gang
    #MvP!
  • Location
    Netherlands

Recent Profile Visitors

452 profile views
  1. [2017-07-23 06:36:21] INFO: <br /> <b>Deprecated</b>: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br /> [{"status":"SUCCESS","connect_status":"SUCCESS","email":"****@gmail.com","name":"Ruzy","connect_id":1}]
  2. It's still comes up as parsing error. mta_sdk.php is installed too and this is the login.php code: <?php include 'mta_sdk.php'; $_SERVER['SCRIPT_FILENAME'] = __FILE__; $path = ''; require_once $path . 'init.php'; \IPS\Session\Front::i(); $input = mta::getInput(); $username = $input[0]['user']; $password = $input[0]['pass']; $member = \IPS\Member::load($username, 'name'); if( !$member->member_id ) { mta::doReturn( array( 'status' => 'FAILED', 'msg' => 'ACCOUNT_NOT_FOUND', ) ); exit; } $salt = $member->members_pass_salt; $hash = crypt($password, '$2a$13$' . $salt); if (\IPS\Login::compareHashes($member->members_pass_hash, $hash) === TRUE) { mta::doReturn( array( "status" => "SUCCESS", "connect_status" => ( $member->members_bitoptions['validating'] ) ? 'VALIDATING' : 'SUCCESS', "email" => $member->email, "name" => $member->name, "connect_id" => $member->member_id, ) ); } else { mta::doReturn( array( 'status' => 'FAILED', 'msg' => 'ACCOUNT_INVALID_PASSWORD', ) ); } ?>
  3. When i add this code it outputs: outputDebugString("PARSING ERROR @ "..getPlayerName(player)"'s login attempt.") Any idea how to fix this? function CPlayer:OnPlayerRequestLogin(data) if not (data[1] == "") then if not (data[2] == "") then fetchRemote("http://forums.link.com/login.php", function(response,errno,player) local response = fromJSON(response) if type(response) == "table" then if response.status == "SUCCESS" then DB:Query(function(res) if #res > 0 then -- login normal Core:Notificate(player, "You successfully logged in. Welcome back" ..data[1].."!", "success") self:InitiateLogin(0x118100F1) elseif #res == 0 then -- login new player self.accountName = data[1] self.uid = response.connect_id local date = getRealTime() --id,name,pw,alias,date,lastseen,playtime,countrycode,lang,team,teamlvl,permlvl,warns,sanction.mutetime DB:Exec("INSERT INTO `Accounts` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", self.uid, data[1], hash("sha256", data[2]), self.name, ("%s-%s-%s"):format(date.year+1900, date.month+1, date.monthday),("%s-%s-%s %s:%s:%s"):format(date.year+1900, date.month+1, date.monthday, date.hour, date.minute, date.second), 0, self:GetCountry(), "", 0, 1, 0, 0, 0) --id,money,exp,mapsdm,mapsdd,mapshunter,pointsdm,pointsdd,pointshunter DB:Exec("INSERT INTO `Players` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", self.uid, 0, 0, 0, 0, 0, 0, 0, 0) --id,chat,chat,chat,chat,carhide,carfade,drawhud,mapmusic DB:Exec("INSERT INTO `Settings` VALUES (?,1,1,1,1,0,1,1,1)", self.uid) --id,moneyspend,mapsbought,mapswon,pvpwon,spinwon,eventswon,timesjoined,dmdeaths,dmmaps,dmfinished,dmwins,dmtoptimes,ddkils,dddeaths,ddmaps,ddwins,ddwinstreak,hunterkills,hunterdeaths,hunterrockets,huntermaps,hunterwins,hunterwinstreak DB:Exec("INSERT INTO `PlayerStats` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", self.uid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) self:InitiateLogin(0x118100F1) Core:Notificate(player, "You successfully logged in. Welcome, "..data[1].." to vigour gaming!", "success") end end, "SELECT `ID` from `Accounts` WHERE `Accountname` = ?", data[1]) else if response.msg == "ACCOUNT_NOT_FOUND" then Core:Notificate(player, "Account not found!", "error") Core:Notificate(player, "Register yourself if you don't have an account", "info") triggerClientEvent(player, "URAL:Response", player, 404) elseif response.msg == "ACCOUNT_INVALID_PASSWORD" then Core:Notificate(player, "Wrong account password!", "error") triggerClientEvent(player, "URAL:Response", player, 401) else outputDebugString("UNRECOGNISED RESPONSE @ "..getPlayerName(player)"'s login attempt.") end end elseif response == "ERROR" then Core:Notificate(player, "Internal error. Please try again later. (Code "..errno..")", "error") outputDebugString("INTERNAL ERROR "..errno.." @ "..getPlayerName(player)"'s login attempt.") else outputDebugString("PARSING ERROR @ "..getPlayerName(player)"'s login attempt.") -- maybe the response was sent in a way other than a table, but its not an error either end end, toJSON({user=data[1], pass=data[2]}), false, source) else Core:Notificate(self.obj, "Enter your password!", "error") triggerClientEvent(self.obj, "URAL:Response", self.obj, 401) end else Core:Notificate(self.obj, "Enter your username!", "error") triggerClientEvent(self.obj, "URAL:Response", self.obj, 401) end end
  4. It didn't return it. That might be working too, gonna try it out.
  5. I tried using fetchRemote , but now getting a error that the username or password are invalid. Code: <?php $dbHost = "***"; $dbUser = "forum"; $dbPass = "***"; $dbDB = "forum"; $dbTable = "core_members"; $dbAccount = "name"; $input = json_decode(file_get_contents("php://input"), true); if(is_array($input)): $dbCon = new PDO(sprintf("mysql:dbname=%s;host=%s;cahrset=utf8", $dbDB, $dbHost), $dbUser, $dbPass); if($dbCon): try { $sql= "SELECT `member_id`, `member_group_id`, `members_pass_hash`, `members_pass_salt` FROM `".$dbTable."` WHERE `".$dbAccount."`= '?' LIMIT 1"; $stmt = $dbCon->prepare($sql); $stmt->execute(array($input[0])); $result = $stmt->fetch(PDO::FETCH_ASSOC); if (crypt($input[1], '$2a$13$' . $result["members_pass_salt"]) == $result["members_pass_hash"]): echo sprintf('[ [ "succes", %d, %d ] ]', $result["member_id"], $result["memer_group_id"]); else: echo '[ [ "invalid" ] ]'; endif; } catch(PDOException $e) { } endif; $dbCon = NULL; endif; ?> function PlayerLogin(strUsername, strPassword, checksave) if not (strUsername == "") then if not (Password == "") then triggerClientEvent(source,"showNotification",getRootElement(), "Loging In...", "information") fetchRemote("[link]", 10, CheckLoginCallback, ('["%s","%s"]'):format(strUsername, strPassword), false, source, strUsername, strPassword, checksave) else triggerClientEvent(source,"showNotification",getRootElement(), "Please enter your password!", "error") end else triggerClientEvent(source,"showNotification",getRootElement(), "Please enter your username!", "error") end end addEvent("playerWantToLogin",true) addEventHandler("playerWantToLogin",getRootElement(),PlayerLogin) function CheckLoginCallback(strResponseData, iError, uPlayer, strUsername, strPassword, checksave) if(not isElement(uPlayer)) then return; end if(strResponseData == "ERROR") then triggerClientEvent(uPlayer,"showNotification",getRootElement(), "Unable to Log In (Failed to contact Server) (Error: " .. iError .. ")", "error") return; end local tblResult = fromJSON(strResponseData); if(tblResult[1] == "invalid" or tblResult[1] == "system") then if(tblResult[1] == "invalid") then triggerClientEvent(uPlayer,"showNotification",getRootElement(), "Invalid username or password specified!", "error") else triggerClientEvent(uPlayer,"showNotification",getRootElement(), "Unable to Log In! (System " ..tblResult[2] .. ")", "error") end elseif(tblResult[1] == "succes") then if checksave == true then triggerClientEvent(uPlayer,"saveLoginToXML",getRootElement(),strUsername,strPassword) else triggerClientEvent(uPlayer,"resetSaveXML",getRootElement(),strUsername,strPassword) end setElementData(uPlayer,"getForumID",tblResult[2]) setElementData(uPlayer,"getForumName",strUsername) triggerClientEvent(uPlayer,"showNotification",getRootElement(), "Successfully logged in!", "success") triggerClientEvent(uPlayer,"loginHide",getRootElement()) end end
  6. How else should i set the source and get the userName then? i have tried many ways. because callremote is triggering another function it can't get the source, so i used callremote to return it
  7. The php is good, right? I used your php code as you can see. Edit: Also got a problem with the source!
  8. Ruzy

    Spawn Serial

    You have to add the resource to the admin group. Go to acl.xml and add the following line into the admin group. <object name="resource.clanpanel"></object> Change clanpanel to whatever your resource is called.
  9. Take a look here: https://forum.mtasa.com/viewtopic.php?f=91&p=850465
  10. php code: <?php // PHP include 'mta_sdk.php'; // Correct path if you use a different one $servername = "localhost"; // Change these details $username = "forum"; // Change these details $password = "*****"; // Change these details $dbname = "forum"; // Change these details $table = "mvp_core_members"; $accountColumn = "name"; // change to "email" if you prefer logging in through email $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { mta::doReturn(false, "Connection failed: " . mysqli_connect_error()); // Account not found #die("Connection failed: " . mysqli_connect_error()); } $input = mta::getInput(); if (isset($input[0]) && isset($input[1]) && isset($input[2]) && $input[0] == "verifyPasswords" ) { $sql = "SELECT `member_id`, `member_group_id`, `members_pass_salt`, `members_pass_hash` FROM `".$table."` WHERE `".$accountColumn."`='".strtolower($input[1])."' LIMIT 1"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_assoc($result); if (crypt($input[2], '$2a$13$' . $row['members_pass_salt']) == $row['members_pass_hash']) { mta::doReturn(true, 0, $row, $input[3], $input[1], $input[2]); // Password correct } else { mta::doReturn(false, 1, $row, $input[3]); // Passwords don't match } } else { mta::doReturn(false, 2, $row, $input[3]); // Account not found } } // Author: MrTasty ?>
  11. Already checked that, it returns nothing.
  12. Hello, I am currently working on my login script but i am getting stuck at a error that the account is false. Debug: WARNING: login_s.lua:15: Bad argument @ 'setAccountPassword' [Expected account at argument 1, got boolean] WARNING: login_s.lua:17: Bad argument @ 'isGuestAccount' [Expected account at argument 1, got boolean] WARNING: login_s.lua:20: Bad argument @ 'logIn' [Expected account at argument 2, got boolean] ERROR: login_s.lua:29: attempt to index global 'userIDs' (a nil value) Code: local userIDs = {}; function PlayerLogin(userName,Password,checksave) if not (userName == "") then userName = string.lower(userName) if not (password == "") then callRemote("http://*****/login.php", function(response,extra,data,player,userName,Password) triggerClientEvent(player,"showNotification",player, "Connecting..", "information") if response == true then local acc = getAccount(userName) if not acc then acc = addAccount(tostring(userName),tostring(Password)) end if not getAccount(userName,Password) then setAccountPassword(acc,Password) end if (not isGuestAccount(acc)) then logOut(player) end logIn (player, acc, Password) if checksave == true then triggerClientEvent(player,"saveLoginToXML",getRootElement(),userName,Password) else triggerClientEvent(player,"resetSaveXML",getRootElement(),userName,Password) end setElementData(player,"getForumID",data["member_id"]) setElementData(player,"getForumName",userName) userIDs[player] = data["member_id"]; triggerClientEvent(player,"loginHide",player) triggerClientEvent(player,"showNotification",player, "Successfully logged in!", "success") elseif extra == 1 then triggerClientEvent(player,"showNotification",player, "Wrong username!", "error") elseif extra == 2 then triggerClientEvent(player,"showNotification",player, "Wrong password!", "error") end end ,"verifyPasswords", userName, Password, source) else triggerClientEvent(source,"showNotification",source, "Please enter your password!", "error") end else triggerClientEvent(source,"showNotification",source, "Please enter your username!", "error") end end addEvent("playerWantToLogin",true) addEventHandler("playerWantToLogin",getRootElement(),PlayerLogin) Can someone help me with this? Regards, Ruzy
  13. Thanks for the information, is it needed to use PHP SDK for this? And it can be done with fetchRemote?