Jump to content
bravo14

Verify URL using google xml file

Recommended Posts

Hi all

 

I have a xml file that builds a league table, but want to provide other sites with access to it for a charge.

 

Is there a way I can check the domain using the xml file has permission to do so?

 

I intended on keeping a key in a database with the URL but how can I get the URL using the xml file?

Edited by bravo14

Share this post


Link to post
Share on other sites

You can't know who (or what domain) is accessing the file. You can give each site a unique key that they can put in the URL like

/path/to/file.xml?key=abcd123
then use URL rewriting to turn that into a PHP script

RewriteRule ^/?path/to/file\.xml$ path/to/file.php [L]
and use PHP to check the key and output the XML if it's allowed.

<?php

if (!isset($_GET["key"])) {
	header("403 Forbidden", true, 403);
	exit;
}

$key = $_GET["key"];
// validate $key
if (/* valid */) {
	header("Content-Type: application/xml");
	header("Content-Length: " . filesize("file.xml"));
	readfile("file.xml");
} else {
	header("403 Forbidden", true, 403);
	exit;
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.