| <?php |
| |
| class ReviewInfo { |
| var $_attributes; |
| /* |
| * J2 - review scheduled date & time |
| * J3 - review slides & bug posted |
| * J4 - review slides & bug & IP posted |
| * JP - review pending, waiting for legal or the Board |
| * J5 - review successful |
| * J6 - review not complete, further work to occur |
| * J7 - review withdrawn |
| */ |
| var $_status; |
| var $_lastdate; |
| var $_reviewdate; |
| |
| function load( $firstbuffer, $lines, &$idx ) { |
| $this->_attributes = Array(); |
| $pos = strpos($firstbuffer, ": "); |
| $key = substr($firstbuffer, 0, $pos); |
| $value = substr($firstbuffer, $pos+2); |
| $value = trim($value); |
| $this->_attributes[$key] = $value; |
| if( trim($value) == "" ) { |
| $this->_status = "bogus"; |
| return; |
| } |
| |
| while($idx < count($lines)){ |
| $buffer = $lines[$idx++]; |
| $buffer = substr($buffer,0,-1); // Remove new line char |
| |
| if (!strlen(trim($buffer))) |
| break; |
| |
| $pos = strpos($buffer, ": "); |
| $key = substr($buffer, 0, $pos); |
| $value = substr($buffer, $pos+2); |
| $this->_attributes[$key] = $value; |
| } |
| if( $this->get("Status; Review Scheduled") != "" ) { |
| $this->_status = "J2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Slides Posted") != "" ) { |
| $this->_status = "J3"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; IP Log Posted") != "" ) { |
| $this->_status = "J4"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Pending") != "" ) { |
| $this->_status = "JP"; |
| $this->_lastdate = $this->_lastget; |
| if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Successful") != "" ) { |
| $this->_status = "J5"; |
| $this->_lastdate = $this->_lastget; |
| if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Unsuccessful") != "" ) { |
| $this->_status = "J6"; |
| $this->_lastdate = $this->_lastget; |
| if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Withdrawn") != "" ) { |
| $this->_status = "J7"; |
| $this->_lastdate = $this->_lastget; |
| if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget; |
| } |
| } |
| function lastdate() { |
| return $this->_lastdate; |
| } |
| function get($key) { |
| if( !array_key_exists($key, $this->_attributes) ) { |
| $this->_lastget = ""; |
| return ""; |
| } |
| $value = $this->_attributes[$key]; |
| if( $value == null ) return ""; |
| $value = trim($value); |
| $this->_lastget = $value; |
| return $value; |
| } |
| function status() { |
| return $this->_status; |
| } |
| function name() { |
| return $this->get("Project Name"); |
| } |
| function is_more_than_one_quarter_old() { |
| $today = getdate(); |
| $then = numerical_date($this->_lastdate); |
| $today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]); |
| return ($then + 110) < $today; |
| } |
| function review_is_more_than_one_month_old() { |
| if( $this->_reviewdate == "" ) return false; |
| $today = getdate(); |
| $then = numerical_date($this->_reviewdate); |
| $today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]); |
| return ($then + 31) < $today; |
| } |
| } |
| |
| class ProposalInfo { |
| var $_attributes; |
| /* |
| * P1 - proposal posted |
| * P2 - proposal updated |
| * P3 - review scheduled date & time |
| * P4 - review slides & bug posted |
| * PP - review completed, waiting for PMC or Board |
| * P5 - review successful, awaiting provisioning |
| * PW - review successful, awaiting webmaster to provision |
| * P6 - review not complete, further work required |
| * P7 - project completed |
| * P8 - proposal withdrawn |
| * P9 - proposal archived |
| */ |
| var $_status; |
| var $_lastdate; |
| var $_lastget; |
| var $_reviewdate; |
| |
| function load( $firstbuffer, $lines, &$idx ) { |
| $this->_attributes = Array(); |
| $pos = strpos($firstbuffer, ": "); |
| $key = substr($firstbuffer, 0, $pos); |
| $value = substr($firstbuffer, $pos+2); |
| $value = trim($value); |
| $this->_attributes[$key] = $value; |
| if( $value == "" ) { |
| $this->_status = "bogus"; |
| return; |
| } |
| |
| while($idx < count($lines)){ |
| $buffer = $lines[$idx++]; |
| $buffer = substr($buffer,0,-1); // Remove new line char |
| |
| if (!strlen(trim($buffer))) |
| break; |
| |
| $pos = strpos($buffer, ": "); |
| $key = substr($buffer, 0, $pos); |
| $value = substr($buffer, $pos+2); |
| $this->_attributes[$key] = $value; |
| } |
| if( $this->get("Status; Proposal Posted") != "" ) { |
| $this->_status = "P1"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 1") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 2") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 3") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 4") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 5") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 6") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 7") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 8") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Updated 9") != "" ) { |
| $this->_status = "P2"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Scheduled") != "" ) { |
| $this->_status = "P3"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Slides Posted") != "" ) { |
| $this->_status = "P4"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Pending") != "" ) { |
| $this->_status = "PP"; |
| $this->_lastdate = $this->_lastget; |
| if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Unsuccessful") != "" ) { |
| $this->_status = "P6"; |
| $this->_lastdate = $this->_lastget; |
| if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget; |
| } |
| if( $this->get("Status; Review Successful") != "" ) { |
| $this->_status = "P5"; |
| $this->_lastdate = $this->_lastget; |
| if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget; |
| } |
| if( $this->get("Status; Waiting Provisioning") != "" ) { |
| $this->_status = "PW"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Provisioning Complete") != "" ) { |
| $this->_status = "P7"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Proposal Withdrawn") != "" ) { |
| $this->_status = "P8"; |
| $this->_lastdate = $this->_lastget; |
| } |
| if( $this->get("Status; Project Archived") != "" ) { |
| $this->_status = "P9"; |
| $this->_lastdate = $this->_lastget; |
| } |
| } |
| function lastdate() { |
| return $this->_lastdate; |
| } |
| function get($key) { |
| if( !array_key_exists($key, $this->_attributes) ) { |
| $this->_lastget = ""; |
| return ""; |
| } |
| $value = $this->_attributes[$key]; |
| if( $value == null ) return ""; |
| $value = trim($value); |
| $this->_lastget = $value; |
| return $value; |
| } |
| function status() { |
| return $this->_status; |
| } |
| function name() { |
| return $this->get("Proposal Name"); |
| } |
| function is_more_than_one_quarter_old() { |
| $today = getdate(); |
| $then = numerical_date($this->_lastdate); |
| $today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]); |
| return ($then + 110) < $today; |
| } |
| function is_more_than_two_months_old() { |
| $today = getdate(); |
| $then = numerical_date($this->_lastdate); |
| $today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]); |
| return ($then + 60) < $today; |
| } |
| function is_more_than_one_month_old() { |
| $today = getdate(); |
| $then = numerical_date($this->_lastdate); |
| $today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]); |
| return ($then + 30) < $today; |
| } |
| function is_more_than_two_weeks_old() { |
| $today = getdate(); |
| $then = numerical_date($this->_lastdate); |
| $today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]); |
| return ($then + 15) < $today; |
| } |
| function review_is_more_than_one_month_old() { |
| if( $this->_reviewdate == "" ) return false; |
| $today = getdate(); |
| $then = numerical_date($this->_reviewdate); |
| $today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]); |
| return ($then + 31) < $today; |
| } |
| function proposal_age() { |
| $tm_then = strtotime( $this->get("Status; Proposal Posted") ); |
| $tm_now = time(); |
| $tm_diff = $tm_now - $tm_then; |
| $tm_str = "seconds"; |
| if( $tm_diff >= (60 * 2) ) { |
| $tm_diff = intval( $tm_diff / 60 ); |
| $tm_str = "minutes"; |
| if( $tm_diff >= (60 * 2) ) { |
| $tm_diff = intval( $tm_diff / 60 ); |
| $tm_str = "hours"; |
| if( $tm_diff >= (24 * 2) ) { |
| $tm_diff = intval( $tm_diff / 24 ); |
| $tm_str = "days"; |
| if( $tm_diff >= (7 * 2) ) { |
| $tm_diff0 = $tm_diff; |
| $tm_diff = intval( $tm_diff / 7 ); |
| $tm_str = "weeks"; |
| if( $tm_diff0 >= (30 * 2) ) { |
| $tm_diff = intval( $tm_diff0 / 30 ); |
| $tm_str = "months"; |
| if( $tm_diff0 >= 365 ) { |
| $tm_diff = intval( $tm_diff0 / 365 ); |
| $tm_str = "year"; |
| if( $tm_diff > 1 ) { |
| $tm_str .= "s"; |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| return $tm_diff . " " . $tm_str; |
| } |
| } |
| |
| class AllInfo { |
| var $_reviews; |
| var $_proposals; |
| |
| function load() { |
| $this->_reviews = Array(); |
| $this->_proposals = Array(); |
| |
| $path = $_SERVER['DOCUMENT_ROOT']; |
| if( $path == "" ) { |
| $path = "../projects.txt"; |
| } else { |
| $path = $_SERVER['DOCUMENT_ROOT'] . "/projects/projects.txt"; |
| } |
| $lines = file( $path ); |
| for( $idx = 0; $idx < count( $lines ); ) { |
| $buffer = $lines[$idx++]; |
| $buffer = substr($buffer,0,-1); // Remove new line char |
| |
| if( substr($buffer, 0, 14) == "Proposal Name:" ) { |
| $temp = new ProposalInfo(); |
| $i = $temp->load($buffer,$lines,$idx); |
| if( $temp->status() != "bogus" ) |
| array_push( $this->_proposals, $temp); |
| } |
| if( substr($buffer, 0, 13) == "Project Name:" ) { |
| $temp = new ReviewInfo(); |
| $i = $temp->load($buffer,$lines,$idx); |
| if( $temp->status() != "bogus" ) |
| array_push( $this->_reviews, $temp); |
| } |
| |
| } |
| |
| usort( $this->_proposals, "cmp_proposals"); |
| } |
| |
| } |
| |
| function cmp_proposals($a, $b) { |
| if( $a == $b ) return 0; |
| if( $a->name() == $b->name() ) return 0; |
| if( $a->name() < $b->name() ) return -1; |
| return 1; |
| } |
| |
| function numerical_date($s) { |
| $sday = substr($s, 0, 3); |
| $s = substr($s, 5); |
| list($day, $smonth, $year, $hour, $minute, $second) = sscanf($s, "%d %s %d %d:%d:%d"); |
| $months = array( "Jan" => 1, "Feb" => 2, "Mar" => 3, |
| "Apr" => 4, "May" => 5, "Jun" => 6, |
| "Jul" => 7, "Aug" => 8, "Sep" => 9, |
| "Oct" => 10, "Nov" => 11, "Dec" => 12 ); |
| $month = $months[$smonth]; |
| return (($year - 2000) * 365) + ($month * 31) + ($day); |
| } |
| |
| function time_and_date_url( $date, $time ) { |
| $hour = substr( $time, 0, 2 ); |
| $min = substr( $time, 2, 2 ); |
| $s = substr($date, 5); |
| list($day, $smonth, $year) = sscanf($s, "%d %s %d"); |
| $months = array( "Jan" => 1, "Feb" => 2, "Mar" => 3, |
| "Apr" => 4, "May" => 5, "Jun" => 6, |
| "Jul" => 7, "Aug" => 8, "Sep" => 9, |
| "Oct" => 10, "Nov" => 11, "Dec" => 12 ); |
| $month = $months[$smonth]; |
| return "http://www.timeanddate.com/worldclock/fixedtime.html?month=" . $month . "&day=" . $day . "&year=" . $year . "&hour=" . $hour . "&min=" . $min . "&sec=0&p1=0"; |
| } |
| ?> |