3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * * Note that this file is used by the crm project track interface. Make note of that before changing anything. * */ function get_task_statuses($in_options=array()) { $options = array_merge( array( "use_keys"=>false, "display_field"=>"display", "value_field"=>"value" ), $in_options ); $statuses = array( array("On Hold", "On Hold"), array("Awaiting Action", "Awaiting Action"), array("In Progress", "In Progress"), array("Duplicate", "Duplicate"), array("Not a Bug", "Not a Bug"), array("Obsolete", "Obsolete"), array("Completed", "Completed"), array("Completed & Closed", "Completed & Closed") ); if($options["use_keys"]) { $keyed_statuses = array(); for($i = 0; $i < count($statuses); $i++) { $keyed_statuses[] = array( $options["value_field"]=>$statuses[$i][0], $options["display_field"]=>$statuses[$i][1] ); } return $keyed_statuses; } else { return $statuses; } } function get_task_status_x_color() { return array( "On Hold"=>"#F1A7EE", "In Progress"=>"#21F8F0", "Awaiting Action"=>"#E8F100", "Completed"=>"#09F872", "Closed"=>"#F57474" ); } function get_task_priorities($in_options=array()) { $options = array_merge( array( "use_keys"=>false, "display_field"=>"display", "value_field"=>"value" ), $in_options ); $priorities = array( array("High", "High"), array("Moderate", "Moderate"), array("Low", "Low") ); if($options["use_keys"]) { $keyed_priorities = array(); for($i = 0; $i < count($priorities); $i++) { $keyed_priorities[] = array( $options["value_field"]=>$priorities[$i][0], $options["display_field"]=>$priorities[$i][1] ); } return $keyed_priorities; } else { return $priorities; } } function get_task_types($in_options=array()) { $options = array_merge( array( "use_keys"=>false, "display_field"=>"display", "value_field"=>"value" ), $in_options ); $types = array( array("Design", "Design"), array("Documentation", "Documentation"), array("Enhancement", "Enhancement"), array("Implementation", "Implementation"), array("Import", "Import"), array("Modification", "Modification"), array("Move", "Move"), array("Security", "Security"), array("Testing", "Testing") ); if($options["use_keys"]) { $keyed_priorities = array(); for($i = 0; $i < count($types); $i++) { $keyed_priorities[] = array( $options["value_field"]=>$types[$i][0], $options["display_field"]=>$types[$i][1] ); } return $keyed_priorities; } else { return $types; } } function get_bug_types($in_options=array()) { $options = array_merge( array( "use_keys"=>false, "display_field"=>"display", "value_field"=>"value" ), $in_options ); $types = array( array("Modification", "Modification"), array("Error", "Error"), array("Fatal Error", "Fatal Error"), array("Enhancement", "Enhancement"), array("Logical", "Logical"), array("Update", "Update"), array("Idea", "Idea"), array("Uptrak Error", "Uptrak Error") ); if($options["use_keys"]) { $keyed_priorities = array(); for($i = 0; $i < count($types); $i++) { $keyed_priorities[] = array( $options["value_field"]=>$types[$i][0], $options["display_field"]=>$types[$i][1] ); } return $keyed_priorities; } else { return $types; } } /* * This function will determine what email to send based on the records given to us. */ function send_task_email($old_task, $new_task) { global $commonDB, $concept_db, $session; $crm_db = clone($commonDB); $crm_db->select_database("allofe_crm"); if ($new_task["category"] == 1) { $category = 'Bug'; } else if ($new_task["category"] == 2) { $category = 'Task'; } else { $category = $new_task["category"]; } $assigned_to_user_id = $new_task["assigned_to_user_id"]; $user_id = $session->get("user_id"); $following_users = ($new_task["following_user_ids"] == NULL) ? array() : explode(',',$new_task["following_user_ids"]); $send_assigned_email = $send_status_email = $comment_change = $url_change = false; //Send email to assigned user when task is created if($new_task["newtask"]) { if ($new_task['status'] != "Completed") { $send_assigned_email = true; $send_status_email = true; } } else { //Send email to assigned users and following users when task changes hands if ($assigned_to_user_id != $old_task["assigned_to_user_id"]) { $send_assigned_email = true; $send_status_email = true; } //Send email to all users if task changes statuses if ($new_task["status"] != $old_task["status"]) { $send_status_email = true; } //Send email to all users when comments are changed if ($old_task["comments"] && $new_task["comments"]) { if(is_string($old_task["comments"]) && $new_task["comments"] !== $old_task["comments"]) { //sort both of the task's comments to verify that a change isn't in how they are sorted. function commentsCompare($a, $b) { if ($a['date'] == $b['date']) { if ($a['username'] == $b['username']) { if ($a['comment'] == $b['comment']) { return 0; } return ($a['comment'] < $b['comment']) ? -1 : 1; } return ($a['username'] < $b['username']) ? -1 : 1; } return ($a['date'] < $b['date']) ? -1 : 1; } $new_comments = json_decode($new_task["comments"], true); $old_comments = json_decode($old_task["comments"], true); usort($new_comments, "commentsCompare"); usort($old_comments, "commentsCompare"); $new_task["comments"] = json_encode($new_comments); $old_task["comments"] = json_encode($old_comments); if ($new_task["comments"] !== $old_task["comments"]) { $comment_change = true; $send_status_email = true; } } } //Determine which items in the comments have been changed/added if ($comment_change) { $new_comments = json_decode($new_task["comments"], true); $old_comments = json_decode($old_task["comments"], true); $num_old_comments = count($old_comments); $num_new_comments = count($new_comments); for ($i = 0; $i < ($num_old_comments <= $num_new_comments ? $num_old_comments : $num_new_comments); $i++) { if (!$new_comments[$i]) { break; } if ($new_comments[$i]["username"] !== $old_comments[$i]["username"]) { $new_comments[$i]["bold"] = true; } if ($new_comments[$i]["date"] !== $old_comments[$i]["date"]) { $new_comments[$i]["bold"] = true; } if ($new_comments[$i]["comment"] !== $old_comments[$i]["comment"]) { $new_comments[$i]["bold"] = true; } } for ($i = $num_old_comments; $i < $num_new_comments; $i++) { $new_comments[$i]["bold"] = true; } $new_task["comments"] = json_encode($new_comments); $old_task["comments"] = json_encode($old_comments); } //Send email to all users when git_urls are changed if (is_string($old_task["git_urls"]) && $new_task["git_urls"] !== $old_task["git_urls"]) { $url_change = true; $send_status_email = true; } $bolded_urls = array(); //Determine which items in the git_urls have been changed/added if ($url_change) { $new_urls = json_decode($new_task["git_urls"], true); $old_urls = json_decode($old_task["git_urls"], true); $num_new_urls = count($new_urls); $num_old_urls = count($old_urls); for ($i = 0; $i < ($num_old_urls <= $num_new_urls ? $num_old_urls : $num_new_urls); $i++) { if ($new_urls[$i] !== $old_urls[$i]) { $bolded_urls[] = true; } else { $bolded_urls[] = false; } } for ($i = $num_old_urls; $i < $num_new_urls; $i++) { $bolded_urls[] = true; } } } if($send_assigned_email || $send_status_email) { //Gets names and emails of all active users $results = $commonDB->query(" SELECT user_id,first_name,last_name, email FROM users WHERE status = 1" ); $emails = $names = array(); while($record = $results->fetch_next_associative()) { $names[$record["user_id"]] = $record["last_name"].", ".$record["first_name"]; $emails[$record["user_id"]] = $record["email"]; } $user_name = ($names[$user_id]) ? $names[$user_id] : " a Root User"; //Creates contents of email $email_content = array(); $email_content[] = "<b>Category:</b> ". $category; $email_content[] = "<b>Assigned To:</b> ". $names[$assigned_to_user_id]; $email_content[] = "<b>Status:</b> " . $new_task["status"]; $email_content[] = "<b>Priority:</b> " . (($new_task["priority"]) ? $new_task["priority"] : "None"); $email_content[] = "<b>Type:</b> " . $new_task["type"]; $email_content[] = "<b>Project:</b> " . $new_task["project_name"]; if ($new_task["due_date"] && strtoupper($new_task["due_date"]) !== "NULL" && $new_task["due_date"] !== NULL) { $email_content[] = "<b>Due Date:</b>" . date("n/j/Y", strtotime($new_task["due_date"])); } if($new_task["date_completed"] && strtoupper($new_task["date_completed"]) !== "NULL" && $new_task["date_completed"] !== NULL) { $email_content[] = "<b>Completion Date:</b>" . date("n/j/Y", strtotime($new_task["date_completed"])); } if($new_task["system_implementation_id"]) { $system_implementation_name = $commonDB->plookup( "system_implementation_name", "system_implementation", "system_implementation_id = ?", $new_task["system_implementation_id"] ); $email_content[] = "<b>System Implementation:</b> " . $system_implementation_name; } if($new_task["crm_company_id"]) { $crm_company_name = $crm_db->plookup( "name", "crm_companies", "crm_company_id = ?", $new_task["crm_company_id"] ); $email_content[] = "<b>CRM Company:</b> " . $crm_company_name; } if($new_task["allofe_product_id"]) { $allofe_product_name = $concept_db->plookup( "name", "allofe_products", "product_id = ?", $new_task["allofe_product_id"] ); $email_content[] = "<b>AllofE Product:</b> " . $allofe_product_name; } if($new_task["crm_project_track_id"]) { $crm_project_name = $crm_db->plookup( "name", "crm_project_tracks", "crm_project_track_id = ?", $new_task["crm_project_track_id"] ); $email_content[] = "<b>CRM Project:</b> " . $crm_project_name; } if ($new_task["newtask"]) { $creator_name = $user_name; } else { $creator_name = ($names[$old_task["create_user_id"]]) ? $names[$old_task["create_user_id"]] : "Root User"; } $email_content[] = "<b>Creator:</b> ". $creator_name; $email_content[] = "<b>Short Description:</b> " . $new_task["short_description"]; $email_content[] = "<br/><u><b>Long Description</b></u>" . html_entity_decode($new_task["long_description"]); $comments = array(); if($new_task["comments"]) { $comments_json = json_decode($new_task["comments"], true); //inline functions not available in earlier versions of php function commentStatusCompare($a, $b) { if ($a["date"] == $b["date"]) { if($a["comment"]=="(Completed & Closed)" || $a["comment"]=="(Completed)") return -1; else return 1; } return ($a["date"] > $b["date"]) ? -1 : 1; } usort($comments_json, "commentStatusCompare");//it is used once here foreach($comments_json as $comment) { if ($comment["bold"]) { $comments[] = "<b>" . date("n/j/Y", strtotime($comment["date"])) . " - " . $comment["username"] . ":<br/><i>" . $comment["comment"]."</i></b>"; } else { $comments[] = date("n/j/Y", strtotime($comment["date"])) . " - " . $comment["username"] . ":<br/><i>" . $comment["comment"]."</i>"; } } } if($comments) { $email_content[] = "<u><b>Comments</b></u><br/>" . implode("<br/>", $comments); } $git_urls = ""; if ($new_task["git_urls"]) { $git_urls_json = json_decode($new_task["git_urls"],true); $index = 0; foreach($git_urls_json as $git) { if ($bolded_urls[$index]) { $git_urls = $git_urls . "<br/><b>" . $git . "</b>"; } else { $git_urls = $git_urls . "<br/>" . $git; } $index++; } $email_content[] = "<br/><u><b>Git Urls</b></u><br/>" . $git_urls; } $email_text = implode("<br/>",$email_content); //Send email notifying user of new task if they have an email and are not the user that assigned the task if ($send_assigned_email) { if ($emails[$assigned_to_user_id] && $assigned_to_user_id != $user_id) { $m = new Mail(); $m->content_type = "text/html"; $m->To($emails[$assigned_to_user_id]); $m->From($category."s <tasks@allofe.net>"); $m->Subject("New ".$category." Assignment: ". $new_task["short_description"] . " --".$category." ID #" .$new_task["task_id"]); $m->Body(rtrim(chunk_split(base64_encode( "The following ".$category." has been assigned to you by <b>" . $user_name . ":</b><br/><br/>". stripslashes($email_text) ))),"text/html"); $m->ctencoding = "base64"; $m->Send(); } //Removes user from following users array so they don't receive 2 emails unset($following_users[array_search($assigned_to_user_id,$following_users)]); } //Sends status emails to all users that are following the task, excluding the current user if($send_status_email && !empty($following_users)) { foreach($following_users as $following_user_id) { if ($emails[$following_user_id] && $following_user_id != $user_id) { $m = new Mail(); $m->content_type = "text/html"; $m->To($emails[$following_user_id]); $m->From($category."s Tracking<tasks@allofe.net>"); $m->Subject($category." Status Report: " . $new_task["short_description"] . " --".$category." ID #" .$new_task["task_id"]); $m->Body(rtrim(chunk_split(base64_encode( "The following task has been updated by <b>" . $user_name . ":</b><br/><br/>".stripslashes($email_text) ))),"text/html"); $m->ctencoding = "base64"; $m->Send(); } } } } } //Establishing email for reminder function send_reminder_email($old_task, $new_task){ global $commonDB, $session; if ($new_task["category"] == 1) { $category = 'Bug'; } else if ($new_task["category"] == 2) { $category = 'Task'; } else { $category = $new_task["category"]; } //look up emails $emails = array(); $names = array(); $results = $commonDB->pquery( "SELECT user_id,first_name,last_name, email, email_on FROM users WHERE user_id in (?,?,?)", array($new_task["assigned_to_user_id"], $old_task["create_user_id"], $session->stored_data["user_id"]) ); while($record = $results->fetch_next_associative()) { $names[$record["user_id"]] = $record["last_name"].", ".$record["first_name"]; $emails[$record["user_id"]] = $record["email"]; } $email_text = "Type: " . $new_task["type"] . "<br/>" . "Priority: " . (($new_task["priority"])? $new_task["priority"] : "None") . "<br/>" . "Status: " . $new_task["status"] . "<br/>" . "Short Description: ". $new_task["short_description"]."<br/>" . "Long Description: <br/>".$new_task["long_description"]."<br/>" . "Due Date: ". $new_task['due_date']. "<br/>" . "Creator: ". ($names[$old_task["create_user_id"]] ? $names[$old_task["create_user_id"]] : "N/A"). "<br/>" . "Assigned To: ". $names[$new_task["assigned_to_user_id"]]; $m = new Mail(); $m->content_type = "text/html"; $m->To($emails[$new_task["assigned_to_user_id"]]); $m->From("tasks Tracking<tasks@allofe.net>"); $m->Subject("REMINDER: ".$project_name." ".$category." Status Report --".$category." ID #" . $new_task["task_id"] . " Status: " . $new_task["status"]); $m->Body(rtrim(chunk_split(base64_encode( $category." ID: ".$new_task["task_id"]. "<br/>". stripslashes($email_text) ))),"text/html"); $m->ctencoding = "base64"; $m->delaySend($new_task['send_by_date']); $batch_email_id = $m->Send(); return $batch_email_id; } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0130.01018.28
8.3.50.0150.00317.86
8.3.40.0120.00318.85
8.3.30.0130.00319.05
8.3.20.0040.00420.50
8.3.10.0050.00321.85
8.3.00.0030.00719.21
8.2.180.0100.00616.75
8.2.170.0000.01522.96
8.2.160.0070.00721.93
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00419.83
8.2.110.0110.00019.58
8.2.100.0110.00017.63
8.2.90.0000.00819.17
8.2.80.0060.00317.97
8.2.70.0070.00317.63
8.2.60.0030.00918.16
8.2.50.0050.00518.07
8.2.40.0080.00018.47
8.2.30.0030.00618.14
8.2.20.0040.00417.72
8.2.10.0040.00418.03
8.2.00.0080.00017.67
8.1.280.0120.00425.92
8.1.270.0000.00919.02
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0030.00619.59
8.1.230.0040.00819.32
8.1.220.0000.00917.88
8.1.210.0000.00918.77
8.1.200.0060.00317.35
8.1.190.0030.00517.35
8.1.180.0050.00318.10
8.1.170.0050.00520.23
8.1.160.0040.00422.18
8.1.150.0080.00019.00
8.1.140.0040.00417.46
8.1.130.0000.00717.91
8.1.120.0050.00217.46
8.1.110.0040.00417.60
8.1.100.0040.00417.43
8.1.90.0040.00417.56
8.1.80.0030.00517.59
8.1.70.0020.00517.54
8.1.60.0000.00917.66
8.1.50.0040.00417.66
8.1.40.0040.00417.51
8.1.30.0000.00817.69
8.1.20.0030.00617.60
8.1.10.0000.00817.46
8.1.00.0050.00317.53
8.0.300.0080.00018.77
8.0.290.0040.00416.75
8.0.280.0000.00718.54
8.0.270.0040.00417.24
8.0.260.0000.00718.55
8.0.250.0040.00417.05
8.0.240.0040.00416.95
8.0.230.0000.00717.07
8.0.220.0070.00016.94
8.0.210.0000.00716.96
8.0.200.0040.00417.05
8.0.190.0030.00516.95
8.0.180.0050.00316.92
8.0.170.0000.00817.06
8.0.160.0070.00017.07
8.0.150.0030.00616.96
8.0.140.0050.00217.02
8.0.130.0030.00613.36
8.0.120.0040.00416.97
8.0.110.0040.00416.96
8.0.100.0040.00417.02
8.0.90.0040.00416.95
8.0.80.0080.00816.92
8.0.70.0000.00816.97
8.0.60.0040.00417.09
8.0.50.0030.00617.11
8.0.30.0110.01117.17
8.0.20.0120.00817.40
8.0.10.0040.00417.07
8.0.00.0070.01116.87
7.4.330.0030.00315.03
7.4.320.0000.00616.68
7.4.300.0030.00316.54
7.4.290.0000.00716.64
7.4.280.0000.00916.59
7.4.270.0040.00416.48
7.4.260.0040.00416.53
7.4.250.0000.00816.66
7.4.240.0050.00316.72
7.4.230.0040.00416.44
7.4.220.0110.00716.61
7.4.210.0100.00716.63
7.4.200.0070.00016.73
7.4.160.0060.01116.55
7.4.150.0160.00917.40
7.4.140.0110.01217.86
7.4.130.0160.00516.46
7.4.120.0090.00916.60
7.4.110.0130.00716.59
7.4.100.0070.01016.57
7.4.90.0030.01516.50
7.4.80.0000.01916.63
7.4.70.0160.00616.42
7.4.60.0090.00916.52
7.4.50.0060.00316.46
7.4.40.0030.01916.59
7.4.30.0130.01016.76
7.4.00.0090.00914.74
7.3.330.0000.00613.36
7.3.320.0130.00013.43
7.3.310.0030.00416.24
7.3.300.0050.00316.38
7.3.290.0060.00316.25
7.3.280.0070.01216.36
7.3.270.0120.00617.40
7.3.260.0120.00616.38
7.3.250.0120.00716.51
7.3.240.0090.01316.50
7.3.230.0160.00316.45
7.3.210.0070.01116.70
7.3.200.0040.02119.39
7.3.190.0110.00616.68
7.3.180.0030.01416.47
7.3.170.0120.00816.39
7.3.160.0030.01316.48
7.3.10.0100.01016.20
7.3.00.0000.01216.32
7.2.330.0150.00416.64
7.2.320.0050.01416.63
7.2.310.0130.00616.65
7.2.300.0130.00316.55
7.2.290.0030.01516.59
7.2.130.0120.00316.68
7.2.120.0030.01316.47
7.2.110.0040.01116.64
7.2.100.0030.01216.77
7.2.90.0030.01316.63
7.2.80.0040.00716.89
7.2.70.0040.01116.79
7.2.60.0020.01216.69
7.2.50.0040.01116.68
7.2.40.0040.00716.52
7.2.30.0060.00916.36
7.2.20.0040.01116.42
7.2.10.0030.00616.65
7.2.00.0070.00918.00
7.1.250.0000.01715.52
7.1.200.0040.00815.35
7.1.100.0200.00916.15
7.1.70.0030.00516.92
7.1.60.0030.00919.46
7.1.50.0030.01616.54
7.1.00.0070.07322.35
7.0.200.0220.00414.92
7.0.140.0100.02722.09
7.0.100.0100.04320.13
7.0.90.0230.08020.05
7.0.80.0000.06320.09
7.0.70.0070.08320.06
7.0.60.0070.07720.05
7.0.50.0200.07720.57
7.0.40.0070.08320.13
7.0.30.0130.07720.13
7.0.20.0130.08020.23
7.0.10.0030.05019.95
7.0.00.0070.05720.07
5.6.250.0100.05320.67
5.6.240.0030.08320.73
5.6.230.0100.07720.69
5.6.220.0000.08720.68
5.6.210.0070.07720.69
5.6.200.0270.06321.14
5.6.190.0100.06321.17
5.6.180.0030.05321.08
5.6.170.0100.04721.07
5.6.160.0170.07721.23
5.6.150.0170.07021.18
5.6.140.0070.05021.08
5.6.130.0100.05021.14
5.6.120.0030.05321.24
5.6.110.0130.07721.06
5.6.100.0200.07021.22
5.6.90.0170.07721.04
5.6.80.0130.06720.59
5.6.70.0100.08020.61
5.6.60.0130.07720.52
5.6.50.0070.08020.55
5.6.40.0030.04320.52
5.6.30.0130.07320.52
5.6.20.0100.04020.61
5.6.10.0130.06720.52
5.6.00.0130.07320.57
5.5.380.0030.04320.45
5.5.370.0100.07320.57
5.5.360.0100.08320.43
5.5.350.0100.08320.50
5.5.340.0100.07720.88
5.5.330.0030.05720.90
5.5.320.0070.04320.94
5.5.310.0100.03720.98
5.5.300.0000.08021.02
5.5.290.0070.09020.88
5.5.280.0070.05020.95
5.5.270.0130.08720.99
5.5.260.0100.08020.91
5.5.250.0070.04720.58
5.5.240.0000.05320.31
5.5.230.0000.07720.41
5.5.220.0100.07720.38
5.5.210.0130.07320.38
5.5.200.0100.04020.36
5.5.190.0200.05020.32
5.5.180.0030.05020.36
5.5.160.0100.05020.25
5.5.150.0100.08720.28
5.5.140.0170.07020.41
5.5.130.0070.07020.23
5.5.120.0030.06720.27
5.5.110.0070.04720.34
5.5.100.0070.04720.20
5.5.90.0000.07320.27
5.5.80.0070.07020.24
5.5.70.0070.08020.18
5.5.60.0030.04720.18
5.5.50.0130.07020.28
5.5.40.0270.06020.27
5.5.30.0030.08020.25
5.5.20.0030.08020.20
5.5.10.0030.07320.17
5.5.00.0070.06020.22
5.4.450.0000.08719.57
5.4.440.0070.07019.23
5.4.430.0100.04019.41
5.4.420.0100.08019.55
5.4.410.0100.07319.29
5.4.400.0030.08019.10
5.4.390.0130.06019.16
5.4.380.0030.06319.24
5.4.370.0070.06719.07
5.4.360.0070.07719.18
5.4.350.0070.06719.02
5.4.340.0130.07018.96
5.4.320.0070.07719.09
5.4.310.0030.07719.10
5.4.300.0030.07719.27
5.4.290.0000.06719.09
5.4.280.0100.08019.12
5.4.270.0070.04319.01
5.4.260.0070.08019.00
5.4.250.0030.06719.16
5.4.240.0100.04019.17
5.4.230.0030.07719.04
5.4.220.0030.07719.08
5.4.210.0030.09019.08
5.4.200.0030.06019.13
5.4.190.0070.06018.94
5.4.180.0100.07319.09
5.4.170.0130.04018.93
5.4.160.0200.05318.98
5.4.150.0000.08019.11
5.4.140.0070.04716.43
5.4.130.0100.07316.46
5.4.120.0130.06716.51
5.4.110.0130.07016.48
5.4.100.0100.06716.60
5.4.90.0030.08016.42
5.4.80.0030.04316.46
5.4.70.0030.07716.39
5.4.60.0030.05716.46
5.4.50.0070.04316.45
5.4.40.0130.07016.45
5.4.30.0030.07016.45
5.4.20.0070.04316.39
5.4.10.0030.03716.42
5.4.00.0000.04015.87

preferences:
78 ms | 400 KiB | 5 Q