Posts Per Day 2.2 Patch 2.2 This mod requires that Posts Per Day Mod version 2.0 is already installed. Changes in Version 2.2: - Improved accuracy for the posts per day - Works with all date formats using numbers - For example: DD.MM.YY or MM.DD.YYYY or MM.DD.YY, etc. - It will output an error if you have an invalid format - Moved text to english.lng file -- Tip -- To display the Posts Per Day up to x decimals, change this line: printf("%.Xf", $ppd); Where the X is replaced with a number, for example: printf("%.3f", $ppd); # (will look like 4.157) or: printf("%.4f", $ppd); # (will look like 4.1579) Andy, StarSaber http://www.czarandy.f2s.com Sources/Display.pl # Posts Per Day Mod # # Math and a few other things by Andy. # Math and other things by StarSaber - Fixed to be compatible with everyone. fopen(FILE, "$memberdir/$useraccount{$musername}.dat"); @memsettings=; fclose(FILE); foreach (@memsettings) { $_ =~ s~[\n\r]~~g; } # Open users reg date for editing. $datereg = $memsettings[14]; # Get Month from user $monthreg = substr($memsettings[14], 0, 2); # Get Day from user $dayreg = substr($memsettings[14], 3, 2); # Get Year from user $yearreg = substr($memsettings[14], 6, 2); ######################### ### POSTS PER DAY MOD ### ### VERSION 2.2 ### ### BY ANDY GODER ### ### AND StarSaber ### ### andy@goder.com ### ######################### $error = ''; $posts = $userprofile[6]; # Load Settings fopen(FILE, "$memberdir/$useraccount{$musername}.dat"); @memsettings=; fclose(FILE); foreach (@memsettings) { $_ =~ s~[\n\r]~~g; } # Get the date/time settings so we can extract the month/day/year if ($timeselected == 1) { $monthreg = substr($datereg, 0, 2); $dayreg = substr($datereg, 3, 2); $yearreg = substr($datereg, 6, 2); } elsif ($timeselected == 2) { $monthreg = substr($datereg, 3, 2); $dayreg = substr($datereg, 0, 2); $yearreg = substr($datereg, 6, 2); } elsif ($timeselected == 3) { $monthreg = substr($datereg, 3, 2); $dayreg = substr($datereg, 0, 2); $yearreg = substr($datereg, 8, 2); } elsif ($timeselected == 5) { $monthreg = substr($datereg, 0, 2); $dayreg = substr($datereg, 3, 2); $yearreg = substr($datereg, 6, 2); } else { $error = $ppd_errors[0]; } # Formula to do for users registration date. $days_reg = (365 * $yearreg) + (30.4166666666666666666666666666667 * $monthreg) + $dayreg; # Formula to do for the current date. $days_now = (365 * $year) + (30.4166666666666666666666666666667 * $month) + $mday; # Formula to get date of registration $days_reg = (365 * $yearreg) + ($ppd_month_day[$month-1] * $monthreg) + $dayreg; # Formula to get current date $days_now = (365 * $year ) + ($ppd_month_day[$month-1] * $month) + $mday; # If user has been registered for less than 1 day display a message on the side so users won't get an error from perl. # If all is correct divide the post count by the subtracted dates done earlier. if( $days_now - $days_reg == 0 ) { $posts_per_day = "na"; } else { $posts_per_day = $postcount / ($days); } # Mod compleate # # Display error message if user has been registered for less than 1 day if ($days > 0) { $ppd = $posts / $days; } else { $error = $ppd_errors[1]; } # Additional error checking if (($month < 0) || ($month > 12)) { $error = $ppd_errors[2]; } if (($ppd == 0) || ($ppd > $posts)) { $ppd = $posts; } # If there is an error, display it if ($error != '') { $ppd = $error; } ################################ ### END OF POSTS PER DAY MOD ### ################################ Posts Per Day: $ppd_txt english.lng $txt{'749'} = "The 'number of posts' box can only contain digits."; $ppd_txt = "Posts Per Day:"; $ppd_errors[0] = 'You are using an invalid time/date format. Posts Per Day mod only works with formats that use numbers for the date. Please change your time/date format so that Posts Per Day mod will work correctly.'; $pdd_errors[1] = 'n/a'; $ppd_errors[2] = 'Invalid Month!'; $ppd_month_day[0] = 31; $ppd_month_day[1] = 28.25; $ppd_month_day[2] = 31; $ppd_month_day[3] = 30; $ppd_month_day[4] = 31; $ppd_month_day[5] = 30; $ppd_month_day[6] = 31; $ppd_month_day[7] = 30; $ppd_month_day[8] = 31; $ppd_month_day[9] = 31; $ppd_month_day[10] = 30; $ppd_month_day[11] = 31;