Jump to content
GIGN Forum

[skripts]hltv Demo Failu Lapa Ar Iedaliijumu Pa Dienaam


Recommended Posts

Par pamatu izmantosim piemeeram smile pamaaciibu

NB - peec smile pamaaciibas tas index.php naw vajaadziigs vajag tikai kompresaacijas skriptu!!!

Luuk skripts:

<?php
include 'lv.php';

$available_dates = array();
$all_files = array();

foreach (glob("demo_mape/demo_nosaukums-*.zip") as $filename) {

    if (preg_match('/^demo\/demo_nosaukums\-\d{10}\-[a-zA-Z0-9_\-\.]{1,200}\.zip$/', $filename)) {

        $parts = explode("-", $filename);
        $date = $parts[1];
        $map = $parts[2];
        $mapparts = explode(".", $map);
        $map = $mapparts[0];

        $year = substr($date,0,2);
        $month = substr($date,2,2);
        $day = substr($date,4,2);
        $hour = substr($date,6,2);
        $minute = substr($date,8,2);

        $size = filesize($filename);

        $ymd = $year.'-'.$month.'-'.$day;

        if (!in_array($ymd, $available_dates)) {
            if ($ymd >= date('y-m-d', time() - 504800)) {
                $available_dates[] = $ymd;
            }
        }

        $all_files[] = array(
            'filename' => $filename,
            'map' => $map,
            'date' => $ymd,
            'fulldate' => '20'.$year.'-'.$month.'-'.$day.' '.$hour.':'.$minute,
            'size' => $size
        );

    }

}

rsort($available_dates);

$date_to_match = '';
if (empty($_GET['date'])) {
    if (!empty($available_dates[0])) {
        $date_to_match = $available_dates[0];
    }
} elseif ($_GET['date'] >= date('y-m-d', time() - 604800)) {
    $date_to_match = $_GET['date'];
}

$files_to_show = array();

foreach($all_files as $v) {

    if ($v['date'] == $date_to_match) {
        $files_to_show[] = $v;
    }

}

?>
<html>
<head>
    <title>Demo files</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/JavaScript">
    <!--
    function jump(select_obj) {
        if (select_obj.value != '') {
            document.getElementById('form1').submit();
        }
    }
    //-->
    </script>
</head>
<body>
    <table width="400" border=0 cellspacing=0 cellpadding=0 align="center">
        <tr>
            <td align="left">
            <form id="form1">
                <select name="date" onchange="jump(this)" size="1">
                    <option value=""><?php echo $web_lang['hltv_chose_date'];?></option>
                    <?php foreach ($available_dates as $v) { ?>
                    <option <?php echo (!empty($_GET['date']) && $_GET['date'] == $v) ? 'selected="selected"' : ''; ?> value="<?php echo $v; ?>"><?php echo $v; ?></option>
                    <?php } ?>
                </select>
            </form>
            </td>
        </tr>
    </table>
    <br>
    <table width="400" border=0 cellspacing=0 cellpadding=0 align="center">
        <tr>
            <td width="150" align="left"><?php echo $web_lang['hltv_name'];?></td><td width="50"><?php echo $web_lang['hltv_size'];?></td><td width="150"><?php echo $web_lang['hltv_date'];?></td>
        </tr>
        <?php foreach ($files_to_show as $v) { ?>
        <tr>
            <td><a href="<?php echo $v['filename']; ?>"><?php echo $v['map']; ?></a></td>
            <td><?php echo $v['size'] ?></td>
            <td><?php echo $v['fulldate']; ?></td>
        </tr>
        <?php } ?>
    </table>
</body>
</html>

Izveidojam piemeeram demo.php un iekopeejam skriptu!

Saaksim editeet:

Šajaa daļā noraadam nosaukumu un vietu kur atrodas demo

foreach (glob("demo/demo_nosaukums-*.zip") as $filename) {

    if (preg_match('/^demo\/demo_nosaukums\-\d{10}\-[a-zA-Z0-9_\-\.]{1,200}\.zip$/', $filename)) {

Noraadiisim kaada laika intervāla demo failus raadiss (

if ($ymd >= date('y-m-d', time() - 504800)) {

504800 - Skaitlis sekundees piemeeram man raada tieši nedēļu

Aprēķinaat nepieciesamo laiku var ar kalkulātoru :) bet jaatnem apmeeram 10 citaadi raadiss 8 dienas

Izveidojam lv.php un iekopeejam šo:

<?
$web_lang['hltv_name'] = "Mape";
$web_lang['hltv_date'] = "Datums";
$web_lang['hltv_chose_date'] = "Izvēlieties datumu";
$web_lang['hltv_size'] = "Izmērs(Kb)";
?>

Viss kaartiibaa!!Varam meeģinaat http://localhost/demo.php

?Lazda

Aizliegts publicēt citur bez manas atļauja!!!

Edited by lazda2
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...