Last active
July 19, 2017 06:28
-
-
Save meowmanijado/a8a4655238dd8fc3badcdb4650afd6dc to your computer and use it in GitHub Desktop.
Created a function for strpos array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Function for array user agent check | |
function strposa ($haystack, $needle, $offset=0) { | |
if (!is_array($needle)) $needle = array($needle); | |
foreach ($needle as $query) { | |
if (strpos($haystack, $query, $offset) !== false) return true; | |
} | |
return false; | |
} | |
$flag = false; | |
$tmp = $_SERVER['HTTP_USER_AGENT']; | |
$user_agent = array('Googlebot', 'Baiduspider'); | |
//var_dump(strposa($tmp, $user_agent, 1)); | |
// Check if user agent is true | |
if (strposa($tmp, $user_agent,1) !== false) $flag = true; | |
if ($flag == false) { | |
header('Location:http://www.myurl.net'); | |
} else { | |
require_once('default.php'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment