So sick! Posted October 6, 2010 Report Share Posted October 6, 2010 Man vajag, lai no šī skripta sataisa tā, ka visus demo, kas vecāki par 7 dienām izdzēš. <?php include 'lv.php'; $available_dates = array(); $all_files = array(); foreach (glob("retry_dd2-*.dem") as $filename) { if (preg_match('/^retry_dd2\-\d{10}\-[a-zA-Z0-9_\-\.]{1,200}\.dem$/', $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); if($size>=1000000){ $size=number_format($size/1000000).' MB'; }elseif($size>=1000){ $size=number_format($size/1000).' KB'; }else{ $size.=' B'; } $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; } } ?> Quote Link to comment Share on other sites More sharing options...
briedis Posted October 6, 2010 Report Share Posted October 6, 2010 Ciklojies cauri, skaties datumu, ja vecāks, dzēs... Kur problēma? Vai tev vienkārši vajag, lai kāds to izdara tavā vietā? Quote Link to comment Share on other sites More sharing options...
So sick! Posted October 7, 2010 Author Report Share Posted October 7, 2010 vienkārši vajag, lai kāds to izdara tavā vietā Tieši tā. Sorry, ka tā prasu, bet man ļoti vajag. Ja nu kāds koderis grib parādīt savu mākslu, kā to izdarīt vispareizāk? :) Quote Link to comment Share on other sites More sharing options...
briedis Posted October 7, 2010 Report Share Posted October 7, 2010 Es domāju, ka šeit tu vari necerēt uz šādiem bezmaksas pakalpojumiem :) Quote Link to comment Share on other sites More sharing options...
indoom Posted October 7, 2010 Report Share Posted October 7, 2010 ieliec zem foreach (glob("retry_dd2-*.dem") as $filename) { if (filemtime($filename) < strtotime('-1 week')) { @unlink($filename); continue; } Quote Link to comment Share on other sites More sharing options...
So sick! Posted October 7, 2010 Author Report Share Posted October 7, 2010 Liels paldies. :) Quote Link to comment Share on other sites More sharing options...
Klez Posted October 7, 2010 Report Share Posted October 7, 2010 #!/bin/bash #dzeesham demkas kas vecaakas par divaam nedeeljaam # find /var/www/vhosts/cs.larsan.lv/www/demo/ -name "PUB*" -mmin +20160 -exec rm '{}' \; | sed -e "s/\.dem//" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.