kirgudu_base 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/kirgudu_base/dynamicEvents.js +2 -1
  3. data/app/assets/javascripts/kirgudu_base/jquery.container-management.js +241 -0
  4. data/app/assets/javascripts/kirgudu_base/jquery.fancybox copia.js +2020 -0
  5. data/app/assets/javascripts/kirgudu_base/scripts_nrg.js +300 -383
  6. data/app/controllers/kirgudu_base/admin_controller.rb +1 -44
  7. data/app/controllers/kirgudu_base/application_controller.rb +135 -92
  8. data/app/controllers/kirgudu_base/cabinet_controller.rb +35 -35
  9. data/app/controllers/kirgudu_base/security/authentications_controller.rb +452 -0
  10. data/app/controllers/kirgudu_base/security/email_confirmations_controller.rb +46 -0
  11. data/app/helpers/kirgudu_base/application_helper.rb +25 -0
  12. data/app/helpers/kirgudu_base/authentication_form_builder.rb +76 -0
  13. data/app/helpers/kirgudu_base/controllers/{basic_actions_with_parent.rb → OLD_basic_actions.rb} +39 -54
  14. data/app/helpers/kirgudu_base/controllers/basic_actions.rb +967 -161
  15. data/app/helpers/kirgudu_base/controllers/container_items_management_actions.rb +118 -40
  16. data/app/helpers/kirgudu_base/controllers/container_items_sorting_actions.rb +2 -2
  17. data/app/helpers/kirgudu_base/controllers/dynamic_pages.rb +147 -11
  18. data/app/helpers/kirgudu_base/form_builder.rb +3 -1
  19. data/app/helpers/kirgudu_base/gui_helper.rb +10 -5
  20. data/app/helpers/kirgudu_base/models/exports.rb +122 -122
  21. data/app/helpers/kirgudu_base/models/scopes.rb +5 -0
  22. data/app/mailers/authentications_mailer.rb +53 -0
  23. data/app/models/kirgudu_base/base_model.rb +47 -14
  24. data/app/models/kirgudu_base/dynamic_pages/builder.rb +0 -8
  25. data/app/models/kirgudu_base/dynamic_pages/controller_link.rb +4 -1
  26. data/app/models/kirgudu_base/dynamic_pages/controller_link_builder.rb +2 -1
  27. data/app/models/kirgudu_base/dynamic_pages/controller_link_id.rb +6 -6
  28. data/app/models/kirgudu_base/dynamic_pages/controller_link_id_builder.rb +6 -6
  29. data/app/models/kirgudu_base/dynamic_pages/element.rb +4 -5
  30. data/app/models/kirgudu_base/dynamic_pages/entry_builder.rb +2 -2
  31. data/app/models/kirgudu_base/dynamic_pages/event_if_block_builder.rb +1 -1
  32. data/app/models/kirgudu_base/dynamic_pages/form_builder.rb +2 -2
  33. data/app/models/kirgudu_base/dynamic_pages/list.rb +2 -0
  34. data/app/models/kirgudu_base/dynamic_pages/list_builder.rb +7 -3
  35. data/app/models/kirgudu_base/dynamic_pages/management_settings.rb +30 -0
  36. data/app/models/kirgudu_base/dynamic_pages/management_settings_builder.rb +47 -0
  37. data/app/models/kirgudu_base/dynamic_pages/menu.rb +9 -5
  38. data/app/models/kirgudu_base/dynamic_pages/menu_builder.rb +8 -5
  39. data/app/models/kirgudu_base/dynamic_pages/menu_item.rb +22 -6
  40. data/app/models/kirgudu_base/dynamic_pages/menu_items_block_builder.rb +9 -4
  41. data/app/models/kirgudu_base/dynamic_pages/menu_section.rb +38 -0
  42. data/app/models/kirgudu_base/dynamic_pages/menu_section_builder.rb +36 -0
  43. data/app/models/kirgudu_base/dynamic_pages/page.rb +6 -2
  44. data/app/models/kirgudu_base/dynamic_pages/page_builder.rb +18 -0
  45. data/app/models/kirgudu_base/dynamic_pages/relation.rb +23 -0
  46. data/app/models/kirgudu_base/dynamic_pages/relation_builder.rb +35 -0
  47. data/app/models/kirgudu_base/dynamic_pages/sorting_settings.rb +31 -0
  48. data/app/models/kirgudu_base/dynamic_pages/sorting_settings_builder.rb +48 -0
  49. data/app/models/kirgudu_base/security/autheintication.rb +4 -0
  50. data/app/models/kirgudu_base/security/authentication.rb +6 -7
  51. data/app/models/kirgudu_base/security/email_confirmation.rb +7 -0
  52. data/app/models/kirgudu_base/security/restore_password_code.rb +5 -0
  53. data/app/models/kirgudu_base/security/user.rb +2 -0
  54. data/app/models/kirgudu_base/security.rb +6 -7
  55. data/app/models/kirgudu_base/settings/group.rb +22 -0
  56. data/app/models/kirgudu_base/settings/option.rb +44 -0
  57. data/app/models/kirgudu_base/settings/settings_manager.rb +69 -0
  58. data/app/models/kirgudu_base/settings/value.rb +36 -0
  59. data/app/views/admin_templates/default/admin/layouts/application.html.erb +6 -4
  60. data/app/views/admin_templates/default/admin/system/settings/groups/edit.html.erb +9 -9
  61. data/app/views/admin_templates/default/admin/system/settings/groups/new.html.erb +1 -1
  62. data/app/views/admin_templates/default/admin/system/settings/options/edit.html.erb +1 -1
  63. data/app/views/admin_templates/default/admin/system/settings/options/new.html.erb +1 -1
  64. data/app/views/admin_templates/default/admin/system/settings/values/edit.html.erb +1 -1
  65. data/app/views/admin_templates/default/admin/system/settings/values/new.html.erb +1 -1
  66. data/app/views/admin_templates/erp/admin/shared/_top_nav_bar.html.erb +1 -3
  67. data/app/views/admin_templates/erp/admin/shared/entry_edit_form_renderer.html.erb +1 -1
  68. data/app/views/admin_templates/erp/admin/shared/entry_new_form_renderer.html.erb +1 -1
  69. data/app/views/admin_templates/good/admin/layouts/OLD_application.html.erb +14 -14
  70. data/app/views/admin_templates/good/admin/layouts/application.html.erb +11 -113
  71. data/app/views/admin_templates/good/admin/shared/_left_menu.html.erb +74 -63
  72. data/app/views/admin_templates/good/{zapanel/files/New Adobe Photoshop Image 12.psd → admin/shared/_left_menu_item.html.erb} +0 -0
  73. data/app/views/admin_templates/good/admin/shared/_left_menu_section.html.erb +21 -0
  74. data/app/views/admin_templates/good/admin/shared/render_new_OLD.html.erb +90 -0
  75. data/app/views/admin_templates/good/admin/shared/renderer_edit.html.erb +44 -13
  76. data/app/views/admin_templates/good/admin/shared/renderer_edit_OLD.html.erb +106 -0
  77. data/app/views/admin_templates/good/admin/shared/renderer_entries_list.html.erb +39 -18
  78. data/app/views/admin_templates/good/admin/shared/renderer_entries_list_with_parent.html.erb +4 -4
  79. data/app/views/admin_templates/good/admin/shared/renderer_management.html.erb +164 -0
  80. data/app/views/admin_templates/good/admin/shared/renderer_new.html.erb +40 -10
  81. data/app/views/admin_templates/good/admin/shared/renderer_show.html.erb +170 -58
  82. data/app/views/admin_templates/good/admin/shared/renderer_show_OLD.html.erb +159 -0
  83. data/app/views/admin_templates/good/admin/shared/renderer_sorting.html.erb +30 -0
  84. data/app/views/admin_templates/good/kirgudu_base/authentications/login.html.erb +13 -13
  85. data/app/views/admin_templates/good/kirgudu_base/authentications/register.html.erb +1 -1
  86. data/app/views/admin_templates/good/kirgudu_base/old/login_page.html.erb +7 -7
  87. data/app/views/admin_templates/good_flexy/admin/layouts/application.html.erb +17 -16
  88. data/app/views/admin_templates/good_flexy/admin/shared/_left_menu.html.erb +7 -0
  89. data/app/views/admin_templates/good_flexy/admin/shared/renderer_entries_list.html.erb +25 -17
  90. data/app/views/admin_templates/good_flexy/admin/shared/renderer_form_edit.html.erb +34 -13
  91. data/app/views/admin_templates/good_flexy/admin/shared/renderer_form_new.html.erb +31 -10
  92. data/app/views/admin_templates/good_flexy/admin/shared/renderer_show.html.erb +67 -52
  93. data/config/locales/kirgudu_base.ru.yml +92 -0
  94. data/config/routes.rb +16 -16
  95. data/db/migrate/20140413134252_create_kirgudu_base_security_authentications.rb +15 -0
  96. data/db/migrate/20140413152144_create_kirgudu_base_security_email_confirmations.rb +17 -0
  97. data/db/migrate/20140413201121_add_confirmations_kirgudu_base_security_users.rb +14 -0
  98. data/db/migrate/20140415093106_create_kirgudu_base_security_restore_password_codes.rb +20 -0
  99. data/lib/kirgudu_base.rb +2 -2
  100. data/test/fixtures/kirgudu_base/kirgudu_base/security/autheintications.yml +11 -0
  101. data/test/fixtures/kirgudu_base/security/applications.yml +21 -0
  102. data/test/fixtures/kirgudu_base/security/autheintications.yml +11 -0
  103. data/test/fixtures/kirgudu_base/security/authentications.yml +11 -0
  104. data/test/fixtures/kirgudu_base/security/email_confirmations.yml +13 -0
  105. data/test/fixtures/kirgudu_base/security/restore_password_codes.yml +13 -0
  106. data/test/models/kirgudu_base/kirgudu_base/security/autheintication_test.rb +9 -0
  107. data/test/models/kirgudu_base/security/application_test.rb +9 -0
  108. data/test/models/kirgudu_base/security/autheintication_test.rb +9 -0
  109. data/test/models/kirgudu_base/security/authentication_test.rb +9 -0
  110. data/test/models/kirgudu_base/security/email_confirmation_test.rb +9 -0
  111. data/test/models/kirgudu_base/security/restore_password_code_test.rb +9 -0
  112. metadata +102 -79
  113. data/app/assets/javascripts/kirgudu_base/jquery.fancybox.pack.js +0 -45
  114. data/app/controllers/kirgudu_base/authentications_controller.rb +0 -157
  115. data/app/views/admin_templates/good/zapanel/404.html +0 -386
  116. data/app/views/admin_templates/good/zapanel/billing.html +0 -550
  117. data/app/views/admin_templates/good/zapanel/blank-page.html +0 -343
  118. data/app/views/admin_templates/good/zapanel/buttons.html +0 -1018
  119. data/app/views/admin_templates/good/zapanel/calendars.html +0 -451
  120. data/app/views/admin_templates/good/zapanel/cart.html +0 -522
  121. data/app/views/admin_templates/good/zapanel/charts.html +0 -611
  122. data/app/views/admin_templates/good/zapanel/collapse.html +0 -555
  123. data/app/views/admin_templates/good/zapanel/contact.php +0 -102
  124. data/app/views/admin_templates/good/zapanel/dashboard.html +0 -985
  125. data/app/views/admin_templates/good/zapanel/dashboard2.html +0 -1091
  126. data/app/views/admin_templates/good/zapanel/dashboard3.html +0 -1079
  127. data/app/views/admin_templates/good/zapanel/data/movies.json +0 -1
  128. data/app/views/admin_templates/good/zapanel/faq.html +0 -435
  129. data/app/views/admin_templates/good/zapanel/file-manager.html +0 -358
  130. data/app/views/admin_templates/good/zapanel/files/index.php +0 -0
  131. data/app/views/admin_templates/good/zapanel/font-awesome/less/bootstrap.less +0 -84
  132. data/app/views/admin_templates/good/zapanel/font-awesome/less/core.less +0 -129
  133. data/app/views/admin_templates/good/zapanel/font-awesome/less/extras.less +0 -93
  134. data/app/views/admin_templates/good/zapanel/font-awesome/less/font-awesome-ie7.less +0 -1953
  135. data/app/views/admin_templates/good/zapanel/font-awesome/less/font-awesome.less +0 -33
  136. data/app/views/admin_templates/good/zapanel/font-awesome/less/icons.less +0 -381
  137. data/app/views/admin_templates/good/zapanel/font-awesome/less/mixins.less +0 -48
  138. data/app/views/admin_templates/good/zapanel/font-awesome/less/path.less +0 -14
  139. data/app/views/admin_templates/good/zapanel/font-awesome/less/variables.less +0 -735
  140. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_bootstrap.scss +0 -84
  141. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_core.scss +0 -129
  142. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_extras.scss +0 -93
  143. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_icons.scss +0 -381
  144. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_mixins.scss +0 -48
  145. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_path.scss +0 -14
  146. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_variables.scss +0 -734
  147. data/app/views/admin_templates/good/zapanel/font-awesome/scss/font-awesome-ie7.scss +0 -1953
  148. data/app/views/admin_templates/good/zapanel/font-awesome/scss/font-awesome.scss +0 -33
  149. data/app/views/admin_templates/good/zapanel/form.html +0 -790
  150. data/app/views/admin_templates/good/zapanel/gallery.html +0 -392
  151. data/app/views/admin_templates/good/zapanel/grids.html +0 -574
  152. data/app/views/admin_templates/good/zapanel/hosting-dashboard.html +0 -448
  153. data/app/views/admin_templates/good/zapanel/icon.html +0 -722
  154. data/app/views/admin_templates/good/zapanel/inbox.html +0 -375
  155. data/app/views/admin_templates/good/zapanel/index.html +0 -48
  156. data/app/views/admin_templates/good/zapanel/invoice.html +0 -423
  157. data/app/views/admin_templates/good/zapanel/js/proxy/elFinderSupportVer1.js +0 -338
  158. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-close.png +0 -0
  159. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-next.png +0 -0
  160. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-prev.png +0 -0
  161. data/app/views/admin_templates/good/zapanel/notification.html +0 -400
  162. data/app/views/admin_templates/good/zapanel/order-recieved.html +0 -348
  163. data/app/views/admin_templates/good/zapanel/php/MySQLStorage.sql +0 -23
  164. data/app/views/admin_templates/good/zapanel/php/connector.php +0 -44
  165. data/app/views/admin_templates/good/zapanel/php/elFinder.class.php +0 -1103
  166. data/app/views/admin_templates/good/zapanel/php/elFinderConnector.class.php +0 -133
  167. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeDriver.class.php +0 -3370
  168. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeLocalFileSystem.class.php +0 -835
  169. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeMySQL.class.php +0 -896
  170. data/app/views/admin_templates/good/zapanel/php/mime.types +0 -512
  171. data/app/views/admin_templates/good/zapanel/price-table.html +0 -400
  172. data/app/views/admin_templates/good/zapanel/profile.html +0 -387
  173. data/app/views/admin_templates/good/zapanel/progressbar.html +0 -555
  174. data/app/views/admin_templates/good/zapanel/range-slider.html +0 -440
  175. data/app/views/admin_templates/good/zapanel/ribbon-grids.html +0 -491
  176. data/app/views/admin_templates/good/zapanel/sale-purchase-dashboard.html +0 -803
  177. data/app/views/admin_templates/good/zapanel/search.html +0 -370
  178. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-close.png +0 -0
  179. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-loading.gif +0 -0
  180. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-next.png +0 -0
  181. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-pause.png +0 -0
  182. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-play.png +0 -0
  183. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-playvideo.png +0 -0
  184. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-prev.png +0 -0
  185. data/app/views/admin_templates/good/zapanel/slider.html +0 -453
  186. data/app/views/admin_templates/good/zapanel/tables.html +0 -470
  187. data/app/views/admin_templates/good/zapanel/typography.html +0 -746
@@ -1,835 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * elFinder driver for local filesystem.
5
- *
6
- * @author Dmitry (dio) Levashov
7
- * @author Troex Nevelin
8
- **/
9
- class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
10
-
11
- /**
12
- * Driver id
13
- * Must be started from letter and contains [a-z0-9]
14
- * Used as part of volume id
15
- *
16
- * @var string
17
- **/
18
- protected $driverId = 'l';
19
-
20
- /**
21
- * Required to count total archive files size
22
- *
23
- * @var int
24
- **/
25
- protected $archiveSize = 0;
26
-
27
- /**
28
- * Constructor
29
- * Extend options with required fields
30
- *
31
- * @return void
32
- * @author Dmitry (dio) Levashov
33
- **/
34
- public function __construct() {
35
- $this->options['alias'] = ''; // alias to replace root dir name
36
- $this->options['dirMode'] = 0755; // new dirs mode
37
- $this->options['fileMode'] = 0644; // new files mode
38
- $this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
39
- $this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
40
- }
41
-
42
- /*********************************************************************/
43
- /* INIT AND CONFIGURE */
44
- /*********************************************************************/
45
-
46
- /**
47
- * Configure after successfull mount.
48
- *
49
- * @return void
50
- * @author Dmitry (dio) Levashov
51
- **/
52
- protected function configure() {
53
- $this->aroot = realpath($this->root);
54
- $root = $this->stat($this->root);
55
-
56
- if ($this->options['quarantine']) {
57
- $this->attributes[] = array(
58
- 'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR.$this->options['quarantine']).'$~',
59
- 'read' => false,
60
- 'write' => false,
61
- 'locked' => true,
62
- 'hidden' => true
63
- );
64
- }
65
-
66
- // chek thumbnails path
67
- if ($this->options['tmbPath']) {
68
- $this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false
69
- // tmb path set as dirname under root dir
70
- ? $this->root.DIRECTORY_SEPARATOR.$this->options['tmbPath']
71
- // tmb path as full path
72
- : $this->_normpath($this->options['tmbPath']);
73
- }
74
-
75
- parent::configure();
76
-
77
- // if no thumbnails url - try detect it
78
- if ($root['read'] && !$this->tmbURL && $this->URL) {
79
- if (strpos($this->tmbPath, $this->root) === 0) {
80
- $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
81
- if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
82
- $this->tmbURL .= '/';
83
- }
84
- }
85
- }
86
-
87
- // check quarantine dir
88
- if (!empty($this->options['quarantine'])) {
89
- $this->quarantine = $this->root.DIRECTORY_SEPARATOR.$this->options['quarantine'];
90
- if ((!is_dir($this->quarantine) && !$this->_mkdir($this->root, $this->options['quarantine'])) || !is_writable($this->quarantine)) {
91
- $this->archivers['extract'] = array();
92
- $this->disabled[] = 'extract';
93
- }
94
- } else {
95
- $this->archivers['extract'] = array();
96
- $this->disabled[] = 'extract';
97
- }
98
-
99
- }
100
-
101
- /*********************************************************************/
102
- /* FS API */
103
- /*********************************************************************/
104
-
105
- /*********************** paths/urls *************************/
106
-
107
- /**
108
- * Return parent directory path
109
- *
110
- * @param string $path file path
111
- * @return string
112
- * @author Dmitry (dio) Levashov
113
- **/
114
- protected function _dirname($path) {
115
- return dirname($path);
116
- }
117
-
118
- /**
119
- * Return file name
120
- *
121
- * @param string $path file path
122
- * @return string
123
- * @author Dmitry (dio) Levashov
124
- **/
125
- protected function _basename($path) {
126
- return basename($path);
127
- }
128
-
129
- /**
130
- * Join dir name and file name and retur full path
131
- *
132
- * @param string $dir
133
- * @param string $name
134
- * @return string
135
- * @author Dmitry (dio) Levashov
136
- **/
137
- protected function _joinPath($dir, $name) {
138
- return $dir.DIRECTORY_SEPARATOR.$name;
139
- }
140
-
141
- /**
142
- * Return normalized path, this works the same as os.path.normpath() in Python
143
- *
144
- * @param string $path path
145
- * @return string
146
- * @author Troex Nevelin
147
- **/
148
- protected function _normpath($path) {
149
- if (empty($path)) {
150
- return '.';
151
- }
152
-
153
- if (strpos($path, '/') === 0) {
154
- $initial_slashes = true;
155
- } else {
156
- $initial_slashes = false;
157
- }
158
-
159
- if (($initial_slashes)
160
- && (strpos($path, '//') === 0)
161
- && (strpos($path, '///') === false)) {
162
- $initial_slashes = 2;
163
- }
164
-
165
- $initial_slashes = (int) $initial_slashes;
166
-
167
- $comps = explode('/', $path);
168
- $new_comps = array();
169
- foreach ($comps as $comp) {
170
- if (in_array($comp, array('', '.'))) {
171
- continue;
172
- }
173
-
174
- if (($comp != '..')
175
- || (!$initial_slashes && !$new_comps)
176
- || ($new_comps && (end($new_comps) == '..'))) {
177
- array_push($new_comps, $comp);
178
- } elseif ($new_comps) {
179
- array_pop($new_comps);
180
- }
181
- }
182
- $comps = $new_comps;
183
- $path = implode('/', $comps);
184
- if ($initial_slashes) {
185
- $path = str_repeat('/', $initial_slashes) . $path;
186
- }
187
-
188
- return $path ? $path : '.';
189
- }
190
-
191
- /**
192
- * Return file path related to root dir
193
- *
194
- * @param string $path file path
195
- * @return string
196
- * @author Dmitry (dio) Levashov
197
- **/
198
- protected function _relpath($path) {
199
- return $path == $this->root ? '' : substr($path, strlen($this->root)+1);
200
- }
201
-
202
- /**
203
- * Convert path related to root dir into real path
204
- *
205
- * @param string $path file path
206
- * @return string
207
- * @author Dmitry (dio) Levashov
208
- **/
209
- protected function _abspath($path) {
210
- return $path == DIRECTORY_SEPARATOR ? $this->root : $this->root.DIRECTORY_SEPARATOR.$path;
211
- }
212
-
213
- /**
214
- * Return fake path started from root dir
215
- *
216
- * @param string $path file path
217
- * @return string
218
- * @author Dmitry (dio) Levashov
219
- **/
220
- protected function _path($path) {
221
- return $this->rootName.($path == $this->root ? '' : $this->separator.$this->_relpath($path));
222
- }
223
-
224
- /**
225
- * Return true if $path is children of $parent
226
- *
227
- * @param string $path path to check
228
- * @param string $parent parent path
229
- * @return bool
230
- * @author Dmitry (dio) Levashov
231
- **/
232
- protected function _inpath($path, $parent) {
233
- return $path == $parent || strpos($path, $parent.DIRECTORY_SEPARATOR) === 0;
234
- }
235
-
236
-
237
-
238
- /***************** file stat ********************/
239
-
240
- /**
241
- * Return stat for given path.
242
- * Stat contains following fields:
243
- * - (int) size file size in b. required
244
- * - (int) ts file modification time in unix time. required
245
- * - (string) mime mimetype. required for folders, others - optionally
246
- * - (bool) read read permissions. required
247
- * - (bool) write write permissions. required
248
- * - (bool) locked is object locked. optionally
249
- * - (bool) hidden is object hidden. optionally
250
- * - (string) alias for symlinks - link target path relative to root path. optionally
251
- * - (string) target for symlinks - link target path. optionally
252
- *
253
- * If file does not exists - returns empty array or false.
254
- *
255
- * @param string $path file path
256
- * @return array|false
257
- * @author Dmitry (dio) Levashov
258
- **/
259
- protected function _stat($path) {
260
- $stat = array();
261
-
262
- if (!file_exists($path)) {
263
- return $stat;
264
- }
265
-
266
- if ($path != $this->root && is_link($path)) {
267
- if (($target = $this->readlink($path)) == false
268
- || $target == $path) {
269
- $stat['mime'] = 'symlink-broken';
270
- $stat['read'] = false;
271
- $stat['write'] = false;
272
- $stat['size'] = 0;
273
- return $stat;
274
- }
275
- $stat['alias'] = $this->_path($target);
276
- $stat['target'] = $target;
277
- $path = $target;
278
- $lstat = lstat($path);
279
- $size = $lstat['size'];
280
- } else {
281
- $size = @filesize($path);
282
- }
283
-
284
- $dir = is_dir($path);
285
-
286
- $stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
287
- $stat['ts'] = filemtime($path);
288
- $stat['read'] = is_readable($path);
289
- $stat['write'] = is_writable($path);
290
- if ($stat['read']) {
291
- $stat['size'] = $dir ? 0 : $size;
292
- }
293
-
294
- return $stat;
295
- }
296
-
297
-
298
- /**
299
- * Return true if path is dir and has at least one childs directory
300
- *
301
- * @param string $path dir path
302
- * @return bool
303
- * @author Dmitry (dio) Levashov
304
- **/
305
- protected function _subdirs($path) {
306
-
307
- if (($dir = dir($path))) {
308
- $dir = dir($path);
309
- while (($entry = $dir->read()) !== false) {
310
- $p = $dir->path.DIRECTORY_SEPARATOR.$entry;
311
- if ($entry != '.' && $entry != '..' && is_dir($p) && !$this->attr($p, 'hidden')) {
312
- $dir->close();
313
- return true;
314
- }
315
- }
316
- $dir->close();
317
- }
318
- return false;
319
- }
320
-
321
- /**
322
- * Return object width and height
323
- * Ususaly used for images, but can be realize for video etc...
324
- *
325
- * @param string $path file path
326
- * @param string $mime file mime type
327
- * @return string
328
- * @author Dmitry (dio) Levashov
329
- **/
330
- protected function _dimensions($path, $mime) {
331
- clearstatcache();
332
- return strpos($mime, 'image') === 0 && ($s = @getimagesize($path)) !== false
333
- ? $s[0].'x'.$s[1]
334
- : false;
335
- }
336
- /******************** file/dir content *********************/
337
-
338
- /**
339
- * Return symlink target file
340
- *
341
- * @param string $path link path
342
- * @return string
343
- * @author Dmitry (dio) Levashov
344
- **/
345
- protected function readlink($path) {
346
- if (!($target = @readlink($path))) {
347
- return false;
348
- }
349
-
350
- if (substr($target, 0, 1) != DIRECTORY_SEPARATOR) {
351
- $target = dirname($path).DIRECTORY_SEPARATOR.$target;
352
- }
353
-
354
- $atarget = realpath($target);
355
-
356
- if (!$atarget) {
357
- return false;
358
- }
359
-
360
- $root = $this->root;
361
- $aroot = $this->aroot;
362
-
363
- if ($this->_inpath($atarget, $this->aroot)) {
364
- return $this->_normpath($this->root.DIRECTORY_SEPARATOR.substr($atarget, strlen($this->aroot)+1));
365
- }
366
-
367
- return false;
368
- }
369
-
370
- /**
371
- * Return files list in directory.
372
- *
373
- * @param string $path dir path
374
- * @return array
375
- * @author Dmitry (dio) Levashov
376
- **/
377
- protected function _scandir($path) {
378
- $files = array();
379
-
380
- foreach (scandir($path) as $name) {
381
- if ($name != '.' && $name != '..') {
382
- $files[] = $path.DIRECTORY_SEPARATOR.$name;
383
- }
384
- }
385
- return $files;
386
- }
387
-
388
- /**
389
- * Open file and return file pointer
390
- *
391
- * @param string $path file path
392
- * @param bool $write open file for writing
393
- * @return resource|false
394
- * @author Dmitry (dio) Levashov
395
- **/
396
- protected function _fopen($path, $mode='rb') {
397
- return @fopen($path, 'r');
398
- }
399
-
400
- /**
401
- * Close opened file
402
- *
403
- * @param resource $fp file pointer
404
- * @return bool
405
- * @author Dmitry (dio) Levashov
406
- **/
407
- protected function _fclose($fp, $path='') {
408
- return @fclose($fp);
409
- }
410
-
411
- /******************** file/dir manipulations *************************/
412
-
413
- /**
414
- * Create dir and return created dir path or false on failed
415
- *
416
- * @param string $path parent dir path
417
- * @param string $name new directory name
418
- * @return string|bool
419
- * @author Dmitry (dio) Levashov
420
- **/
421
- protected function _mkdir($path, $name) {
422
- $path = $path.DIRECTORY_SEPARATOR.$name;
423
-
424
- if (@mkdir($path)) {
425
- @chmod($path, $this->options['dirMode']);
426
- return $path;
427
- }
428
-
429
- return false;
430
- }
431
-
432
- /**
433
- * Create file and return it's path or false on failed
434
- *
435
- * @param string $path parent dir path
436
- * @param string $name new file name
437
- * @return string|bool
438
- * @author Dmitry (dio) Levashov
439
- **/
440
- protected function _mkfile($path, $name) {
441
- $path = $path.DIRECTORY_SEPARATOR.$name;
442
-
443
- if (($fp = @fopen($path, 'w'))) {
444
- @fclose($fp);
445
- @chmod($path, $this->options['fileMode']);
446
- return $path;
447
- }
448
- return false;
449
- }
450
-
451
- /**
452
- * Create symlink
453
- *
454
- * @param string $source file to link to
455
- * @param string $targetDir folder to create link in
456
- * @param string $name symlink name
457
- * @return bool
458
- * @author Dmitry (dio) Levashov
459
- **/
460
- protected function _symlink($source, $targetDir, $name) {
461
- return @symlink($source, $targetDir.DIRECTORY_SEPARATOR.$name);
462
- }
463
-
464
- /**
465
- * Copy file into another file
466
- *
467
- * @param string $source source file path
468
- * @param string $targetDir target directory path
469
- * @param string $name new file name
470
- * @return bool
471
- * @author Dmitry (dio) Levashov
472
- **/
473
- protected function _copy($source, $targetDir, $name) {
474
- return copy($source, $targetDir.DIRECTORY_SEPARATOR.$name);
475
- }
476
-
477
- /**
478
- * Move file into another parent dir.
479
- * Return new file path or false.
480
- *
481
- * @param string $source source file path
482
- * @param string $target target dir path
483
- * @param string $name file name
484
- * @return string|bool
485
- * @author Dmitry (dio) Levashov
486
- **/
487
- protected function _move($source, $targetDir, $name) {
488
- $target = $targetDir.DIRECTORY_SEPARATOR.$name;
489
- return @rename($source, $target) ? $target : false;
490
- }
491
-
492
- /**
493
- * Remove file
494
- *
495
- * @param string $path file path
496
- * @return bool
497
- * @author Dmitry (dio) Levashov
498
- **/
499
- protected function _unlink($path) {
500
- return @unlink($path);
501
- }
502
-
503
- /**
504
- * Remove dir
505
- *
506
- * @param string $path dir path
507
- * @return bool
508
- * @author Dmitry (dio) Levashov
509
- **/
510
- protected function _rmdir($path) {
511
- return @rmdir($path);
512
- }
513
-
514
- /**
515
- * Create new file and write into it from file pointer.
516
- * Return new file path or false on error.
517
- *
518
- * @param resource $fp file pointer
519
- * @param string $dir target dir path
520
- * @param string $name file name
521
- * @return bool|string
522
- * @author Dmitry (dio) Levashov
523
- **/
524
- protected function _save($fp, $dir, $name, $mime, $w, $h) {
525
- $path = $dir.DIRECTORY_SEPARATOR.$name;
526
-
527
- if (!($target = @fopen($path, 'wb'))) {
528
- return false;
529
- }
530
-
531
- while (!feof($fp)) {
532
- fwrite($target, fread($fp, 8192));
533
- }
534
- fclose($target);
535
- @chmod($path, $this->options['fileMode']);
536
- clearstatcache();
537
- return $path;
538
- }
539
-
540
- /**
541
- * Get file contents
542
- *
543
- * @param string $path file path
544
- * @return string|false
545
- * @author Dmitry (dio) Levashov
546
- **/
547
- protected function _getContents($path) {
548
- return file_get_contents($path);
549
- }
550
-
551
- /**
552
- * Write a string to a file
553
- *
554
- * @param string $path file path
555
- * @param string $content new file content
556
- * @return bool
557
- * @author Dmitry (dio) Levashov
558
- **/
559
- protected function _filePutContents($path, $content) {
560
- if (@file_put_contents($path, $content, LOCK_EX) !== false) {
561
- clearstatcache();
562
- return true;
563
- }
564
- return false;
565
- }
566
-
567
- /**
568
- * Detect available archivers
569
- *
570
- * @return void
571
- **/
572
- protected function _checkArchivers() {
573
- if (!function_exists('exec')) {
574
- $this->options['archivers'] = $this->options['archive'] = array();
575
- return;
576
- }
577
- $arcs = array(
578
- 'create' => array(),
579
- 'extract' => array()
580
- );
581
-
582
- //exec('tar --version', $o, $ctar);
583
- $this->procExec('tar --version', $o, $ctar);
584
-
585
- if ($ctar == 0) {
586
- $arcs['create']['application/x-tar'] = array('cmd' => 'tar', 'argc' => '-cf', 'ext' => 'tar');
587
- $arcs['extract']['application/x-tar'] = array('cmd' => 'tar', 'argc' => '-xf', 'ext' => 'tar');
588
- //$test = exec('gzip --version', $o, $c);
589
- unset($o);
590
- $test = $this->procExec('gzip --version', $o, $c);
591
-
592
- if ($c == 0) {
593
- $arcs['create']['application/x-gzip'] = array('cmd' => 'tar', 'argc' => '-czf', 'ext' => 'tgz');
594
- $arcs['extract']['application/x-gzip'] = array('cmd' => 'tar', 'argc' => '-xzf', 'ext' => 'tgz');
595
- }
596
- unset($o);
597
- //$test = exec('bzip2 --version', $o, $c);
598
- $test = $this->procExec('bzip2 --version', $o, $c);
599
- if ($c == 0) {
600
- $arcs['create']['application/x-bzip2'] = array('cmd' => 'tar', 'argc' => '-cjf', 'ext' => 'tbz');
601
- $arcs['extract']['application/x-bzip2'] = array('cmd' => 'tar', 'argc' => '-xjf', 'ext' => 'tbz');
602
- }
603
- }
604
- unset($o);
605
- //exec('zip --version', $o, $c);
606
- $this->procExec('zip -v', $o, $c);
607
- if ($c == 0) {
608
- $arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
609
- }
610
- unset($o);
611
- $this->procExec('unzip --help', $o, $c);
612
- if ($c == 0) {
613
- $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
614
- }
615
- unset($o);
616
- //exec('rar --version', $o, $c);
617
- $this->procExec('rar --version', $o, $c);
618
- if ($c == 0 || $c == 7) {
619
- $arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
620
- $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
621
- } else {
622
- unset($o);
623
- //$test = exec('unrar', $o, $c);
624
- $test = $this->procExec('unrar', $o, $c);
625
- if ($c==0 || $c == 7) {
626
- $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
627
- }
628
- }
629
- unset($o);
630
- //exec('7za --help', $o, $c);
631
- $this->procExec('7za --help', $o, $c);
632
- if ($c == 0) {
633
- $arcs['create']['application/x-7z-compressed'] = array('cmd' => '7za', 'argc' => 'a', 'ext' => '7z');
634
- $arcs['extract']['application/x-7z-compressed'] = array('cmd' => '7za', 'argc' => 'e -y', 'ext' => '7z');
635
-
636
- if (empty($arcs['create']['application/x-gzip'])) {
637
- $arcs['create']['application/x-gzip'] = array('cmd' => '7za', 'argc' => 'a -tgzip', 'ext' => 'tar.gz');
638
- }
639
- if (empty($arcs['extract']['application/x-gzip'])) {
640
- $arcs['extract']['application/x-gzip'] = array('cmd' => '7za', 'argc' => 'e -tgzip -y', 'ext' => 'tar.gz');
641
- }
642
- if (empty($arcs['create']['application/x-bzip2'])) {
643
- $arcs['create']['application/x-bzip2'] = array('cmd' => '7za', 'argc' => 'a -tbzip2', 'ext' => 'tar.bz');
644
- }
645
- if (empty($arcs['extract']['application/x-bzip2'])) {
646
- $arcs['extract']['application/x-bzip2'] = array('cmd' => '7za', 'argc' => 'a -tbzip2 -y', 'ext' => 'tar.bz');
647
- }
648
- if (empty($arcs['create']['application/zip'])) {
649
- $arcs['create']['application/zip'] = array('cmd' => '7za', 'argc' => 'a -tzip -l', 'ext' => 'zip');
650
- }
651
- if (empty($arcs['extract']['application/zip'])) {
652
- $arcs['extract']['application/zip'] = array('cmd' => '7za', 'argc' => 'e -tzip -y', 'ext' => 'zip');
653
- }
654
- if (empty($arcs['create']['application/x-tar'])) {
655
- $arcs['create']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'a -ttar -l', 'ext' => 'tar');
656
- }
657
- if (empty($arcs['extract']['application/x-tar'])) {
658
- $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'e -ttar -y', 'ext' => 'tar');
659
- }
660
- }
661
-
662
- $this->archivers = $arcs;
663
- }
664
-
665
- /**
666
- * Unpack archive
667
- *
668
- * @param string $path archive path
669
- * @param array $arc archiver command and arguments (same as in $this->archivers)
670
- * @return void
671
- * @author Dmitry (dio) Levashov
672
- * @author Alexey Sukhotin
673
- **/
674
- protected function _unpack($path, $arc) {
675
- $cwd = getcwd();
676
- $dir = $this->_dirname($path);
677
- chdir($dir);
678
- $cmd = $arc['cmd'].' '.$arc['argc'].' '.escapeshellarg($this->_basename($path));
679
- $this->procExec($cmd, $o, $c);
680
- chdir($cwd);
681
- }
682
-
683
- /**
684
- * Recursive symlinks search
685
- *
686
- * @param string $path file/dir path
687
- * @return bool
688
- * @author Dmitry (dio) Levashov
689
- **/
690
- protected function _findSymlinks($path) {
691
- if (is_link($path)) {
692
- return true;
693
- }
694
-
695
- if (is_dir($path)) {
696
- foreach (scandir($path) as $name) {
697
- if ($name != '.' && $name != '..') {
698
- $p = $path.DIRECTORY_SEPARATOR.$name;
699
- if (is_link($p)) {
700
- return true;
701
- }
702
- if (is_dir($p) && $this->_findSymlinks($p)) {
703
- return true;
704
- } elseif (is_file($p)) {
705
- $this->archiveSize += filesize($p);
706
- }
707
- }
708
- }
709
- } else {
710
- $this->archiveSize += filesize($path);
711
- }
712
-
713
- return false;
714
- }
715
-
716
- /**
717
- * Extract files from archive
718
- *
719
- * @param string $path archive path
720
- * @param array $arc archiver command and arguments (same as in $this->archivers)
721
- * @return true
722
- * @author Dmitry (dio) Levashov,
723
- * @author Alexey Sukhotin
724
- **/
725
- protected function _extract($path, $arc) {
726
-
727
- if ($this->quarantine) {
728
- $dir = $this->quarantine.DIRECTORY_SEPARATOR.str_replace(' ', '_', microtime()).basename($path);
729
- $archive = $dir.DIRECTORY_SEPARATOR.basename($path);
730
-
731
- if (!@mkdir($dir)) {
732
- return false;
733
- }
734
-
735
- chmod($dir, 0777);
736
-
737
- // copy in quarantine
738
- if (!copy($path, $archive)) {
739
- return false;
740
- }
741
-
742
- // extract in quarantine
743
- $this->_unpack($archive, $arc);
744
- @unlink($archive);
745
-
746
- // get files list
747
- $ls = array();
748
- foreach (scandir($dir) as $i => $name) {
749
- if ($name != '.' && $name != '..') {
750
- $ls[] = $name;
751
- }
752
- }
753
-
754
- // no files - extract error ?
755
- if (empty($ls)) {
756
- return false;
757
- }
758
-
759
- $this->archiveSize = 0;
760
-
761
- // find symlinks
762
- $symlinks = $this->_findSymlinks($dir);
763
- // remove arc copy
764
- $this->remove($dir);
765
-
766
- if ($symlinks) {
767
- return $this->setError(elFinder::ERROR_ARC_SYMLINKS);
768
- }
769
-
770
- // check max files size
771
- if ($this->options['maxArcFilesSize'] > 0 && $this->options['maxArcFilesSize'] < $this->archiveSize) {
772
- return $this->setError(elFinder::ERROR_ARC_MAXSIZE);
773
- }
774
-
775
-
776
-
777
- // archive contains one item - extract in archive dir
778
- if (count($ls) == 1) {
779
- $this->_unpack($path, $arc);
780
- $result = dirname($path).DIRECTORY_SEPARATOR.$ls[0];
781
-
782
-
783
- } else {
784
- // for several files - create new directory
785
- // create unique name for directory
786
- $name = basename($path);
787
- if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
788
- $name = substr($name, 0, strlen($name)-strlen($m[0]));
789
- }
790
- $test = dirname($path).DIRECTORY_SEPARATOR.$name;
791
- if (file_exists($test) || is_link($test)) {
792
- $name = $this->uniqueName(dirname($path), $name, '-', false);
793
- }
794
-
795
- $result = dirname($path).DIRECTORY_SEPARATOR.$name;
796
- $archive = $result.DIRECTORY_SEPARATOR.basename($path);
797
-
798
- if (!$this->_mkdir(dirname($path), $name) || !copy($path, $archive)) {
799
- return false;
800
- }
801
-
802
- $this->_unpack($archive, $arc);
803
- @unlink($archive);
804
- }
805
-
806
- return file_exists($result) ? $result : false;
807
- }
808
- }
809
-
810
- /**
811
- * Create archive and return its path
812
- *
813
- * @param string $dir target dir
814
- * @param array $files files names list
815
- * @param string $name archive name
816
- * @param array $arc archiver options
817
- * @return string|bool
818
- * @author Dmitry (dio) Levashov,
819
- * @author Alexey Sukhotin
820
- **/
821
- protected function _archive($dir, $files, $name, $arc) {
822
- $cwd = getcwd();
823
- chdir($dir);
824
-
825
- $files = array_map('escapeshellarg', $files);
826
-
827
- $cmd = $arc['cmd'].' '.$arc['argc'].' '.escapeshellarg($name).' '.implode(' ', $files);
828
- $this->procExec($cmd, $o, $c);
829
- chdir($cwd);
830
-
831
- $path = $dir.DIRECTORY_SEPARATOR.$name;
832
- return file_exists($path) ? $path : false;
833
- }
834
-
835
- } // END class