- 1,748
- Posts
- 15
- Years
- Age 28
- Nearby my feet.
- Seen Apr 18, 2021
Dang, I was meaning to release this on monday...
Anyways it's an easy way to use MySQL.
also you must download this too: "image removed"
IF YOU DON'T KNOW WHAT A PHP FILE IS OR HOW TO USE A PHP FILE DON'T USE IT!
Anyways it's an easy way to use MySQL.
Code:
=begin
* PHP SQL
* By Hansiec
* Allows connection to mysql via PHP
* Example:
$sql = MySql.new("php script url")
sql=$sql.query("SELECT * FROM `$base`.`table`")
print $sql.get_data(sql, "test", $sql.size(sql, "test")-1)
* The following example will print out the last index of test from the given
query.
* Yes I do know this breaks from traditional sql connections but in this case
it is slightly more easier to handle : D
* Features:
~ Allows you to connect to databases without any difficulty at all
~ Easily retrieve data from your queries by using the get_data function
~ No Harm done when your RGSSAD is cracked (see the warning concerning this)
* Warnings:
~ If your game is cracked, your database is as good as cracked even though
they don't have the password (as they can still query using the url)
although there are a few simple tricks to stop those who cannot script
from by passing this.
* Tricks:
You can also do a VERY simple checks against hacks in a few ways:
~ Below the comment end line put this: exit if $DEBUG
This will prevent the game from loading in debug mode.
~ in the function initialize (below the line: @database = d) put down:
@database = "" if $DEBUG
This will prevent the url from being used.
~ same as the first trick except replace the if $DEBUG with:
if !FileTest.exist?("Game.rgssad")
This will prevent the game from being loaded if there is no rgssad.
NOTE: This is a very small amount of methods you can use to check against
Hacks but in the end with a small amount of scripting can be hacked
though.
NOTE: The namespaces to use in get_data and get_size are column names.
NOTE: Credits ARE REQUIRED!!
BEFORE REPORTING BUGS MAKE SURE TO GET THE ERROR REPORT!
THE PHP FILE SHOULD ALSO PRODUCE ERRORS IN IT'S RETURN, BE SURE TO GET THAT
TOO!
=end
$base = "pokemon" # database name
SQL_ENABLED = true # don't remove/change this, it allows other external sql scripts
# of mine to connect with the sql.
class MySql
attr_accessor :database
# initializes the database
def initialize(d)
@database = d;
end
# creates a mysql query (Untested)
def query(query)
if query.include?("$base")
tmp = query.split("$base")
query = ""
for j in 0..tmp.length-2
i=tmp[j]
query += i+$base
end
query+=tmp[tmp.length-1]
end
return pbPostData(@database, {"query"=>query})
end
# returns the data from a namespacing and it's index id (Fully Tested)
def get_data(data, name, index)
dat=data.split(";"+name+"#{index}=")[1]
return false if dat == nil
return dat.split(";")[0].to_i if dat.split(";")[0].to_i.to_s == dat.split(";")[0]
return dat.split(";")[0]
end
# returns this size of a namespace (Fully Tested)
def get_size(data, name)
return 0 if !data.include?(name+"0") # return if name0 doesn't exist which
# makes it useless to process everything.
amt = data.count(";")
size=data.count(";"+name)/(name.length)
while !data.include?(";"+name+"#{size}")
size -= 1
end
return size+1
end
end
also you must download this too: "image removed"
IF YOU DON'T KNOW WHAT A PHP FILE IS OR HOW TO USE A PHP FILE DON'T USE IT!
Last edited by a moderator: