Open Analytics Protocol Draft #2

A php page that outputs only ONCE the following tag:
<MAGIC_NUMBER_284537_OPEN_ANALYTICS_TAG_RESULT>

Closed by:
</MAGIC_NUMBER_284537_OPEN_ANALYTICS_TAG_RESULT>

Between those two html tags one should output one of the following:
(TRUE|FALSE|ERROR)

The website shall receive by POST METHOD the following:
Tag Name, the name of the tag being request $_POST[“tag_name”]
-If this field doesn’t match the tag a page is supposed to output, one shall output ERROR
Data Url, the link to the data to be analyzed $_POST[“data_url”]

Example:

<html>
<body>

<form action=”AnalyticsSubPage.php” method=”post”>
<input type=”text” name=”tag_name”>
<input type=”text” name=”data_url”>
<input type=”submit”>
</form>

<?php
$_RESULT=”ERROR”;

if ($_POST[“tag_name”]==”English”)
{
$raw_page= file_get_contents($_POST[“data_url”]);
$stripped_page= strip_tags($raw_page);
$freq_ar= count_chars($stripped_page);

$en_letter= $freq_ar[ord(“t”)]+$freq_ar[ord(“T”)];
$ot_letter= $freq_ar[ord(“r”)]+$freq_ar[ord(“R”)];

if ($en_letter>$ot_letter)
{
$_RESULT=”TRUE”;
}
else
$_RESULT=”FALSE”;
/*
arsort($freq_ar);
foreach ($freq_ar as $char_code=>$freq)
{
echo $char_code.”, “.chr($char_code).”: “;
echo $freq.”<br />”;
}*/

}

echo “<MAGIC_NUMBER_284537_OPEN_ANALYTICS_TAG_RESULT>”.$_RESULT.”</MAGIC_NUMBER_284537_OPEN_ANALYTICS_TAG_RESULT>”;

?>

</body>
</html>

Advertisements

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s