Просмотр файла mc-2.7.0/modules/downloads/helpers/downloads_installer.php

Размер файла: 3.94Kb
  1. <?php
  2.  
  3. /**
  4. * MobileCMS
  5. *
  6. * Open source content management system for mobile sites
  7. *
  8. * @author MobileCMS Team <support@mobilecms.pro>
  9. * @copyright Copyright (c) 2011-2019, MobileCMS Team
  10. * @link https://mobilecms.pro Official site
  11. * @license MIT license
  12. */
  13. defined('IN_SYSTEM') or die('<b>403<br />Запрет доступа!</b>');
  14.  
  15. //---------------------------------------------
  16.  
  17. /**
  18. * Хелпер установки модуля
  19. */
  20. class downloads_installer {
  21.  
  22. /**
  23. * Установка модуля
  24. */
  25. public static function install($db) {
  26. $db->query("CREATE TABLE IF NOT EXISTS #__downloads_directories (
  27. `directory_id` int(11) NOT NULL auto_increment,
  28. `parent_id` int(11) default '0',
  29. `name` varchar(30) NOT NULL,
  30. `images` enum('yes','no') NOT NULL default 'no',
  31. `user_files` enum('yes','no') NOT NULL default 'no',
  32. `position` int(11) default '0',
  33. PRIMARY KEY (`directory_id`),
  34. KEY `parent_id` (`parent_id`)
  35. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  36. ");
  37.  
  38. $db->query("CREATE TABLE IF NOT EXISTS #__downloads_files (
  39. `file_id` int(11) NOT NULL auto_increment,
  40. `user_id` int(11) NOT NULL,
  41. `directory_id` int(11) default '0',
  42. `time` int(11) NOT NULL,
  43. `name` varchar(50) NOT NULL,
  44. `real_name` varchar(50) NOT NULL,
  45. `path_to_file` varchar(100) NOT NULL,
  46. `filesize` float NOT NULL,
  47. `file_ext` varchar(10) NOT NULL,
  48. `about` varchar(1000) NOT NULL,
  49. `downloads` int(11) default '0',
  50. `screen1` varchar(50) NOT NULL,
  51. `screen2` varchar(50) NOT NULL,
  52. `screen3` varchar(50) NOT NULL,
  53. `add_file_real_name_1` varchar(50) NOT NULL,
  54. `add_file_view_name_1` varchar(50) NOT NULL,
  55. `add_file_real_name_2` varchar(50) NOT NULL,
  56. `add_file_view_name_2` varchar(50) NOT NULL,
  57. `add_file_real_name_3` varchar(50) NOT NULL,
  58. `add_file_view_name_3` varchar(50) NOT NULL,
  59. `add_file_real_name_4` varchar(50) NOT NULL,
  60. `add_file_view_name_4` varchar(50) NOT NULL,
  61. `add_file_real_name_5` varchar(50) NOT NULL,
  62. `add_file_view_name_5` varchar(50) NOT NULL,
  63. `status` enum('active','moderate') NOT NULL default 'active',
  64. `previews` enum('yes','no') NOT NULL default 'no',
  65. PRIMARY KEY (`file_id`),
  66. KEY `dirrectory_id` (`directory_id`)
  67. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  68. ");
  69.  
  70. $db->query("INSERT INTO #__config (`id`, `module`, `key` , `value`) VALUES
  71. (NULL , 'downloads', 'files_prefix', 'site'),
  72. (NULL , 'downloads', 'files_per_page', '7'),
  73. (NULL , 'downloads', 'directories_per_page', '50');
  74. ");
  75.  
  76. if (!is_dir(ROOT . 'files/downloads')) {
  77. mkdir(ROOT . 'files/downloads');
  78. chmod(ROOT . 'files/downloads', 0777);
  79. }
  80. if (!is_dir(ROOT . 'files/downloads/_ftp_upload')) {
  81. mkdir(ROOT . 'files/downloads/_ftp_upload');
  82. chmod(ROOT . 'files/downloads/ftp_upload', 0777);
  83. }
  84.  
  85. # Добавляем правила в реврайт
  86. if (!strstr(file_get_contents(ROOT . '.htaccess'), '[DOWNLOADS MODULE]')) {
  87. $rules = "\t# [DOWNLOADS MODULE]" . PHP_EOL;
  88. $rules .= "\t# Скачать файл" . PHP_EOL;
  89. $rules .= "\tRewriteRule ^download_file/(.*)?$ index.php?segment1=downloads&segment2=download_file&file=$1 [L,QSA]" . PHP_EOL;
  90. $rules .= "\t# Листинг папок" . PHP_EOL;
  91. $rules .= "\tRewriteRule ^downloads/([0-9*])(/)?$ index.php?segment1=downloads&directory_id=$1 [L,QSA]" . PHP_EOL;
  92. $rules .= "\t# Просмотр файла" . PHP_EOL;
  93. $rules .= "\tRewriteRule ^downloads/view/([0-9*])(/)?$ index.php?segment1=downloads&segment2=view_file&file_id=$1 [L,QSA]" . PHP_EOL;
  94.  
  95. main::add_rewrite_rules($rules);
  96. }
  97. }
  98.  
  99. /**
  100. * Деинсталляция модуля
  101. */
  102. public static function uninstall($db) {
  103. #$db->query("DROP TABLE #__downloads_directories, #__downloads_files");
  104. }
  105.  
  106. }
  107.  
  108. ?>