예제 #1
0
파일: Facebook.php 프로젝트: surfyst/oasys
 /**
  * Revoke a user's app auth on Facebook
  *
  * @param string $providerUserId
  *
  * @throws \DreamFactory\Platform\Exceptions\BadRequestException
  */
 protected function _revokeAuthorization($providerUserId = null)
 {
     $_id = $providerUserId ?: null;
     if (empty($providerUserId) && null === ($_id = $this->getConfig('provider_user_id'))) {
         $_profile = $this->getUserData();
         if (!empty($_profile) && null !== ($_id = $_profile->getUserId())) {
             throw new BadRequestException('Revocation not possible without provider user ID.');
         }
     }
     $_result = $this->fetch('/' . $_id . '/permissions', array(), HttpMethod::Delete);
     if (true !== ($_success = Option::get($_result, 'result', false))) {
         if (HttpResponse::BadRequest !== Option::get($_result, 'code')) {
             Log::error('Facebook revocation for user ID "' . $_id . '" FAILED.');
             return;
         } else {
             Log::debug('Facebook revocation for user ID "' . $_id . '" already completed.');
         }
     } else {
         Log::debug('Facebook revocation for user ID "' . $_id . '" successful.');
     }
     parent::_revokeAuthorization();
 }
예제 #2
0
 /**
  * Testing endpoint for events
  */
 public function actionEventReceiver()
 {
     $_request = Pii::requestObject();
     $_data = $_request->getContent();
     if (is_string($_data)) {
         $_data = json_decode($_data, true);
         if (JSON_ERROR_NONE != json_last_error()) {
             Log::error('  * DSP event could not be converted from JSON.');
             return;
         }
     }
     if (isset($_data['details'])) {
         $_eventName = Option::getDeep($_data, 'details', 'event_name');
         Log::debug('DSP event "' . $_eventName . '" received');
         return;
     }
     Log::error('Weird event received: ' . var_export($_data, true));
 }
예제 #3
0
파일: Curl.php 프로젝트: kisma/kisma
 /**
  * Returns the validated URL that has been called to get here
  *
  * @param bool $includeQuery If true, query string is included
  * @param bool $includePath  If true, the uri path is included
  *
  * @return string
  */
 public static function currentUrl($includeQuery = true, $includePath = true)
 {
     //	Are we SSL? Check for load balancer protocol as well...
     $_port = intval(Option::get($_SERVER, 'HTTP_X_FORWARDED_PORT', Option::get($_SERVER, 'SERVER_PORT', 80)));
     $_protocol = Option::get($_SERVER, 'HTTP_X_FORWARDED_PROTO', 'http' . (Option::getBool($_SERVER, 'HTTPS') ? 's' : null)) . '://';
     $_host = Option::get($_SERVER, 'HTTP_X_FORWARDED_HOST', Option::get($_SERVER, 'HTTP_HOST', gethostname()));
     $_parts = parse_url($_protocol . $_host . Option::get($_SERVER, 'REQUEST_URI'));
     if ((empty($_port) || !is_numeric($_port)) && null !== ($_parsePort = Option::get($_parts, 'port'))) {
         $_port = @intval($_parsePort);
     }
     if (null !== ($_query = Option::get($_parts, 'query'))) {
         $_query = static::urlSeparator($_query) . http_build_query(explode('&', $_query));
     }
     if (false !== strpos($_host, ':') || $_protocol == 'https://' && $_port == 443 || $_protocol == 'http://' && $_port == 80) {
         $_port = null;
     } else {
         $_port = ':' . $_port;
     }
     if (false !== strpos($_host, ':')) {
         $_port = null;
     }
     $_currentUrl = $_protocol . $_host . $_port . (true === $includePath ? Option::get($_parts, 'path') : null) . (true === $includeQuery ? $_query : null);
     if (\Kisma::get('debug.curl.current_url')) {
         Log::debug('Parsed current URL to be: ' . $_currentUrl, $_parts);
     }
     return $_currentUrl;
 }
예제 #4
0
파일: Oasys.php 프로젝트: surfyst/oasys
 /**
  * Makes a list of available templates
  *
  * @param string $pattern
  *
  * @return void
  */
 protected static function _loadTemplates($pattern = self::DEFAULT_TEMPLATE_PATTERN)
 {
     if (array() !== (static::$_templateCache = Oasys::getStore()->get('oasys.template_cache', array()))) {
         //	Loaded from cache...
         return;
     }
     $_list = array();
     foreach (static::$_providerPaths as $_path) {
         $_templates = glob($_path . '/Templates/' . $pattern);
         foreach ($_templates as $_template) {
             $_templateName = str_ireplace('.template.php', null, basename($_template));
             $_templateId = Inflector::neutralize($_templateName);
             //	Skip base classes in these directories...
             if ('base_' == substr($_templateId, 0, 4)) {
                 continue;
             }
             $_list[$_templateId] = $_path . '/Templates/' . $_template;
             unset($_template, $_templateId, $_templateName);
         }
         unset($_path, $_templates);
     }
     //	Merge in the found templates
     Oasys::getStore()->set('oasys.template_cache', static::$_templateCache = array_merge(static::$_templateCache, $_list));
     Log::debug('Cached templates: ' . implode(', ', array_keys(static::$_templateCache)));
 }
예제 #5
0
 /**
  * Retrieves the users' profile from the provider and stores it
  */
 protected function _updateUserProfile()
 {
     $_profile = $this->getUserData();
     if (!empty($_profile)) {
         //	For us...
         $_profile->setProviderId($this->_providerId);
         $this->setConfig('provider_user_id', $_id = $_profile->getUserId());
         //	For posterity - Check if method exists so testing works.
         /** @noinspection PhpUndefinedMethodInspection */
         if (method_exists(Oasys::getStore(), 'setProviderUserId')) {
             Oasys::getStore()->setProviderUserId($_id);
         }
         //	A tag
         Log::debug('User profile updated [' . $this->_providerId . ':' . $_id . ']');
     }
 }
 /**
  * @param PackageInterface $package
  *
  * @throws \InvalidArgumentException
  * @return string
  */
 protected function _validatePackage(PackageInterface $package)
 {
     $_packageName = $package->getPrettyName();
     $_parts = explode('/', $_packageName, 2);
     $this->_extra = Option::clean($package->getExtra());
     $this->_config = Option::get($this->_extra, 'config', array());
     $this->_plugIn = static::DSP_PLUGIN_PACKAGE_TYPE == $package->getType();
     //	Only install DreamFactory packages if not a plug-in
     if (static::PACKAGE_PREFIX != ($_vendor = @current($_parts)) && !$this->_plugIn) {
         throw new \InvalidArgumentException('This package is not a DreamFactory package and cannot be installed by this installer.' . PHP_EOL . '  * Name: ' . $_packageName . PHP_EOL . '  * Parts: ' . implode(' / ', $_parts) . PHP_EOL);
     }
     //	Effectively /docRoot/shared/[vendor]/[namespace]/[package]
     Log::debug('Package "' . $_packageName . '" installation type: ' . ($this->_plugIn ? 'Plug-in' : 'Package'));
     $this->_packageName = $_packageName;
     $this->_installPath = $this->_buildInstallPath($_vendor, @end($_parts));
     //	Link path for plug-ins
     $_extra = Option::clean($package->getExtra());
     $this->_linkName = Option::get($_extra, 'link_name', $_parts[1]);
     //	Relative to composer.json... i.e. web/[link_name]
     $this->_linkPath = trim(static::PLUG_IN_LINK_PATH . '/' . $this->_linkName, '/');
     Log::info('Platform Installer Debug > ' . $_packageName . ' > Version ' . $package->getVersion());
     Log::debug('  * Install path: ' . $this->_installPath);
     if ($this->_plugIn) {
         Log::debug('  *    Link name: ' . $this->_linkName);
         Log::debug('  *    Link path: ' . $this->_linkPath);
     }
     return true;
 }
예제 #7
0
 /**
  * Executes a SOQL query and iterates through the data or returns the results
  *
  * @param string   $sql
  * @param \Closure $callback
  *
  * @throws \InvalidArgumentException
  * @return bool
  */
 public function executePagedQuery($sql, $callback = null)
 {
     if (!is_callable($callback)) {
         throw new \InvalidArgumentException('The $callback value provided is not callable. Try again.');
     }
     if (false === ($_rows = $this->executeQuery($sql))) {
         Log::error('Error: ' . $this->_lastError);
         return false;
     }
     $_resultSetCount = 0;
     if (!empty($_rows)) {
         while (true) {
             $_records = $_rows->getRecords();
             if (empty($_records) || 0 == count($_records)) {
                 Log::debug('Empty records object received, re-pulling');
                 break;
             } else {
                 Log::debug('Result set #' . ++$_resultSetCount . ' contains ' . count($_records) . ' record(s)');
                 foreach ($_records as $_record) {
                     if (!is_object($_record)) {
                         Log::error('Data record returned from Salesforce is invalid: ' . print_r($_record, true));
                         continue;
                     }
                     //	Call the callback
                     $callback($_record);
                 }
             }
             if ($_rows->getDone()) {
                 break;
             }
             $_nextUrl = $_rows->getNextRecordsUrl();
             Log::debug('Looking for next result set from: ' . $_nextUrl);
             $this->_nextRecordsUrl = $_nextUrl;
             unset($_rows, $_records);
             $_rows = new ForceContainer($this->getNextRecordSet());
         }
     }
 }