조회 수 2775 추천 수 0 댓글 3
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
Extra Form

#======================================================================
#                                                                    Net::Mysql
#       29-05-2010                             www.rpgmakervx-fr.com                                    Rgss1&2  v.1
#                                                                     par berka                  
#--------------------------------------------------------------------------------------------------------------
# This script is free to use. Do not post anywhere without my permission. Credits needed.
#--------------------------------------------------------------------------------------------------------------
# Warning: if your game is cracked and decrypted, your mysql login will be available !
# Do not use with a database containing personal information.
# Your mysql host should accept external connections.
# Check with it for remote SSH access to your database.
#--------------------------------------------------------------------------------------------------------------
# This script allows interractions with a mysql database directly in the game
# It requires a file "libmysql.dll" in the game folder
#--------------------------------------------------------------------------------------------------------------
# Attention: en cas de d?cryptage de votre jeu, vos identifiants mysql seront accessibles !
#  Ne pas utiliser de base de donn?e contenant des informations personnelles.
#  Votre h?bergeur Mysql doit accepter les connexions mysql externes.
#  V?rifiez aupr?s de lui que vous avec un acc?s distant SSH ? votre base de donn?es.
#--------------------------------------------------------------------------------------------------------------------------
# Ce script permet d'interragir avec une base de donn?es mysql directement via le jeu.
# Il n?cessite un fichier "libmysql.dll" ? placer dans le dossier du jeu.
#--------------------------------------------------------------------------------------------------------------------------
# ??? md5() support
# ??? Mysql functions:
#   - Net::Mysql.new([host,user,pass,base,port]) : return : mysql connection handle
#   - @mysql.close : return : bool
#   - @mysql.list_tables([filter]) : return : ["table1", "table2"]
#   - @mysql.select_db(base_name) : return : true if the db exists or false
#   - @mysql.query("query",ret=false) : return : if ret = true : rows else result handle
#   - @mysql.get_fields([handle result]) : return : ["field1", "field2"]
#   - @mysql.get_rows([handle result]) : return : [["l1 row1", "l1 row2"], ["l2 row1", "l2 row2"]]
#   - @mysql.fetch_assoc : return : {"field" => ["row1", "row2"] }
#   - @mysql.num_rows([handle result]) : return : integer
# ??? Html functions:
#   - "string".to_ruby : return : true, false, nil, Integer, Float, self, etc.
#   - "<berka>".htmlspecialchars : return : "&lr;berka&gt;"
#   - "<berka>".urlencode : return : "%3Cberka%3E"
#   - "%3Cberka%3E".urldecode : return : "<berka>"
#--------------------------------------------------------------------------------------------------------------------------
# SQL queries samples
# ???  "SELECT * FROM table"
# ???  "INSERT INTO table (fields) VALUES (values)"
# ???  "INSERT INTO table SET field = value WHERE field = value"
# ???  "UPDATE table SET field = value WHERE field = value"
#--------------------------------------------------------------------------------------------------------------------------
# Sample :
# @mysql = Net::Mysql.new
# @mysql.query("SELECT * FROM `members`)
# res = @mysql.fetch_assoc
# => {:id=>["1","2"], :nom=>["berka","rgss"], :age=>["19",""]}
#======================================================================

module Berka
  module Mysql
    Host   = "127.0.0.1"                          # mysql server(local : 127.0.0.1)
    User   = ""                                           # mysql user
    Pass  = ""                                           # mysql password
    Base  = "rgss"                                   # base name
    Port    = 3306                                     # server port (default: 3306)
    
    Err_Con = "Mysql:\nUnable to connect to the database"
    Err_Req = "Mysql:\nUnable to send the query"
  end
  
  module Html
    Spec_Char=["$","&","+",",","/",";",":","=","@","?"," ","<",">","#","%","{","}","|","\\","^","~","[","]","`"]
  end
end

class Numeric
  def copymem(len)
    # move memory to convert c structs to ruby objects
    Win32API.new("kernel32", "RtlMoveMemory", "ppl", "").call(buf="\0"*len,self,len);buf
  end
end

class String
  
  def to_ruby
    # detect if the string is a md5 hash
    return self if self=~/^[a-f0-9]{32}$/
    # converts syntax of a string to ruby controls
    eval(self)rescue self
  end
  
  def htmlspecialchars
    # converts special chars to html compatibles chars (ASCII)
    {"&"=>"&amp;",'"'=>"&quot;","'"=>"'","<"=>"&lr;",">"=>"&gt;"}.each_pair{|k,v|self.gsub!(k,v)}
    self
  end
    
  def urlencode
    # converts special char of url
    o="";self.scan(/./).each{|c|c="%"+c.unpack('H*')[0]if Berka::Html::Spec_Char.include?(c);o<<c};o
  end
    
  def urldecode
    # converts encoded special char of url to normal chars
    self.gsub!(/\%(\w\w)/){|c|c.gsub!("%","").hex.chr}
  end
end
  
module Net
  class Mysql
    MI=Win32API.new("libmysql.dll","mysql_init","l","l")
    MC=Win32API.new("libmysql.dll","mysql_close","l","l")
    MQ=Win32API.new("libmysql.dll","mysql_query","lp","l")
    MLT=Win32API.new("libmysql.dll","mysql_list_tables","lp","l")
    MFL=Win32API.new("libmysql.dll","mysql_fetch_lengths","p","l")
    MFR=Win32API.new("libmysql.dll","mysql_fetch_row","p","l")
    MNF=Win32API.new("libmysql.dll","mysql_num_fields","p","l")
    MFC=Win32API.new("libmysql.dll","mysql_field_count","p","l")
    MSR=Win32API.new("libmysql.dll","mysql_store_result","l","l")
    MRC=Win32API.new("libmysql.dll","mysql_real_connect","lpppplpl","l")
    MNR=Win32API.new("libmysql.dll","mysql_num_rows","p","l")
    MFFD=Win32API.new("libmysql.dll","mysql_fetch_field_direct","pi","l")
    MFRE=Win32API.new("libmysql.dll","mysql_free_result","p","l")
    MSDB=Win32API.new("libmysql.dll","mysql_select_db","p","l")
    
    attr_reader :handle
    
    def initialize(h=Berka::Mysql::Host,u=Berka::Mysql::User,p=Berka::Mysql::Pass,b=Berka::Mysql::Base,po=Berka::Mysql::Port)
      # @handle : handle of mysql initialization
      @handle=MI.call(0)
      # establishes the mysql connection
      (print(Berka::Mysql::Err_Con))if MRC.call(@handle,h,u,p,b,po,nil,0)==0
      # returns: handle
      @handle
    end
    
    def close
      # closes the current connection
      MC.call(@handle)
    end
    
    def select_db(base)
      # selects a current database
      MSDB.call(base)==true
    end
    
    def list_tables(m="")
      # lists tables request -> fetch the result -> to ruby string
      l=MFR.call(MLT.call(@my,m)).copymem(1024)
      # splits the string to array -> list of tables
      l.scan(/\t(\w+)\0/).flatten
    end
    
    def query(req,ret=false)
      # sends the query (msg error)
      (return print(Berka::Mysql::Err_Req+req))if !MQ.call(@handle,req)
      # previous results are released
      MFRE.call(@result)if @result
      # gets the results from the query -> c struct handle
      @result=MSR.call(@handle)
      ret ? get_rows(@result) : @result
    end
    
    # Proc: gets the name of the field (cstruct) -> to ruby string of handles -> to ruby string
    # returns the fieldname or nil if the field is not found.
    ReadField=Proc.new{|r,i,of|MFFD.call(r,i).copymem(1024).unpack("iissi")[0].copymem(of).delete!("\0")}
    
    def get_fields(res=nil)
      # if a result handle is provided
      r=res.nil? ? @result : res
      # gets the number of fields, offset: 8bytes-2 (cf. loop)
      nf,ch,of=MFC.call(@handle),[],6
      # each field: if the fieldname is not found: increase the offset of bytes.
      nf.times{|i|a=ReadField.call(r,i,of+=2)until a
        # add to the fields array
        ch<<a
        # reinitialize the offset for the next iteration
        of=6}
      # returns an array of fields
      ch
    end
    
    def get_rows(res=nil)
      # if a result handle is provided
      r=res.nil? ? @result : res
      # nr: number of rows, nf: number of fields
      nr,nf,en=MNR.call(r),MNF.call(r),[]
      # each row:
      nr.times{|i|
       # gets each row: c struct -> to ruby string -> to array (handles)
       c=MFR.call(r).copymem(4).unpack("i")[0]
       # gets each field length: c struct -> to ruby string -> to array (handles)
       tf=MFL.call(r).copymem(4*nf).unpack("i*")
       # size of field: offset of each field
       sf=tf.inject(0){|n,i|n+i}
       # handle of row -> to string (offset) -> to array
       en<<c.copymem(sf+nf).split("\0")
       }
       # returns each row as an array
      en
    end
    
    def num_rows(res=nil)
      # if a result handle is provided
      r=res.nil? ? @result : res
      # returns: number of rows
      MNR.call(r)
    end
    
    def fetch_assoc(to_ruby=false)
      # gets rows and fields
      h,f,r={},get_fields,get_rows
      # each field: read the rows and store them to an hash : h[:field]=[rows]
      # rows are converted to ruby objects if to_ruby == true
      f.each_with_index{|fi,i|t=[];r.each{|l|t<<l[i]};h[fi.to_sym]=(to_ruby ? t.map!{|o|o.to_ruby if o} : t)}
      h
    end
  end
end

 

압축을 풀어서 나오는 libmysql.dll을 제작하고 있는 게임의 폴더 상위에다 넣으시기 바랍니다.

libmysql.zip

출처 : http://www.rpgrevolution.com

  • profile
    니오티 2010.07.25 14:52

    보안에는 엄청 취약하군요..;;

  • profile
    니오티 2010.07.26 03:41

    혹시 첨부파일은 없었나요?

     

    libmysql.dll 이파일도 있을것 같은데..

  • ?
    독도2005 2010.07.26 08:08

    제가 글을 퍼올 때 첨부파일이 있는지 제대로 못봤군요..

    올렸습니다.


  1. 일본어 스크립트를 번역하기 좋은 번역사이트 두곳입니다

    Date2010.01.09 Category공지사항 Byruby Views22086 Votes0
    read more
  2. 스크립트 게시판 관리자' ruby ' 입니다

    Date2010.01.09 Category공지사항 Byruby Views20726 Votes0
    read more
  3. 일본 스크립트/소스 공유 포럼

    Date2010.01.05 Category공지사항 By니오티 Views22257 Votes0
    read more
  4. 자동저장 스크립트

    Date2010.12.23 Category세이브 By레오 Views3201 Votes0
    Read More
  5. HG_SHOOT_ANIMATION

    Date2010.11.21 By허걱 Views2424 Votes0
    Read More
  6. HG_LIMIT_CARRY

    Date2010.11.11 By허걱 Views2066 Votes0
    Read More
  7. RPG XP Web Kit

    Date2010.11.05 Category온라인 By니오티 Views3031 Votes0
    Read More
  8. ruby-1.9.1-p429 Standard Pack

    Date2010.11.05 By니오티 Views1874 Votes0
    Read More
  9. 루비 html 라이브러리

    Date2010.11.05 Category공통 Script By펜릴 Views2833 Votes0
    Read More
  10. T?tulo Final Fantasy

    Date2010.10.15 Bydizman Views3009 Votes0
    Read More
  11. 전투시 화면 확대..!

    Date2010.10.15 Bydizman Views2536 Votes0
    Read More
  12. 상태창표시 스크립투 Ver 6.0

    Date2010.09.21 Category기타 By코아 코스튬 Views2412 Votes2
    Read More
  13. Cacao 엔진 출처사이트의 스크립트 모움

    Date2010.08.02 Byruby Views2217 Votes0
    Read More
  14. XP 형식 메뉴

    Date2010.07.29 ByJenpia Views3641 Votes0
    Read More
  15. 온라인

    Date2010.07.27 Category온라인 By개임 매니저 Views2232 Votes0
    Read More
  16. MYSQL 사용할 수 있게 하는 스크립트

    Date2010.07.25 By독도2005 Views2775 Votes0
    Read More
  17. 얼굴 띄워주는 기능&대화창 명령어

    Date2010.07.23 Category대화관련 By니오티 Views2904 Votes0
    Read More
  18. 한 글자씩 대화창에 띄웁니다.

    Date2010.07.23 Category메시지 By니오티 Views1870 Votes0
    Read More
  19. 메뉴에 얼굴 그래픽을 표현

    Date2010.07.23 Category메뉴관련 By니오티 Views1840 Votes0
    Read More
  20. 온라인

    Date2010.07.21 Category온라인 By개임 매니저 Views2117 Votes0
    Read More
  21. 메뉴를 바꿉니다.

    Date2010.06.19 ByAqua Views3210 Votes2
    Read More
  22. HG_QUEST_SYSTEM

    Date2010.06.18 By허걱 Views3598 Votes1
    Read More
  23. HG_Variables : 변수 확장 시스템

    Date2010.06.14 By허걱 Views2559 Votes1
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7

Copyright ⓒ Nioting All Rights Reserved. (since 1999)    개인정보
        

Fatal error: Cannot access property sessionController::$lifetime in /web/old/xe/modules/session/session.controller.php on line 45