-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd.php
174 lines (140 loc) · 2.95 KB
/
cmd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* Contao Open Source CMS
*
* Copyright (C) 2005-2012 Leo Feyer
*
* @package cloud-api
* @author David Molineus <http://www.netzmacht.de>
* @license GNU/LGPL
* @copyright Copyright 2012 David Molineus netzmacht creative
*
**/
namespace Netzmacht\Cloud\Api;
use Backend;
/**
* Initialize the system
*/
define('TL_MODE', 'BE');
require_once '/var/www/dev/system/initialize.php';
/**
* AccesToken will redirect to cloud authorize page
*
* @copyright Leo Feyer 2005-2012
* @author Leo Feyer <http://contao.org>
* @package Core
*/
class CloudCMD extends Backend
{
/**
* Initialize the controller
*
* 1. Import the user
* 2. Call the parent constructor
* 3. Authenticate the user
* 4. Load the language files
* DO NOT CHANGE THIS ORDER!
*/
public function __construct()
{
$this->import('BackendUser', 'User');
parent::__construct();
$this->User->authenticate();
$this->loadLanguageFile('default');
$this->loadLanguageFile('modules');
}
/**
* load cloud api and redirect to authorize page
*
* @return void
*/
public function run()
{
//$this->import('Input');
//$objApi = CloudApiManager::getApi($this->Input->get('api'));
//$strUrl = $objApi->getAuthorizeUrl();
//$this->redirect($strUrl);
//CloudApiManager::installApi('dropbox');
$do = \Input::get('do');
if($do == 'install')
{
CloudApiManager::installApi('dropbox');
return;
}
elseif ($do == 'mount') {
echo serialize(array('/studium'));
return;
}
elseif ($do == 'test') {
return $this->test();
}
$objAPI = CloudApiManager::getApi('dropbox');
try
{
$objAPI->authenticate();
}
catch(\Exception $e)
{
//throw $e;
$do = token;
//die($e);
}
switch ($do)
{
case 'sync':
$objAPI->sync();
break;
case 'delta':
$arrDelta = $objAPI->getConnection()->delta('');
var_dump($arrDelta['entries']);
break;
case 'token':
$this->redirect('system/modules/cloud-api/token.php?api=dropbox');
break;
}
}
protected function test()
{
$arr = array('/studium/affenhals', '/tl/blob', '/hans/meyerstiftung');
$arrMounted = array('/studium');
foreach ($arr as $key => $strPath)
{
$blnMounted = false;
if($arrMounted !== null)
{
foreach($arrMounted as $strFolder)
{
if(strncasecmp($strPath, $strFolder, strlen($strFolder)) === 0)
{
$blnMounted = true;
break;
}
}
if(!$blnMounted)
{
continue;
}
}
echo $strPath . '<br>';
}
}
}
/**
* Instantiate the controller
*/
$objCMD = new CloudCMD();
$objCMD->run();
/*
$objAPI = CloudApiManager::getApi('dropbox');
try
{
$objAPI->authenticate();
}
catch(\Exception $e)
{
//throw $e;
$do = token;
//die($e);
}
$objAPI->sync();
*/