Пример #1
0
        private void cmdClose_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            string lCode = null;
            string leCode = null;
            string lPassword = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            short x = 0;
            CDKey = false;
            string strSerial = null;
            string strTmp = null;
            short intDate = 0;
            short intYear = 0;
            short intMonth = 0;
            string dtDate = null;
            string dtMonth = null;
            string dtYear = null;
            string stPass = null;
            // clsCryptoAPI
            //UPGRADE_ISSUE: clsCryptoAPI object was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6B85A2A7-FE9F-4FBE-AA0C-CF11AC86A305"'
            clsCryptoAPI cCrypto = null;
            if (modRecordSet.openConnection()) {
                rs = modRecordSet.getRS(ref "SELECT * From Company");
                if (rs.RecordCount) {

                    //if old database don't chk secuirty
                    if (rs.Fields.Count <= 55) {
                        CDKey = false;
                        Interaction.MsgBox("You need to download latest 4POS upgrades in order to Register.", MsgBoxStyle.Critical, "4POS");
                        return;
                    }

                    txtFields.Text = Strings.Trim(Strings.Replace(txtFields.Text, "-", ""));

                    cCrypto = new clsCryptoAPI();
                    //clsCryptoAPI
                    System.Windows.Forms.Application.DoEvents();
                    txtFields.Text = Strings.LTrim(txtFields.Text);
                    txtFields.Text = Strings.RTrim(txtFields.Text);
                    txtFields.Text = Strings.Trim(txtFields.Text);
                    //strTmp = cCrypto.ConvertStringFromHex(Left(rs("Company_ResMS"), 6))
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.ConvertStringFromHex. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    strTmp = cCrypto.ConvertStringFromHex(Strings.Left(txtFields.Text, Strings.Len(txtFields.Text) - 5));
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.StringToByteArray. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    arData = cCrypto.StringToByteArray(strTmp);
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.StringToByteArray. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    arPWord = cCrypto.StringToByteArray(Conversion.Val(Strings.Right(txtFields.Text, 5)));
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.password. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    cCrypto.PassWord = arPWord;
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.InputData. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    cCrypto.InputData = System.Text.UnicodeEncoding.Unicode.GetString(arData);
                    System.Windows.Forms.Application.DoEvents();

                    // Decrypt the data input from the encrypted text box
                    //If cCrypto.Decrypt(g_intHashType, m_intCipher) Then
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.Decrypt. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    if (cCrypto.Decrypt(2, 1)) {
                        System.Windows.Forms.Application.DoEvents();
                        //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.OutputData. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        arData = cCrypto.OutputData.Clone();
                        //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.ByteArrayToString. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        strSerial = cCrypto.ByteArrayToString(arData);
                    }

                    if (Strings.Left(strSerial, 3) == "met") {

                        //Create date password
                        if (Information.IsNumeric(Strings.Mid(strSerial, 4, Strings.Len(strSerial)))) {
                            strSerial = Strings.Mid(strSerial, 4, Strings.Len(strSerial));
                            intYear = Convert.ToInt16(Strings.Mid(strSerial, 5, 2));
                            intMonth = Convert.ToInt16(Strings.Mid(strSerial, 3, 2));
                            intDate = Convert.ToInt16(Strings.Left(strSerial, 2));

                            if ((intDate / 2) == System.Math.Round(intDate / 2)) {
                                intDate = intDate / 2;
                            } else {
                                goto jumpOut;
                            }

                            if ((intMonth / 3) == System.Math.Round(intMonth / 3)) {
                                intMonth = intMonth / 3;
                            } else {
                                goto jumpOut;
                            }

                            if ((intYear / 4) == System.Math.Round(intYear / 4)) {
                                intYear = intYear / 4;
                            } else {
                                goto jumpOut;
                            }

                            stPass = "******";
                            if (Strings.Len(Convert.ToString(intYear)) == 1)
                                stPass = stPass + "0" + intYear + "/";
                            else
                                stPass = stPass + intYear + "/";
                            if (Strings.Len(Convert.ToString(intMonth)) == 1)
                                stPass = stPass + "0" + intMonth + "/";
                            else
                                stPass = stPass + intMonth + "/";
                            if (Strings.Len(Convert.ToString(intDate)) == 1)
                                stPass = stPass + "0" + intDate;
                            else
                                stPass = stPass + intDate;

                            if (Information.IsDate(stPass)) {
                                if (Convert.ToDateTime(stPass) >= (System.Date.FromOADate(DateAndTime.Today.ToOADate() - 31))) {
                                    modRecordSet.cnnDB.Execute("UPDATE Company SET Company_ResMS = '" + txtFields.Text + "';");
                                    CDKey = true;
                                }
                            }

                        } else {
                            Interaction.MsgBox("Not a Valid 4MEAT Key!", MsgBoxStyle.Critical);
                        }
                    } else {
                        Interaction.MsgBox("Not a Valid 4MEAT Key!", MsgBoxStyle.Critical);
                    }
                    jumpOut:
                    cCrypto = null;
                    // Free the Crypto class from memory
                    strTmp = new string(Strings.Chr(0), 250);
                    // overwrite data in temp variable
                    //Exit Sub

                } else {
                    Interaction.MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS");
                    //End
                }
            } else {
                Interaction.MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS");
                //End
            }

            cmdClose.Focus();
            System.Windows.Forms.Application.DoEvents();
            this.Close();
        }
Пример #2
0
        private void cmdClose_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            // ERROR: Not supported in C#: OnErrorStatement

            clsCryptoAPI cCrypto = null;
            // clsCryptoAPI

            string strSerial = null;
            string strTmp = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rj = default(ADODB.Recordset);

            //Piracy check
            System.DateTime lastCDKeyDate = default(System.DateTime);
            lastCDKeyDate = System.Date.FromOADate(DateAndTime.Today.ToOADate() - 356);
            //check if he is backdating while on the cd-key screen
            if (DateAndTime.Today != modApplication.loginDate) {
                if (DateAndTime.Today < (System.Date.FromOADate(modApplication.loginDate.ToOADate() - 30))) {
                    Interaction.MsgBox("ErrorCode:31 - The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                    CDKey = false;
                    cmdClose.Focus();
                    System.Windows.Forms.Application.DoEvents();
                    this.Close();
                    return;
                }
            }
            //
            //check if he is changing the date before the install date
            strSerial = Strings.FormatDateTime(modApplication.instalDate, DateFormat.ShortDate);
            modApplication.instalDate = Convert.ToDateTime(strSerial);
            strSerial = "";
            if (Convert.ToDateTime(modApplication.instalDate) > DateAndTime.Today) {
                Interaction.MsgBox("ErrorCode:64 - The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                CDKey = false;
                cmdClose.Focus();
                System.Windows.Forms.Application.DoEvents();
                this.Close();
                return;
            }
            //
            //check if current key is not older then the last used key (if any)
             // ERROR: Not supported in C#: OnErrorStatement

            rs = modRecordSet.getRS(ref "SELECT TOP 1 * FROM POS ORDER BY POS_CID DESC;");
            if (rs.RecordCount) {
                if (Strings.InStr(1, rs.Fields("POS_Code").Value, Strings.Chr(255))) {
                    lastCDKeyDate = getCDKeyDate(ref Convert.ToString(Strings.Split(rs.Fields("POS_Code").Value, Strings.Chr(255))[1]));
                }
            }
            //Piracy check

            txtFields.Text = Strings.Trim(Strings.Replace(txtFields.Text, "-", ""));
            if (Strings.Len(txtFields.Text) < 23) {
                Interaction.MsgBox("The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                CDKey = false;
                cmdClose.Focus();
                System.Windows.Forms.Application.DoEvents();
                this.Close();
                return;
            }

            cCrypto = new clsCryptoAPI();
            //clsCryptoAPI
            System.Windows.Forms.Application.DoEvents();
            txtFields.Text = Strings.LTrim(txtFields.Text);
            txtFields.Text = Strings.RTrim(txtFields.Text);
            txtFields.Text = Strings.Trim(txtFields.Text);
            txtFields.Text = Strings.Replace(txtFields.Text, " ", "");
            //strTmp = cCrypto.ConvertStringFromHex(Left(txtFields.Text, 6))
            strTmp = cCrypto.ConvertStringFromHex(Strings.Left(txtFields.Text, Strings.Len(txtFields.Text) - 5));
            System.Windows.Forms.Application.DoEvents();
            arData = cCrypto.StringToByteArray(strTmp);
            System.Windows.Forms.Application.DoEvents();
            arPWord = cCrypto.StringToByteArray(Conversion.Val(Strings.Right(txtFields.Text, 5)));
            System.Windows.Forms.Application.DoEvents();
            cCrypto.PassWord = arPWord;
            System.Windows.Forms.Application.DoEvents();
            cCrypto.InputData = System.Text.UnicodeEncoding.Unicode.GetString(arData);
            System.Windows.Forms.Application.DoEvents();

            // Decrypt the data input from the encrypted text box
            //If cCrypto.Decrypt(g_intHashType, m_intCipher) Then
            if (cCrypto.Decrypt(2, 1)) {
                System.Windows.Forms.Application.DoEvents();
                arData = cCrypto.OutputData.Clone();
                strSerial = cCrypto.ByteArrayToString(arData);
            }

            //If strSerial = "pos" Then
            short intDate = 0;
            short intYear = 0;
            short intMonth = 0;
            string dtDate = null;
            string dtMonth = null;
            string dtYear = null;
            string stPass = null;
            if (Strings.Left(strSerial, 3) == "pos") {

                //Create date password
                if (Information.IsNumeric(Strings.Mid(strSerial, 4, Strings.Len(strSerial)))) {
                    strSerial = Strings.Mid(strSerial, 4, Strings.Len(strSerial));
                    intYear = Convert.ToInt16(Strings.Mid(strSerial, 5, 2));
                    intMonth = Convert.ToInt16(Strings.Mid(strSerial, 3, 2));
                    intDate = Convert.ToInt16(Strings.Left(strSerial, 2));

                    if ((intDate / 2) == System.Math.Round(intDate / 2)) {
                        intDate = intDate / 2;
                    } else {
                        goto jumpOut;
                    }

                    if ((intMonth / 3) == System.Math.Round(intMonth / 3)) {
                        intMonth = intMonth / 3;
                    } else {
                        goto jumpOut;
                    }

                    if ((intYear / 4) == System.Math.Round(intYear / 4)) {
                        intYear = intYear / 4;
                    } else {
                        goto jumpOut;
                    }

                    stPass = "******";
                    if (Strings.Len(Convert.ToString(intYear)) == 1)
                        stPass = stPass + "0" + intYear + "/";
                    else
                        stPass = stPass + intYear + "/";
                    if (Strings.Len(Convert.ToString(intMonth)) == 1)
                        stPass = stPass + "0" + intMonth + "/";
                    else
                        stPass = stPass + intMonth + "/";
                    if (Strings.Len(Convert.ToString(intDate)) == 1)
                        stPass = stPass + "0" + intDate;
                    else
                        stPass = stPass + intDate;

                    if (Information.IsDate(stPass)) {
                        if (Convert.ToDateTime(stPass) < lastCDKeyDate) {
                            Interaction.MsgBox("ErrorCode:97 - The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                            CDKey = false;
                            cmdClose.Focus();
                            System.Windows.Forms.Application.DoEvents();
                            this.Close();
                            return;
                        }

                        if (Convert.ToDateTime(stPass) < 01/01/2012 00:00:00) {
                            Interaction.MsgBox("ErrorCode:82 - The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                            CDKey = false;
                            cmdClose.Focus();
                            System.Windows.Forms.Application.DoEvents();
                            this.Close();
                            return;
                        }

                        rs = modRecordSet.getRS(ref "Select TOP 1 * FROM Sale ORDER BY SaleID DESC;");
                        if (rs.RecordCount) {
                            if (Convert.ToDateTime(stPass) < System.Date.FromOADate(rs.Fields("Sale_Date").Value - 30)) {
                                Interaction.MsgBox("ErrorCode:28 - The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                                CDKey = false;
                                cmdClose.Focus();
                                System.Windows.Forms.Application.DoEvents();
                                this.Close();
                                return;
                            }
                        }

                        if (Convert.ToDateTime(stPass) >= (System.Date.FromOADate(DateAndTime.Today.ToOADate() - 31))) {
                            //Dim rs As Recordset
                            //Dim rj As Recordset
                            //Set rs = getRS("Select * FROM POS WHERE POS_Code = '" & Trim(strCDKey) & "'")
                            //    If rs.RecordCount > 0 Then
                            //       MsgBox "This CD has already been used for Installation. A 4POS CD is licensed for 1 Computer only, Please Insert next 4POS CD for the additional POS terminal you wish to Install.", vbApplicationModal + vbInformation + vbOKOnly, App.title
                            //       CDKey = False
                            //    Else
                            //        CDKey = True
                            //    End If
                            //
                            //    cnnDB.Execute "UPDATE Company SET Company_ResMS = '" & txtFields.Text & "';"
                            //    CDKey = True
                             // ERROR: Not supported in C#: OnErrorStatement

                            rs = modRecordSet.getRS(ref "Select * FROM POS;");
                            while (rs.EOF == false) {
                                if (Strings.InStr(1, rs.Fields("POS_Code").Value, Strings.Chr(255))) {
                                    if (Strings.Split(rs.Fields("POS_Code").Value, Strings.Chr(255))[1] == txtFields.Text) {
                                        Interaction.MsgBox("This CD has already been used for Installation. A 4POS CD is licensed for 1 Computer only, Please Insert next 4POS CD for the additional POS terminal you wish to Install.", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
                                        CDKey = false;
                                        goto jumpOut;
                                    }
                                }
                                rs.moveNext();
                            }
                            //all validation OK
                            CDKey = true;
                            basCryptoProcs.strCDKey = txtFields.Text;
                        } else {
                            Interaction.MsgBox("This '4POS CD Key' is expired!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                            CDKey = false;
                            goto jumpOut;
                        }
                    }

                } else {
                    Interaction.MsgBox("The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                    CDKey = false;
                    goto jumpOut;
                }

            } else {
                //MsgBox "Not a Valid 4POS CD or CD Key!", vbCritical
                Interaction.MsgBox("The '4POS CD Key' is invalid!", MsgBoxStyle.Exclamation, "4POS REGISTRATION");
                CDKey = false;
            }
            jumpOut:
            cCrypto = null;
            // Free the Crypto class from memory
            strTmp = new string(Strings.Chr(0), 250);
            // overwrite data in temp variable

            cmdClose.Focus();
            System.Windows.Forms.Application.DoEvents();
            //CDKey = False
            this.Close();
            Err_Close:

            //If Err.Number = 0 Then
            //Else
            //End If
             // ERROR: Not supported in C#: ResumeStatement
        }
Пример #3
0
        private bool checkSecurity()
        {
            bool functionReturnValue = false;
            int intMonth = 0;
            int intYear = 0;
            string lCode = null;
            string leCode = null;
            string lPassword = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            short x = 0;
            functionReturnValue = false;
            string strSerial = null;
            object strTmp = null;
            short intDate = 0;
            string dtDate = null;
            string dtMonth = null;
            string dtYear = null;
            string stPass = null;
            // clsCryptoAPI
            clsCryptoAPI cCrypto = null;
            if (modRecordSet.openConnection()) {
                rs = modRecordSet.getRS(ref "SELECT * From Company");

                if (rs.RecordCount) {
                    //if old database don't chk secuirty
                    if (rs.Fields.Count <= 55){functionReturnValue = true;return functionReturnValue;}

                    if (Information.IsDBNull(rs.Fields("Company_ResMS").Value)){functionReturnValue = false;return functionReturnValue;}

                    cCrypto = new clsCryptoAPI();
                    //clsCryptoAPI
                    System.Windows.Forms.Application.DoEvents();
                    //strTmp = cCrypto.ConvertStringFromHex(Left(rs("Company_ResMS"), 6))
                    strTmp = cCrypto.ConvertStringFromHex(Strings.Left(rs.Fields("Company_ResMS").Value, Strings.Len(rs.Fields("Company_ResMS").Value) - 5));
                    System.Windows.Forms.Application.DoEvents();
                    arData = cCrypto.StringToByteArray(strTmp);
                    System.Windows.Forms.Application.DoEvents();
                    arPWord = cCrypto.StringToByteArray(Conversion.Val(Strings.Right(rs.Fields("Company_ResMS").Value, 5)));
                    System.Windows.Forms.Application.DoEvents();
                    cCrypto.PassWord = arPWord;
                    System.Windows.Forms.Application.DoEvents();
                    cCrypto.InputData = System.Text.UnicodeEncoding.Unicode.GetString(arData);
                    System.Windows.Forms.Application.DoEvents();

                    // Decrypt the data input from the encrypted text box
                    //If cCrypto.Decrypt(g_intHashType, m_intCipher) Then
                    if (cCrypto.Decrypt(2, 1)) {
                        System.Windows.Forms.Application.DoEvents();
                        arData = cCrypto.OutputData.Clone();
                        strSerial = cCrypto.ByteArrayToString(arData);
                    }

                    if (Strings.Left(strSerial, 3) == "veg") {
                        //Create date password

                        if (Information.IsNumeric(Strings.Mid(strSerial, 4, Strings.Len(strSerial)))) {
                            functionReturnValue = true;
                            goto jumpOut;

                            strSerial = Strings.Mid(strSerial, 4, Strings.Len(strSerial));
                            intYear = Strings.Mid(strSerial, 5, 2);
                            intMonth = Strings.Mid(strSerial, 3, 2);
                            intDate = Convert.ToInt16(Strings.Left(strSerial, 2));

                            if ((intDate / 2) == System.Math.Round(intDate / 2)) {
                                intDate = intDate / 2;
                            } else {
                                goto jumpOut;
                            }

                            if ((intMonth / 3) == System.Math.Round(intMonth / 3)) {
                                intMonth = intMonth / 3;
                            } else {
                                goto jumpOut;
                            }

                            if ((intYear / 4) == System.Math.Round(intYear / 4)) {
                                intYear = intYear / 4;
                            } else {
                                goto jumpOut;
                            }

                            stPass = "******";
                            if (Strings.Len(Convert.ToString(intYear)) == 1) {
                                stPass = stPass + "0" + intYear + "/";
                            } else {
                                stPass = stPass + intYear + "/";
                            }
                            if (Strings.Len(Convert.ToString(intMonth)) == 1) {
                                stPass = stPass + "0" + intMonth + "/";
                            } else {
                                stPass = stPass + intMonth + "/";
                            }
                            if (Strings.Len(Convert.ToString(intDate)) == 1)
                                stPass = stPass + "0" + intDate;
                            else
                                stPass = stPass + intDate;

                            if (Information.IsDate(stPass)) {
                                if (Convert.ToDateTime(stPass) >= (System.Date.FromOADate(DateAndTime.Today.ToOADate() - 31))) {
                                    functionReturnValue = true;
                                }
                            }

                        } else {
                            //MsgBox "Not a Valid 4MEAT Key!", vbCritical
                        }
                    } else {
                        //MsgBox "Not a Valid 4MEAT Key!", vbCritical
                    }
                    jumpOut:
                    cCrypto = null;
                    // Free the Crypto class from memory
                    strTmp = new string(Strings.Chr(0), 250);
                    return functionReturnValue;
                    // overwrite data in temp variable

                } else {
                    Interaction.MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS");
                    //End
                }
            } else {
                Interaction.MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS");
                //End
            }
            return functionReturnValue;
        }
Пример #4
0
        private System.DateTime getCDKeyDate(ref string posCDKey)
        {
            // ERROR: Not supported in C#: OnErrorStatement

            clsCryptoAPI cCrypto = null;
            // clsCryptoAPI

            string strSerial = null;
            string strTmp = null;

            cCrypto = new clsCryptoAPI();
            //clsCryptoAPI
            System.Windows.Forms.Application.DoEvents();
            //strTmp = cCrypto.ConvertStringFromHex(Left(txtFields.Text, 6))
            strTmp = cCrypto.ConvertStringFromHex(Strings.Left(posCDKey, Strings.Len(posCDKey) - 5));
            System.Windows.Forms.Application.DoEvents();
            arData = cCrypto.StringToByteArray(strTmp);
            System.Windows.Forms.Application.DoEvents();
            arPWord = cCrypto.StringToByteArray(Conversion.Val(Strings.Right(posCDKey, 5)));
            System.Windows.Forms.Application.DoEvents();
            cCrypto.PassWord = arPWord;
            System.Windows.Forms.Application.DoEvents();
            cCrypto.InputData = System.Text.UnicodeEncoding.Unicode.GetString(arData);
            System.Windows.Forms.Application.DoEvents();

            // Decrypt the data input from the encrypted text box
            //If cCrypto.Decrypt(g_intHashType, m_intCipher) Then
            if (cCrypto.Decrypt(2, 1)) {
                System.Windows.Forms.Application.DoEvents();
                arData = cCrypto.OutputData.Clone();
                strSerial = cCrypto.ByteArrayToString(arData);
            }

            //If strSerial = "pos" Then
            short intDate = 0;
            short intYear = 0;
            short intMonth = 0;
            string dtDate = null;
            string dtMonth = null;
            string dtYear = null;
            string stPass = null;
            if (Strings.Left(strSerial, 3) == "pos" | Strings.Left(strSerial, 3) == "pre") {

                //Create date password
                if (Information.IsNumeric(Strings.Mid(strSerial, 4, Strings.Len(strSerial)))) {
                    strSerial = Strings.Mid(strSerial, 4, Strings.Len(strSerial));
                    intYear = Convert.ToInt16(Strings.Mid(strSerial, 5, 2));
                    intMonth = Convert.ToInt16(Strings.Mid(strSerial, 3, 2));
                    intDate = Convert.ToInt16(Strings.Left(strSerial, 2));

                    if ((intDate / 2) == System.Math.Round(intDate / 2)) {
                        intDate = intDate / 2;
                    } else {
                        goto jumpOut;
                    }

                    if ((intMonth / 3) == System.Math.Round(intMonth / 3)) {
                        intMonth = intMonth / 3;
                    } else {
                        goto jumpOut;
                    }

                    if ((intYear / 4) == System.Math.Round(intYear / 4)) {
                        intYear = intYear / 4;
                    } else {
                        goto jumpOut;
                    }

                    stPass = "******";
                    if (Strings.Len(Convert.ToString(intYear)) == 1)
                        stPass = stPass + "0" + intYear + "/";
                    else
                        stPass = stPass + intYear + "/";
                    if (Strings.Len(Convert.ToString(intMonth)) == 1)
                        stPass = stPass + "0" + intMonth + "/";
                    else
                        stPass = stPass + intMonth + "/";
                    if (Strings.Len(Convert.ToString(intDate)) == 1)
                        stPass = stPass + "0" + intDate;
                    else
                        stPass = stPass + intDate;

                    if (Information.IsDate(stPass)) {
                        //    If CDate(stPass) >= (Date - 31) Then

                    }
                }
            }
            jumpOut:

            cCrypto = null;
            // Free the Crypto class from memory
            strTmp = new string(Strings.Chr(0), 250);
            // overwrite data in temp variable

            return Convert.ToDateTime(stPass);
        }
Пример #5
0
        private bool checkSecurity()
        {
            bool functionReturnValue = false;
            object intMonth = null;
            object intYear = null;
            string lCode = null;
            string leCode = null;
            string lPassword = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            short x = 0;
            functionReturnValue = false;
            string strSerial = null;
            object strTmp = null;
            short intDate = 0;
            string dtDate = null;
            string dtMonth = null;
            string dtYear = null;
            string stPass = null;
            // clsCryptoAPI
            //UPGRADE_ISSUE: clsCryptoAPI object was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6B85A2A7-FE9F-4FBE-AA0C-CF11AC86A305"'
            clsCryptoAPI cCrypto = null;
            if (modRecordSet.openConnection()) {
                rs = modRecordSet.getRS(ref "SELECT * From Company");
                if (rs.RecordCount) {

                    //if old database don't chk secuirty
                    if (rs.Fields.Count <= 55){functionReturnValue = true;return functionReturnValue;}

                    //UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
                    if (Information.IsDBNull(rs.Fields("Company_ResMS").Value)){functionReturnValue = false;return functionReturnValue;}

                    cCrypto = new clsCryptoAPI();
                    //clsCryptoAPI
                    System.Windows.Forms.Application.DoEvents();
                    //strTmp = cCrypto.ConvertStringFromHex(Left(rs("Company_ResMS"), 6))
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.ConvertStringFromHex. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    //UPGRADE_WARNING: Couldn't resolve default property of object strTmp. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    strTmp = cCrypto.ConvertStringFromHex(Strings.Left(rs.Fields("Company_ResMS").Value, Strings.Len(rs.Fields("Company_ResMS").Value) - 5));
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.StringToByteArray. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    arData = cCrypto.StringToByteArray(strTmp);
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.StringToByteArray. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    arPWord = cCrypto.StringToByteArray(Conversion.Val(Strings.Right(rs.Fields("Company_ResMS").Value, 5)));
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.password. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    //UPGRADE_TODO: Code was upgraded to use System.Text.UnicodeEncoding.Unicode.GetString() which may not have the same behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="93DD716C-10E3-41BE-A4A8-3BA40157905B"'
                    cCrypto.PassWord = arPWord;
                    System.Windows.Forms.Application.DoEvents();
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.InputData. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    //UPGRADE_TODO: Code was upgraded to use System.Text.UnicodeEncoding.Unicode.GetString() which may not have the same behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="93DD716C-10E3-41BE-A4A8-3BA40157905B"'
                    cCrypto.InputData = System.Text.UnicodeEncoding.Unicode.GetString(arData);
                    System.Windows.Forms.Application.DoEvents();

                    // Decrypt the data input from the encrypted text box
                    //If cCrypto.Decrypt(g_intHashType, m_intCipher) Then
                    //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.Decrypt. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    if (cCrypto.Decrypt(2, 1)) {
                        System.Windows.Forms.Application.DoEvents();
                        //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.OutputData. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        arData = cCrypto.OutputData.Clone();
                        //UPGRADE_WARNING: Couldn't resolve default property of object cCrypto.ByteArrayToString. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                        strSerial = cCrypto.ByteArrayToString(arData);
                    }

                    if (Strings.Left(strSerial, 3) == "liq") {

                        //Create date password
                        if (Information.IsNumeric(Strings.Mid(strSerial, 4, Strings.Len(strSerial)))) {

                            functionReturnValue = true;
                            goto jumpOut;

                            strSerial = Strings.Mid(strSerial, 4, Strings.Len(strSerial));
                            //UPGRADE_WARNING: Couldn't resolve default property of object intYear. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                            intYear = Strings.Mid(strSerial, 5, 2);
                            //UPGRADE_WARNING: Couldn't resolve default property of object intMonth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                            intMonth = Strings.Mid(strSerial, 3, 2);
                            intDate = Convert.ToInt16(Strings.Left(strSerial, 2));

                            if ((intDate / 2) == System.Math.Round(intDate / 2)) {
                                intDate = intDate / 2;
                            } else {
                                goto jumpOut;
                            }

                            //UPGRADE_WARNING: Couldn't resolve default property of object intMonth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                            if ((intMonth / 3) == System.Math.Round(intMonth / 3)) {
                                //UPGRADE_WARNING: Couldn't resolve default property of object intMonth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                                intMonth = intMonth / 3;
                            } else {
                                goto jumpOut;
                            }

                            //UPGRADE_WARNING: Couldn't resolve default property of object intYear. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                            if ((intYear / 4) == System.Math.Round(intYear / 4)) {
                                //UPGRADE_WARNING: Couldn't resolve default property of object intYear. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                                intYear = intYear / 4;
                            } else {
                                goto jumpOut;
                            }

                            stPass = "******";
                            //UPGRADE_WARNING: Couldn't resolve default property of object intYear. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                            if (Strings.Len(Convert.ToString(intYear)) == 1) {
                                stPass = stPass + "0" + intYear + "/";
                            } else {
                                //UPGRADE_WARNING: Couldn't resolve default property of object intYear. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                                stPass = stPass + intYear + "/";
                            }
                            //UPGRADE_WARNING: Couldn't resolve default property of object intMonth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                            if (Strings.Len(Convert.ToString(intMonth)) == 1) {
                                stPass = stPass + "0" + intMonth + "/";
                            } else {
                                //UPGRADE_WARNING: Couldn't resolve default property of object intMonth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                                stPass = stPass + intMonth + "/";
                            }
                            if (Strings.Len(Convert.ToString(intDate)) == 1)
                                stPass = stPass + "0" + intDate;
                            else
                                stPass = stPass + intDate;

                            if (Information.IsDate(stPass)) {
                                if (Convert.ToDateTime(stPass) >= (System.Date.FromOADate(DateAndTime.Today.ToOADate() - 31))) {
                                    functionReturnValue = true;
                                }
                            }

                        } else {
                            //MsgBox "Not a Valid 4MEAT Key!", vbCritical
                        }
                    } else {
                        //MsgBox "Not a Valid 4MEAT Key!", vbCritical
                    }
                    jumpOut:
                    //UPGRADE_NOTE: Object cCrypto may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
                    cCrypto = null;
                    // Free the Crypto class from memory
                    //UPGRADE_WARNING: Couldn't resolve default property of object strTmp. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    strTmp = new string(Strings.Chr(0), 250);
                    return functionReturnValue;
                    // overwrite data in temp variable

                } else {
                    Interaction.MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS");
                    //End
                }
            } else {
                Interaction.MsgBox("Unable to locate the '4POS Application Suite' database.", MsgBoxStyle.Critical, "4POS");
                //End
            }
            return functionReturnValue;
        }