1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

skript-db MySQL issues

Discussion in 'Skript' started by DavivaD, Jan 11, 2018.

Thread Status:
Not open for further replies.
  1. DavivaD

    DavivaD Member

    Joined:
    Jan 11, 2018
    Messages:
    1
    Likes Received:
    0
    I was wrote a MySQL Report system using skript-db and skUtilities with connect checking...
    Code (Skript):
    1.  
    2. # MultiGameReportSystem
    3. # Autor: DavivaD
    4. # Opis: Skript po poprawnym /zglos wysyła informację o zgłoszeniu do bazy danych MySQL do wyświetlenia ich na stronie WWW ###
    5. # Wymagane moduły: skript-db, skUtilities
    6.  
    7. # OPCJE
    8. options:
    9.     # BAZA DANYCH
    10.     host: hosting.pukawka.pl               # Adres Bazy
    11.     port: 3306               # Port Bazy (Domyślnie: 3306)
    12.     user: thecich_677352               # Login
    13.     pass: *****               # Hasło
    14.     db: 677352               # Nazwa Bazy
    15.     table: mgrs               # Prefiks Tabeli (Domyślnie: mgrs)
    16.     # ZGŁOSZENIE
    17.     game: mc               # Typ Gry (Domyślnie: mc)
    18.     server: <span style=""color: red;"">1.11.2</span> Survival+Gildie           # Wyświetlana nazwa Serwera (HTML Dozwolone)
    19.     # CHAT
    20.     prefix: &8[&9Zgłoszenie&8]           # Prefiks Wiadomości (Domyślnie: [MGRS])
    21.     messagecolor: &f       # Kolor Wiadomości (Domyślnie: &f)
    22.     errorcolor: &c           # Kolor Błędu (Domyślnie: &c)
    23.     infocolor: &a           # Kolor Informacji (Domyślnie: &a)
    24.     accentcolor: &9   # Akcentowany Kolor
    25.     command: mgrs       # Nazwa Komendy (Domyślnie: mgrs)
    26.  
    27. on script load:
    28.     set {output::*} to "<none>"
    29.     set {sql} to the database "mysql://{@host}:{@port}/{@db}?user={@user}&password={@pass}&useSSL=false"
    30.     execute "CREATE TABLE `{@table}_testconnect` (`connect` int(11))" in {sql}
    31.     execute "CREATE TABLE IF NOT EXISTS `{@table}_reports` ( `time` INT NOT NULL , `game` VARCHAR(10) NOT NULL DEFAULT 'unknown' , `server` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reporter` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reported` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Nieznany' , `reason` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL )" in {sql}
    32.     execute "INSERT INTO `{@table}_testconnect` (`connect`) VALUES ('1')" in {sql}
    33.     execute "SELECT connect FROM `{@table}_testconnect`" in {sql} and store the result in {output::*}
    34.     if "%{output::connect::*}%" is "1":
    35.         send "{@prefix} {@infocolor}Nawiązano połączenie z MySQL!" to console
    36.         set {connected} to "yes"
    37.     else:
    38.         send "{@prefix} {@errorcolor}Nie nawiązano połączenia z MySQL!" to console
    39.         set {connected} to "no"
    40.     execute "DROP TABLE `{@table}_testconnect`" in {sql}
    41.  
    42. command /{@command} <text="help"> [<player>] [<text>]:
    43.     trigger:
    44.         if arg 1 is "help":
    45.             send "{@accentcolor}+---------&r{@prefix}&r{@accentcolor}---------+"
    46.             send ""
    47.             send "{@accentcolor}/{@command} help &8- {@messagecolor}Wyświetla Pomoc"
    48.             send "{@accentcolor}/{@command} report <gracz> <powód> &8- {@messagecolor}Wysyła zgłoszenie na Gracza"
    49.             send ""
    50.             send "{@accentcolor}+---------&r{@prefix}&r{@accentcolor}---------+"
    51.         if arg 1 is "report":
    52.             if arg 2 is not set:
    53.                 send "{@prefix} {@errorcolor}Nie ma takiego Gracza na Serwerze!"
    54.             else:
    55.                 loop all players:
    56.                     if name of loop-player is arg 2:
    57.                         if arg 3 is not set:
    58.                             send "{@prefix} {@errorcolor}Podaj powód!"
    59.                         else:
    60.                             if "%{connected}%" is "yes":
    61.                                 set {player} to player
    62.                                 set {time} to convert date now to unix date
    63.                                 execute "INSERT INTO `{@table}_reports` (`time`,`game`,`server`,`reporter`,`reported`,`reason`) VALUES ('%{time}%','{@game}','{@server}','%{player}%','%arg-2%','%arg-3%')" in {sql}
    64.                                 send "{@prefix} {@infocolor}Zgłoszono Gracza {@accentcolor}%arg-2% {@infocolor}za {@accentcolor}%arg-3%{@infocolor}!"
    65.                             else:
    66.                                 send "{@prefix} {@errorcolor}Wystąpił błąd przy wysyłaniu Zgłoszenia! Skontaktuj się z Administratorem!"
    67.                         stop
    68.  
    My problem is: `execute` command on line 63 theoretically should work (I checked from skript and MySQL side) but... It doesn't send it to MySQL...
    WTH is wrong? skript-db is bugged or something else?
     
    #1 DavivaD, Jan 11, 2018
    Last edited: Jan 11, 2018
  2. Pikachu

    Moderator Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    871
    Likes Received:
    139
    Medals:
    remove the ' around the values, skript-db will automatically arrange expressions (barring the unsafe expression which is, well, unsafe) into prepared statements to mitigate sql injection
     
Thread Status:
Not open for further replies.

Share This Page

Loading...