* Process Alerts * @param array integration_output */
( array $integration_output)
| 13 | * @param array integration_output |
| 14 | */ |
| 15 | function process_alerts( array $integration_output) { |
| 16 | |
| 17 | // Let's log our process for the CLI. |
| 18 | update_scan_log("\n\n\n> Processing alerts..."); |
| 19 | $time_pre = microtime(true); |
| 20 | |
| 21 | // From the previous process, we should have |
| 22 | // the following data that we'll use. |
| 23 | $processed_urls = $integration_output[ |
| 24 | 'processed_urls' |
| 25 | ]; |
| 26 | $processed_sites = $integration_output[ |
| 27 | 'processed_sites' |
| 28 | ]; |
| 29 | |
| 30 | // We don't know where helpers are being called, so |
| 31 | // we must set the directory if it isn't already set. |
| 32 | if(!defined('__ROOT__')) |
| 33 | define('__ROOT__', dirname(dirname(__FILE__))); |
| 34 | |
| 35 | // We'll use the directory to include required files. |
| 36 | require_once(__ROOT__.'/config.php'); |
| 37 | require_once(__ROOT__.'/models/db.php'); |
| 38 | |
| 39 | // Now let's get our existing alerts, filtered to the |
| 40 | // pages we're interested in. |
| 41 | $urls_to_filter = array(); |
| 42 | foreach ( $processed_urls as $url){ |
| 43 | array_push($urls_to_filter, array( |
| 44 | 'name' => 'url', |
| 45 | 'value' => $url, |
| 46 | 'condition'=> 'OR' |
| 47 | )); |
| 48 | }; |
| 49 | $existing_alert_filters = array( |
| 50 | array( |
| 51 | 'name' => 'archived', |
| 52 | 'value' => 0 |
| 53 | ), |
| 54 | array( |
| 55 | 'name' => 'url', |
| 56 | 'value' => $urls_to_filter |
| 57 | ) |
| 58 | ); |
| 59 | $existing_alerts = DataAccess::get_db_rows( |
| 60 | 'alerts', $existing_alert_filters, 1, 1000000 |
| 61 | )['content']; |
| 62 | if(empty($existing_alerts)) |
| 63 | $existing_alerts = array(); |
| 64 | |
| 65 | // Let's find equalified alerts. |
| 66 | $equalified_alerts = DataAccess::get_joined_db( |
| 67 | 'equalified_alerts', $processed_sites |
| 68 | ); |
| 69 | |
| 70 | // Let's mark the status of these alerts "Equalified". |
| 71 | if(!empty($equalified_alerts)){ |
| 72 |
no test coverage detected