コード例 #1
0
ファイル: Users.cs プロジェクト: sedogo/business-objects
        //===============================================================
        // Function: CheckChangePassword
        //
        // This function checks the password is valid for this contact
        // It does NOT change the password in the database
        // The following rules can be checked depending on system settings
        // - Min password length
        // - Max password length
        // - Mixed case
        // - Force alphanumeric (password must have letters and numbers)
        // - Force non-alphanumerix (password must have punctuation characters in it)
        // - Password history check, cannot re-use any of the last x passwords
        //===============================================================
        public Boolean CheckChangePassword(string password, out Byte reason)
        {
            // passwordChangeResults { passwordOK, passwordTooShort, passwordTooLong, passwordMixedCase,
            // passwordNeedsDigit, passwordSpecialCharacter, passwordReused }
            Boolean returnStatus = true;
            reason = 0;

            string pwdCheckMinLengthEnabled = "N";
            int pwdCheckMinLength = 1;
            string pwdCheckMaxLengthEnabled = "N";
            int pwdCheckMaxLength = 999;
            string pwdCheckMixedCaseEnabled = "N";
            string pwdCheckNeedsDigitEnabled = "N";
            string pwdCheckSpecialCharacterEnabled = "N";
            string pwdCheckNeedsReusedEnabled = "N";
            int pwdCheckReusedNumber = 1;

            const string lower = "abcdefghijklmnopqrstuvwxyz";
            const string upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            const string digits = "0123456789";
            string allChars = lower + upper + digits;

            try
            {
                GlobalData globalData = new GlobalData(m_loggedInUser);
                pwdCheckMinLengthEnabled = globalData.GetStringValue("PwdCheckMinLengthEnabled");
                pwdCheckMinLength = globalData.GetIntegerValue("PwdCheckMinLength");
                pwdCheckMaxLengthEnabled = globalData.GetStringValue("PwdCheckMaxLengthEnabled");
                pwdCheckMaxLength = globalData.GetIntegerValue("PwdCheckMaxLength");
                pwdCheckMixedCaseEnabled = globalData.GetStringValue("PwdCheckMixedCaseEnabled");
                pwdCheckNeedsDigitEnabled = globalData.GetStringValue("PwdCheckNeedsDigitEnabled");
                pwdCheckSpecialCharacterEnabled = globalData.GetStringValue("PwdCheckSpecialCharacterEnabled");
                pwdCheckNeedsReusedEnabled = globalData.GetStringValue("PwdCheckNeedsReusedEnabled");
                pwdCheckReusedNumber = globalData.GetIntegerValue("PwdCheckReusedNumber");
            }
            catch (Exception)
            {
                throw (new Exception("Error getting global data values for password checks"));
            }

            if (pwdCheckMinLengthEnabled == "Y")
            {
                if (password.Length < pwdCheckMinLength)
                {
                    reason = reason |= (int)passwordChangeResults.passwordTooShort;
                    returnStatus = false;
                }
            }
            if (pwdCheckMaxLengthEnabled == "Y")
            {
                if (password.Length > pwdCheckMaxLength)
                {
                    reason = reason |= (int)passwordChangeResults.passwordTooLong;
                    returnStatus = false;
                }
            }
            if (pwdCheckMixedCaseEnabled == "Y")
            {
                if (!((password.IndexOfAny(lower.ToCharArray()) >= 0) && (password.IndexOfAny(upper.ToCharArray()) >= 0)))
                {
                    reason = reason |= (int)passwordChangeResults.passwordMixedCase;
                    returnStatus = false;
                }
            }
            if (pwdCheckNeedsDigitEnabled == "Y")
            {
                if (!(password.IndexOfAny(digits.ToCharArray()) >= 0))
                {
                    reason = reason |= (int)passwordChangeResults.passwordNeedsDigit;
                    returnStatus = false;
                }
            }
            if (pwdCheckSpecialCharacterEnabled == "Y")
            {
                if (!(password.Trim(allChars.ToCharArray()).Length > 0))
                {
                    reason = reason |= (int)passwordChangeResults.passwordSpecialCharacter;
                    returnStatus = false;
                }
            }
            if (pwdCheckNeedsReusedEnabled == "Y")
            {
                // pwdCheckReusedNumber
            }

            return returnStatus;
        }
コード例 #2
0
ファイル: ImageHelper.cs プロジェクト: sedogo/site
    /// <summary>
    /// Returns the Triplet{width, height, radius} with coordinates containnig respictive width and height of the image
    /// </summary>
    /// <returns>Triplet{width, height, radius}</returns>
    public static Triplet<int, int, int> GetImageSize(ImageType type)
    {
        GlobalData gd = new GlobalData("");
        int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
        int previewSize = gd.GetIntegerValue("PreviewSize");
        int thumbnailSizeSmall = gd.GetIntegerValue("ThumbnailSizeSmall");//110 gd.GetIntegerValue("ThumbnailSize");
        int thumbnailSizeSlideShow = gd.GetIntegerValue("ThumbnailSizeSlideShow");

        Triplet<int, int, int> dimensions;
        switch (type)
        {
            case ImageType.UserPreview: //1
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.UserThumbnail: //2
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventPreview: //3
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.EventThumbnail: //4
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventCommentPreview: //5
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.EventCommentThumbnail: //6
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventPicturePreview: //7
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.EventPictureThumbnail: //8
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventPictureThumbnailSmall: //13
                dimensions = new Triplet<int, int, int>(thumbnailSizeSmall, thumbnailSizeSmall, 0);
                break;
            case ImageType.EventPictureThumbnailSlideShow: //14
                dimensions = new Triplet<int, int, int>(thumbnailSizeSlideShow, thumbnailSizeSlideShow, 0);
                break;
            default:
                dimensions = new Triplet<int, int, int>();
                break;
        }
        return dimensions;
    }
コード例 #3
0
ファイル: MiscUtils.cs プロジェクト: sedogo/business-objects
        //===============================================================
        // Function: CreatePreviews
        // Description:
        //===============================================================
        public static int CreatePreviews(string fullFileName)
        {
            int returnStatus = -1;
            string filename = Path.GetFileName(fullFileName);
            string filePath = Path.GetFullPath(fullFileName);
            GlobalData gd = new GlobalData("");
            int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
            int previewSize = gd.GetIntegerValue("PreviewSize");
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\profilePics";
            string thumbnailFileName = "";
            string previewFileName = "";
             //           File.Copy(fullFileName, Path.Combine(fileStoreFolderTemp, filename));
            int thumbnailStatus = GenerateThumbnail(filePath,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(filePath, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(filePath, previewFileName));

                //File.Move(Path.Combine(fileStoreFolderTemp, filename), destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);
                returnStatus = 0;
            }

            return returnStatus;
        }
コード例 #4
0
ファイル: MiscUtils.cs プロジェクト: sedogo/business-objects
        //===============================================================
        // Function: CreatePreviews
        // Description:
        //===============================================================
        public static int CreatePreviews(string filename, int userID)
        {
            int returnStatus = -1;

            GlobalData gd = new GlobalData("");
            int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
            int previewSize = gd.GetIntegerValue("PreviewSize");
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\profilePics";
            string thumbnailFileName = "";
            string previewFileName = "";

            int thumbnailStatus = GenerateThumbnail(fileStoreFolderTemp,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, previewFileName));

                File.Move(Path.Combine(fileStoreFolderTemp, filename),
                    destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);

                SedogoUser user = new SedogoUser("", userID);
                user.profilePicFilename = filename;
                user.profilePicPreview = previewFileName;
                user.profilePicThumbnail = thumbnailFileName;
                user.UpdateUserProfilePic();

                returnStatus = 0;
            }

            return returnStatus;
        }
コード例 #5
0
ファイル: MiscUtils.cs プロジェクト: sedogo/business-objects
        //===============================================================
        // Function: CreateGoalPicPreviews
        // Description:
        //===============================================================
        public static int CreateGoalPicPreviews(string filename, int eventID, string loggedInContactName,
            int postedByUserID, string caption)
        {
            int returnStatus = -1;

            GlobalData gd = new GlobalData("");
            int thumbnailSize =  gd.GetIntegerValue("ThumbnailSize");//100;
            int previewSize =  gd.GetIntegerValue("PreviewSize");//500;
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\eventPics";

            string thumbnailFileName = "";
            string previewFileName = "";
            int thumbnailStatus = GenerateThumbnail(fileStoreFolderTemp,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, previewFileName));

                File.Move(Path.Combine(fileStoreFolderTemp, filename),
                    destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);

                SedogoEventPicture pic = new SedogoEventPicture(loggedInContactName);
                pic.eventID = eventID;
                pic.postedByUserID = postedByUserID;
                pic.eventImageFilename = Path.GetFileName(destFilename);
                pic.eventImagePreview = Path.GetFileName(destPreviewFilename);
                pic.eventImageThumbnail = Path.GetFileName(destThumbnailFilename);
                pic.caption = caption;
                pic.Add();

                returnStatus = pic.eventPictureID;
            }

            return returnStatus;
        }
コード例 #6
0
ファイル: MiscUtils.cs プロジェクト: sedogo/business-objects
        //===============================================================
        // Function: CreateEventCommentImagePreviews
        // Description:
        //===============================================================
        public static int CreateEventCommentImagePreviews(string filename,
            out string savedFileName, out string thumbnailFileName, out string previewFileName)
        {
            int returnStatus = -1;

            GlobalData gd = new GlobalData("");
            int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
            int previewSize = 500;  // gd.GetIntegerValue("PreviewSize");
            string fileStoreFolder = gd.GetStringValue("FileStoreFolder");
            string fileStoreFolderTemp = fileStoreFolder + "\\temp";
            string fileStoreFolderProfilePics = fileStoreFolder + "\\eventPics";
            savedFileName = "";
            thumbnailFileName = "";
            previewFileName = "";

            // Just for the goal comments, if the image is smaller than 500, leave it at its
            // original size
            System.Drawing.Image sourceImagePreview = System.Drawing.Image.FromFile(fileStoreFolderTemp + @"\" + filename);
            if (sourceImagePreview.Width < previewSize)
            {
                previewSize = sourceImagePreview.Width;
            }
            sourceImagePreview.Dispose();

            int thumbnailStatus = GenerateThumbnail(fileStoreFolderTemp,
                filename, thumbnailSize, thumbnailSize, previewSize, previewSize,
                out thumbnailFileName, out previewFileName);

            if (thumbnailStatus > 0)
            {
                // Move the thumbnails to the /profilePics folder and update the user
                string destFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, filename));
                string destThumbnailFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, thumbnailFileName));
                string destPreviewFilename = MiscUtils.GetUniqueFileName(Path.Combine(fileStoreFolderProfilePics, previewFileName));

                File.Move(Path.Combine(fileStoreFolderTemp, filename),
                    destFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, thumbnailFileName),
                    destThumbnailFilename);
                File.Move(Path.Combine(fileStoreFolderTemp, previewFileName),
                    destPreviewFilename);

                savedFileName = destFilename;
                thumbnailFileName = destThumbnailFilename;
                previewFileName = destPreviewFilename;

                returnStatus = 0;
            }

            return returnStatus;
        }