diff --git a/plugins/Html.php b/plugins/Html.php
index ea516d1..ee2b1fe 100644
--- a/plugins/Html.php
+++ b/plugins/Html.php
@@ -51,4 +51,26 @@ Class Html {
return $platform;
}
+ //根据ctime进行排序,默认按时间先后倒序排列
+ public static function sortFilesByCreateTime($files, $way = 'desc') {
+ $ctimes = array();
+ foreach($files as $id => $item) {
+ $ctimes[$id] = $item['fstat']['ctime'];
+ }
+
+ if ($way == 'desc') {
+ arsort($ctimes, SORT_NUMERIC);
+ }else {
+ asort($ctimes, SORT_NUMERIC);
+ }
+
+ $sorted = array();
+
+ foreach($ctimes as $id => $ctime) {
+ array_push($sorted, $files[$id]);
+ }
+
+ return $sorted;
+ }
+
}
diff --git a/themes/tajian/views/site/index.php b/themes/tajian/views/site/index.php
index 1b8cf1c..e6abe29 100644
--- a/themes/tajian/views/site/index.php
+++ b/themes/tajian/views/site/index.php
@@ -62,7 +62,8 @@ eof;
if (!empty($category['files'])) { //一级目录支持,目录下直接存放视频文件
- foreach($category['files'] as $file) {
+ $cate_files = Html::sortFilesByCreateTime($category['files'], 'desc'); //按创建时间排序
+ foreach($cate_files as $file) {
//跳过非.url文件
if (!in_array($file['extension'], $videoExts) || empty($file['shortcut'])) {
continue;