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? Quote Link to comment 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 Quote Link to comment 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... Quote Link to comment 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] Quote Link to comment 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.) Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
fert Posted February 21, 2007 Share Posted February 21, 2007 The contents of the webpage Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
fert Posted February 22, 2007 Share Posted February 22, 2007 yep Quote Link to comment Share on other sites More sharing options...
AXiSS Posted February 22, 2007 Author Share Posted February 22, 2007 Thank you! :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.