From 4c3b99938bfa3008889dd18c8bf33f2544c9021f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikki=20S=C3=B8rensen?= Date: Sat, 10 Mar 2018 01:44:23 +0100 Subject: [PATCH] adding some commen functions to the script --- scripts/lib/functions.php | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 scripts/lib/functions.php diff --git a/scripts/lib/functions.php b/scripts/lib/functions.php new file mode 100644 index 0000000..b1cfd22 --- /dev/null +++ b/scripts/lib/functions.php @@ -0,0 +1,75 @@ + 0) + { + return true; + } + + if (!array_key_exists('REQUEST_METHOD', $_SERVER)) + { + return true; + } + + return false; +} + + +// --------------------------------------------------------- // +// Funktion til at gemme kun den data man har behov for +// --------------------------------------------------------- // +// Defining the basic scraping function +function scrape_between($data, $start, $end) +{ + $data = stristr($data, $start); // Stripping all data from before $start + $data = substr($data, strlen($start)); // Stripping $start + $stop = stripos($data, $end); // Getting the position of the $end of the data to scrape + $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape + return $data; // Returning the scraped data from the function +} + +// --------------------------------------------------------- // +// Funktion til at gemme kun den data man har behov for +// --------------------------------------------------------- // +// Defining the basic scraping function +function scrape_to($data, $end) +{ + //$data = stristr($data, $start); // Stripping all data from before $start + //$data = substr($data, strlen($start)); // Stripping $start + $stop = stripos($data, $end); // Getting the position of the $end of the data to scrape + $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape + return $data; // Returning the scraped data from the function +} + +// --------------------------------------------------------- // +// Funktion til at gemme kun den data man har behov for +// --------------------------------------------------------- // +// Defining the basic scraping function +function scrape_from($data, $start) +{ + $data = stristr($data, $start); // Stripping all data from before $start + $data = substr($data, strlen($start)); // Stripping $start + //$stop = stripos($data, $end); // Getting the position of the $end of the data to scrape + //$data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape + return $data; // Returning the scraped data from the function +} + + + +?> \ No newline at end of file