Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2019-03-20, 18:49


okupski2000







Wiek: 42
Na forum: 3997 dni
Posty: 21
Nick w MP: Volvo



Respekt: 50

Cze??, wgra?em sobie paczk? OWL i przy pr?bie zarejestrowania mam "Sending request to server". Wszystko mam dobrze pod??czone, w razie czego dam skrypt (has?a wygwiazdkowane)

P.S. Modu?y wgrane

connection.lua


-- connection settings
local hostname "87.98.236.134"
local username ="db_41935"
local password =  "*****************"
local database "db_41935"
local port =  3306

-- global things.
local MySQLConnection nil
local resultPool = { }
local sqllog false
local countqueries 0

-- connectToDatabase Internal function, to spawn a DB connection
function connectToDatabase(res)
    MySQLConnection mysql_connect(hostnameusernamepassworddatabaseport)
    
    if (not MySQLConnectionthen
        if (res == getThisResource()) then
            cancelEvent(true"Cannot connect to the database.")
        end
        return nil
    end
    
    return nil
end
addEventHandler("onResourceStart"getResourceRootElement(getThisResource()), connectToDatabasefalse)
    
-- destroyDatabaseConnection Internal function, kill the connection if theres one.
function destroyDatabaseConnection()
    if (not MySQLConnectionthen
        return nil
    end
    mysql_close(MySQLConnection)
    return nil
end
addEventHandler("onResourceStop"getResourceRootElement(getThisResource()), destroyDatabaseConnectionfalse)

-- do something usefull here
function logSQLError(str)
    local message str or 'N/A'
    outputDebugString("MYSQL ERROR "..mysql_errno(MySQLConnection) .. ": " .. mysql_error(MySQLConnection))
    exports['logs']:logMessage("MYSQL ERROR :O! [QUERY] " .. message .. " [ERROR] " .. mysql_errno(MySQLConnection) .. ": " .. mysql_error(MySQLConnection), 24)
end

function getFreeResultPoolID()
    local size #resultPool
    if (size == 0then
        return 1 
    end
    for indexquery in ipairs(resultPool) do
        if (query == nilthen
            return index
        end
    end
    return (size 1)
end

------------ EXPORTED FUNCTIONS ---------------

function ping()
    if (mysql_ping(MySQLConnection) == falsethen
        -- FUUNO MOAR CONNECTION
        destroyDatabaseConnection()
        connectToDatabase(nil)
        if (mysql_ping(MySQLConnection) == falsethen
            logSQLError()
            return false
        end
        return true
    end

    return true
end

function escape_string(str)
    if (ping()) then
        return mysql_escape_string(MySQLConnectionstr)
    end
    return false
end

function query(str)
    if sqllog then
        exports['logs']:logMessage(str24)
    end
    countqueries countqueries 1
    
    if (ping()) then
        local result mysql_query(MySQLConnectionstr)
        if (not resultthen
            logSQLError(str)
            return false
        end

        local resultid getFreeResultPoolID()
        resultPool[resultid] = result
        return resultid
    end
    return false
end

function unbuffered_query(str)
    if sqllog then
        exports['logs']:logMessage(str24)
    end
    countqueries countqueries 1
    
    if (ping()) then
        local result mysql_unbuffered_query(MySQLConnectionstr)
        if (not resultthen
            logSQLError(str)
            return false
        end

        local resultid getFreeResultPoolID()
        resultPool[resultid] = result
        return resultid
    end
    return false
end

function query_free(str)
    local queryresult query(str)
    if  not (queryresult == falsethen
        free_result(queryresult)
        return true
    end
    return false
end

function rows_assoc(resultid)
    if (not resultPool[resultid]) then
        return false
    end
    return mysql_rows_assoc(resultPool[resultid])
end

function fetch_assoc(resultid)
    if (not resultPool[resultid]) then
        return false
    end
    return mysql_fetch_assoc(resultPool[resultid])
end

function free_result(resultid)
    if (not resultPool[resultid]) then
        return false
    end
    mysql_free_result(resultPool[resultid])
    table.remove(resultPoolresultid)
    return nil
end

-- incase a nub wants to use itFINE
function result(resultidrow_offsetfield_offset)
    if (not resultPool[resultid]) then
        return false
    end
    return mysql_result(resultPool[resultid], row_offsetfield_offset)
end

function num_rows(resultid)
    if (not resultPool[resultid]) then
        return false
    end
    return mysql_num_rows(resultPool[resultid])
    
end

function insert_id()
    return mysql_insert_id(MySQLConnection) or false
end

function query_fetch_assoc(str)
    local queryresult query(str)
    if  not (queryresult == falsethen
        local result fetch_assoc(queryresult)
        free_result(queryresult)
        return result
    end
    return false
end

function query_rows_assoc(str)
    local queryresult query(str)
    if  not (queryresult == falsethen
        local result rows_assoc(queryresult)
        free_result(queryresult)
        return result
    end
    return false
end

function query_insert_free(str)
    local queryresult query(str)
    if  not (queryresult == falsethen
        local result insert_id()
        free_result(queryresult)
        return result
    end
    return false
end

function escape_string(str)
    return mysql_escape_string(MySQLConnectionstr)
end

function debugMode()
    if (sqllogthen
        sqllog false
    else
        sqllog true
    end
    return sqllog
end

function returnQueryStats()
    return countqueries
    -- maybe later more
end


s.mysql


username "db_41935"
password "***************"
db "db_41935"
host "87.98.236.134"
port =  3306

function getMySQLUsername()
    return username
end

function getMySQLPassword()
    return password
end

function getMySQLDBName()
    return db
end

function getMySQLHost()
    return host
end

function getMySQLPort()
    return port
end


[ Dodano: 2019-03-20, 19:12 ]
Jedyne dwa b??dy wyskakuj?ce w konsoli odno?nie mysql

[19-03-20 19:10] ERROR: mysql/connection.lua:62: attempt to call global 'mysql_ping' (a nil value)
[19-03-20 19:10] ERROR: help/commands/help_s.lua:6: call: failed to call 'mysql:query' [string "?"]

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-20, 19:27


mlodasnygo







Wiek: 16
Na forum: 3972 dni
Posty: 205

Piwa: 518

Respekt: 161,8
Respekt: 161,8Respekt: 161,8

Skrypt u?ywa przestarza?ych funkcji mysql zamie? je na te nowe dbConnect itd, itp.
lub u?yj modu?u https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-20, 19:43


okupski2000







Wiek: 42
Na forum: 3997 dni
Posty: 21
Nick w MP: Volvo



Respekt: 50

"mlodasnygo" napisał/a:

Skrypt u?ywa przestarza?ych funkcji mysql zamie? je na te nowe dbConnect itd, itp.
lub u?yj modu?u https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL


Co? takiego?


function connect()
    DBConnection dbConnect"mysql""dbname=DBNAME;host=HOST;charset=utf8""USERNAME""PASSWORD" )
    if (not DBConnectionthen
        outputDebugString("Error: Failed to establish connection to the MySQL database server")
    else
        outputDebugString("Success: Connected to the MySQL database server")
    end
end

addEventHandler("onResourceStart",resourceRootconnect)
 
function query(...)
    local queryHandle dbQuery(DBConnection, ...)
    if (not queryHandlethen
        return nil
    end
    local rows dbPoll(queryHandle, -1)
    return rows
end
 
function execute(...)
    local queryHandle dbQuery(DBConnection, ...)
    local resultnumRows dbPoll(queryHandle, -1)
    return numRows
end

function getDBConnection()
    return DBConnection
end


[ Dodano: 2019-03-20, 21:11 ]
Ogarnialem co nieco.

Tak teraz wyglada plik connection
https://pastebin.com/QLYn52Vx

Tak teraz wyglada plik s_mysql
https://pastebin.com/aeiWy18U





Zmienilem mety

Oryginal: https://pastebin.com/bNZA5Psm
Zmienione: https://pastebin.com/vRJzV0n8


P.S. Sorry, ?e w ten sposob, ale mi blokuje strona wrzucenie normalnego posta

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-20, 22:00


mlodasnygo







Wiek: 16
Na forum: 3972 dni
Posty: 205

Piwa: 518

Respekt: 161,8
Respekt: 161,8Respekt: 161,8

Rzuci?em na to szybko okiem, wygl?da ok, sprawd? kod w grze.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-03-21, 13:57


okupski2000







Wiek: 42
Na forum: 3997 dni
Posty: 21
Nick w MP: Volvo



Respekt: 50

Zaraz po klikni?ciu "SUBMIT" sprawdzi?em czy nie ma ?adnych b??d?w w konsoli i jest jeden

[19-03-21 13] ERROR: account/login-panel/server.lua:215: attempt to concatenate a nil value


--MAXIME 2014.12.29
local mysql exports.mysql
local accountCharacters = {}
function validateCredentials(username,password,checksave)
    if not (username == ""then
        if not (password == ""then
            if checksave == true then
                triggerClientEvent(client,"saveLoginToXML",client,username,password)
            else
                triggerClientEvent(client,"resetSaveXML",client,username,password)
            end
            return true
        else
            triggerClientEvent(client,"set_warning_text",client,"Login","Please enter your password!")
        end
    else
        triggerClientEvent(client,"set_warning_text",client,"Login","Please enter your username!")
    end
    return false
end
addEvent("onRequestLogin",true)
addEventHandler("onRequestLogin",getRootElement(),validateCredentials)

function playerLogin(username,password,checksave)
    local encryptionRuleDataencryptionRuleQueryaccountCheckQuerypreparedQueryaccountData,newAccountHash,safeusername,safepassword nil

    if not validateCredentials(username,password,checksavethen
        return false
    end

    --Get Encyption Rule for user.
    preparedQuery "SELECT * FROM `accounts` WHERE `username`='".. mysql:escape_string(username) .."'"
    encryptionRuleQuery mysql:query(preparedQuery)
    if encryptionRuleQuery then
        --triggerClientEvent(client,"set_authen_text",client,"Login","Retrieving encryption rule for username '".. username  .."'..")
    else
        triggerClientEvent(client,"set_warning_text",client,"Login","Failed to connect to game server. Database error!")
        return false
    end

    if (mysql:num_rows(encryptionRuleQuery) > 0then
        --triggerClientEvent(client,"set_authen_text",client,"Login","Encryption rule successfully retrieved!")
    else
        triggerClientEvent(client,"set_warning_text",client,"Login","Account name '".. username .."' doesn't exist!")
        return false
    end
    accountData mysql:fetch_assoc(encryptionRuleQuery)
    mysql:free_result(encryptionRuleQuery)

    -- Check if the account is banned
    if exports.bans:checkAccountBan(accountData["id"]) then
        triggerClientEvent(client,"set_warning_text",client,"Login","Account is banned. Appeal at www.owlgaming.net")
        return false
    end

    --Now check if passwords are matched or the account is activatedthis is to prevent user with fake emails.
    triggerClientEvent(client,"set_authen_text",client,"Login","Password Accepted! Authenticating..")
    local encryptionRule accountData["salt"]
    local encryptedPW string.lower(md5(string.lower(md5(password))..encryptionRule))

    if accountData["password"] ~= encryptedPW then
        triggerClientEvent(client,"set_warning_text",client,"Login","Password is incorrect for account name '".. username .."'!")
        return false
    end

    if accountData["activated"] == "0" then
        triggerClientEvent(client,"set_warning_text",client,"Login","Account '".. username .."' is not activated.")
        return false
    end

    --Validation is donefetching some more details
    triggerClientEvent(client,"set_authen_text",client,"Login","Account authenticated! Logging in..")

    -- Check the account is already logged in
    local found false
    for _thePlayer in ipairs(exports.pool:getPoolElementsByType("player")) do
        local playerAccountID tonumber(getElementData(thePlayer"account:id"))
        if (playerAccountIDthen
            if (playerAccountID == tonumber(accountData["id"])) and (thePlayer ~= clientthen
                kickPlayer(thePlayerthePlayer"Someone else has logged into your account.")
                triggerClientEvent(client,"set_authen_text",client,"Login","Account is currently online. Disconnecting other user..")
                break
            end
        end
    end


    -----------------------------------------------------------------------START THE MAGIC-----------------------------------------------------------------------------------
    triggerClientEvent(client"items:inventory:hideinv"client)

    -- Start the magic
    setElementDataEx(client"account:loggedin"truetrue)
    setElementDataEx(client"account:id"tonumber(accountData["id"]), true)
    setElementDataEx(client"account:username"accountData["username"], true)
    setElementDataEx(client"electionsvoted"accountData["electionsvoted"], true)

    --STAFF PERMISSIONS MAXIME
    setElementDataEx(client"admin_level"tonumber(accountData['admin']), true)
    setElementDataEx(client"supporter_level"tonumber(accountData['supporter']), true)
    setElementDataEx(client"vct_level"tonumber(accountData['vct']), true)
    setElementDataEx(client"mapper_level"tonumber(accountData['mapper']), true)
    setElementDataEx(client"scripter_level"tonumber(accountData['scripter']), true)

    exports['report-system']:reportLazyFix(client)

    setElementDataEx(client"adminreports"tonumber(accountData["adminreports"]), true)
    setElementDataEx(client"adminreports_saved"tonumber(accountData["adminreports_saved"]))

    if tonumber(accountData['referrer']) and tonumber(accountData['referrer']) > 0 then
        setElementDataEx(client"referrer"tonumber(accountData['referrer']), falsetrue)
    end

    if exports.integration:isPlayerLeadAdmin(clientthen
        setElementDataEx(client"hiddenadmin"accountData["hiddenadmin"], true)
    else
        setElementDataEx(client"hiddenadmin"0true)
    end
    --fetchRemote "https://forums.owlgaming.net/image.php?u=" .. tonumber(accountData["id"]) .. "&type=thumb"myCallback""falseaccountData["id"] )
    --[[
    --ADMINS
    local staffDuty tonumber(accountData["duty_admin"]) or 0
    if exports.integration:isPlayerTrialAdmin(clientthen
        setElementDataEx(client"duty_admin"staffDuty true)
        setElementDataEx(client"wrn:style"tonumber(accountData["warn_style"]), true)
    end

    --GMs
    if exports.integration:isPlayerSupporter(clientthen --GMs
        setElementDataEx(client"duty_supporter"staffDuty true)
    end
    ]]

    --MAXIME VEHICLECONSULTATIONTEAM 18.02.14
    local vehicleConsultationTeam exports.integration:isPlayerVehicleConsultant(client)
    setElementDataEx(client"vehicleConsultationTeam"vehicleConsultationTeamfalse)

    if  tonumber(accountData["adminjail"]) == 1 then
        setElementDataEx(client"adminjailed"truetrue)
    else
        setElementDataEx(client"adminjailed"falsetrue)
    end
    setElementDataEx(client"jailtime"tonumber(accountData["adminjail_time"]), true)
    setElementDataEx(client"jailadmin"accountData["adminjail_by"], true)
    setElementDataEx(client"jailreason"accountData["adminjail_reason"], true)

    if accountData["monitored"] ~= "" then
        setElementDataEx(client"admin:monitor"accountData["monitored"], true)
    end

    exports.logs:dbLog("ac"..tostring(accountData["id"]), 27"ac"..tostring(accountData["id"]), "Connected from "..getPlayerIP(client) .. " - "..getPlayerSerial(client) )
    mysql:query_free("UPDATE `accounts` SET `ip`='" .. mysql:escape_string(getPlayerIP(client)) .. "', `mtaserial`='" .. mysql:escape_string(getPlayerSerial(client)) .. "' WHERE `id`='".. mysql:escape_string(tostring(accountData["id"])) .."'")

    --[[
    local dataTable = { }
    table.insert(dataTable, { "account:characters"characterListclient ) } )
    accountCharacters[tonumber(accountData["id"])] = dataTable
    ]]

    setElementDataEx(client"jailreason"accountData["adminjail_reason"], true)
    
    triggerEvent("updateCharacters"client)

    exports.donators:loadAllPerks(client)
    local togNewsPerktogNewsStatus exports.donators:hasPlayerPerk(client3)
    if (togNewsPerkthen
        setElementDataEx(client"tognews"tonumber(togNewsStatus), falsetrue)
    end

    --SETTINGS MAXIME
    loadAccountSettings(clientaccountData["id"])

    -- Check if player passed application
    --outputDebugString(type(accountData["appreason"]))
    if tonumber(accountData["appstate"]) < 3 then
        if exports.integration:isPlayerTrialAdmin(client) or exports.integration:isPlayerSupporter(clientthen
            exports.mysql:query_free("UPDATE `accounts` SET `appstate`='3', `appreason`=NULL WHERE `id`='"..accountData["id"].."' ")
        else
            triggerClientEvent(client,"account:showRules",clienttonumber(accountData["appstate"]) )
            return false
        end
    end

    triggerClientEvent(client"vehicle_rims"client)
    triggerClientEvent(client"accounts:login:attempt"client)
    triggerEvent"social:account"clienttonumberaccountData.id ) )
    triggerClientEvent (client,"hideLoginWindow",client)
end
addEvent("accounts:login:attempt",true)
addEventHandler("accounts:login:attempt",getRootElement(),playerLogin)

function myCallbackresponseDataerrnoid )
    if errno == 0 then
        --Cache it
        exports.cache:addImage(idresponseData)
    end
end

function playerFinishApps()
    if source then
        client source
    end
    local index getElementData(client"account:id")
    triggerClientEvent(client"accounts:login:attempt"client0)--, accountCharacters[index] )
    triggerEvent"social:account"clientindex )
    triggerClientEvent (client,"hideLoginWindow",client)
    triggerClientEvent (client,"apps:destroyGUIPart3",client)
    --accountCharacters[index] = nil
end
addEvent("accounts:playerFinishApps",true)
addEventHandler("accounts:playerFinishApps",getRootElement(),playerFinishApps)

--local lastClient nil
function playerRegister(username,password,confirmPasswordemail)
    --CHECK FOR EXISTANCE OF USERNAME AND EMAIL ADDRESS MAXIME
    local preparedQuery1 "SELECT `id` FROM `accounts` WHERE `username`='".. mysql:escape_string(username) .."' OR `email`='".. mysql:escape_string(email) .."' "  ----------------- LINIJKA 215
    local Q1 mysql:query(preparedQuery1)
    if not Q1 then
        triggerClientEvent(client,"set_warning_text",client,"Register","Error code 0002 occurred.")
        return false
    end

    if (mysql:num_rows(Q1) > 0then
        triggerClientEvent(client,"set_warning_text",client,"Register","Username or email existed.")
        mysql:free_result(Q1)
        return false
    end

    --CHECK FOR EXISTANCE OF MTA SERIAL TO ENCOUNTER MULTIPLE ACCOUNTS PER USER MAXIME.
    local mtaSerial getPlayerSerial(client)
    local preparedQuery2 "SELECT `mtaserial`, `username`, `id` FROM `accounts` WHERE `mtaserial`='".. toSQL(mtaSerial) .."' LIMIT 1"
    local Q2 mysql:query(preparedQuery2)
    if not Q2 then
        triggerClientEvent(client,"set_warning_text",client,"Register","Error code 0003 occurred.")
        return false
    end

    local usernameExisted mysql:fetch_assoc(Q2)
    if (mysql:num_rows(Q2) > 0) and usernameExisted["id"] ~= "1" then
        triggerClientEvent(client,"set_warning_text",client,"Register","Multiple Accounts is not allowed (Existed: "..tostring(usernameExisted["username"])..")")
        return false
    end
    mysql:free_result(Q2)

    --START CREATING ACCOUNT.
    local encryptionRule tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))..tostring(math.random(0,9))
    local encryptedPW string.lower(md5(string.lower(md5(password))..encryptionRule))
    local ipAddress getPlayerIP(client)
    preparedQuery3 "INSERT INTO `accounts` SET `username`='"..toSQL(username).."', `password`='"..toSQL(encryptedPW).."', `email`='"..toSQL(email).."', `registerdate`=NOW(), `ip`='"..toSQL(ipAddress).."', `salt`='"..toSQL(encryptionRule).."', `mtaserial`='"..mtaSerial.."', `activated`='1' "
    local id mysql:query_insert_free(preparedQuery3)
    if id and tonumber(idthen
        triggerClientEvent(client,"accounts:register:complete",clientusernamepassword)
        return true
    else
        triggerClientEvent(client,"set_warning_text",client,"Register","Could not create new account.")
        return false
    end
    --[[
    local token exports.usercontrolpanel:makeToken(id"INGAME_ACC_REGISTRATION")
    lastClient client
    callRemote"http://www.owlgaming.net/mta/functions.php", function(error)
        outputDebugString(tostring(error))
        if error == "ok" then
            triggerClientEvent(lastClient,"accounts:register:complete",lastClientusernamepassword)
            return true
        else
            if error == nil or error == "ERROR" then --In case webserver is not available.
                --mysql:query_free("UPDATE accounts SET activated=1 WHERE id='"..id.."'")
                --triggerClientEvent(lastClient,"accounts:register:complete",lastClient"Account has been created and activated.")
                return true
            else
                triggerClientEvent(lastClient,"set_warning_text",lastClient,"Register",error)
                return false
            end
        end
    endtokenidusernameemail)
    --]]

end
addEvent("accounts:register:attempt",true)
addEventHandler("accounts:register:attempt",getRootElement(),playerRegister)

function toSQL(stuff)
    return mysql:escape_string(stuff)
end


P.S. Zaznaczy?em, kt?ra to linijka 215 :)

[ Dodano: 2019-03-22, 14:48 ]
Ktos jest w stanie pomoc?

[ Dodano: 2019-03-25, 18:21 ]
Jest kto? w stanie pomoc? :/

Postaw piwo autorowi tego posta
 

 
Tagi: sending :: request :: server :: owl
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Sending request to server - OWL Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku