1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class DriveController extends Controller { |
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Setup the layout used by the controller. |
7
|
|
|
* |
8
|
|
|
* @return void |
9
|
|
|
*/ |
10
|
|
|
public function drive() |
11
|
|
|
{ |
12
|
|
|
$output= exec("ls -l"); |
13
|
|
|
echo $output; |
14
|
|
|
exit; |
|
|
|
|
15
|
|
|
$url_array = explode('?', 'http://'.$_SERVER ['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
|
|
|
16
|
|
|
$url = $url_array[0]; |
17
|
|
|
echo $url; |
18
|
|
|
|
19
|
|
|
require_once base_path('google-api-php-client/src/Google_Client.php'); |
20
|
|
|
require_once base_path('google-api-php-client/src/contrib/Google_DriveService.php'); |
21
|
|
|
|
22
|
|
|
$client = new Google_Client(); |
|
|
|
|
23
|
|
|
$client->setClientId('767548203421-kvg9d6jnkvgh05mp5dekrsiviu4bfism.apps.googleusercontent.com'); |
24
|
|
|
$client->setClientSecret('Af0cSwzFvviIsXmmZXudxBmi'); |
25
|
|
|
$client->setRedirectUri($url); |
26
|
|
|
$client->setScopes(array('https://www.googleapis.com/auth/drive')); |
27
|
|
|
//echo Session::get('code'); |
28
|
|
|
//exit; |
29
|
|
|
|
30
|
|
|
if (Session::get('code')!='') { |
31
|
|
|
$_SESSION['accessToken'] = $client->authenticate($_GET['code']); |
32
|
|
|
header('location:'.$url); |
33
|
|
|
} elseif (Session::get('accessToken')!='') { |
34
|
|
|
$client->authenticate(); |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
} |
38
|
|
|
//echo Session::get('accessToken'); |
39
|
|
|
// exit; |
40
|
|
|
$files= array(); |
41
|
|
|
$dir = dir('fusionmate/files'); |
|
|
|
|
42
|
|
|
while ($file = $dir->read()) { |
43
|
|
|
if ($file != '.' && $file != '..') { |
44
|
|
|
$files[] = $file; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
$dir->close(); |
48
|
|
|
|
49
|
|
|
$client->setAccessToken('{"access_token":"ya29..uQI2E1zBl8ulgKGvg9-wy0gos_AovRnDtm9vAmE3OGTODtDvwnvE1QEYG0Yn6iKNIw","token_type":"Bearer","expires_in":3600,"refresh_token":"1\/DGZ19GkYcEir0jux7NKj6GT_jHLQL0foSDOTN-poL6EMEudVrK5jSpoR30zcRFq6","created":1459692855}'); |
50
|
|
|
$service = new Google_DriveService($client); |
|
|
|
|
51
|
|
|
$finfo = finfo_open(FILEINFO_MIME_TYPE); |
52
|
|
|
$file = new Google_DriveFile(); |
|
|
|
|
53
|
|
|
foreach ($files as $file_name) { |
54
|
|
|
$file_path = 'fusionmate/files/'.$file_name; |
55
|
|
|
$mime_type = finfo_file($finfo, $file_path); |
56
|
|
|
$file->setTitle($file_name); |
57
|
|
|
$file->setDescription('This is a '.$mime_type.' document'); |
58
|
|
|
$file->setMimeType($mime_type); |
59
|
|
|
$a= $service->files->insert( |
60
|
|
|
$file, |
61
|
|
|
array( |
62
|
|
|
'data' => file_get_contents($file_path), |
63
|
|
|
'mimeType' => $mime_type |
64
|
|
|
) |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
finfo_close($finfo); |
68
|
|
|
print_r($a); |
69
|
|
|
// header('location:'.$url);exit; |
70
|
|
|
|
71
|
|
|
//include 'fusionmate/index.phtml'; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths