コード例 #1
0
ファイル: rate.php プロジェクト: pattertom/chambana-nightlife
<?php

define('STORE', 'ratings.dat');
function put_contents($file, $content)
{
    $f = fopen($file, "w");
    fwrite($f, $content);
    fclose($f);
}
if (isset($_REQUEST["rating"])) {
    $rating = $_REQUEST["rating"];
    $storedRatings = unserialize(file_get_contents(STORE));
    $storedRatings[] = $rating;
    put_contents(STORE, serialize($storedRatings));
    $average = round(array_sum($storedRatings) / count($storedRatings), 2);
    $count = count($storedRatings);
    $xml = "<ratings><average>{$average}</average><count>{$count}</count></ratings>";
    header('Content-type: text/xml');
    echo $xml;
}
コード例 #2
0
ファイル: backend.php プロジェクト: DevdutttaBain/nanoserv
<?php

//
// NanoServ: Home Server
// | Module -> Media -> Backend
//
require "include/functions.php";
function put_contents($file, $content)
{
    $f = fopen($file, "w");
    fwrite($f, $content);
    fclose($f);
}
if (isset($_REQUEST["file"])) {
    $file = urldecode($_REQUEST["file"]);
    $xml = "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\"><trackList><track><title>NanoServ Sync Item</title><location>{$file}</location></track></trackList></playlist>";
    put_contents($cfg["media-player"]["sync-store"], $xml);
} else {
    $xml = file_get_contents($cfg["media-player"]["sync-store"]);
}
header("Cache-control: public");
header("Content-Disposition: filename=playlist.xspf");
header("Content-Type: text/xml; charset=utf-8");
echo $xml;
?>