function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement ) { $uri = new eZURI( $namedParameters[ 'uri' ] ); $moduleName = $uri->element( 0 ); $moduleList = eZINI::instance( 'module.ini' )->variable( 'ModuleSettings', 'ModuleList' ); if ( in_array( $moduleName, $moduleList, true ) ) $check = eZModule::accessAllowed( $uri ); $operatorValue = isset( $check['result'] ) ? $check['result'] : false; }
protected function parse() { $urlAlias = '/' . $this->rawResult['main_url_alias']; eZURI::transformURI($urlAlias, false, 'full'); $this->data = array('id' => $this->rawResult['id'], 'name' => $this->rawResult['name'], 'class_identifier' => $this->rawResult['class_identifier'], 'main_node_id' => $this->rawResult['main_node_id'], 'href' => $urlAlias); $fromDate = self::getDateTime($this->rawResult['fields']['attr_from_time_dt']); if (!$fromDate instanceof DateTime) { throw new Exception("Value of 'attr_from_time_dt' not a valid date"); } $this->data['fromDateTime'] = $fromDate; $this->data['from'] = $fromDate->getTimestamp(); $this->data['identifier'] = $fromDate->format(OpenPACalendarData::FULLDAY_IDENTIFIER_FORMAT); if (isset($this->rawResult['fields']['attr_to_time_dt'])) { $toDate = self::getDateTime($this->rawResult['fields']['attr_to_time_dt']); if (!$toDate instanceof DateTime) { throw new Exception("Param 'attr_to_time_dt' is not a valid date"); } if ($toDate->getTimestamp() == 0) { $toDate = $this->fakeToTime($this->data['fromDateTime']); } } else { $toDate = $this->fakeToTime($this->data['fromDateTime']); } $this->data['toDateTime'] = $toDate; $this->data['to'] = $toDate->getTimestamp(); $this->data['duration'] = $this->data['to'] - $this->data['from']; $this->isValid = $this->isValid(); }
public function requestToken($Account) { $NGPushIni = eZINI::instance('ngpush.ini'); $SiteIni = eZINI::instance('site.ini'); $AccessToken = $NGPushIni->variable($Account, 'AccessToken'); // If access tokens are given if ($AccessToken) { //Save request signing tokens to cache ngPushBase::save_token($Account, $AccessToken, 'main_token'); } else { $AdministrationUrl = '/'; eZURI::transformURI($AdministrationUrl, false, 'full'); $AdministrationUrl = base64_encode($AdministrationUrl); $SettingsBlock = base64_encode($Account); $redirectUrl = 'http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=facebook'; $Facebook = new Facebook(array('appId' => $NGPushIni->variable($Account, 'AppAPIKey'), 'secret' => $NGPushIni->variable($Account, 'AppSecret'))); $Permissions = array('publish_actions', 'user_posts'); if ($NGPushIni->variable($Account, 'EntityType') == 'page') { $Permissions[] = 'manage_pages'; } $state = md5(uniqid(rand(), true)); $http = eZHTTPTool::instance(); $http->setSessionVariable('ngpush_state', $state); $LoginUrl = $Facebook->getLoginUrl(array('redirect_uri' => $redirectUrl, 'scope' => implode($Permissions, ','), 'state' => $state)); self::$response['RequestPermissionsUrl'] = $LoginUrl; } }
/** * This method is used to process the first part of authentication workflow, before redirect * * @return array Array with status and redirect URI */ public function getRedirectUri() { $ngConnectINI = eZINI::instance('ngconnect.ini'); $http = eZHTTPTool::instance(); $consumerKey = trim($ngConnectINI->variable('LoginMethod_twitter', 'AppConsumerKey')); $consumerSecret = trim($ngConnectINI->variable('LoginMethod_twitter', 'AppConsumerSecret')); if (empty($consumerKey) || empty($consumerSecret)) { return array('status' => 'error', 'message' => 'Consumer key or consumer secret undefined.'); } $callbackUri = self::CALLBACK_URI_PART; $loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType')); if ($loginWindowType == 'popup') { $callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART; } $state = md5(session_id() . (string) time()); $http->setSessionVariable('NGConnectOAuthState', $state); $callbackUri .= '?state=' . $state; eZURI::transformURI($callbackUri, false, 'full'); $connection = new TwitterOAuth($consumerKey, $consumerSecret); $connection->host = self::TWITTER_API_URI; $tempCredentials = $connection->getRequestToken($callbackUri); $redirectUri = $connection->getAuthorizeURL($tempCredentials); if (!$redirectUri) { return array('status' => 'error', 'message' => 'Invalid redirection URI.'); } $http->setSessionVariable('NGConnectOAuthToken', $tempCredentials['oauth_token']); $http->setSessionVariable('NGConnectOAuthTokenSecret', $tempCredentials['oauth_token_secret']); return array('status' => 'success', 'redirect_uri' => $redirectUri); }
public function requestToken($Account) { $NGPushIni = eZINI::instance('ngpush.ini'); $ConsumerKey = $NGPushIni->variable($Account, 'ConsumerKey'); $ConsumerSecret = $NGPushIni->variable($Account, 'ConsumerSecret'); $AccessToken = $NGPushIni->variable($Account, 'AccessToken'); $AccessTokenSecret = $NGPushIni->variable($Account, 'AccessTokenSecret'); // If access tokens are given if ($AccessToken && $AccessTokenSecret) { // Save request signing tokens to cache ngPushBase::save_token($Account, $AccessToken, 'request_sign_oauth_token'); ngPushBase::save_token($Account, $AccessTokenSecret, 'request_sign_oauth_token_secret'); ngPushBase::save_token($Account, $AccessToken . '%%%' . $AccessTokenSecret, 'main_token'); } else { $connection = new TwitterOAuth($ConsumerKey, $ConsumerSecret); $connection->host = "https://api.twitter.com/1.1/"; $AdministrationUrl = '/'; eZURI::transformURI($AdministrationUrl, false, 'full'); $AdministrationUrl = base64_encode($AdministrationUrl); $SettingsBlock = base64_encode($Account); $temporary_credentials = $connection->getRequestToken('http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=twitter'); // Save request signing tokens to cache ngPushBase::save_token($Account, $temporary_credentials['oauth_token'], 'request_sign_oauth_token'); ngPushBase::save_token($Account, $temporary_credentials['oauth_token_secret'], 'request_sign_oauth_token_secret'); $redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE); self::$response['RequestPermissionsUrl'] = $redirect_url; } }
function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters) { switch ($operatorName) { case 'ngurl': if (empty($namedParameters['siteaccess'])) { return; } $ini = eZSiteAccess::getIni($namedParameters['siteaccess'], 'site.ini'); $destinationLocale = $ini->variable('RegionalSettings', 'ContentObjectLocale'); $siteLanguageList = $ini->variable('RegionalSettings', 'SiteLanguageList'); $nodeID = eZURLAliasML::fetchNodeIDByPath($operatorValue); $destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeID, $destinationLocale, false); if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) { if ($this->isModuleUrl($operatorValue) || $this->isCurrentLocaleAvailable($siteLanguageList)) { $destinationUrl = $operatorValue; } else { $destinationUrl = ''; } } else { $destinationUrl = $destinationElement[0]->getPath($destinationLocale, $siteLanguageList); } $siteaccessUrlMapping = eZINI::instance('nglanguageswitcher.ini')->variable('LanguageSwitcher', 'SiteAccessUrlMapping'); $destinationUrl = eZURI::encodeURL($destinationUrl); $operatorValue = rtrim($siteaccessUrlMapping[$namedParameters['siteaccess']], '/') . '/' . ltrim($destinationUrl, '/'); break; } }
function feZMetaData_ContentActionHandler( &$module, &$http, &$objectID ) { // Action when user clicks on the Add Button if( $http->hasPostVariable( 'AddMetaDataButton' ) ) { $link = 'fezmetadata/edit/0/(contentObjectID)/'.$objectID; $link .= '/(metaDataName)/'.$_POST['metaDataName']; $link .= '/(language)/'.$_POST['language']; eZURI::transformURI( $link ); $http->redirect( $link ); } // Action when user clicks on the Remove Button if( $http->hasPostVariable( 'RemoveMetaDataButton' ) and $http->hasPostVariable( 'MetaDataIDSelection' ) ) { $metaDataSelection = $http->postVariable( 'MetaDataIDSelection' ); foreach( $metaDataSelection as $metaData ) { $metaDataObject = feZMetaData::fetch( $metaData ); $metaDataObject->remove(); } eZContentCacheManager::clearContentCache( $objectID ); $ContentObject = eZContentObject::fetch( $objectID ); $ContentNodeID = $ContentObject->mainNodeID(); return $module->redirect( 'content', 'view', array( 'full', $ContentNodeID ) ); } }
public static function message($publishHandler, eZContentObject $object, $message, $messageLength = null, $options) { $url = false; if (isset($options['include_url']) && (bool) $options['include_url'] === true) { $url = $object->attribute('main_node')->attribute('url_alias'); eZURI::transformURI($url, true, 'full'); if (isset($options['shorten_url']) && (bool) $options['shorten_url'] === true) { $urlReturned = $publishHandler->shorten($url, $options['shorten_handler']); if (is_string($urlReturned)) { $url = $urlReturned; } } if ($messageLength != null) { $messageLength = $messageLength - strlen($url) - 1; } } if (class_exists('Normalizer')) { $message = Normalizer::normalize($message, Normalizer::FORM_C); } if ($messageLength != null) { $message = mb_substr($message, 0, $messageLength); } if ($url) { $message .= ' ' . $url; } return $message; }
public function getLoginURL(array $scopes = null, $redirectURL = null) { eZURI::transformURI($redirectURL, false, 'full'); $connection = $this->getFacebookConnection(); $params = array('scope' => implode(', ', $scopes), 'redirect_uri' => $redirectURL); return $connection->getLoginUrl($params); }
/** * Test scenario for issue #13186: UserParameters works differently in 4.0 compared to 3.10 * * @result $eZURI->userParameters() returns an empty array * @expected $eZURI->userParameters() should return array( "ole" => "a", "dull" => "boy" ). * * @link http://issues.ez.no/13186 */ public function testUserParameters() { $expectedParams = array("ole" => "a", "dull" => "boy"); $eZURI = eZURI::instance(); $userParams = $eZURI->userParameters(); $this->assertEquals($expectedParams, $userParams); }
/** * Returns metadata for given content location as array * @param ezpContentLocation $location * @return array */ public static function getMetadataByLocation(ezpContentLocation $location) { $url = $location->url_alias; eZURI::transformURI($url, false, 'full'); // $url is passed as a reference $aMetadata = array('nodeId' => (int) $location->node_id, 'nodeRemoteId' => $location->remote_id, 'fullUrl' => $url); return $aMetadata; }
public static function status( $args ) { if ( count( $args ) != 2 ) { throw new ezcBaseFunctionalityNotSupportedException( 'status', 'Missing argument(s)' ); } list( $contentObjectId, $version ) = $args; $process = ezpContentPublishingProcess::fetchByContentObjectVersion( $contentObjectId, $version ); // No process: check if the object's still a draft // @todo Change to a PENDING check when applied (operation => step 2) if ( $process instanceof ezpContentPublishingProcess ) { $return = array(); $status = $process->attribute( 'status' ) == ezpContentPublishingProcess::STATUS_WORKING ? 'working' : 'finished'; switch( $process->attribute( 'status' ) ) { case ezpContentPublishingProcess::STATUS_WORKING: $status = 'working'; break; case ezpContentPublishingProcess::STATUS_FINISHED: $status = 'finished'; $objectVersion = $process->attribute( 'version' ); $object = $objectVersion->attribute( 'contentobject' ); $node = $object->attribute( 'main_node' ); $uri = $node->attribute( 'url_alias' ); eZURI::transformURI( $uri ); $return['node_uri'] = $uri; break; case ezpContentPublishingProcess::STATUS_PENDING: $status = 'pending'; break; case ezpContentPublishingProcess::STATUS_DEFERRED: $status = 'deferred'; $versionViewUri = "content/versionview/{$contentObjectId}/{$version}"; eZURI::transformURI( $versionViewUri ); $return['versionview_uri'] = $versionViewUri; break; } $return['status'] = $status; } else { $version = eZContentObjectVersion::fetchVersion( $version, $contentObjectId ); if ( $version === null ) throw new ezcBaseFunctionalityNotSupportedException( 'status', 'Object version not found' ); else $return = array( 'status' => 'queued' ); } return $return; }
/** * This method is used to process the second part of authentication workflow, after redirect * * @return array Array with status and user details */ public function processAuth() { $ngConnectINI = eZINI::instance('ngconnect.ini'); $http = eZHTTPTool::instance(); $appID = trim($ngConnectINI->variable('LoginMethod_facebook', 'FacebookAppID')); $appSecret = trim($ngConnectINI->variable('LoginMethod_facebook', 'FacebookAppSecret')); if (empty($appID) || empty($appSecret)) { return array('status' => 'error', 'message' => 'Facebook app ID or Facebook app secret undefined.'); } $code = trim($http->getVariable('code', '')); $state = trim($http->getVariable('state', '')); if (empty($code) || empty($state)) { return array('status' => 'error', 'message' => 'code or state GET parameters undefined.'); } if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) { $http->removeSessionVariable('NGConnectOAuthState'); return array('status' => 'error', 'message' => 'State parameter does not match stored value.'); } else { $http->removeSessionVariable('NGConnectOAuthState'); } $callbackUri = self::CALLBACK_URI_PART; $loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType')); if ($loginWindowType == 'popup') { $callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART; } eZURI::transformURI($callbackUri, false, 'full'); $tokenUri = str_replace(array('%app_id%', '%site_url%', '%app_secret%', '%code%'), array(urlencode($appID), urlencode($callbackUri), urlencode($appSecret), urlencode($code)), self::TOKEN_URI); $accessToken = ngConnectFunctions::fetchDataFromUrl($tokenUri); if (!$accessToken) { return array('status' => 'error', 'message' => 'Error while retrieving access token.'); } $accessTokenJson = json_decode($accessToken, true); if ($accessTokenJson !== null) { return array('status' => 'error', 'message' => $accessTokenJson['error']['message']); } $graphUri = str_replace(array('%access_token%'), array(trim($accessToken)), self::GRAPH_URI); $graphResponse = ngConnectFunctions::fetchDataFromUrl($graphUri); if (!$graphResponse) { return array('status' => 'error', 'message' => 'Error while retrieving graph response.'); } $user = json_decode($graphResponse, true); if ($user === null) { return array('status' => 'error', 'message' => 'Invalid JSON data returned.'); } if (!isset($user['id'])) { return array('status' => 'error', 'message' => 'Invalid Facebook user.'); } $pictureUri = self::PICTURE_URI; $imageSize = trim($ngConnectINI->variable('LoginMethod_facebook', 'ImageSize')); if ($imageSize == 'original') { $pictureUri = $pictureUri . '?type=large'; } $result = array('status' => 'success', 'login_method' => 'facebook', 'id' => $user['id'], 'first_name' => isset($user['first_name']) ? $user['first_name'] : '', 'last_name' => isset($user['last_name']) ? $user['last_name'] : '', 'email' => isset($user['email']) ? $user['email'] : '', 'picture' => str_replace('%user_id%', $user['id'], $pictureUri)); return $result; }
/** * Execution point for controller actions. * Returns false if not supported * * @return ezpKernelResult */ public function run() { $db = eZDB::instance(); if ($db->isConnected()) { $this->sessionInit(); } else { return $this->exitWithInternalError(ezpI18n::tr('kernel/content/treemenu', 'Database is not connected')); } $moduleINI = eZINI::instance('module.ini'); $globalModuleRepositories = $moduleINI->variable('ModuleSettings', 'ModuleRepositories'); eZModule::setGlobalPathList($globalModuleRepositories); $module = eZModule::exists('content'); if (!$module) { return $this->exitWithInternalError(ezpI18n::tr('kernel/content/treemenu', '"content" module could not be found.')); } $function_name = 'treemenu'; $this->uri->increase(); $this->uri->increase(); $currentUser = eZUser::currentUser(); $siteAccessResult = $currentUser->hasAccessTo('user', 'login'); $hasAccessToSite = false; if ($siteAccessResult['accessWord'] == 'limited') { $policyChecked = false; foreach ($siteAccessResult['policies'] as $policy) { if (isset($policy['SiteAccess'])) { $policyChecked = true; $crc32AccessName = eZSys::ezcrc32($this->access['name']); if (in_array($crc32AccessName, $policy['SiteAccess'])) { $hasAccessToSite = true; break; } } if ($hasAccessToSite) { break; } } if (!$policyChecked) { $hasAccessToSite = true; } } else { if ($siteAccessResult['accessWord'] == 'yes') { $hasAccessToSite = true; } } if (!$hasAccessToSite) { return $this->exitWithInternalError(ezpI18n::tr('kernel/content/treemenu', 'Insufficient permissions to display the treemenu.'), 403); } $GLOBALS['eZRequestedModule'] = $module; $content = $module->run($function_name, $this->uri->elements(false), false, array('use-cache-headers' => $this->settings['use-cache-headers'])); $attributes = isset($content['lastModified']) ? array('lastModified' => $content['lastModified']) : array(); $this->shutdown(); return new ezpKernelResult($content['content'], $attributes); }
public function testInstanceRepeatCallsWithDifferentUri() { $docstring = "Calling eZURI::instance( \$uri ) with different \$uri" . " each time should return seperate instances of eZURI" . " when \$uri is not equal eZSys::requestURI(). No caching" . " in \$_GLOBALS should be done."; $uri1 = "/i/have/(no)/imageination"; $uri2 = "/lorem/ipsum/dolor/(sit)/amet"; $ezuri = eZURI::instance(); $ezuri1 = eZURI::instance($uri1); $ezuri2 = eZURI::instance($uri2); $this->assertNotSame($ezuri, $ezuri1, $docstring); $this->assertNotSame($ezuri, $ezuri2, $docstring); $this->assertNotSame($ezuri1, $ezuri2, $docstring); }
public static function fetchMapMarkers($parentNodeId, $childrenClassIdentifiers) { foreach ($childrenClassIdentifiers as $key => $value) { if (empty($value)) { unset($childrenClassIdentifiers[$key]); } } $sortBy = array('name' => 'asc'); $result = array(); if ($parentNode = self::getNode($parentNodeId)) { if (!empty($childrenClassIdentifiers)) { $childrenClassTypes = (array) eZContentClass::fetchList(0, true, false, null, null, $childrenClassIdentifiers); } else { $childrenClassTypes = self::getChildrenClasses($parentNodeId); } // ricavo gli attributi delle classi $geoAttributes = array(); foreach ($childrenClassTypes as $classType) { if ($classType instanceof eZContentClass) { $geoAttributes = array_merge($geoAttributes, eZContentClassAttribute::fetchFilteredList(array('contentclass_id' => $classType->attribute('id'), 'version' => $classType->attribute('version'), 'data_type_string' => 'ezgmaplocation'))); } } if (count($geoAttributes)) { // imposto i filtri di ricerca $geoFields = $geoFieldsNames = array(); foreach ($geoAttributes as $geoAttribute) { if ($geoAttribute instanceof eZContentClassAttribute) { $geoFields[$geoAttribute->attribute('identifier')] = $geoAttribute->attribute('name'); $geoFieldsNames[] = "subattr_{$geoAttribute->attribute('identifier')}___coordinates____gpt"; } } $childrenParameters = array('SearchSubTreeArray' => array($parentNode->attribute('node_id')), 'Filter' => array('-meta_id_si:' . $parentNode->attribute('contentobject_id')), 'SearchLimit' => 1000, 'AsObjects' => false, 'SortBy' => $sortBy, 'FieldsToReturn' => $geoFieldsNames); // cerco i figli $solr = new OCSolr(); $children = $solr->search('', $childrenParameters); if ($children['SearchCount'] > 0) { foreach ($children['SearchResult'] as $item) { foreach ($geoFieldsNames as $geoFieldsName) { @(list($longitude, $latitude) = explode(',', $item['fields'][$geoFieldsName][0])); if (intval($latitude) > 0 && intval($longitude) > 0) { $href = isset($item['main_url_alias']) ? $item['main_url_alias'] : $item['main_url_alias_ms']; eZURI::transformURI($href, false, 'full'); $popup = isset($item['name']) ? $item['name'] : $item['name_t']; $id = isset($item['id_si']) ? $item['id_si'] : $item['id']; $result[] = array('id' => $id, 'type' => null, 'lat' => floatval($latitude), 'lon' => floatval($longitude), 'lng' => floatval($longitude), 'popupMsg' => $popup, 'title' => $popup, 'description' => "<h3><a href='{$href}'>{$popup}</a></h3>", 'urlAlias' => $href, 'objectID' => $id); } } } } } } return array('result' => $result); }
/** * This method is used to process the second part of authentication workflow, after redirect * * @return array Array with status and user details */ public function processAuth() { $ngConnectINI = eZINI::instance('ngconnect.ini'); $http = eZHTTPTool::instance(); $clientID = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientID')); $clientSecret = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientSecret')); if (empty($clientID) || empty($clientSecret)) { return array('status' => 'error', 'message' => 'Google client ID or Google client secret undefined.'); } $code = trim($http->getVariable('code', '')); $state = trim($http->getVariable('state', '')); if (empty($code) || empty($state)) { return array('status' => 'error', 'message' => 'code or state GET parameters undefined.'); } if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) { $http->removeSessionVariable('NGConnectOAuthState'); return array('status' => 'error', 'message' => 'State parameter does not match stored value.'); } else { $http->removeSessionVariable('NGConnectOAuthState'); } $callbackUri = self::CALLBACK_URI_PART; $loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType')); if ($loginWindowType == 'popup') { $callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART; } eZURI::transformURI($callbackUri, false, 'full'); $scope = self::SCOPE; $userScope = trim($ngConnectINI->variable('LoginMethod_google', 'Scope')); if (!empty($userScope)) { $scope = $userScope . ' ' . $scope; } $client = new Google_Client(); $client->setApplicationName(trim($ngConnectINI->variable('LoginMethod_google', 'MethodName'))); $client->setScopes($scope); $client->setClientId($clientID); $client->setClientSecret($clientSecret); $client->setRedirectUri($callbackUri); $client->setUseObjects(true); $plus = new Google_PlusService($client); $authString = $client->authenticate(); $accessToken = $client->getAccessToken(); if (empty($authString) || empty($accessToken)) { return array('status' => 'error', 'message' => 'Unable to authenticate to Google.'); } $me = $plus->people->get('me'); if (!$me instanceof Google_Person) { return array('status' => 'error', 'message' => 'Invalid Google user.'); } $result = array('status' => 'success', 'login_method' => 'google', 'id' => $me->id, 'first_name' => !empty($me->name->givenName) ? $me->name->givenName : '', 'last_name' => !empty($me->name->familyName) ? $me->name->familyName : '', 'email' => !empty($me->emails[0]['value']) ? $me->emails[0]['value'] : '', 'picture' => !empty($me->image->url) ? $me->image->url : ''); return $result; }
public function getAccessToken($redirectURL = null) { $http = eZHTTPTool::instance(); if ($http->hasGetVariable('code') === false) { throw new Exception('Wrong request token. Refresh the page or try again later.'); } if ($redirectURL !== null) { eZURI::transformURI($redirectURL, false, 'full'); $this->connection->setRedirectUri($redirectURL); } $this->connection->authenticate(); $accessToken = $this->connection->getAccessToken(); return array('token' => $accessToken, 'secret' => null); }
public static function checkIfNeeded(eZURI $uri) { $original = $uri->uriString(); $parts = $uri->URIArray; $checkUrls = array($original); $countParts = count($parts); for ($i = 0; $i <= $countParts; $i++) { $slice = array_slice($parts, 0, $i); if (!empty($slice)) { $sliceString = implode('/', $slice); $checkUrls[] = $sliceString . '/*'; } } $ini = eZINI::instance('cookielaw.ini'); if ($ini->hasVariable('UriExcludeList', 'Exclude')) { $excludeList = (array) $ini->variable('UriExcludeList', 'Exclude'); foreach ($checkUrls as $url) { if (in_array($url, $excludeList)) { self::$isActive = false; } } } }
public function getAuthorizeURL(array $scopes = null, $redirectURL = null) { $http = eZHTTPTool::instance(); if ($redirectURL !== null) { eZURI::transformURI($redirectURL, false, 'full'); $this->connection->setCallbackUrl($redirectURL); } $response = $this->connection->retrieveTokenRequest($scopes); if ($response['success'] === true) { $http->setSessionVariable('linkedin_request_token', $response['linkedin']); return LinkedIn::_URL_AUTH . $response['linkedin']['oauth_token']; } else { throw new Exception('Request token retrieval failed. Refresh the page or try again later.'); } }
public function getAccessToken($redirectURL = null) { $http = eZHTTPTool::instance(); if ($redirectURL === null) { $redirectURL = '/nxc_social_network_token/get_access_token/facebook'; } eZURI::transformURI($redirectURL, false, 'full'); $data = file_get_contents('https://graph.facebook.com/oauth/access_token?' . 'client_id=' . $this->appSettings['key'] . '&' . 'client_secret=' . $this->appSettings['secret'] . '&' . 'code=' . $http->getVariable('code') . '&' . 'redirect_uri=' . $redirectURL); if (strpos($data, 'access_token=') !== false) { preg_match('/access_token=([^&]*)/i', $data, $matches); if (isset($matches[1])) { return array('token' => $matches[1], 'secret' => null); } } throw new Exception('Could not get access token. Refresh the page or try again later.'); }
/** Get an include tag for the given base URL and parameters. * * This performs the processing common to both types of includes. * @param string $url The base of the URL that should be included. * @param array $keys An associative array of GET parameters to add to the * URL before including it. * @return string The generated esi:include tag for the given URL. */ private function getIncludeTag($url, $params) { if ($this->sendDoESIHeader) { header(self::DO_ESI_HEADER); } nxcESIEAS::setUseESI(true); foreach ($params as $key => $value) { $url .= '&' . rawurlencode($key) . '=' . rawurlencode($value); } eZURI::transformURI($url); $include = '<esi:include src="' . $url; if ($this->continueOnError) { $include .= '" onerror="continue'; } $include .= '"/>'; return $include; }
public static function getMetadataByLocation(ezpContentLocation $location) { $url = $location->url_alias; eZURI::transformURI($url, false, 'full'); // $url is passed as a reference // Forzo l'utilizzo di HTTPS $url_https = str_replace("http://", "https://", $url); $aMetadata = array('nodeId' => (int) $location->node_id, 'nodeRemoteId' => $location->remote_id, 'fullUrl' => $url_https); try { $node = eZContentObjectTreeNode::fetch($location->node_id); if ($node instanceof eZContentObjectTreeNode) { $pathNames = explode('/', $node->attribute('path_with_names')); $aMetadata['path'] = $pathNames; } } catch (Exception $e) { } return $aMetadata; }
public function execute($process, $event) { $processParameters = $process->attribute('parameter_list'); $object = eZContentObject::fetch($processParameters['object_id']); $node = $object->mainNode(); $href = '/push/node/' . $node->attribute('node_id'); $version = eZContentObjectVersion::fetchVersion($processParameters['version'], $processParameters['object_id']); if ($version instanceof eZContentObjectVersion) { $language = eZContentLanguage::fetch($version->attribute('initial_language_id')); if ($language instanceof eZContentLanguage) { $href .= '/' . $language->attribute('locale'); } } eZURI::transformURI($href, false, 'full'); $http = eZHTTPTool::instance(); $http->setSessionVariable('RedirectURIAfterPublish', $href); return eZWorkflowType::STATUS_ACCEPTED; }
public function getAuthorizeURL(array $scopes = null, $redirectURL = null) { $connection = new TwitterOAuth($this->appSettings['key'], $this->appSettings['secret']); if ($redirectURL === null) { $redirectURL = '/nxc_social_network_token/get_access_token/twitter'; } eZURI::transformURI($redirectURL, false, 'full'); $requestToken = $connection->getRequestToken($redirectURL); $http = eZHTTPTool::instance(); $http->setSessionVariable('twitter_request_token', $requestToken['oauth_token']); $http->setSessionVariable('twitter_request_token_secret', $requestToken['oauth_token_secret']); switch ($connection->http_code) { case 200: return $connection->getAuthorizeURL($requestToken['oauth_token'], true); default: throw new Exception('Could not connect to Twitter. Refresh the page or try again later.'); } }
function execute($process, $event) { // get object being published $parameters = $process->attribute('parameter_list'); $objectId = $parameters['object_id']; eZDebug::writeDebug('Expire remote cache event begins execution for object ' . $objectId); $ini = eZINI::instance('ezworkflowcollection.ini'); $object = eZContentObject::fetch($objectId); if ($object != null) { if ($ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireOnlyObjectNodes') == 'enabled') { // basic version // get list of nodes this object is published with $assigned_nodes = $object->attribute('assigned_nodes'); } else { // smart-cache enabled version // get list of nodes whose view-cache is expired $assigned_nodes = array(); eZContentCacheManager::nodeListForObject($object, true, eZContentCacheManager::CLEAR_DEFAULT, $assigned_nodes, $handledObjectList); foreach ($assigned_nodes as $i => $nodeID) { $assigned_nodes[$i] = eZContentObjectTreeNode::fetch($nodeID); } } $domains = $ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireDomains'); foreach ($assigned_nodes as $assigned_node) { // for every node, call eZHTTPCacheManager to clean the remote cache $url = $assigned_node->urlAlias(); if (is_array($domains) && (count($domains) > 1 || count($domains) > 0 && $domains[0] != '')) { eZURI::transformURI($url); foreach ($domains as $domain) { eZHTTPCacheManager::execute($domain . $url); } } else { eZURI::transformURI($url, false, 'full'); eZHTTPCacheManager::execute($url); } } } else { eZDebug::writeError('Expire remote cache event triggered for inexisting object: ' . $objectId); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } return eZWorkflowType::STATUS_ACCEPTED; }
public function getAccessToken($redirectURL = null) { $http = eZHTTPTool::instance(); if ($redirectURL === null) { $redirectURL = '/nxc_social_network_token/get_access_token/instagram'; } eZURI::transformURI($redirectURL, false, 'full'); $postdata = http_build_query(array('client_id' => $this->appSettings['key'], 'grant_type' => 'authorization_code', 'client_secret' => $this->appSettings['secret'], 'code' => $http->getVariable('code'), 'redirect_uri' => $redirectURL)); $opts = array('http' => array('method' => 'POST', 'content' => $postdata)); $context = stream_context_create($opts); $data = file_get_contents('https://api.instagram.com/oauth/access_token', false, $context); $dataArray = json_decode($data, true); if (isset($adataArray['access_token'])) { return array('token' => $adataArray['access_token'], 'secret' => null); } if (isset($dataArray['access_token'])) { return array('token' => $dataArray['access_token'], 'secret' => null); } if (isset($dataArray['error_message']) && isset($dataArray['code']) && isset($dataArray['error_type'])) { throw new Exception($dataArray['error_type'] . '(' . $dataArray['code'] . '): ' . $dataArray['error_message']); } throw new Exception('Could not get access token. Refresh the page or try again later.'); }
public function generateNodeListCache($nodeList) { eZDebug::accumulatorStart('StaticCacheMugo', '', 'StaticCacheMugo'); if (!empty($nodeList)) { foreach ($nodeList as $nodeId) { $urls = $this->nodeId2Urls($nodeId); foreach ($urls as $url) { if ($this->pathPrefixModifier) { $this->applyPreFixModifier($url); } $key = md5($url); if (!isset(self::$urlsToPurge[$key])) { if ($this->uriTransformation) { eZURI::transformURI($url); } if ($this->urlModifierMatch) { $url = preg_replace($this->urlModifierMatch, $this->urlModifierReplace, $url); } // exclude URLs based on configured patterns if (!empty($this->omitUrlPatterns)) { $matched = false; foreach ($this->omitUrlPatterns as $pattern) { $matched = preg_match($pattern, $purgeUrl); } // skip it and process next URL if ($matched) { continue; } } // add final version of URL to list self::$urlsToPurge[$key] = $url; } } } } eZDebug::accumulatorStop('StaticCacheMugo', '', 'StaticCacheMugo'); }
} while (is_object($var5) and method_exists($var5, 'templateValue')) { $var5 = $var5->templateValue(); } while (is_object($var5) and method_exists($var5, 'templateValue')) { $var5 = $var5->templateValue(); } $var1 = 'content/edit/' . $var3 . '/f/' . $var5; unset($var3, $var5); if (!isset($var1)) { $var1 = NULL; } while (is_object($var1) and method_exists($var1, 'templateValue')) { $var1 = $var1->templateValue(); } eZURI::transformURI($var1, false, eZURI::getTransformURIMode()); $var = $var1; unset($var1); if (!isset($var)) { $var = NULL; } while (is_object($var) and method_exists($var, 'templateValue')) { $var = $var->templateValue(); } $text .= $var; unset($var); $text .= '"> <img src="/design/standard/images/edit.gif" width="16" height="16" alt="Modifier" title="'; unset($var); unset($var1); unset($var3);
// Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs): $_SERVER['SCRIPT_FILENAME'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME'] ); $_SERVER['PHP_SELF'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF'] ); $ini = eZINI::instance(); $timezone = $ini->variable( 'TimeZoneSettings', 'TimeZone' ); if ( $timezone ) { putenv( "TZ=$timezone" ); } // init uri code $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' ); eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' ); $uri = eZURI::instance( eZSys::requestURI() ); $GLOBALS['eZRequestedURI'] = $uri; // Check for extension eZExtension::activateExtensions( 'default' ); // load siteaccess $access = eZSiteAccess::match( $uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile() ); $access = eZSiteAccess::change( $access ); $GLOBALS['eZCurrentAccess'] = $access; // Check for new extension loaded by siteaccess