예제 #1
0
        public static bool credentials_correct(string driver, string user, string password)
        {
            crypt crypt = new crypt();
            string encPass = crypt.HashString(password);

            try
            {

                OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");

                OdbcCommand com = new OdbcCommand("SELECT user FROM users where user = '******' and password = '******'", con);

                con.Open();
                OdbcDataReader dr = com.ExecuteReader();

                int tmpInt = 0;

                while (dr.Read())
                {
                    tmpInt++;
                }
                dr.Close();
                con.Close();

                return tmpInt > 0;
            }
            catch
            {
                return false;
            }
        }
예제 #2
0
        public static ArrayList database_get_data(string driver, string user, string instance, string column)
        {
            crypt crypt = new crypt();

            OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");

            OdbcCommand com = new OdbcCommand("SELECT " + column + " FROM settings where user = '******' and instance_name = '" + instance + "'", con);

            //OdbcCommand com = new OdbcCommand("SELECT online_request FROM settings where user = '******'", con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();
                OdbcDataReader dr = com.ExecuteReader();

                while (dr.Read())
                {
                    if (dr.GetValue(0) != DBNull.Value)
                    {
                        result.Add(dr.GetString(0));
                    }
                    else
                    {
                        result.Add("NULL");
                    }
                }
                dr.Close();
                con.Close();

                return result;
            }
            catch
            {
                result.Add("NULL");
                return result;
            }
        }
예제 #3
0
        public static bool credentials_correct(string driver, string user, string password)
        {
            crypt  crypt   = new crypt();
            string encPass = crypt.HashString(password);

            try
            {
                //OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");
                OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";Uid=" + uid + ";Password="******";Option=3");


                OdbcCommand com = new OdbcCommand("SELECT user FROM users where user = '******' and password = '******'", con);

                con.Open();
                OdbcDataReader dr = com.ExecuteReader();

                int tmpInt = 0;

                while (dr.Read())
                {
                    tmpInt++;
                }
                dr.Close();
                con.Close();

                return(tmpInt > 0);
            }
            catch
            {
                return(false);
            }
        }
예제 #4
0
        public static int set_licence_data(string driver, string cmd)
        {
            crypt          crypt = new crypt();
            OdbcConnection con   = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");
            OdbcCommand    com   = new OdbcCommand(cmd, con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();

                OdbcDataReader dr = com.ExecuteReader();

                dr.Close();
                con.Close();

                return(dr.RecordsAffected);
            }
            catch
            {
                return(0);
            }
        }
예제 #5
0
        public static ArrayList get_licence_data(string driver, string query)
        {
            crypt crypt = new crypt();

            OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");

            OdbcCommand com = new OdbcCommand(query, con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();
                OdbcDataReader dr = com.ExecuteReader();

                while (dr.Read())
                {
                    if (dr.GetValue(0) != DBNull.Value)
                    {
                        result.Add(dr.GetString(0));
                    }
                    else
                    {
                        result.Add("NULL");
                    }
                }
                dr.Close();
                con.Close();

                return(result);
            }
            catch
            {
                result.Add("NULL");
                return(result);
            }
        }
예제 #6
0
        public static int database_update_data(string driver, string user, string instance, string option, string value)
        {
            string update = "";
            string cmd    = "";

            crypt crypt = new crypt();

            if (option == "statuson")
            {
                update = "set status = 'On'";
                cmd    = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "statusoff")
            {
                update = "set status = 'Off'";
                cmd    = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "statusactive")
            {
                update = "set status = 'Active'";
                cmd    = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "statusinactive")
            {
                update = "set status = 'Inactive'";
                cmd    = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "log")
            {
                update = "set log = '" + value + "'";
                cmd    = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "reset")
            {
                update = "set online_request = null , lastTeboCamUpdate = '" + value + "'";
                cmd    = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "picLoc")
            {
                update = "set picloc = '" + value + "'";
                cmd    = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "poll")
            {
                update = "set teboCamLastPoll = '" + value + "'";
                cmd    = "update poll " + update + " where user = '******'";
            }

            //Console.WriteLine(cmd);

            OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");


            OdbcCommand com = new OdbcCommand(cmd, con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();

                OdbcDataReader dr = com.ExecuteReader();

                dr.Close();
                con.Close();

                return(dr.RecordsAffected);
            }
            catch
            {
                return(0);
            }
        }
예제 #7
0
        public static ArrayList database_get_data(string driver, string user, string instance, string column)
        {
            crypt crypt = new crypt();

            OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");

            OdbcCommand com = new OdbcCommand("SELECT " + column + " FROM settings where user = '******' and instance_name = '" + instance + "'", con);

            //OdbcCommand com = new OdbcCommand("SELECT online_request FROM settings where user = '******'", con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();
                OdbcDataReader dr = com.ExecuteReader();

                while (dr.Read())
                {
                    if (dr.GetValue(0) != DBNull.Value)
                    {
                        result.Add(dr.GetString(0));
                    }
                    else
                    {
                        result.Add("NULL");
                    }
                }
                dr.Close();
                con.Close();

                return(result);
            }
            catch
            {
                result.Add("NULL");
                return(result);
            }
        }
예제 #8
0
        public static int database_update_data(string driver, string user, string instance, string option, string value)
        {
            string update = "";
            string cmd = "";

            crypt crypt = new crypt();

            if (option == "statuson")
            {
                update = "set status = 'On'";
                cmd = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "statusoff")
            {
                update = "set status = 'Off'";
                cmd = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "statusactive")
            {
                update = "set status = 'Active'";
                cmd = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "statusinactive")
            {
                update = "set status = 'Inactive'";
                cmd = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "log")
            {
                update = "set log = '" + value + "'";
                cmd = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "reset")
            {
                update = "set online_request = null , lastTeboCamUpdate = '" + value + "'";
                cmd = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "picLoc")
            {
                update = "set picloc = '" + value + "'";
                cmd = "update settings " + update + " where user = '******' and instance_name = '" + instance + "'";
            }
            if (option == "poll")
            {
                update = "set teboCamLastPoll = '" + value + "'";
                cmd = "update poll " + update + " where user = '******'";
            }

            //Console.WriteLine(cmd);

            OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");

            OdbcCommand com = new OdbcCommand(cmd, con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();

                OdbcDataReader dr = com.ExecuteReader();

                dr.Close();
                con.Close();

                return dr.RecordsAffected;

            }
            catch
            {
                return 0;
            }
        }
예제 #9
0
        public static int set_licence_data(string driver, string cmd)
        {
            crypt crypt = new crypt();
            OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");
            OdbcCommand com = new OdbcCommand(cmd, con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();

                OdbcDataReader dr = com.ExecuteReader();

                dr.Close();
                con.Close();

                return dr.RecordsAffected;

            }
            catch
            {
                return 0;
            }
        }
예제 #10
0
        public static ArrayList get_licence_data(string driver, string query)
        {
            crypt crypt = new crypt();

            OdbcConnection con = new OdbcConnection("Driver=" + driver + ";Server=" + server + ";Database=" + dbase + ";UID=" + uid + ";PWD=" + crypt.DecryptString(pwd) + ";OPTION=3");

            OdbcCommand com = new OdbcCommand(query, con);

            ArrayList result = new ArrayList();

            try
            {
                con.Open();
                OdbcDataReader dr = com.ExecuteReader();

                while (dr.Read())
                {
                    if (dr.GetValue(0) != DBNull.Value)
                    {
                        result.Add(dr.GetString(0));
                    }
                    else
                    {
                        result.Add("NULL");
                    }
                }
                dr.Close();
                con.Close();

                return result;
            }
            catch
            {
                result.Add("NULL");
                return result;
            }
        }
예제 #11
0
        private static string decrypt(string inStr)
        {
            if (inStr.Length < 2) return "";

            try
            {
                crypt crypt = new crypt();

                if (LeftRightMid.Left(inStr, 1) == "a")
                {
                    inStr = inStr.Remove(0, 1);
                    return crypt.DecryptString(inStr);
                }
                else
                {
                    return ConvertFromAscii(inStr);
                }
            }
            catch { return ""; }
        }