سهل جدا وانا اعتقده مميز ويمكن اخفاءه ويكون لك سري
مثال صوره وحط له اي اسم تحب لـ php
وسلامتكم
مثال صوره وحط له اي اسم تحب لـ php
<?php
error_reporting(1);
/*****************************************[ SETTINGS ]***/// تعيين خصائص الفرز$sort = array( array('key'=>'lname', 'sort'=>'asc'), // ... هذا يحدد نوع "عمود" الأولي والنظام ... array('key'=>'size', 'sort'=>'asc') // ... للبنود ذات نفس القيمة الفرز الأولي، فرز بهذه الطريقة);
/**************************************[ DIRECTORY LOGIC ]***/// الحصول على هذا المجلد والملفات اسم$this_script = basename(__FILE__);$this_folder = str_replace('/'.$this_script, '', $_SERVER['SCRIPT_NAME']);
// تعلن فار تستخدم أبعد من هذه النقطة$file_list = array();$folder_list = array();$total_size = 0;
// فتح الدليل الحالي ...if ($handle = opendir('.')){ // ... بدء المسح الضوئي من خلال ذلك while (false !== ($file = readdir($handle))) { // تأكد من أننا لا قائمة هذا المجلد، ملف أو روابطهم if ($file != "." && $file != ".." && $file != $this_script) { // الحصول على معلومات الملف $stat = stat($file); // ... slow, but faster than using filemtime() & filesize() instead. $info = pathinfo($file); // تنظيم معلومات الملف $item['name'] = $info['filename']; $item['lname'] = strtolower($info['filename']); $item['ext'] = $info['extension']; if($info['extension'] == '') $item['ext'] = '.'; $item['bytes'] = $stat['size']; $item['size'] = bytes_to_string($stat['size'], 2); $item['mtime'] = $stat['mtime']; // إضافة ملفات إلى قائمة الملفات ... if($info['extension'] != '') { array_push($file_list, $item); } //... والمجلدات إلى قائمة المجلدات else { array_push($folder_list, $item); } // Clear stat() cache to free up memory (not really needed). clearstatcache(); // إضافة هذه المواد إلى حجم ملف هذه المجلدات الحجم الإجمالي $total_size += $item['bytes']; } } // إغلاق الدليل عند الانتهاء closedir($handle);}// قائمة نوع مجلدif($folder_list) $folder_list = php_multisort($folder_list, $sort);// قائمة الملفات الفرزif($file_list) $file_list = php_multisort($file_list, $sort);// حساب إجمالي حجم مجلدif($file_list && $folder_list) $total_size = bytes_to_string($total_size, 2);
/****************************************************[ FUNCTIONS ]***/
/** * http://us.php.net/manual/en/function.array-multisort.php#83117 */function php_multisort($data,$keys){ foreach ($data as $key => $row) { foreach ($keys as $k) { $cols[$k['key']][$key] = $row[$k['key']]; } } $idkeys = array_keys($data); $i=0; foreach ($keys as $k) { if($i>0){$sort.=',';} $sort.='$cols['.$k['key'].']'; if($k['sort']){$sort.=',SORT_'.strtoupper($k['sort']);} if($k['type']){$sort.=',SORT_'.strtoupper($k['type']);} $i++; } $sort .= ',$idkeys'; $sort = 'array_multisort('.$sort.');'; eval($sort); foreach($idkeys as $idkey) { $result[$idkey]=$data[$idkey]; } return $result;}
/** * @ http://us3.php.net/manual/en/function.filesize.php#84652 */function bytes_to_string($size, $precision = 0) { $sizes = array('YB', 'ZB', 'EB', 'PB', 'TB', 'GB', 'MB', 'KB', 'Bytes'); $total = count($sizes); while($total-- && $size > 1024) $size /= 1024; $return['num'] = round($size, $precision); $return['str'] = $sizes[$total]; return $return;}
/** * @ http://us.php.net/manual/en/function.time.php#71342 */function time_ago($timestamp, $recursive = 0){ $current_time = time(); $difference = $current_time - $timestamp; $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade"); $lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($val = sizeof($lengths) - 1; ($val >= 0) && (($number = $difference / $lengths[$val]) <= 1); $val--); if ($val < 0) $val = 0; $new_time = $current_time - ($difference % $lengths[$val]); $number = floor($number); if($number != 1) { $periods[$val] .= "s"; } $text = sprintf("%d %s ", $number, $periods[$val]);
if (($recursive == 1) && ($val >= 1) && (($current_time - $new_time) > 0)) { $text .= time_ago($new_time); } return $text;}
/******************************************************[ TEMPLATE ]***/?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>PHPDL - دليل كشف الروابط لموقعك</title><style type="text/css">body{ font-family: "Lucida Grande",Calibri,Arial; font-size: 9pt; color: #333; background: #f8f8f8;}a{ color: #b00; font-size: 11pt; font-weight: bold; text-decoration: none;}a:hover{ color: #000;}table{ margin: 0 auto; padding: 0; width: 600px;} table td{ padding: 5px; } thead td{ padding-left: 0; font-family: "Trebuchet MS"; font-size: 11pt; font-weight: bold; } tbody .folder td{ border: solid 1px #f8f8f8; } tbody .file td{ background: #fff; border: solid 1px #ddd; } tbody .file td.size, tbody .file td.time{ white-space: nowrap; width: 1%; padding: 5px 10px; } tbody .file td.size span{ color: #999; font-size: 8pt; } tbody .file td.time{ color: #555; } tfoot td{ padding: 5px 0; color: #777; font-size: 8pt; background: #f8f8f8; border-color: #f8f8f8; } tfoot td.copy{ text-align: right; white-space: nowrap; } tfoot td.copy sup{ color: #999; } tfoot td.cc{ padding: 40px; text-align: center; } tfoot td.cc img{ padding: 0; border: none; }</style></head>
<body><table cellpadding="0" cellspacing="1"> <thead> <tr> <td colspan="3">هنا مسار الدليل <?=$this_folder?></td> </tr> </thead> <tfoot> <tr> <td class="total"><? if($folder_list): ?>هذا المجلد له<?=count($file_list)?> ملفات مجموعها<?=$total_size['num']?> <?=$total_size['str']?> in size<? endif; ?></td> <td colspan="2" class="copy"><a target="_blank" href="http://greg-j.com/phpdl/"> PHPDL</a><sup>lite</sup> created by <a target="_blank" href="http://greg-j.com"> Greg Johnson</a></td> </tr> <tr> <td colspan="3" class="cc"><a target="_blank" href="http://creativecommons.org/licenses/by-sa/3.0/us/"><img src="http://creativecommons.org/images/public/somerights20.png" alt="CC 3.0" /></a></td> </tr> </tfoot> <tbody><!-- folders --><? if($folder_list): ?><? foreach($folder_list as $item) : ?> <tr class="folder"> <td colspan="3" class="name"><a href="<?=$item['name']?>/">./<?=$item['name']?></a></td> </tr><? endforeach; ?><? endif; ?><!-- /folders --><!-- files --><? if($file_list): ?><? foreach($file_list as $item) : ?> <tr class="file"> <td class="name"><a href="<?=$item['name']?>.<?=$item['ext']?>"><?=$item['name']?>.<?=$item['ext']?></a></td> <td class="size"><?=$item['size']['num']?><span><?=$item['size']['str']?></span></td> <td class="time"><?=time_ago($item['mtime'])?> old</td> </tr><? endforeach; ?><? endif; ?><!-- /files --> </tbody></table>
</body></html>
ليست هناك تعليقات:
إرسال تعليق