Welcome to the RaGEZONE - MMORPG development forums.

[C#] Webbuild Updater by JNike

This is a discussion on [C#] Webbuild Updater by JNike within the Habbo Releases forums, part of the Habbo Hotel category; Hey, i've coded before 1 week a cool tool. It updates your webbuild to the actualest. Every 60 seconds it ...

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Ultimate Member
    Rank
    Member
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    191
    Liked
    59

    thumbs up [C#] Webbuild Updater by JNike

    Click
    Hey,

    i've coded before 1 week a cool tool. It updates your webbuild to the actualest. Every 60 seconds it gets the newest webbuild with help of Regex and updates your database table and the row for the webbuild.

    I think its useful for my hotel cuz i use all habbo styles from habbo.de. So i'm ripping every 60 Seconds the styles of the Hotel.

    Here are the classes in C#, only for good programmers in C# meaned, they have to create their own classes etc.: (Don't forget to import the mysql dll from the mysql conector :-])

    Mysql.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using MySql.Data.MySqlClient;
    using MySql.Data;
    
    using System.Data;
    
    namespace Webbuild_Updater_for_HabbuCMS
    {
        class Mysql
        {
            protected string HOST;
            protected string USERNAME;
            protected string PASSWORT;
            protected string DATABASE;
            protected uint PORT = 3306;
    
            private static MySqlCommand mCommand;
            private static MySqlConnection mConnection;
    
            public Mysql(string H, string U, string P, string D, uint PORT = 3306)
            {
                this.HOST = H;
                this.USERNAME = U;
                this.PASSWORT = P;
                this.DATABASE = D;
                this.PORT = PORT;
            }
    
            public bool OpenMysqlConnection()
            {
                MySqlConnectionStringBuilder mString = new MySqlConnectionStringBuilder();
                mString.Server = this.HOST;
                mString.Port = this.PORT;
                mString.Database = this.DATABASE;
                mString.Password = this.PASSWORT;
                mString.UserID = this.USERNAME;
    
                mConnection = new MySqlConnection(mString.ToString());
    
                try
                {
                    mConnection.Open();
                }
                catch { }
    
                return mConnection.State == ConnectionState.Open ? true : false;
            }
    
            public void ExecuteQuery(string Q)
            {
                mCommand = new MySqlCommand(Q, mConnection);
                mCommand.ExecuteNonQuery();
            }
        }
    }
    Regex.cs

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using MySql.Data.MySqlClient;
    using MySql.Data;
    
    using System.Text.RegularExpressions;
    
    using System.Net;
    
    namespace Webbuild_Updater_for_HabbuCMS
    {
        class REGEX
        {
            protected string URL;
            private WebClient WEBCLIENT = new WebClient();
            private Regex mRegex;
            private Match mMatch;
    
            public REGEX(string URL)
            {
                this.URL = URL;
            }
    
            public string ReturnWebbuild()
            {
                string HTML = WEBCLIENT.DownloadString(this.URL);
                this.mRegex = new Regex("<link rel=\"shortcut icon\" href=\"http://images.habbo.com/habboweb/(.*?)/web-gallery/v2/favicon.ico\" type=\"image/vnd.microsoft.icon\" />", RegexOptions.Compiled);
                this.mMatch = this.mRegex.Match(HTML);
                return this.mMatch.Value.ToString().Substring(65, 40);
            }
        }
    }
    Program.cs

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using System.Threading;
    
    namespace Webbuild_Updater_for_HabbuCMS
    {
        class Program
        {
            private static Mysql mSQL;
    
            private static string HOST, USER, PASS, DATA;
            private static uint PORT;
    
            private static bool MYSQL_CONNECTED = false;
    
            private static Thread _TRE;
            private static REGEX mRegex = new REGEX("http://habbo.de");
    
            static void Main(string[] args)
            {
                Console.WriteLine("Habbo Webbuild Leaker\nProgrammiert von JNike in C#\nBenutzt MySQL, Regex und das .NET Framework");
                Console.WriteLine("\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
    
                Console.Write("\n[..] MySQL Host >> ");
                HOST = Console.ReadLine();
    
                Console.Write("\n[.:] MySQL User >> ");
                USER = Console.ReadLine();
    
                Console.Write("\n[::] MySQL Pass >> ");
                PASS = Console.ReadLine();
    
                Console.Write("\n[:+] MySQL Datenbank >> ");
                DATA = Console.ReadLine();
    
                Console.Write("\n[++] MySQL Port [3306] >> ");
    
                try
                {
                    PORT = Convert.ToUInt32(Console.ReadLine());
                }
                catch { }
    
                MYSQL_CONNECTED = StartMysqlConnection();
    
                Console.WriteLine(Environment.NewLine);
    
                if (MYSQL_CONNECTED)
                {
                    _TRE = new Thread(new ThreadStart(ExecuteUpdateSql));
                    _TRE.Start();
                }
    
                Console.ReadKey(true);
            }
    
            private static bool StartMysqlConnection()
            {
                mSQL = new Mysql(HOST, USER, PASS, DATA, PORT);
                return mSQL.OpenMysqlConnection();
            }
    
            private static void ExecuteUpdateSql()
            {
                while (true)
                {
                    for (int i = 0; i <= 60; i++)
                    {
                        Thread.Sleep(1000);
                        Console.WriteLine("Noch {0} Sekunden bis zum nächsten Update!", 60 - i);
                    }
    
                    if (MYSQL_CONNECTED)
                    {
                        mSQL.ExecuteQuery("UPDATE web_settings SET webbuild = '" + mRegex.ReturnWebbuild() + "'");
                        Console.WriteLine(" >> Update wurde ausgeführt  -- " + mRegex.ReturnWebbuild() + " --");
                    }
                    else
                        Console.WriteLine(" [++] -- MYSQL DATENBANKVERBINDUNG NICHT VERBUNDEN!");
                }
            }
        }
    }
    Well, done! There you go RZ :)

  2. #2
    @_Prizm
    Rank
    Subscriber
    Join Date
    Feb 2012
    Location
    Denmark
    Posts
    2,141
    Liked
    518
    PSN ID: InfraRedDude Steam ID: lehprizm

    Re: [C#] Webbuild Updater by JNike

    Thanks, I would definitely goint to use it! :-)

  3. #3
    Ultimate Member
    Rank
    Member
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    191
    Liked
    59

    Re: [C#] Webbuild Updater by JNike

    No problem.

    Just to know:

    mSQL.ExecuteQuery("UPDATE web_settings SET webbuild = '" + mRegex.ReturnWebbuild() + "'");

    Change the Query with your own table and row. If you've got problems doing this, just let me know how your table is named and your row is named and i'll do it for you.

  4. #4
    Alpha Member
    Rank
    Alpha Member
    Join Date
    Oct 2011
    Location
    New York
    Posts
    2,126
    Liked
    489
    Gamertag: DannyRunsNYC

    Re: [C#] Webbuild Updater by JNike

    Nice job I'll have a look at it.
    Thanks, Facebook


    Rest In Peace, To my dog Sparky. Never forgotten <3

    Skype: Danny.runsnyc

    msn: dannyrunsnyc@hotmail.com

  5. #5
    I broke my computer :/
    Rank
    Alpha Member
    Join Date
    Sep 2009
    Location
    Kings Landing
    Posts
    1,806
    Liked
    422
    Gamertag: kthxbye

    Re: [C#] Webbuild Updater by JNike

    This should be done web side, and every 60 seconds? Might be hard on the server, do it every hour or so :P
    Regards, zJordan---------------------------------------I rep back. So do the wise thing, and rep me for 1 free rep back!



  6. #6
    Developer
    Rank
    Member +
    Join Date
    May 2008
    Location
    Kanaada
    Posts
    1,058
    Liked
    771

    Re: [C#] Webbuild Updater by JNike

    Quote Originally Posted by zJordan View Post
    This should be done web side, and every 60 seconds? Might be hard on the server, do it every hour or so :P
    Once a minute is not hard on the server at all.... all it does is get the content of a web page and gets the web build from it, then does a query to write it to the db.

  7. #7
    I broke my computer :/
    Rank
    Alpha Member
    Join Date
    Sep 2009
    Location
    Kings Landing
    Posts
    1,806
    Liked
    422
    Gamertag: kthxbye

    Re: [C#] Webbuild Updater by JNike

    Quote Originally Posted by leenster View Post
    Once a minute is not hard on the server at all.... all it does is get the content of a web page and gets the web build from it, then does a query to write it to the db.
    Well true but if its done every hour there is 60 requests less :P true its only 1 request, but Every little help lol.
    Regards, zJordan---------------------------------------I rep back. So do the wise thing, and rep me for 1 free rep back!



  8. #8
    Goodcat.
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    1,410
    Liked
    531

    Re: [C#] Webbuild Updater by JNike

    Every 24 hours would be best, it's not like Habbo update their webbuild every hour...

  9. #9
    Developer
    Rank
    Member +
    Join Date
    May 2008
    Location
    Kanaada
    Posts
    1,058
    Liked
    771

    Re: [C#] Webbuild Updater by JNike

    Quote Originally Posted by ησвяαιη View Post
    Every 24 hours would be best, it's not like Habbo update their webbuild every hour...
    but that way your site could be messed up for almost 24hrs.... with the 60 seconds it will be fixed in a minute...

  10. #10
    Alpha Member
    Rank
    Alpha Member
    Join Date
    Dec 2010
    Posts
    1,818
    Liked
    726

    Re: [C#] Webbuild Updater by JNike

    Quote Originally Posted by ησвяαιη View Post
    Every 24 hours would be best, it's not like Habbo update their webbuild every hour...
    Every hour would be better than every 24 hours, as if they update between the 24 hours you could experience difficulties.


    If I like your post, it doesn't mean I like you - it means I agree with you (for once).

  11. #11
    Goodcat.
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    1,410
    Liked
    531

    Re: [C#] Webbuild Updater by JNike

    Quote Originally Posted by n0minal View Post
    Every hour would be better than every 24 hours, as if they update between the 24 hours you could experience difficulties.
    Every hour would still be kinda pointless though, every 6 hours?

  12. #12
    Member
    Rank
    Member
    Join Date
    Aug 2010
    Posts
    62
    Liked
    13

    Re: [C#] Webbuild Updater by JNike

    Hmmm. It's better when somebody can code it in his our Habbo Hotel private server. That would be very nice! Then your hotel server can automatically update every (let we say) 1 hour your web_build. I think it's easy to make?

  13. #13
    T09
    Learning C#
    Rank
    Member +
    Join Date
    Oct 2011
    Location
    The Netherlands
    Posts
    219
    Liked
    33
    Gamertag: Recoated

    Re: [C#] Webbuild Updater by JNike

    Habbo won't remove their previous webbuild in at least 6 hours so why each minute?

    Website: http://T09.nl
    Skype: T09.nl
    MSN: arh-t09@live.com


  14. #14
    The one and only!
    Rank
    Subscriber
    Join Date
    Nov 2008
    Posts
    4,117
    Liked
    1452
    Gamertag: DecidingClock47 Steam ID: hejularz

    Re: [C#] Webbuild Updater by JNike

    What's the advantages of using this over the PHP version? :s

  15. #15
    C# | C++
    Rank
    Member +
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    422
    Liked
    61

    Re: [C#] Webbuild Updater by JNike

    PHP Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using MySql.Data.MySqlClient;
    using MySql.Data;
    using System.Threading;

    namespace 
    Webbuild_Update
    {
        class 
    Program
        
    {
            private static 
    MysqlManager mSQL;

            private static 
    string HOSTUSERPASSDATA;
            private static 
    string Webbuild "";

            private static 
    bool MYSQL_CONNECTED false;

            private static 
    Thread _TRE;
            private static 
    Updater mRegex = new Updater("http://habbo.de");

            static 
    void Main(string[] args)
            {
                
    Console.WriteLine("Booting up Habbo Webbuild Updater...");
                
    Console.WriteLine("Starting MysqlManager :: ");
                
    Console.Write("Mysql Host: "); HOST Console.ReadLine();
                
    Console.Write("Mysql User: "); USER Console.ReadLine();
                
    Console.Write("Mysql Password: "); PASS Console.ReadLine();
                
    Console.Write("Mysql Database: "); DATA Console.ReadLine();

                
    MysqlManager Manager = new MysqlManager(HOSTUSERPASSDATA);

                
    Webbuild mRegex.ReturnWebbuild();
                
    mSQL.ExecuteQuery("UPDATE web_settings SET webbuild = '" mRegex.ReturnWebbuild() + "'");

                
    MYSQL_CONNECTED StartMysqlConnection();

                
    Console.WriteLine(Environment.NewLine);

                if (
    MYSQL_CONNECTED)
                {
                    
    _TRE = new Thread(new ThreadStart(ExecuteUpdateSql));
                    
    _TRE.Start();
                }

                
    Console.ReadKey(true);
            }

            private static 
    bool StartMysqlConnection()
            {
                
    mSQL = new MysqlManager(HOSTUSERPASSDATA);
                return 
    mSQL.OpenMysqlConnection();
            }

            private static 
    void ExecuteUpdateSql()
            {
                while (
    true)
                {
                    for (
    int i 0<= 60i++)
                    {
                        
    Thread.Sleep(1000);
                        
    Console.WriteLine("{0} seconds to the next webbuild check"60 i);
                    }

                    if (
    MYSQL_CONNECTED)
                    {
                        if (
    Webbuild == mRegex.ReturnWebbuild())
                            
    Console.WriteLine("Allready downloaded the latest webbuild of Habbo");
                        else
                        {
                            
    mSQL.ExecuteQuery("UPDATE web_settings SET webbuild = '" mRegex.ReturnWebbuild() + "'");
                            
    Console.WriteLine("Updated your Webbuild  -- " mRegex.ReturnWebbuild() + " --");
                        }
                    }
                    else
                        
    Console.WriteLine("MYSQL ERROR");
                }
            }
        }

    I don't know if this code is working, didn't test it but...
    why don't save the webbuild in a string by starting the program ?
    It runs a Query and it save it in a string.

    Now the program checks Habbo's webbuild every minute.
    If the checked webbuild == the Webbuild in the string, than it doesn't run the query.
    Otherwise it runs the query..

    Maybe better,

    - Waves ~~

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •