From cc909ebf7aef3702b8d41776fe9e20e455007075 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 7 Jan 2018 16:23:41 +0100 Subject: [PATCH] Added URL analyzer library --- classes/URLanalyzer.php | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 classes/URLanalyzer.php diff --git a/classes/URLanalyzer.php b/classes/URLanalyzer.php new file mode 100644 index 0000000..d9c9dc3 --- /dev/null +++ b/classes/URLanalyzer.php @@ -0,0 +1,64 @@ +#is', $source, $results, PREG_PATTERN_ORDER); + + //Process results + $list = array(); + foreach($results[1] as $entry){ + + //Remove spaces + $entry = str_replace(array(" =", "= "), "=", $entry); + + //Check if the meta tag represent an interest + if(preg_match("/property/", $entry) AND preg_match("/og:/", $entry)){ + + //Search for property tag and content tag + preg_match("#property=[\"\']og:(.*?)[\"\']#is", $entry, $matches1); + preg_match("#content=[\"\'](.*?)[\"\']#is", $entry, $matches2); + + $name = isset($matches1[1]) ? $matches1[1] : 1; + $value = isset($matches2[1]) ? $matches2[1] : ""; + $list[$name] = $value; + } + } + + + return $list; + } + +} \ No newline at end of file