Question on location the script is looking for files?

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).'&amp;server='.$path.'">'.($i + 1).'</a>';
        else
            echo '<span>'.($page + 1).'</span>';
    }
    echo '</div>';
}

}
?>

body { padding: 0px; margin: 0px; text-align: center; background-color: #1F1F1F; color: #6BA9BF; font-size: 9pt; font-family: sans-serif; } #wrapper { margin: 0 auto; padding: 0em 0.5em; max-width: 960px; min-width: 760px; width: auto !important; } #header { padding-bottom: 1em; } ul.menu { list-style-type: none; margin: 0em; margin-left: 1em; border-left: solid 3px #3f6fEF; padding: 0em; font-size: 11pt; float: left; } ul.menu li { padding-bottom: 1px; border-right: solid 1px #313A3F; border-bottom: solid 1px #313A3F; float: left; } ul.menu li:hover { border-bottom: solid 1px #6BA9BF; padding-bottom: 0px; } ul.menu li a { display: block; padding: 3px 1em; } ul.menu a:hover { padding: 3px 1em 4px 1em; background-color: #313A3F; } a { color: #6BA9BF !important; text-decoration:none; } h1.title { clear: left; text-shadow: 1px 1px 1px #666, -1px -1px 1px #000; } #content { min-height: 450px; } .list { width: 99%; text-align: left; border: #313A3F solid 1px; } .list th { border-bottom: solid 1px #313A3F; color: #4F6F7F; background: url('bgth.gif') repeat-x scroll center bottom #000; color: #EFEFEF; text-shadow: 1px 1px 1px #555, -1px -1px 1px #000; } .list tr:hover { background-color: #272F2F; } .list .ll { background-color: #313A3F; } .pagination { padding: 0.5em; font-size: 1.5em; } .pagination a { text-decoration: underline; margin: 0 0.2em; } .pagination span { margin: 0 0.1em; padding: 0 0.1em; background-color: #272F2F; } #footer { background-color: #272F2F; border: 1px solid #3f3f3f; padding: 1em; margin: 1em 0em 0.25em 0em; }

HLTV Demos

<?php if(is_array($servers)) { $count = count($servers); if($count > 1) { ?> Server: <?php foreach ($servers as $key => $value) { echo ''.$value['title'].''; } ?> Go <?php }
            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]

it may help to read the comments on a file … according to this bit of code the array name is the folder … so i would create a folder called classic-1 and classic-2 at the root of this file…

[php]/*
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"
          )
      );[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service