function getAnalytics() { $client = getClient(); $token = Authenticate($client); $analytics = new Google_Service_Analytics($client); return $analytics; }
/** * @throws ClientException */ public function setUp() { $connector = new Connector($this->client); $this->client = getClient($connector); $collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection'; $collectionOptions = ['waitForSync' => true]; $collectionParameters = []; $options = $collectionOptions; $this->client->bind('Request', function () { $request = $this->client->getRequest(); return $request; }); $request = $this->client->make('Request'); $request->options = $options; $request->body = ['name' => $collectionName]; $request->body = self::array_merge_recursive_distinct($request->body, $collectionParameters); $request->body = json_encode($request->body); $request->path = $this->client->fullDatabasePath . self::API_COLLECTION; $request->method = self::METHOD_POST; $responseObject = $request->send(); $body = $responseObject->body; $this->assertArrayHasKey('code', json_decode($body, true)); $decodedJsonBody = json_decode($body, true); $this->assertEquals(200, $decodedJsonBody['code']); $this->assertEquals($collectionName, $decodedJsonBody['name']); }
function getAccessToken(&$fb, $bucket, $tokenFile) { // Read file from Google Storage $client = getClient(); $storage = getStorageService($client); $tokensStr = getTokens($client, $storage, $bucket, $tokenFile); if (empty($tokensStr)) { quit("No more FB access tokens in storage -- login to app ASAP to generate a token"); } else { $tokens = json_decode($tokensStr, true); // 'true' will turn this into associative array instead of object // Validate the token before use. User may have logged off facebook, or deauthorized this app. // shuffle the array to get random order of iteration shuffle($tokens); //var_dump($tokens); foreach ($tokens as $token) { $response = $fb->get('/me', $token); if (!$response->isError()) { // access_token is valid token return $token; } } quit("None of the tokens are valid"); } }
/** * */ public function setUp() { $connector = new Connector(); $this->client = $this->client = getClient($connector); $this->collectionNames[0] = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection-01'; $this->collectionNames[1] = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection-02'; $this->collectionNames[2] = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection-03'; }
/** * */ public function setUp() { $connector = new Connector(); $this->connector = $connector; $this->client = $this->client = getClient($connector); $this->client->bind('Request', function () { $request = $this->client->getRequest(); return $request; }); }
public static function IsSubscribed($clientId = NULL) { if (is_null($clientId)) { if (!isset($_GET["clientid"])) { return NULL; } else { $CurrentClientId = $_GET["clientid"]; return self::IsSubscribed($CurrentClientId); } } return getClient($clientId)->IsSubscribed; }
function __construct($appid, $appsecret, $mime_type, $folder_id) { $curl_options = array(CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE, CURLOPT_FORBID_REUSE => TRUE, CURLOPT_SSLVERSION => 1, CURLOPT_FORBID_REUSE => TRUE, CURLOPT_RETURNTRANSFER => TRUE); $this->parallel_curl = new ParallelCurl(100, $curl_options); $this->appid = $appid; $this->appsecret = $appsecret; $this->mime_type = $mime_type; $this->folder_id = $folder_id; $this->cache = new Cache(); $this->cache->setCache('cache'); $this->get_token_from_wechat(); if (file_exists(__DIR__ . "/csv/") == false) { mkdir(__DIR__ . "/csv/"); } $this->client = getClient(); $this->service = new Google_Service_Drive($this->client); }
/** * Fetch and process a paged response from JoindIn. * * @param $initial * The initial URL to fetch. That URL may result in others getting * fetched as well. * @param callable $processor * A callable that will be used to process each page of results. Its signature * must be: (\SplQueue $pages, ResponseInterface $response, $index) * @param int $concurrency * The number of concurrent requests to send. In practice this kinda has to * be 1, or else Guzzle will conclude itself before getting to later-added * entries. */ function fetchPages($initial, callable $processor, $concurrency = 1) { $client = getClient(); $pages = new \SplQueue(); $pages->enqueue($initial); $pageProcessor = partial($processor, $pages); $pageRequestGenerator = function (\SplQueue $pages) { foreach ($pages as $page) { (yield new Request('GET', $page)); } }; $pool = new Pool($client, $pageRequestGenerator($pages), ['concurrency' => $concurrency, 'fulfilled' => $pageProcessor]); // Initiate the transfers and create a promise $promise = $pool->promise(); // Force the pool of requests to complete. $promise->wait(); }
function getClientForToken ($access_token, $fake_it = false) { $client = getClient(); $accessToken = false; // Since w're passed the access_token part only, // we will fake the token. // We don't know when it was created or when it expires, // so we fake it. $tmpl = '{ "access_token":"%s", "token_type":"Bearer", "expires_in":"3600", "id_token":"", "created":%s}'; $token_file = PATH.'/tokens/'.$access_token; if (!file_exists($token_file)) { if ($fake_it) { $accessToken = sprintf($tmpl, $access_token, time()); } } else { $accessToken = file_get_contents(PATH.'/tokens/'.$access_token); } if (empty($accessToken)) { $client = null; } else { $client->setAccessToken($accessToken); // Refresh the token if it's expired. if ($client->isAccessTokenExpired()) { $refreshToken = $client->getRefreshToken(); if (!empty($refreshToken)) { $client->refreshToken($refreshToken); //We'd want to return this. $accessToken = $client->getAccessToken(); file_put_contents(PATH.'/tokens/'.$access_token); } } } return $client; }
/** * */ public function setUp() { $connector = new Connector(); $this->client = getClient($connector); }
} if (!isset($arguments['partner_id']) || !$arguments['partner_id'] || is_null($arguments['partner_id'])) { print_usage('missing argument --partner_id'); } if (!isset($arguments['admin_secret']) || !$arguments['admin_secret'] || is_null($arguments['admin_secret'])) { print_usage('missing argument --admin_secret'); } if (!isset($arguments['host']) || !$arguments['host'] || is_null($arguments['host'])) { print_usage('missing argument --host'); } if (!file_exists($arguments['ini'])) { print_usage('config file not found ' . $arguments['ini']); } error_reporting(0); $confObj = init($arguments['ini'], $arguments['infra']); $kclient = getClient($arguments['partner_id'], $arguments['admin_secret'], $arguments['host']); $baseTag = $confObj->general->component->name; $defaultTags = "autodeploy, {$baseTag}_{$confObj->general->component->version}"; $sections = explode(',', $confObj->general->component->required_widgets); if ($includeCode) { $code[] = '$c = new Criteria();'; $code[] = '$c->addAnd(UiConfPeer::PARTNER_ID, ' . $confObj->statics->partner_id . ');'; $code[] = '$c->addAnd(UiConfPeer::TAGS, "%' . $baseTag . '_".$this->kmc_' . $baseTag . '_version."%", Criteria::LIKE);'; $code[] = '$c->addAnd(UiConfPeer::TAGS, "%autodeploy%", Criteria::LIKE);'; $code[] = '$this->confs = UiConfPeer::doSelect($c);'; } $tags_search = array(); foreach ($sections as $section) { $sectionName = trim($section); $sectionBase = $sectionName . 's'; $baseSwfUrl = $confObj->{$sectionName}->{$sectionBase}->swfpath;
/** * When a test case contains adds/modifies/deletes being sent to the server, * these changes must be extracted from the test data and manually performed * using the api to achieve the desired behaviour by the server * * @throws Horde_Exception */ function testPre($name, $number) { global $debuglevel; $ref0 = getClient($name, $number); // Extract database (in horde: service). if (preg_match('|<Alert>.*?<Target>\\s*<LocURI>([^>]*)</LocURI>.*?</Alert>|si', $ref0, $m)) { $GLOBALS['service'] = $m[1]; } if (!preg_match('|<SyncHdr>.*?<Source>\\s*<LocURI>(.*?)</LocURI>.*?</SyncHdr>|si', $ref0, $m)) { echo $ref0; throw new Horde_Exception('Unable to find device id'); } $device_id = $m[1]; // Start backend session if not already done. if ($GLOBALS['testbackend']->getSyncDeviceID() != $device_id) { $GLOBALS['testbackend']->sessionStart($device_id, null, Horde_SyncMl_Backend::MODE_TEST); } // This makes a login even when a logout has occured when the session got // deleted. $GLOBALS['testbackend']->setUser(SYNCMLTEST_USERNAME); $ref1 = getServer($name, $number + 1); if (!$ref1) { return; } $ref1 = str_replace(array('<![CDATA[', ']]>', '<?xml version="1.0"?><!DOCTYPE SyncML PUBLIC "-//SYNCML//DTD SyncML 1.1//EN" "http://www.syncml.org/docs/syncml_represent_v11_20020213.dtd">'), '', $ref1); // Check for Adds. if (preg_match_all('|<Add>.*?<type[^>]*>(.*?)</type>.*?<LocURI[^>]*>(.*?)</LocURI>.*?<data[^>]*>(.*?)</data>.*?</Add|si', $ref1, $m, PREG_SET_ORDER)) { foreach ($m as $c) { list(, $contentType, $locuri, $data) = $c; // Some Sync4j tweaking. switch (Horde_String::lower($contentType)) { case 'text/x-s4j-sifn': $data = Horde_SyncMl_Device_sync4j::sif2vnote(base64_decode($data)); $contentType = 'text/x-vnote'; $service = 'notes'; break; case 'text/x-s4j-sifc': $data = Horde_SyncMl_Device_sync4j::sif2vcard(base64_decode($data)); $contentType = 'text/x-vcard'; $service = 'contacts'; break; case 'text/x-s4j-sife': $data = Horde_SyncMl_Device_sync4j::sif2vevent(base64_decode($data)); $contentType = 'text/calendar'; $service = 'calendar'; break; case 'text/x-s4j-sift': $data = Horde_SyncMl_Device_sync4j::sif2vtodo(base64_decode($data)); $contentType = 'text/calendar'; $service = 'tasks'; break; case 'text/x-vcalendar': case 'text/calendar': if (preg_match('/(\\r\\n|\\r|\\n)BEGIN:\\s*VTODO/', $data)) { $service = 'tasks'; } else { $service = 'calendar'; } break; default: throw new Horde_Exception("Unable to find service for contentType={$contentType}"); } $result = $GLOBALS['testbackend']->addEntry($service, $data, $contentType); if (is_a($result, 'PEAR_Error')) { echo "error importing data into {$service}:\n{$data}\n"; throw new Horde_Exception_Wrapped($result); } if ($debuglevel >= 2) { echo "simulated {$service} add of {$result} as {$locuri}!\n"; echo ' at ' . date('Y-m-d H:i:s') . "\n"; if ($debuglevel >= 10) { echo "data: {$data}\nsuid={$result}\n"; } } // Store UID used by server. $GLOBALS['mapping_locuri2uid'][$locuri] = $result; } } // Check for Replaces. if (preg_match_all('|<Replace>.*?<type[^>]*>(.*?)</type>.*?<LocURI[^>]*>(.*?)</LocURI>.*?<data[^>]*>(.*?)</data>.*?</Replace|si', $ref1, $m, PREG_SET_ORDER)) { foreach ($m as $c) { list(, $contentType, $locuri, $data) = $c; // Some Sync4j tweaking. switch (Horde_String::lower($contentType)) { case 'sif/note': case 'text/x-s4j-sifn': $data = Horde_SyncMl_Device_sync4j::sif2vnote(base64_decode($data)); $contentType = 'text/x-vnote'; $service = 'notes'; break; case 'sif/contact': case 'text/x-s4j-sifc': $data = Horde_SyncMl_Device_sync4j::sif2vcard(base64_decode($data)); $contentType = 'text/x-vcard'; $service = 'contacts'; break; case 'sif/calendar': case 'text/x-s4j-sife': $data = Horde_SyncMl_Device_sync4j::sif2vevent(base64_decode($data)); $contentType = 'text/calendar'; $service = 'calendar'; break; case 'sif/task': case 'text/x-s4j-sift': $data = Horde_SyncMl_Device_sync4j::sif2vtodo(base64_decode($data)); $contentType = 'text/calendar'; $service = 'tasks'; break; case 'text/x-vcalendar': case 'text/calendar': if (preg_match('/(\\r\\n|\\r|\\n)BEGIN:\\s*VTODO/', $data)) { $service = 'tasks'; } else { $service = 'calendar'; } break; default: throw new Horde_Exception("Unable to find service for contentType={$contentType}"); } /* Get SUID. */ $suid = $GLOBALS['testbackend']->getSuid($service, $locuri); if (empty($suid)) { throw new Horde_Exception("Unable to find SUID for CUID {$locuri} for simulating replace"); } $result = $GLOBALS['testbackend']->replaceEntry($service, $data, $contentType, $suid); if (is_a($result, 'PEAR_Error')) { echo "Error replacing data {$locuri} suid={$suid}!\n"; throw new Horde_Exception_Wrapped($result); } if ($debuglevel >= 2) { echo "simulated {$service} replace of {$locuri} suid={$suid}!\n"; if ($debuglevel >= 10) { echo "data: {$data}\nnew id={$result}\n"; } } } } // Check for Deletes. // <Delete><CmdID>5</CmdID><Item><Target><LocURI>1798147</LocURI></Target></Item></Delete> if (preg_match_all('|<Delete>.*?<Target>\\s*<LocURI>(.*?)</LocURI>|si', $ref1, $m, PREG_SET_ORDER)) { foreach ($m as $d) { list(, $locuri) = $d; /* Get SUID. */ $service = $GLOBALS['service']; $suid = $GLOBALS['testbackend']->getSuid($service, $locuri); if (empty($suid)) { // Maybe we have a handletaskincalendar. if ($service == 'calendar') { if ($debuglevel >= 2) { echo "special tasks delete...\n"; } $service = 'tasks'; $suid = $GLOBALS['testbackend']->getSuid($service, $locuri); } } if (empty($suid)) { throw new Horde_Exception("Unable to find SUID for CUID {$locuri} for simulating {$service} delete"); } $result = $GLOBALS['testbackend']->deleteEntry($service, $suid); // @TODO: simulate a delete by just faking some history data. if (is_a($result, 'PEAR_Error')) { echo "Error deleting data {$locuri}!"; throw new Horde_Exception_Wrapped($result); } if ($debuglevel >= 2) { echo "simulated {$service} delete of {$suid}!\n"; } } } }
/** * */ public function setUp() { $this->connector = $this->getMockBuilder('TestConnector')->getMock(); $this->client = getClient($this->connector); }
include_once "mod.order.php"; include_once "mod.optional.php"; include_once "ctrl.order.php"; include_once "ctrl.client.php"; include_once "ctrl.login.php"; // check user authentication checkSession($_SESSION['sess_user_id']); if (isset($_GET['ordid'])) { $oid = $_GET['ordid']; $orddetail = getOrderById($oid, $db); $rf = getRf($db); $odrf = getRfById($oid, $db); $os = getOS($db); $app = getApp($db); $odapp = getAppById($oid, $db); $cli = getClient($db); $sta = getStatus($db); } else { header("location: " . ROOT . "order_list.php"); exit; } ?> <html lang="en-US"> <head> <meta charset="utf-8"> <link href="<?php echo CSS; ?> import.css" type="text/css" rel="stylesheet"/> <script src="<?php echo JS;
<?php include_once "session.php"; $search = $_POST['searchFor']; $where = $_POST['where']; if ($where == "Clients") { if (strlen($search) == 0) { getClient(0, "all"); } else { searchClient($search); } } elseif ($where == "Drivers") { if (strlen($search) == 0) { getDrivers(0, "all"); } else { searchDriver($search); } } elseif ($where == "Deliveries") { if (strlen($search) == 0) { //Get all data here } else { //Get specific data here. } } elseif ($where == "Reports") { if (strlen($search) == 0) { getEmergencyTable(0, "all"); } else { searchEmergencies($search); } } elseif ($where == "Accounts") { if (strlen($search) == 0) {
$code = array(); $kcw_for_editors = array(); $kdp_for_studio = array(); $exlude_tags_from_code = array('uploadforkae', 'uploadforkse'); error_reporting(0); if (strpos($argv[1], '--ini=') && file_exists(str_replace('--ini=', '', $argv[1]))) { $config_path = str_replace('--ini=', '', $argv[1]); } elseif (strpos($argv[2], '--ini=') && file_exists(str_replace('--ini=', '', $argv[2]))) { $config_path = str_replace('--ini=', '', $argv[2]); } elseif (strpos($argv[3], '--ini=') && file_exists(str_replace('--ini=', '', $argv[3]))) { $config_path = str_replace('--ini=', '', $argv[3]); } else { $config_path = 'config.ini'; } $confObj = init($config_path); $kclient = getClient($confObj); if ($argv[1] == '--include-code') { $includeCode = true; } else { $includeCode = false; } if ($argv[1] == '--no-create' || $argv[2] == '--no-create') { $skipAddUiconf = true; } else { $skipAddUiconf = false; } $baseTag = $confObj->general->component->name; $defaultTags = "autodeploy, {$baseTag}_{$confObj->general->component->version}"; $sections = explode(',', $confObj->general->component->required_widgets); if ($includeCode) { $code[] = '$c = new Criteria();';
function search($model, $searcharr) { global $oerpuser, $oerppwd, $dbname, $server_url, $client; /*$key = array(new xmlrpcval(array(new xmlrpcval($attribute , "string"),new xmlrpcval($operator,"string"),new xmlrpcval($keys,"string")),"array"),); */ if ($userId <= 0) { $uid = connect(); } if (!isset($client)) { $client = getClient(); } try { $msg = new xmlrpcmsg('execute'); $msg->addParam(new xmlrpcval($dbname, "string")); $msg->addParam(new xmlrpcval($uid, "int")); $msg->addParam(new xmlrpcval($oerppwd, "string")); $msg->addParam(new xmlrpcval($model, "string")); $msg->addParam(new xmlrpcval("search", "string")); $msg->addParam(new xmlrpcval($searcharr, "array")); $resp = $client->send($msg); $val = $resp->value(); $ids = $val->scalarval(); //print "Response: ".php_xmlrpc_decode($resp); } catch (Exception $merr) { print "Error setting up search message " . $merr->getMessage() . "\n"; } return $ids; }
public function mostrarDetalle($cuadrante_id) { function getClient() { $client = new Google_Client(); $client->setApplicationName(APPLICATION_NAME); $client->setScopes(SCOPES); $client->setAuthConfigFile(CLIENT_SECRET_PATH); $client->setAccessType('offline'); $client->setApprovalPrompt('force'); //esta linea la he añadido yo // Load previously authorized credentials from a file. $credentialsPath = CREDENTIALS_PATH; // dd($credentialsPath); if (file_exists($credentialsPath)) { $accessToken = file_get_contents($credentialsPath); } else { // Request authorization from the user. dd('no hay autorización, habrá que modificar el código'); $authUrl = $client->createAuthUrl(); printf("Open the following link in your browser:\n%s\n", $authUrl); print 'Enter verification code: '; $authCode = trim(fgets(STDIN)); // Exchange authorization code for an access token. $accessToken = $client->authenticate($authCode); // Store the credentials to disk. if (!file_exists(dirname($credentialsPath))) { mkdir(dirname($credentialsPath), 0700, true); } file_put_contents($credentialsPath, $accessToken); // printf("Credentials saved to %s\n", $credentialsPath); } $client->setAccessToken($accessToken); // Refresh the token if it's expired. if ($client->isAccessTokenExpired()) { $client->refreshToken($client->getRefreshToken()); file_put_contents($credentialsPath, $client->getAccessToken()); } return $client; } function listMessages($service, $userId, $fecha, $email) { $pageToken = NULL; $messages = array(); $opt_param = array(); //mensaje de ese empleado para ese día $opt_param['q'] = 'subject:' . $fecha . ' from:' . $email . ' label:Inbox'; do { try { if ($pageToken) { $opt_param['pageToken'] = $pageToken; } $messagesResponse = $service->users_messages->listUsersMessages($userId, $opt_param); if ($messagesResponse->getMessages()) { $messages = array_merge($messages, $messagesResponse->getMessages()); $pageToken = $messagesResponse->getNextPageToken(); } } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } } while ($pageToken); return $messages; } function modifyMessage($service, $userId, $messageId, $labelsToAdd, $labelsToRemove) { $mods = new Google_Service_Gmail_ModifyMessageRequest(); $mods->setAddLabelIds($labelsToAdd); $mods->setRemoveLabelIds($labelsToRemove); try { $message = $service->users_messages->modify($userId, $messageId, $mods); // print 'Message with ID: ' . $messageId . ' successfully modified.'; return $message; } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } } function getHeader($headers, $name) { foreach ($headers as $header) { if ($header['name'] == $name) { return $header['value']; } } } function getHeaders($headers, $campos) { foreach ($headers as $header) { for ($i = 0; $i < count($campos); $i++) { if ($header['name'] == $campos[$i]) { $results[$campos[$i]] = $header['value']; } } } return $results; } // function getBody($partes){ // foreach($partes as $parte){ // if($parte['name'] == 'body') // } // } /* * Decode the body. * @param : encoded body - or null * @return : the body if found, else FALSE; */ function decodeBody($body) { $rawData = $body; $sanitizedData = strtr($rawData, '-_', '+/'); $decodedMessage = base64_decode($sanitizedData); if (!$decodedMessage) { $decodedMessage = FALSE; } return $decodedMessage; } $cuadrante = Cuadrante::where('id', $cuadrante_id)->first(); $lineas = LineaCuadrante::where('cuadrante_id', $cuadrante_id)->orderBy('tipo', 'asc')->orderBy('salida', 'asc')->get(); $fecha = $cuadrante->fecha; $fecha = date_format($fecha, 'd-m-Y'); $valores = $this->empleadosTrabajando($cuadrante_id); Javascript::put(['valores' => $valores]); if ($cuadrante->estado == 'Validado') { define('APPLICATION_NAME', 'Gmail API PHP Quickstart'); define('CREDENTIALS_PATH', base_path() . '/storage/app/.credentials/gmail-php-quickstart.json'); define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json'); // If modifying these scopes, delete your previously saved credentials define('SCOPES', implode(' ', array(Google_Service_Gmail::GMAIL_MODIFY))); /** * Returns an authorized API client. * @return Google_Client the authorized client object */ // Get the API client and construct the service object. $client = getClient(); $service = new Google_Service_Gmail($client); $userId = 'me'; // lista de labels con ids // $results = $service->users_labels->listUsersLabels($userId); // dd($results); $messages = listMessages($service, $userId, $fecha, null); if ($messages) { foreach ($lineas as $linea) { $email = $linea->empleado->email; $mensaje = listMessages($service, $userId, $fecha, $email); // $labelsToAdd = ['Label_1']; $labelsToRemove = ['INBOX']; if (count($mensaje) == 1) { // dd('hay uno'); $linea->mensaje_id = $mensaje[0]->id; $detalle_mensaje = $service->users_messages->get($userId, $mensaje[0]->id); $headers = $detalle_mensaje->getPayload()->getHeaders(); $partsBody = $detalle_mensaje->getPayload()->getParts(); $body = decodeBody($partsBody[0]['body']['data']); $campos = array('Subject', 'Date'); $results = getHeaders($headers, $campos); $linea->asunto = $results['Subject']; $fechaLocal = date("Y-m-d H:i:s", strtotime($results['Date'])); $linea->fechaMensaje = $fechaLocal; $linea->body = $body; // $subject = getHeader($headers, 'Subject'); // $linea->asunto = $subject; $linea->estado = 'Firmado'; $linea->save(); // modifyMessage($service,$userId,$linea->mensaje_id,$labelsToAdd,$labelsToRemove); modifyMessage($service, $userId, $linea->mensaje_id, ['Label_1'], $labelsToRemove); } else { if (count($mensaje) > 1) { //archivo en duplicados(Label_2) los antiguos // dd(count($mensaje)); for ($i = 1; $i < count($mensaje); $i++) { $detalle_mensaje = $service->users_messages->get($userId, $mensaje[$i]->id); $headers = $detalle_mensaje->getPayload()->getHeaders(); $subject = getHeader($headers, 'Subject'); modifyMessage($service, $userId, $mensaje[$i]->id, ['Label_2'], $labelsToRemove); } } else { if (!count($mensaje)) { // no hay ninguno y continua el foreach } } } } } } return view('controlHorario.detalleCuadrante', compact('cuadrante', 'lineas')); }
</header> <div class="header-mobile"> <span class="btn-mobile glyphicon glyphicon glyphicon-menu-hamburger pull-left"></span> <h1 class="pull-left"> OBRAS </h1> </div> <div class="container"> <div class="work-archive"> <?php foreach ($works as $i => $work) { $gallery = getWorkGallery($work["id_work"]); $client = getClient($work["id_client"]); if ($gallery) { $filename = generateRandomString(); file_put_contents("_temp/" . $filename . getExtension($gallery[0]->getTypeImage()), $gallery[0]->getWorkImage()); ?> <div class="work-thumb"> <a class="gal<?php echo $work["id_work"]; ?> " href="_temp/<?php echo $filename . getExtension($gallery[0]->getTypeImage()); ?> " data-name="<?php echo $work["work_name"]; ?> " data-location="<?php
function getDriveService() { return $driveService = new Google_Service_Drive(getClient()); }
function requestAuthorization() { $client = getClient(); return $client->createAuthUrl(); }
file_put_contents($credentialsPath, $client->getAccessToken()); } return $client; } /** * Expands the home directory alias '~' to the full path. * @param string $path the path to expand. * @return string the expanded path. */ function expandHomeDirectory($path) { $homeDirectory = getenv('HOME'); if (empty($homeDirectory)) { $homeDirectory = getenv("HOMEDRIVE") . getenv("HOMEPATH"); } return str_replace('~', realpath($homeDirectory), $path); } // Get the API client and construct the service object. $client = getClient(); $service = new Google_Service_Gmail($client); // Print the labels in the user's account. $user = '******'; $results = $service->users_labels->listUsersLabels($user); if (count($results->getLabels()) == 0) { print "No labels found.\n"; } else { print "Labels:\n"; foreach ($results->getLabels() as $label) { printf("- %s\n", $label->getName()); } }
$metadata = $dbxClient->getFile($path, $fd); header("Content-Type: {$metadata['mime_type']}"); fseek($fd, 0); fpassthru($fd); fclose($fd); } else { if ($requestPath === "/upload") { if (empty($_FILES['file']['name'])) { echo renderHtmlPage("Error", "Please choose a file to upload"); exit; } if (!empty($_FILES['file']['error'])) { echo renderHtmlPage("Error", "Error " . $_FILES['file']['error'] . " uploading file. See <a href='http://php.net/manual/en/features.file-upload.errors.php'>the docs</a> for details"); exit; } $dbxClient = getClient(); $remoteDir = "/"; if (isset($_POST['folder'])) { $remoteDir = $_POST['folder']; } $remotePath = rtrim($remoteDir, "/") . "/" . $_FILES['file']['name']; $fp = fopen($_FILES['file']['tmp_name'], "rb"); $result = $dbxClient->uploadFile($remotePath, dbx\WriteMode::add(), $fp); fclose($fp); $str = print_r($result, true); echo renderHtmlPage("Uploading File", "Result: <pre>{$str}</pre>"); } else { echo renderHtmlPage("Bad URL", "No handler for {$requestPath}"); exit; } }
function retrieveGCS($bucket, $file) { // Use Google Cloud Storage (not Cloud DataStore, which is a DB). GCS is unstructured data. // Use this to create buckets and manage: https://console.cloud.google.com/storage/browser?project=zouk-event-calendar // Code below is generally out of date with documentation. See source in vendor/google/... for correct usage // I created 1 bucket through web interface (can also be created programmatically). Inside this bucket will be many files. $client = getClient(); $storage = getStorageService($client); try { // get the url for our file $object = $storage->objects->get($bucket, $file); // use print_r($object) or var_dump to see the contents $url = $object['mediaLink']; $httpClient = $client->authorize(); // creates guzzle http client and authorizes it $response = $httpClient->get($url); // see guzzle docs for this $str = (string) $response->getBody(); // local scope return $str; } catch (Exception $e) { syslog(LOG_EMERG, $e->getMessage()); sendMail('Cannot get data from GCS: ' . $e->getMessage()); } return NULL; }
function syncAllS3($srcS3Key, $srcS3Secret, $srcRegion, $srcS3Bucket, $desS3Key, $desS3Secret, $desRegion, $desS3Bucket, $prefix) { $srcClient = getClient($srcS3Key, $srcS3Secret, $srcRegion); $desClient = getClient($desS3Key, $desS3Secret, $desRegion); $iterator = $srcClient->getIterator('ListObjects', array('Bucket' => $srcS3Bucket, 'Prefix' => $prefix)); foreach ($iterator as $object) { if (strpos($object['Key'], "log.json") !== false) { moveData($srcClient, $srcRegion, $srcS3Bucket, $desClient, $desRegion, $desS3Bucket, $object['Key']); } } }
<?php use tomzx\GoogleDocsToMarkdown\Exporter; require 'vendor/autoload.php'; define('SCOPES', implode(' ', [Google_Service_Drive::DRIVE_READONLY])); /** * Returns an authorized API client. * * @param string $email * @return \Google_Client the authorized client object */ function getClient($email) { $privateKey = file_get_contents('google-documents-exporter.p12'); $credentials = new Google_Auth_AssertionCredentials($email, SCOPES, $privateKey); $client = new Google_Client(); $client->setAssertionCredentials($credentials); if ($client->getAuth()->isAccessTokenExpired()) { $client->getAuth()->refreshTokenWithAssertion(); } return $client; } // Get the API client and construct the service object. $client = getClient($argv[1]); $exporter = new Exporter($client); $exporter->export($argv[2], 'output');
function createService() { // Get the API client and construct the service object. $client = getClient(); return new Google_Service_Script($client); }
function searchClient($name) { getClient($name, "search"); }
include_once "ini.dbstring.php"; include_once "ini.functions.php"; sec_session_start(); include_once "mod.order.php"; include_once "mod.login.php"; include_once "mod.optional.php"; include_once "ctrl.order.php"; include_once "ctrl.client.php"; include_once "ctrl.login.php"; // check user authentication checkSession($_SESSION['sess_user_id']); checkOrderSession($_SESSION['sess_order_type'], $_SESSION['sess_client']); $rf = getRf($db); $os = getOS($db); $app = getApp($db); $showclient = getClient($db); ?> <html lang="en-US"> <head> <meta charset="utf-8"> <link href="<?php echo CSS; ?> import.css" type="text/css" rel="stylesheet"/> <link href="<?php echo CSS; ?> style.css" type="text/css" rel="stylesheet"/> <script src="<?php echo JS; ?>
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once '../Source/vendor/autoload.php'; use Sabre\VObject\Component\VCalendar; function getClient() { $client = new SimpleCalDAVClient(); $client->connect("http://localhost:8008/calendars/users/test/calendar/", "test", "test"); $arrayOfCalendars = $client->findCalendars(); $client->setCalendar($arrayOfCalendars["calendar"]); return $client; } $events = getClient()->getEvents("19000101T000000Z", "20991231T235959Z"); while (count($events) > 0) { getClient()->delete($events[0]->getHref(), $events[0]->getEtag()); $events = getClient()->getEvents("19000101T000000Z", "20991231T235959Z"); } $test1 = new VCalendar(['VEVENT' => ['SUMMARY' => 'Test 1', 'DTSTART' => new \DateTime('2016-03-07 10:00:00'), 'DTEND' => new \DateTime('2016-03-07 12:00:00')]]); $test2 = new VCalendar(['VEVENT' => ['SUMMARY' => 'Test 2', 'DTSTART' => new \DateTime('2016-03-07 12:00:00'), 'DTEND' => new \DateTime('2016-03-07 14:00:00')]]); $test3 = new VCalendar(['VEVENT' => ['SUMMARY' => 'Test 3', 'DTSTART' => new \DateTime('2016-03-07 12:00:00'), 'DTEND' => new \DateTime('2016-03-07 15:00:00')]]); $test4 = new VCalendar(['VEVENT' => ['SUMMARY' => 'Test 4', 'DTSTART' => new \DateTime('2016-03-07 16:00:00'), 'DTEND' => new \DateTime('2016-03-07 18:00:00')]]); getClient()->create($test1->serialize()); getClient()->create($test2->serialize()); getClient()->create($test3->serialize()); getClient()->create($test4->serialize());