Skrypt SH:
############# - SERWER FFA - #############
mkdir gotv
find /home/goffa/serverfiles/csgo/auto-* -mmin +10 -exec mv {} /root/gotv \;
gzip -1f -S .zip /root/gotv/*
cd /root/gotv
ftp -in ftp.sloneczny-dust.sldc.pl << KONIEC
user
[email protected] ;JPNl&3S]Z@e
binary
cd files/server_4
send *
close
KONIEC
cd /root/
rm -r gotv
############# - SERWER RJ - #############
mkdir gotv
find /home/go4maps/serverfiles/csgo/auto-* -mmin +10 -exec mv {} /root/gotv \;
gzip -1f -S .zip /root/gotv/*
cd /root/gotv
ftp -in ftp.sloneczny-dust.sldc.pl << KONIEC
user
[email protected] ;JPNl&3S]Z@e
binary
cd files/server_5
send *
close
KONIEC
cd /root/
rm -r gotv
Strona WWW:
<?
$server = $_GET['srv'];
$folder = "files/server_".$server."/";
$path = $folder;
$days = 1;
if ($server == '') {
echo '<td width="100%" colspan="6">Błąd, brak id serwera..</td>';
}
else if (file_exists($folder)) {
// Czyszczenie katalogu z demek starszych niz X
if ($handle = opendir($path))
{
// Loop through the directory
while (false !== ($file = readdir($handle)))
{
if (is_file($path.$file))
{
if (filemtime($path.$file) < ( time() - ( $days * 24 * 60 * 60 ) ) )
{
// Do the deletion
unlink($path.$file);
}
}
}
}
$ext = array('zip', 'rar');
$sciezka = pathinfo($_SERVER['PHP_SELF']);
$adres = 'http://'.$_SERVER['HTTP_HOST'].$sciezka['dirname'].'/';
$files = scandir($folder);
$list = array();
foreach($files as $file)
{
$file = pathinfo($file);
if (in_array($file['extension'], $ext))
{
$list[] = $file['basename'];
}
}
rsort($list, SORT_STRING);
echo '<table width="100%" style="padding-left: 50px; padding-right: 50px;">
<tr style="font-weight: bold;"><td width="25%">Link</td><td>Mapa</td><td>Data</td><td>Godzina</td><td>Rozmiar</td><td>Pobierz</td></tr>';
//auto-20150724-1437-de_dust2.dem.zip
foreach ($list as $nazwa)
{
$demo = $folder.'/'.$nazwa;
$dane = explode('-', $nazwa);
$data = $dane[1];
$rok = substr($data, 2, 2);
$mies = substr($data, 4, 2);
$dzien = substr($data, 6, 2);
$data2 = $dane[2];
$godz = substr($data2, 0, 2);
$min = substr($data2, 2, 4);
$data = '20'.$rok.'-'.$mies.'-'.$dzien;
$godzina = $godz.':'.$min;
$mapa = $dane[3];
$mapa = explode('.', $mapa);
$mapa = $mapa[0];
$rozmiar = round( filesize($demo) / 1024 / 1024, 2);
echo '<tr>
<td><input type="text" value="'.$adres.$demo.'" readonly="yes" onclick="this.select()" /></td>
<td>'.$mapa.'</td>
<td>'.$data.'</td>
<td>'.$godzina.'</td>
<td>'.$rozmiar.' MB</td>
<td><a href="'.$adres.$demo.'">Pobierz</a></td>
</tr>';
}
}
else {
echo '<td width="100%" colspan="6">Brak nagrań do wyświetlenia..</td>';
}
?>
</table>
Skrypt działał, ale ważna rzeczy:
* musisz porobić sobie foldery, bo zapewne pominąłem temat ich tworzenia.
* skrypt bedzie przerzucał pliku do spakowania której mają +10 min życia.
* parametr days odpowiada na www od ilosci dni, po których usuwa.
* do pliku php przy wejsciu należy użyć odrazu ?serwer="numer" np. ?serwer=1 gdzy to odpowiada ścieszce files/serwer_1.
* nie jestem wstanie cie wspierać w tym więc musisz wsiąść to co podsyłamy i zrobić z tego SZTOSIWO.
* Plugin do nagrywania: https://forums.alliedmods.net/showthread.php?p=2070519