'); if ($posSpace !== false && $posClose !== false) { $element = substr($startContentStr, 1, $posSpace < $posClose ? $posSpace : $posClose); } else if ($posSpace !== false) { $element = substr($startContentStr, 1, $posSpace - 1); } else if ($posClose !== false) { $element = substr($startContentStr, 1, $posClose - 1); } else { $element = substr($startContentStr, 1); } $element = trim($element); } if ($startContentStr == '^') { $startContentStr = ''; $contentPos = 0; } else { $contentPos = strpos($contents, $startContentStr); //if ($contentPos === false) die('Problem reading page '.$startContentStr); if ($contentPos === false) { $contents = ''; return ''; } } $start = $contentPos + strlen($startContentStr); if ($endContentStr == '^') { $end = strlen($contents); } else { $end = strpos($contents, $endContentStr, $start); if (strlen($element) > 0) { // make sure we find the right ending element. count the number of open element tags $result = substr($contents, $start, $end - $start); while (substr_count($result, '<'.$element) <> substr_count($result, '') && $end !== false) { $end = strpos($contents, $endContentStr, $end + 1); $result = substr($contents, $start, $end - $start); } if ($end === false) { // something went wrong. incorrect number of elements $end = strlen($contents); } } } $result = substr($contents, $start, $end - $start); $contents = substr($contents, $end); return $result; } // it seems file_get_contents does not return the full page function curl_get_file_contents($URL) { $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_URL, str_replace('&', '&', $URL)); $contents = curl_exec($c); curl_close($c); if ($contents) return $contents; else return FALSE; } function AlreadyRead($date) { global $postsAlreadyRead; if (strpos($postsAlreadyRead, $date) === false) { return false; } return true; } function getLatestPosts($SearchUrl) { global $url; global $postsAlreadyRead; global $hostname; $email=""; if (strlen($SearchUrl) == 0) { $latestPosts = curl_get_file_contents($url."index.php?title=Special:RecentChanges"); } else { $latestPosts = curl_get_file_contents($SearchUrl); } $content = $latestPosts; while (strlen($content) > 0) { $item = getContent(&$content, '
  • '; $itemBackup = $item; $latestPost = getContent($itemBackup, ' 0) { $emailText = (''); } $MinorEmailText = getLatestPosts($url."index.php?title=Special:RecentChanges"); if (strlen($MinorEmailText) > 0) { $emailText .= "

    \n\nMinor Changes:
    \n"; } if (strlen($emailText) > 0) { sendMail($emailText); } else { echo "nothing to be sent"; } file_put_contents ($historyFile, $postsAlreadyRead."\n"); ?>