| <?php |
| /////////////////////////////////////////////////////////////////////////////// |
| // mailing_test.php // |
| // // |
| // Generates data for the mailing_list_stats table inside phoenix database // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection.class.php"; |
| require_once "utils.php"; |
| |
| #Connection to Eclipse Database |
| $db_connection = new DBConnection(); |
| $db_handle = $db_connection->connect(); |
| |
| #Read groups.txt File |
| $testFile = "groups.txt"; |
| $fileObject = fopen($testFile,'r'); |
| |
| #Read the date parameter |
| /*$start_date = 0; |
| if(isset($_GET['start_date'])){ |
| $start_date = $_GET['start_date']; |
| } |
| */ |
| #Clean the table for fresh data |
| $deleteData = mysql_query("DELETE FROM `mailing_list_stats`",$db_handle); |
| |
| #Table Feed begins... |
| while (!feof($fileObject)){ |
| $line=fgets($fileObject); |
| $firstChar = substr($line,0,1); |
| if($firstChar<>"#"){ |
| $separatedLine = explode("|",$line); |
| if($separatedLine[3] <> ""){ |
| $projectName = $separatedLine[2]; |
| $mailing_lists = $separatedLine[3]; |
| $mail_list = explode(",",$mailing_lists); |
| $number_of_lists = sizeof($mail_list); |
| for($i = 0;$i<$number_of_lists;$i++){ |
| |
| #Set the seed for Member count |
| mt_srand((double)microtime()*1000000); |
| $member_count = mt_rand(0,100); |
| |
| for($x=30;$x>=1;$x--){ |
| #<!-- Generate Randoms BEGIN--> |
| mt_srand((double)microtime()*1000000); |
| |
| #<!-- For the is_private parameter BEGIN--> |
| $is_private = mt_rand(0,1); |
| #<!-- For the is_private parameter END--> |
| |
| #<!-- For the daily_post_parameter BEGIN--> |
| $daily_post_count = mt_rand(0,1); |
| |
| if($daily_post_count == 1){ |
| $daily_post_count = mt_rand(0,10); |
| } |
| #<!-- For the daily_post_parameter END--> |
| |
| #<!-- For the member_count_parameter BEGIN--> |
| $decission = mt_rand(0,49); |
| if($decission == 49){ |
| $member_count = $member_count-2; |
| } |
| if($decission == 48){ |
| $member_count = $member_count-1; |
| } |
| if($decission >= 0 && $decission <= 35){ |
| $member_count = $member_count; //Keeps the same value |
| } |
| if($decission >= 36 && $decission <= 38){ |
| $member_count = $member_count+1; //plus 1 |
| } |
| if($decission >= 39 && $decission <= 41){ |
| $member_count = $member_count+2; //plus 2 |
| } |
| if($decission >= 42 && $decission <= 44){ |
| $member_count = $member_count+3; //plus 3 |
| } |
| if($decission >= 45 && $decission <= 47){ |
| $member_count = $member_count+4; //plus 4 |
| } |
| #<!-- For the member_count_parameter END--> |
| |
| #<!-- Generate Randoms END--> |
| |
| #Calculates the start date (it will start 30 days before today) |
| $myDate = getDateBefore($x); |
| /* |
| echo "NAME: ".$mail_list[$i]." "; |
| echo "SUMMARY DATE: ".$myDate." "; |
| echo "DAILY POST COUNT: ".$daily_post_count." "; |
| echo "MEMBER COUNT: ".$member_count." "; |
| echo "IS PRIVATE: ".$is_private." "; |
| echo "<br>"; |
| */ |
| $altaLista=mysql_query("INSERT INTO `mailing_list_stats` ( `list_name` , `summary_date` , `daily_post_count` , `total_member_count` |
| )VALUES ('$mail_list[$i]', '$myDate', $daily_post_count, $member_count)", $db_handle)or die("MySQL Error: ".mysql_error()); |
| } |
| } |
| } |
| } |
| } |
| |
| $db_handle = null; |
| $db_connection = null; |
| |
| ?> |
| |