Im having issues figuring out where this script is looking for the demos on the webserver so i can make them go there.
Do i need to edit where i want it? If so how?
or do you see where this is pulling from?
Thanks Mark
[php]<?php
/*
Simple “HLTV Demos archive” databaseless script
Copyright © 2011 CL0NE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Configure server archives
[subfolder name without trailing '/']
title = [server title]
prefix = [demo file prefixes without trailing '-']
*/
$servers = array (
‘classic-1’ => array(
“title” => “[CL0NE] Classic #1”,
“prefix” => “hltv”
),
'classic-2' => array(
"title" => "[CL0NE] Classic #2",
"prefix" => "cs"
)
);
$filesPerPage = 20;
Size in bytes
function format_size($size, $round = 0)
{
$sizes = array(‘B’, ‘kB’, ‘MB’, ‘GB’, ‘TB’, ‘PB’, ‘EB’, ‘ZB’, ‘YB’);
for ($i=0; $size > 1024 && isset($sizes[$i+1]); $i++)
$size /= 1024;
return round($size, $round)." ".$sizes[$i];
}
function browse($path)
{
global $servers;
global $filesPerPage;
$data = array();
$page = $_GET[‘page’];
$page = !isset($page) || $page < 1 ? 0 : $page - 1;
$prefix = $servers[$path][‘prefix’];
$prefix_sz = strlen($prefix) + 1;
$offsets = array(
year => $prefix_sz,
month => $prefix_sz + 2,
day => $prefix_sz + 4,
hour => $prefix_sz + 6,
minute => $prefix_sz + 8,
map => $prefix_sz + 11
);
if(is_dir($path))
{
$files = glob($path."/*.dem.gz");
$count = count($files);
$pages = ceil( $count / $filesPerPage );
$page = $page >= $pages ? $pages - 1 : $page;
$begin = $count - ($page + 1) * $filesPerPage;
$end = $count - $page * $filesPerPage;
for($i = $begin < 0 ? 0 : $begin; $i < $end; ++$i)
{
$file = end( explode('/', $files[$i]) );
$name_end = strrpos($file, ".dem");
$name_end = $name_end === FALSE ? strrpos($file, ".gz") : $name_end;
$tmpfilesize = @filesize($files[$i]);
if($name_end === FALSE)
continue;
$tmp = array();
$tmp[year] = substr($file, $offsets[year], 2);
$tmp[month] = substr($file, $offsets[month], 2);
$tmp[day] = substr($file, $offsets[day], 2);
$tmp[hour] = substr($file, $offsets[hour], 2);
$tmp[minute] = substr($file, $offsets[minute], 2);
$tmp[map] = substr($file, $offsets[map], $name_end - $offsets[map]);
$tmp[file] = $file;
$tmp[size] = format_size($tmpfilesize);
$tmp[path] = $files[$i];
$data[] = $tmp;
}
$files = array();
}
echo '<table class="list" cellspacing="0" cellpadding="2">
<tr>
<th style="width: 10%; text-align: center;"> Date</th>
<th style="width: 9%; text-align: center;"> Time</th>
<th style="width: 25%;"> Map</th>
<th style="width: 10%;"> Size</th>
<th style=""> Link</th>
</tr>';
if($count > 0)
{
$ll = 0;
foreach($data as $field)
{
echo '<tr'.($ll?' class="ll"':'').'>
<td style="text-align: center;">'.$field[day].'.'.$field[month].'.'.$field[year].'</td>
<td style="text-align: center;">'.$field[hour].':'.$field[minute].'</td>
<td>'.$field[map].'</td>
<td>'.$field[size].'</td>
<td><a href="'.$field[path].'">'.$field[file].'</a></td>
</tr>';
$ll = !$ll;
}
}
else
{
echo '<tr><td class="ll" colspan="5" align="center">- Нет демо -</td></tr>';
}
echo '</table>';
if($pages > 1)
{
echo '<div class="pagination">';
for($i = 0; $i < $pages; ++$i)
{
if($pages > 10)
{
if($i > 2 && $i < $page - 1)
{
echo '...';
$i = $page - 1;
}
else
if($i > $page + 1 && $i > 2 && $i < $pages - 3)
{
echo '...';
$i = $pages - 3;
}
}
if($i != $page)
echo '<a href="?page='.($i + 1).'&server='.$path.'">'.($i + 1).'</a>';
else
echo '<span>'.($page + 1).'</span>';
}
echo '</div>';
}
}
?>
if($count == 1)
{
end($servers);
browse( key($servers) );
}
else if($count == 0)
{
echo "- Список серверов пуст -";
}
elseif( isset( $servers[$_GET['server']] ) )
browse($_GET['server']);
}
else
{
echo "- Скрипт не сконфигурирован -";
}
?>
</div>
<div id="footer">HLTV demos archive. [C] CL0NE</div>
</div>
</body>
[/php]