Bontiv-Sourceer source code viewer
Root | Help
./nk-auto-install-googlecode/ajax.php
<?php
error_reporting
(E_ALL);
set_time_limit(10);

require_once
'class/mercurial.php';

$tag = 'tip';
$server = 'http://nuked-klan.googlecode.com/hg-history';
$toDir = './install';

$mercure = new Mercurial ($server, $tag, $toDir);

if (!isset(
$_GET['action']))
{
   
header('HTTP/1.1 500 Internal Error');
    echo
'Aucune action !';
}
elseif (
$_GET['action'] == 'list')
{
   
header('Content-Type: text/xml');
   
   
$remote = $mercure->GetRemote ();
   
$mercure->chdir ($_GET['dir']);
   
$files = $remote->list_dir ();
    echo
'<directory name="' . $_GET['dir'] . '">';
    foreach (
$files as $entry)
    {
        if (
$remote->isDir($entry))
        {
            echo
"<dir>$entry</dir>";
        }
        elseif (
$entry != '..')
        {
            echo
"<file>$entry</file>";
        }
    }
    echo
'</directory>';
}
elseif (
$_GET['action'] == 'update')
{
   
header('Content-Type: text/plain');
   
$mercure->chdir(dirname($_GET['file']));
    if (!
$mercure->download(basename($_GET['file'])))
    {
       
header('HTTP/1.1 500 Internal Error');
        echo
'Impossible D\'écrire le fichier ' . $_GET['file'];
        exit;        
    }
    echo
'Mis à jour : ' . $_GET['file'];
}
else
{
   
header('HTTP/1.1 501 Not Implemented');
    echo
'Error ! Not implemented.';
}
Presented with Bontiv-Sourceer