Contador de Descargas Firefox

Para incluir el contador de descargas de Firefox debemos incluir el siguiente código PHP:

<?php

function GetNumFirefoxDownloads($Url, $Port, $Timeout) {

$XmlData = file_get_contents($Url);
if (
$XmlData === NULL) return "?";

global $ReturnValue;
global
$IsRightTag;
$ReturnValue = "?";
$IsRightTag = false;

function XmlStartElement($Parser, $Name, $Attrs) {
global
$IsRightTag;
if (
$Name == "DESCRIPTION") $IsRightTag = true;
}

function XmlEndElement($Parser, $Name) {
global
$IsRightTag;
if (
$Name == "DESCRIPTION") $IsRightTag = false;
}

function XmlTextData($Parser, $Data) {
global
$ReturnValue;
global
$IsRightTag;
if (
$IsRightTag) $ReturnValue = $Data;
}

$XmlParser = xml_parser_create();
xml_set_element_handler($XmlParser, "XmlStartElement", "XmlEndElement");
xml_set_character_data_handler($XmlParser, "XmlTextData");
xml_parse($XmlParser, $XmlData, true);
xml_parser_free($XmlParser);

return $ReturnValue;
}

$NumDownloads = GetNumFirefoxDownloads("http://feeds.spreadfirefox.com/downloads/firefox", 80, 25);

echo
"$NumDownloads";

?>

Responder

El contenido de este campo se mantiene como privado y no se muestra públicamente.
  • Las direcciones de las páginas web y las de correo se convierten en enlaces automáticamente.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Potentially problem-causing HTML tags are filtered.
  • Saltos automáticos de líneas y de párrafos.
  • You may quote other posts using [quote] tags.

Más información sobre opciones de formato