/** * Create filters with AND conjunction * * @param array $options * @param array $filters * @param bool $placeholder * * @return string */ public static function andFilter(array $options, array $filters, $placeholder = true) { $condition = ""; if (empty($options) || empty($filters)) { return $condition; } $clause = array(); foreach ($filters as $key => $value) { $value = $placeholder === true ? ":{$key}" : (Steelcode_Types_Helper::isNumeric($value) ? $value : "'{$value}'"); $clause[] = $options[$key] . "=" . $value; } if (!empty($clause)) { $condition = " WHERE " . Steelcode_Array_Helper::implode(' AND ', $clause); } return $condition; }
/** * Encode the JSON web token */ protected function _encode() { $this->_header['typ'] = 'JWT'; $this->_header['alg'] = $this->_algorithm; $segments = array('header' => $this->urlSafeB64Encode(Steelcode_Json_Helper::encode($this->_header)), 'payload' => $this->urlSafeB64Encode(Steelcode_Json_Helper::encode($this->_payload)), 'signature' => ''); $this->_signature = $this->_sign("{$segments['header']}.{$segments['payload']}"); $segments['signature'] = $this->urlSafeB64Encode($this->_signature); return Steelcode_Array_Helper::implode('.', $segments); }
/** * Generate request path from $_SERVER variable * * @return string */ public function _generatePath() { if (isset($_SERVER['REDIRECT_URL']) && isset($_SERVER['SCRIPT_NAME']) && !isset($_SERVER['FCGI_ROLE'])) { $requestUrl = $_SERVER['REDIRECT_URL']; $scriptName = $_SERVER['SCRIPT_NAME']; } elseif (isset($_SERVER['REQUEST_URI'])) { list($requestUrl) = Steelcode_String_Helper::explode('?', $_SERVER['REQUEST_URI']); $scriptName = $_SERVER['SCRIPT_NAME']; } else { return '/'; } if ($requestUrl == '' || $requestUrl == '/') { return '/'; } $arrayUrl = Steelcode_String_Helper::explode('/', $requestUrl); $arrayScript = Steelcode_String_Helper::explode('/', $scriptName); foreach ($arrayScript as $key => $value) { if ($arrayUrl[$key] == $value) { unset($arrayUrl[$key]); } } return '/' . Steelcode_Array_Helper::implode('/', $arrayUrl); }