Browse Source

Updated regex

Some monitorr instances don't put `style="cursor: default"` so have accounted for that
Henry Whitaker 6 years ago
parent
commit
3da206ee12
1 changed files with 4 additions and 4 deletions
  1. 4 4
      api/functions/homepage-connect-functions.php

+ 4 - 4
api/functions/homepage-connect-functions.php

@@ -2528,7 +2528,7 @@ function getMonitorr()
 				// This section grabs the names of all services by regex
 				// This section grabs the names of all services by regex
 				$services = [];
 				$services = [];
 				$servicesMatch = [];
 				$servicesMatch = [];
-				$servicePattern = '/<div id="servicetitle"><div>(.*)<\/div><\/div><div class="btnonline">Online<\/div><\/a><\/div><\/div>|<div id="servicetitleoffline" style="cursor: default"><div>(.*)<\/div><\/div><div class="btnoffline" style="cursor: default">Offline<\/div><\/div><\/div>/';
+				$servicePattern = '/<div id="servicetitle"><div>(.*)<\/div><\/div><div class="btnonline">Online<\/div><\/a><\/div><\/div>|<div id="servicetitleoffline".*><div>(.*)<\/div><\/div><div class="btnoffline".*>Offline<\/div><\/div><\/div>/';
 				preg_match_all($servicePattern, $html, $servicesMatch);
 				preg_match_all($servicePattern, $html, $servicesMatch);
 				unset($servicesMatch[0]);
 				unset($servicesMatch[0]);
 				$servicesMatch = array_values($servicesMatch);
 				$servicesMatch = array_values($servicesMatch);
@@ -2543,7 +2543,7 @@ function getMonitorr()
 				// This section then grabs the status and image of that service with regex
 				// This section then grabs the status and image of that service with regex
 				$statuses = [];
 				$statuses = [];
 				foreach($services as $service) {
 				foreach($services as $service) {
-					$statusPattern = '/' . $service . '<\/div><\/div><div class="btnonline">(Online)<\/div><\/a><\/div><\/div>|' . $service . '<\/div><\/div><div class="btnoffline" style="cursor: default">(Offline)<\/div><\/div><\/div>/';
+					$statusPattern = '/' . $service . '<\/div><\/div><div class="btnonline">(Online)<\/div><\/a><\/div><\/div>|' . $service . '<\/div><\/div><div class="btnoffline".*>(Offline)<\/div><\/div><\/div>/';
 					$status = [];
 					$status = [];
 					preg_match($statusPattern, $html, $status);
 					preg_match($statusPattern, $html, $status);
 					$statuses[$service] = $status;
 					$statuses[$service] = $status;
@@ -2561,7 +2561,7 @@ function getMonitorr()
 
 
 					$imageMatch = [];
 					$imageMatch = [];
 
 
-					$imgPattern = '/assets\/img\/..\/img\/(.*)" class="serviceimg" alt=.*><\/div><\/div><div id="servicetitle"><div>' . $service . '|assets\/img\/\.\.\/img\/(.*)" class="serviceimg imgoffline" alt=.*><\/div><\/div><div id="servicetitleoffline" style="cursor: default"><div>' . $service . '/';
+					$imgPattern = '/assets\/img\/\.\.(.*)" class="serviceimg" alt=.*><\/div><\/div><div id="servicetitle"><div>'.$service.'|assets\/img\/\.\.(.*)" class="serviceimg imgoffline" alt=.*><\/div><\/div><div id="servicetitleoffline".*><div>'.$service.'/';
 
 
 					preg_match($imgPattern, $html, $imageMatch);
 					preg_match($imgPattern, $html, $imageMatch);
 					unset($imageMatch[0]);
 					unset($imageMatch[0]);
@@ -2572,7 +2572,7 @@ function getMonitorr()
 							$image = $match;
 							$image = $match;
 						}
 						}
 					}
 					}
-					$statuses[$service]['image'] = $url . '/assets/img/' . $image;
+					$statuses[$service]['image'] = $url . '/assets' . $image;
 				}
 				}
 
 
 				ksort($statuses);
 				ksort($statuses);