1
0

app.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. /**
  3. * @author Christian Berendt <berendt@b1-systems.de>
  4. * @author fibsifan <fi@volans.uberspace.de>
  5. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  6. * @author j-ed <juergen@eisfair.org>
  7. * @author Martin Mattel <martin.mattel@diemattels.at>
  8. * @author Michael Gapczynski <GapczynskiM@gmail.com>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Philipp Kapfer <philipp.kapfer@gmx.at>
  11. * @author Robin Appelman <icewind@owncloud.com>
  12. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  13. * @author Ross Nicoll <jrn@jrn.me.uk>
  14. * @author Thomas Müller <thomas.mueller@tmit.eu>
  15. * @author Vincent Petry <pvince81@owncloud.com>
  16. * @author Volkan Gezer <volkangezer@gmail.com>
  17. *
  18. * @copyright Copyright (c) 2015, ownCloud, Inc.
  19. * @license AGPL-3.0
  20. *
  21. * This code is free software: you can redistribute it and/or modify
  22. * it under the terms of the GNU Affero General Public License, version 3,
  23. * as published by the Free Software Foundation.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU Affero General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU Affero General Public License, version 3,
  31. * along with this program. If not, see <http://www.gnu.org/licenses/>
  32. *
  33. */
  34. $app = new \OCA\Files_external\Appinfo\Application();
  35. $l = \OC::$server->getL10N('files_external');
  36. OC::$CLASSPATH['OC\Files\Storage\StreamWrapper'] = 'files_external/lib/streamwrapper.php';
  37. OC::$CLASSPATH['OC\Files\Storage\FTP'] = 'files_external/lib/ftp.php';
  38. OC::$CLASSPATH['OC\Files\Storage\OwnCloud'] = 'files_external/lib/owncloud.php';
  39. OC::$CLASSPATH['OC\Files\Storage\Google'] = 'files_external/lib/google.php';
  40. OC::$CLASSPATH['OC\Files\Storage\Swift'] = 'files_external/lib/swift.php';
  41. OC::$CLASSPATH['OC\Files\Storage\SMB'] = 'files_external/lib/smb.php';
  42. OC::$CLASSPATH['OC\Files\Storage\SMB_OC'] = 'files_external/lib/smb_oc.php';
  43. OC::$CLASSPATH['OC\Files\Storage\AmazonS3'] = 'files_external/lib/amazons3.php';
  44. OC::$CLASSPATH['OC\Files\Storage\Dropbox'] = 'files_external/lib/dropbox.php';
  45. OC::$CLASSPATH['OC\Files\Storage\SFTP'] = 'files_external/lib/sftp.php';
  46. OC::$CLASSPATH['OC\Files\Storage\SFTP_Key'] = 'files_external/lib/sftp_key.php';
  47. OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php';
  48. OC::$CLASSPATH['OCA\Files\External\Api'] = 'files_external/lib/api.php';
  49. require_once __DIR__ . '/../3rdparty/autoload.php';
  50. OCP\App::registerAdmin('files_external', 'settings');
  51. if (OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes') == 'yes') {
  52. OCP\App::registerPersonal('files_external', 'personal');
  53. }
  54. \OCA\Files\App::getNavigationManager()->add([
  55. "id" => 'extstoragemounts',
  56. "appname" => 'files_external',
  57. "script" => 'list.php',
  58. "order" => 30,
  59. "name" => $l->t('External storage')
  60. ]);
  61. // connecting hooks
  62. OCP\Util::connectHook('OC_Filesystem', 'post_initMountPoints', '\OC_Mount_Config', 'initMountPointsHook');
  63. OCP\Util::connectHook('OC_User', 'post_login', 'OC\Files\Storage\SMB_OC', 'login');
  64. OC_Mount_Config::registerBackend('\OC\Files\Storage\Local', [
  65. 'backend' => (string)$l->t('Local'),
  66. 'priority' => 150,
  67. 'configuration' => [
  68. 'datadir' => (string)$l->t('Location')
  69. ],
  70. ]);
  71. OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', [
  72. 'backend' => (string)$l->t('Amazon S3'),
  73. 'priority' => 100,
  74. 'configuration' => [
  75. 'key' => (string)$l->t('Key'),
  76. 'secret' => '*'.$l->t('Secret'),
  77. 'bucket' => (string)$l->t('Bucket'),
  78. ],
  79. 'has_dependencies' => true,
  80. ]);
  81. OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', [
  82. 'backend' => (string)$l->t('Amazon S3 and compliant'),
  83. 'priority' => 100,
  84. 'configuration' => [
  85. 'key' => (string)$l->t('Access Key'),
  86. 'secret' => '*'.$l->t('Secret Key'),
  87. 'bucket' => (string)$l->t('Bucket'),
  88. 'hostname' => '&'.$l->t('Hostname'),
  89. 'port' => '&'.$l->t('Port'),
  90. 'region' => '&'.$l->t('Region'),
  91. 'use_ssl' => '!'.$l->t('Enable SSL'),
  92. 'use_path_style' => '!'.$l->t('Enable Path Style')
  93. ],
  94. 'has_dependencies' => true,
  95. ]);
  96. OC_Mount_Config::registerBackend('\OC\Files\Storage\Dropbox', [
  97. 'backend' => 'Dropbox',
  98. 'priority' => 100,
  99. 'configuration' => [
  100. 'configured' => '#configured',
  101. 'app_key' => (string)$l->t('App key'),
  102. 'app_secret' => '*'.$l->t('App secret'),
  103. 'token' => '#token',
  104. 'token_secret' => '#token_secret'
  105. ],
  106. 'custom' => 'dropbox',
  107. 'has_dependencies' => true,
  108. ]);
  109. OC_Mount_Config::registerBackend('\OC\Files\Storage\FTP', [
  110. 'backend' => 'FTP',
  111. 'priority' => 100,
  112. 'configuration' => [
  113. 'host' => (string)$l->t('Host'),
  114. 'user' => (string)$l->t('Username'),
  115. 'password' => '*'.$l->t('Password'),
  116. 'root' => '&'.$l->t('Remote subfolder'),
  117. 'secure' => '!'.$l->t('Secure ftps://')
  118. ],
  119. 'has_dependencies' => true,
  120. ]);
  121. OC_Mount_Config::registerBackend('\OC\Files\Storage\Google', [
  122. 'backend' => 'Google Drive',
  123. 'priority' => 100,
  124. 'configuration' => [
  125. 'configured' => '#configured',
  126. 'client_id' => (string)$l->t('Client ID'),
  127. 'client_secret' => '*'.$l->t('Client secret'),
  128. 'token' => '#token',
  129. ],
  130. 'custom' => 'google',
  131. 'has_dependencies' => true,
  132. ]);
  133. OC_Mount_Config::registerBackend('\OC\Files\Storage\Swift', [
  134. 'backend' => (string)$l->t('OpenStack Object Storage'),
  135. 'priority' => 100,
  136. 'configuration' => [
  137. 'user' => (string)$l->t('Username'),
  138. 'bucket' => (string)$l->t('Bucket'),
  139. 'region' => '&'.$l->t('Region (optional for OpenStack Object Storage)'),
  140. 'key' => '&*'.$l->t('API Key (required for Rackspace Cloud Files)'),
  141. 'tenant' => '&'.$l->t('Tenantname (required for OpenStack Object Storage)'),
  142. 'password' => '&*'.$l->t('Password (required for OpenStack Object Storage)'),
  143. 'service_name' => '&'.$l->t('Service Name (required for OpenStack Object Storage)'),
  144. 'url' => '&'.$l->t('URL of identity endpoint (required for OpenStack Object Storage)'),
  145. 'timeout' => '&'.$l->t('Timeout of HTTP requests in seconds'),
  146. ],
  147. 'has_dependencies' => true,
  148. ]);
  149. if (!OC_Util::runningOnWindows()) {
  150. OC_Mount_Config::registerBackend('\OC\Files\Storage\SMB', [
  151. 'backend' => 'SMB / CIFS',
  152. 'priority' => 100,
  153. 'configuration' => [
  154. 'host' => (string)$l->t('Host'),
  155. 'user' => (string)$l->t('Username'),
  156. 'password' => '*'.$l->t('Password'),
  157. 'share' => (string)$l->t('Share'),
  158. 'root' => '&'.$l->t('Remote subfolder'),
  159. ],
  160. 'has_dependencies' => true,
  161. ]);
  162. OC_Mount_Config::registerBackend('\OC\Files\Storage\SMB_OC', [
  163. 'backend' => (string)$l->t('SMB / CIFS using OC login'),
  164. 'priority' => 90,
  165. 'configuration' => [
  166. 'host' => (string)$l->t('Host'),
  167. 'username_as_share' => '!'.$l->t('Username as share'),
  168. 'share' => '&'.$l->t('Share'),
  169. 'root' => '&'.$l->t('Remote subfolder'),
  170. ],
  171. 'has_dependencies' => true,
  172. ]);
  173. }
  174. OC_Mount_Config::registerBackend('\OC\Files\Storage\DAV', [
  175. 'backend' => 'WebDAV',
  176. 'priority' => 100,
  177. 'configuration' => [
  178. 'host' => (string)$l->t('URL'),
  179. 'user' => (string)$l->t('Username'),
  180. 'password' => '*'.$l->t('Password'),
  181. 'root' => '&'.$l->t('Remote subfolder'),
  182. 'secure' => '!'.$l->t('Secure https://'),
  183. ],
  184. 'has_dependencies' => true,
  185. ]);
  186. OC_Mount_Config::registerBackend('\OC\Files\Storage\OwnCloud', [
  187. 'backend' => 'ownCloud',
  188. 'priority' => 100,
  189. 'configuration' => [
  190. 'host' => (string)$l->t('URL'),
  191. 'user' => (string)$l->t('Username'),
  192. 'password' => '*'.$l->t('Password'),
  193. 'root' => '&'.$l->t('Remote subfolder'),
  194. 'secure' => '!'.$l->t('Secure https://'),
  195. ],
  196. ]);
  197. OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP', [
  198. 'backend' => 'SFTP',
  199. 'priority' => 100,
  200. 'configuration' => [
  201. 'host' => (string)$l->t('Host'),
  202. 'user' => (string)$l->t('Username'),
  203. 'password' => '*'.$l->t('Password'),
  204. 'root' => '&'.$l->t('Remote subfolder'),
  205. ],
  206. ]);
  207. OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP_Key', [
  208. 'backend' => 'SFTP with secret key login',
  209. 'priority' => 100,
  210. 'configuration' => array(
  211. 'host' => (string)$l->t('Host'),
  212. 'user' => (string)$l->t('Username'),
  213. 'public_key' => (string)$l->t('Public key'),
  214. 'private_key' => '#private_key',
  215. 'root' => '&'.$l->t('Remote subfolder')),
  216. 'custom' => 'sftp_key',
  217. ]
  218. );
  219. $mountProvider = new \OCA\Files_External\Config\ConfigAdapter();
  220. \OC::$server->getMountProviderCollection()->registerProvider($mountProvider);