Шаблоны DLE 9.6

Хак формат файлов атач для Dle

Хак формат файлов атач для Dle

Интересный хак файлов аттача (ссылки на скачивание файла), хак показывает формат файла в виде картинки (смотрите скрин). Получилось довольно симпатично.
Установка:

1. Открыть enginemodulesfunctions.php найти:

while ( $row = $db->get_row() ) {                  $size = formatsize( @filesize( ROOT_DIR . '/uploads/files/' . $row['onserver'] ) );         $row['name'] = explode( "/", $row['name'] );         $row['name'] = end( $row['name'] );          $find_1[] = '[attachment=' . $row['id'] . ']';         $find_2[] = "#[attachment={$row['id']}:(.+?)]#i";          if ( ! $user_group[$member_id['user_group']]['allow_files'] ) {              $replace_1[] = "<span class="attachment">{$lang['att_denied']}</span>";             $replace_2[] = "<span class="attachment">{$lang['att_denied']}</span>";          } elseif( $config['files_count'] == 'yes' ) {              $replace_1[] = "<span class="attachment"><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >{$row['name']}</a> [{$size}] ({$lang['att_dcount']} {$row['dcount']})</span>";             $replace_2[] = "<span class="attachment"><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >1</a> [{$size}] ({$lang['att_dcount']} {$row['dcount']})</span>";          } else {              $replace_1[] = "<span class="attachment"><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >{$row['name']}</a> [{$size}]</span>";             $replace_2[] = "<span class="attachment"><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >1</a> [{$size}]</span>";          }      }

Заменить на:

while ( $row = $db->get_row() ) {                  $size = formatsize( @filesize( ROOT_DIR . '/uploads/files/' . $row['onserver'] ) );         $row['name'] = explode( "/", $row['name'] );         $row['name'] = end( $row['name'] );                  $path_info = pathinfo(ROOT_DIR . '/uploads/files/' . $row['onserver']);                 $format = $path_info['extension'];                       switch($format)                                {                                 default: $icon = '/templates/winzeos/filetypes/blank.png'; break;                                 case 'doc': $icon = '/templates/winzeos/filetypes/word.png'; break;                                 case 'bmp': $icon = '/templates/winzeos/filetypes/word.png'; break;                                         case 'jpg': $icon = '/templates/winzeos/filetypes/jpg.png'; break;                                 case 'jpeg': $icon = '/templates/winzeos/filetypes/jpg.png'; break;                                         case 'png': $icon = '/templates/winzeos/filetypes/png.png'; break;                                         case 'gif': $icon = '/templates/winzeos/filetypes/gif.png'; break;                         case 'psd': $icon = '/templates/winzeos/filetypes/photoshop.png'; break;                                     case 'mp3': case 'wav': case 'ogg': $icon = '/templates/winzeos/filetypes/music.png'; break;                         case 'avi': case 'flv': case 'wmv': $icon = '/templates/winzeos/filetypes/music.png'; break;                                     case 'pdf': $icon = '/templates/winzeos/filetypes/finerider.png'; break;                                 case 'exe': $icon = '/templates/winzeos/filetypes/exe.png'; break;                                     case 'txt': $icon = '/templates/winzeos/filetypes/txt.png'; break;                                             case 'phps': $icon = '/templates/winzeos/filetypes/php.png'; break;                                         case 'html': case 'htm': $icon = '/templates/winzeos/filetypes/code.png'; break;                                 case 'rar': case 'zip':  case '7z': $icon = '/templates/winzeos/filetypes/rar.png'; break;                                }                          $find_1[] = '[attachment=' . $row['id'] . ']';         $find_2[] = "#[attachment={$row['id']}:(.+?)]#i";          if ( ! $user_group[$member_id['user_group']]['allow_files'] ) {              $replace_1[] = "<span class="attachment">{$lang['att_denied']}</span>";             $replace_2[] = "<span class="attachment">{$lang['att_denied']}</span>";          } elseif( $config['files_count'] == 'yes' ) {              $replace_1[] = "<span class="attachment"><img src="$icon" alt="$format" align=  "middle"/><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >{$row['name']}</a>   [{$size}] ({$lang['att_dcount']} {$row['dcount']})</span>";             $replace_2[] = "<span class="attachment"><img src="$icon" alt="$format" align=  "middle"/><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >1</a> [{$size}]   ({$lang['att_dcount']} {$row['dcount']})</span>";          } else {              $replace_1[] = "<span class="attachment"><img src="$icon" alt="$format" align=  "middle"/><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >{$row['name']}</a>   [{$size}]</span>";             $replace_2[] = "<span class="attachment"><img src="$icon" alt="$format" align=  "middle"/><a href="{$config['http_home_url']}engine/download.php?id={$row['id']}{$area}" >1</a> [{$size}]  </span>";          }      }

Если Вы хотите добавить новую иконку и новый тип файла, то после:

case 'rar': case 'zip':  case '7z': $icon = '/templates/winzeos/filetypes/rar.png'; break;

Следует добавить:

case 'Формат файла, например mp4': $icon = 'Путь к изображению формата файла, например /templates/winzeos/filetypes/mp4.png'; break;

2. Скопировать папку filetypes в папку Вашего шаблона (templatesDefaultfiletypes).