| Server IP : 162.214.74.102 / Your IP : 216.73.216.192 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/google/ |
Upload File : |
<?php
include_once __DIR__ . "/Google.php";
class GoogleDrive extends Google {
public function __construct() {
parent::__construct();
$this->scope = "https://www.googleapis.com/auth/drive";
}
public function downloadFile($file_id, $dir, $filename) {
$url = 'https://www.googleapis.com/drive/v2/files/'.$file_id.'?key='.$this->api_key . '&alt=media';
$download_request = curl_init($url);
curl_setopt($download_request, CURLOPT_HTTPHEADER, $this->requestHeaders());
curl_setopt($download_request, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($download_request);
mkdir($dir, 0755, true);
$handle = fopen($dir.$filename, 'w+');
$foo = fwrite($handle, $response); //fwrite to handle bytes stream
fclose($handle);
return $foo;
}
public function fileData($file_id) {
$url = 'https://www.googleapis.com/drive/v2/files/'.$file_id.'?key='.$this->api_key;
$download_request = curl_init($url);
curl_setopt($download_request, CURLOPT_HTTPHEADER, $this->requestHeaders());
curl_setopt($download_request, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($download_request);
return json_decode($response);
}
public function listFiles() {
$url = 'https://www.googleapis.com/drive/v3/files';
$url = $url . '?pageSize=1000';
$request = curl_init($url);
curl_setopt($request, CURLOPT_HTTPHEADER, $this->requestHeaders());
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($request);
return json_decode($response);
}
public function filesByFolder($folder_id) {
$url = 'https://www.googleapis.com/drive/v2/files'
.'/'. $folder_id.'/children'
.'?pageSize=1000'
.'&q='.urlencode("mimeType = 'application/pdf'");
$request = curl_init($url);
curl_setopt($request, CURLOPT_HTTPHEADER, $this->requestHeaders());
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($request);
return json_decode($response);
}
}