本文整理汇总了PHP中Zend_Controller_Request_Http::getServer方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::getServer方法的具体用法?PHP Zend_Controller_Request_Http::getServer怎么用?PHP Zend_Controller_Request_Http::getServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::getServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirectAdmin
public function redirectAdmin()
{
$hostHttp = new Zend_Controller_Request_Http();
$host = $hostHttp->getServer('HTTP_HOST');
$requestUri = $hostHttp->getServer('REQUEST_URI');
$url = 'http://admin.' . $host . $requestUri;
Zend_Controller_Front::getInstance()->getResponse()->setRedirect($url, 301);
return;
}
示例2: _isUnderSSL
/**
* checks if the current connection is under SSL
*
* @param Zend_Controller_Request_Http $request
* @return boolean
*/
private function _isUnderSSL(Zend_Controller_Request_Http $request)
{
// $_SERVER['https'] is used by apache
// $_SERVER['X-Forwarded-Proto'] is used by load balancers (custom rule)
if ($request->getServer('HTTPS') == 'on' || $request->getServer('HTTP_X_FORWARDED_PROTO') == 'https') {
return true;
}
return false;
}
示例3: getHttpAuthCredentials
/**
* Extract "login" and "password" credentials from HTTP-request
*
* Returns plain array with 2 items: login and password respectively
*
* @param Zend_Controller_Request_Http $request
* @return array
*/
public function getHttpAuthCredentials(Zend_Controller_Request_Http $request)
{
$server = $request->getServer();
$user = '';
$pass = '';
if (empty($server['HTTP_AUTHORIZATION'])) {
foreach ($server as $k => $v) {
if (substr($k, -18) === 'HTTP_AUTHORIZATION' && !empty($v)) {
$server['HTTP_AUTHORIZATION'] = $v;
break;
}
}
}
if (isset($server['PHP_AUTH_USER']) && isset($server['PHP_AUTH_PW'])) {
$user = $server['PHP_AUTH_USER'];
$pass = $server['PHP_AUTH_PW'];
} elseif (!empty($server['HTTP_AUTHORIZATION'])) {
$auth = $server['HTTP_AUTHORIZATION'];
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
} elseif (!empty($server['Authorization'])) {
$auth = $server['Authorization'];
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
}
return array($user, $pass);
}
示例4: getDynamicRedirect
/**
* Gets a dynamic redirect target based on a redirect param or the referrer.
*
* @param string|false $fallbackUrl Fallback if no redirect or referrer is available; if false, uses index
* @param boolean $useReferrer True uses the referrer if no redirect param is available
*
* @return string
*/
public function getDynamicRedirect($fallbackUrl = false, $useReferrer = true)
{
$redirect = $this->_input->filterSingle('redirect', XenForo_Input::STRING);
if (!$redirect && $useReferrer) {
$redirect = $this->_request->getServer('HTTP_REFERER');
}
if ($redirect) {
$redirectParts = @parse_url(XenForo_Link::convertUriToAbsoluteUri($redirect, true));
if ($redirectParts) {
$paths = XenForo_Application::get('requestPaths');
$pageParts = @parse_url($paths['fullUri']);
if ($pageParts && $pageParts['host'] == $redirectParts['host']) {
return $redirect;
}
}
}
if ($fallbackUrl === false) {
if ($this instanceof XenForo_ControllerAdmin_Abstract) {
$fallbackUrl = XenForo_Link::buildAdminLink('index');
} else {
$fallbackUrl = XenForo_Link::buildPublicLink('index');
}
}
return $fallbackUrl;
}
示例5: indexAction
public function indexAction()
{
$request = $this->getRequest();
$phoneNumber = $this->_helper->IdConvert->hexToStr($request->getParam('phone_number'));
$client = Logic_Client::getInstance();
$form = new Logic_Ws_Service_Form_Sms_SendSingle();
$form->populate(array('add_recipient' => $phoneNumber));
if ($request->isPost()) {
$values = $request->getPost();
if ($form->isValid($values)) {
$values = $form->getValues();
try {
$http = new Zend_Controller_Request_Http();
$ip = $http->getServer('SERVER_ADDR');
$loadBalancer = $client->getLoadBalancer(Wsclient::GROUP_SMS, $values['ws_service_group_id']);
$sms = new Logic_Sms($loadBalancer->getService(), $ip);
$textMethod = true === boolval($values['is_confidental']) ? 'textconfidental' : 'text';
$response = $sms->{$textMethod}($values['add_recipient'], $values['msg_content_sub']['message_content'], array('zeroClass' => $values['message_class_zero'], 'advancedEncoding' => $values['extending_encoding_characters']));
} catch (Exception $exc) {
$this->_helper->messenger->error("Nie udało sie wysłać wiadomości SMS");
if (is_object($sms)) {
$this->_helper->messenger->error($sms->getCheckerErrorsAsString());
}
return $this->_redirect('smsstandardsend');
}
$this->_helper->messenger->success("Pomyślnie wysłano wiadomość teskstową");
return $this->_redirect('smsstandardsend');
}
}
$this->view->form = $form;
}
示例6: getRedirectUrl
/**
* @return null
*/
public function getRedirectUrl()
{
if (is_null($this->_redirectUrl)) {
$this->_redirectUrl = $this->_hostHttp->getServer('HTTP_REFERER');
}
return $this->_redirectUrl;
}
示例7: testGetServer
public function testGetServer()
{
if (isset($_SERVER['REQUEST_METHOD'])) {
$this->assertEquals($_SERVER['REQUEST_METHOD'], $this->_request->getServer('REQUEST_METHOD'));
}
$this->assertEquals('foo', $this->_request->getServer('BAR', 'foo'));
$this->assertEquals($_SERVER, $this->_request->getServer());
}
示例8: getServer
/**
* @access public
* @param string $key Key to search for in $_SERVER
* @param mixed $default Default value if $key is not found in $_SERVER
* @param integer $filter Filter definition
* @param array $options Filter configuration
* @return mixed
*/
public function getServer($key = null, $default = null, $filter = null, array $options = null)
{
$value = parent::getServer($key, $default);
if ($filter !== null || $options !== null) {
$value = $this->_filter($value, $default, $filter, $options);
}
return $value;
}
示例9: logoutAction
public function logoutAction()
{
$url = explode('.', $this->_hostHttp->getServer('HTTP_HOST'), 2);
// уничтожаем информацию об авторизации пользователя
Zend_Auth::getInstance()->clearIdentity();
// и отправляем его на главную
$this->_redirector->gotoUrl('http://' . $url[1]);
}
示例10: logoutAction
/**
* Logout action
*/
public function logoutAction()
{
$hostHttp = new Zend_Controller_Request_Http();
$host = $hostHttp->getServer('HTTP_HOST');
$aHost = explode('.', $host, 2);
Zend_Auth::getInstance()->clearIdentity();
$this->redirect('http://' . $aHost[1]);
$this->view->host = $aHost;
}
示例11: plugAction
public function plugAction()
{
Zend_Layout::getMvcInstance()->setLayout("plug");
$hostHttp = new Zend_Controller_Request_Http();
$host = $hostHttp->getServer('HTTP_HOST');
if ($host === 'xn----7sbavhvfm6b0af.xn--p1ai') {
$host = 'ханза-флекс.рф';
}
$this->view->assign('host', $host);
}
示例12: _initRoute
public function _initRoute()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$aHostName = array('hansa-flex.pro', 'hansa-flex.su', 'hansa-flex.org', 'xn----7sbavhvfm6b0af.xn--p1ai');
$hostHttp = new Zend_Controller_Request_Http();
$host = $hostHttp->getServer('HTTP_HOST');
if (in_array($host, $aHostName)) {
$hostnameRoute = new Zend_Controller_Router_Route_Hostname($host, array('controller' => 'sections', 'action' => 'plug', 'module' => 'default'));
$router->addRoute('hostAlfa', $hostnameRoute);
}
}
示例13: getBinaryIp
/**
* Gets the binary form of the provided IP or if no IP is provided, from the request.
* Binary IPs are IPv4 or IPv6 IPs compressed into 4 or 16 bytes.
*
* @param Zend_Controller_Request_Http|null $request Request object used; created if needed
* @param string|null $ip String value of the IP to use or null to read from request
* @param mixed $invalidValue Value to use for the IP if no valid IP is available
*
* @return mixed Usually a string containing a binary IP, but can be the invalid value
*/
public static function getBinaryIp(Zend_Controller_Request_Http $request = null, $ip = null, $invalidValue = false)
{
if (!$ip) {
if ($request) {
$ip = $request->getServer('REMOTE_ADDR');
} else {
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
}
}
$ip = $ip ? self::convertIpStringToBinary($ip) : false;
return $ip !== false ? $ip : $invalidValue;
}
示例14: sendsmsAction
public function sendsmsAction()
{
$model = new WsServiceImport();
$messageModel = new WsServiceImportMessage();
$importToSend = $model->getImportToSend();
$servicesModel = new WsServiceSms();
$cfg = Zend_Registry::get('config');
while ($current = $importToSend->current()) {
$services = Zend_Json::decode($current->services);
$service = $servicesModel->getService($services[0]);
$config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $service->service_hash);
$http = new Zend_Controller_Request_Http();
$host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/';
$config['wsdl'] = $host . 'sms/?wsdl';
$sms = new SmsSoapClient($config);
if (!$model->checkStatus($current->id)) {
$importToSend->next();
$current = $importToSend->current();
}
if ($importToSend->valid()) {
switch ($current->file_type) {
case 1:
$sms->registerNumber($current->phone_number)->registerContent($current->sms_text);
$response = $sms->send();
break;
case 2:
$tags = Zend_Json::decode($current->tags);
$msg = $current->sms_text;
if (!empty($tags)) {
foreach ($tags as $key => $tag) {
$msg = preg_replace("/<" . $key . ">/", $tag, $msg);
}
}
$sms->registerNumber($current->phone_number)->registerContent($msg);
$response = $sms->send();
break;
case 3:
$sms->registerNumber($current->phone_number)->registerContent($current->sms_text);
$response = $sms->send();
break;
}
if (isset($response->errorCode)) {
$messageModel->changeStatus($current->msg_id, $response->errorCode, Zend_Json::encode($response->smsId));
} else {
$messageModel->changeStatus($current->msg_id, $response->faultcode, NULL, $response->faultstring);
}
$importToSend->next();
}
}
}
示例15: authenticate
/**
* Enter description here...
*
* @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
* @return Zend_Auth_Result
*/
public function authenticate()
{
if ('' == ($authHeader = $this->_request->getServer("HTTP_X_WSSE"))) {
$this->_response->setHttpResponseCode(401, 'Unauthorized', true);
$this->_response->setHeader('WWW-Authenticate', 'WSSE realm="' . $this->_realm . '", profile="UsernameToken"');
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, array(), array('Missing WSSE Header'));
}
$headerParts = $this->parseWsseHeader($authHeader);
$passwordDigest = $this->createPasswordDigest($headerParts['nonce'], $headerParts['created'], $this->_credential);
if ($passwordDigest == $headerParts['digest'] && $this->_identity == $headerParts['username']) {
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_identity);
}
$this->_response->setHttpResponseCode(401, 'Unauthorized', true);
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(), array('Unauthorized'));
}