AXiSS Posted January 27, 2007 Share Posted January 27, 2007 I want to have a feature on my site where the user is provided a meta tag consisting of a random 32 character string, of which they would place on their site's index page. Then I'd have a page on my site that checks if the specified site contains that meta tag. (Similiar to what you need to do if you have ever used Google Webmaster tools)I am guessing this requires the index page file of the site to be moved into a temporary folder on why server and then it gets scanned for the meta. I think I can do everything up to the scanning part. What would be the best way to do this? Or is there a better way to verify if the user owns that site or not? Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/ Share on other sites More sharing options...
shocker-z Posted January 27, 2007 Share Posted January 27, 2007 well say you tell them to put this onto there page[code]<META name="sitekey" content="thisisa32keycodeforwebsites12345">[/code]then you could use this code to check that they have that key[code] $metakeysite=file_get_contents('http://www.thewebsite.com/'); $keyposs1 = strpos ($metakeysite, '<META name="sitekey" content="'); $keyposs2= strpos ($metakeysite, '">', $keyposs1); $key= substr($metakeysite, $keyposs1+30, $keyposs2-($keyposs1+30));[/code]that should give the variable $key with the key from meta tag and im sure you can do the validation :)RegardsLiam Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-170751 Share on other sites More sharing options...
AXiSS Posted February 21, 2007 Author Share Posted February 21, 2007 Not working, using:[code]$metakeysite = file_get_contents($url); $keyposs1 = strpos($metakeysite, '<meta name="wakey" content="'); $keyposs2 = strpos($metakeysite, '">', $keyposs1); $key = substr($metakeysite, $keyposs1+30, $keyposs2-($keyposs1+30)); if($key == $meta_key){ echo 'GOOD!'; } else { echo 'BAD!';}[/code]Where $url is the site to check... Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190029 Share on other sites More sharing options...
fert Posted February 21, 2007 Share Posted February 21, 2007 [code]preg_match("<meta name=\"wakey\" content=\"(.*?)\">",$contents,$matches);if($matches[1]==$key){echo "Good";}else{echo "Bad";}[/code] Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190063 Share on other sites More sharing options...
AXiSS Posted February 21, 2007 Author Share Posted February 21, 2007 Could I get an explanation fo what that code does?Also, the variable $meta_key is what I need to verify against. (It is the meta key content code.) Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190406 Share on other sites More sharing options...
AXiSS Posted February 21, 2007 Author Share Posted February 21, 2007 Is something special supposed to go in content? I'm confused... please help! Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190870 Share on other sites More sharing options...
fert Posted February 21, 2007 Share Posted February 21, 2007 The contents of the webpage Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190875 Share on other sites More sharing options...
AXiSS Posted February 22, 2007 Author Share Posted February 22, 2007 ??? Now I am extremely confused...In the code you provided, could you please define what each variable is? Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190908 Share on other sites More sharing options...
fert Posted February 22, 2007 Share Posted February 22, 2007 $contents: contents of a webpage$matches: array containing the result of the Regex evaluation$key: the key you want to them to have in the <meta> tag Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190912 Share on other sites More sharing options...
AXiSS Posted February 22, 2007 Author Share Posted February 22, 2007 So the full code should be something like:[code]$contents = file_get_contents($url);$key = 32charactercodetomatchto12345678;preg_match("<meta name=\"wakey\" content=\"(.*?)\">",$contents,$matches);if($matches[1]==$key){echo "Good";}else{echo "Bad";}[/code]Correct? Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190974 Share on other sites More sharing options...
fert Posted February 22, 2007 Share Posted February 22, 2007 yep Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190978 Share on other sites More sharing options...
AXiSS Posted February 22, 2007 Author Share Posted February 22, 2007 Thank you! :D Link to comment https://forums.phpfreaks.com/topic/35992-solved-check-for-meta-tag/#findComment-190982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.