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;
 }
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * 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);
 }
Beispiel #4
0
 /**
  * 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;
 }
 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;
 }
 /**
  * @return null
  */
 public function getRedirectUrl()
 {
     if (is_null($this->_redirectUrl)) {
         $this->_redirectUrl = $this->_hostHttp->getServer('HTTP_REFERER');
     }
     return $this->_redirectUrl;
 }
Beispiel #7
0
 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());
 }
Beispiel #8
0
 /**
  * @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;
 }
 public function logoutAction()
 {
     $url = explode('.', $this->_hostHttp->getServer('HTTP_HOST'), 2);
     // уничтожаем информацию об авторизации пользователя
     Zend_Auth::getInstance()->clearIdentity();
     // и отправляем его на главную
     $this->_redirector->gotoUrl('http://' . $url[1]);
 }
 /**
  * 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;
 }
 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);
 }
 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);
     }
 }
Beispiel #13
0
 /**
  * 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;
 }
Beispiel #14
0
 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();
         }
     }
 }
Beispiel #15
0
 /**
  * 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'));
 }
Beispiel #16
0
 /**
  * Calculate Nonce
  *
  * @return string The nonce value
  */
 protected function _calcNonce()
 {
     // Once subtle consequence of this timeout calculation is that it
     // actually divides all of time into _nonceTimeout-sized sections, such
     // that the value of timeout is the point in time of the next
     // approaching "boundary" of a section. This allows the server to
     // consistently generate the same timeout (and hence the same nonce
     // value) across requests, but only as long as one of those
     // "boundaries" is not crossed between requests. If that happens, the
     // nonce will change on its own, and effectively log the user out. This
     // would be surprising if the user just logged in.
     $timeout = ceil(time() / $this->_nonceTimeout) * $this->_nonceTimeout;
     $nonce = hash('md5', $timeout . ':' . $this->_request->getServer('HTTP_USER_AGENT') . ':' . __CLASS__);
     return $nonce;
 }
 public function indexAction()
 {
     // Disable Layout
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     // Output XML than HTML
     $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=utf-8');
     $cache = Zend_Registry::get('cache');
     $hostHttp = new Zend_Controller_Request_Http();
     $host = $hostHttp->getServer('HTTP_HOST');
     $cacheName = 'sitemap_' . str_replace(array('.', '-'), '_', $host);
     //Zend_Debug::dump($cacheName);
     if (!($sitemap = $cache->load($cacheName))) {
         $sitemap = new Zend_Navigation();
         $pageMapper = new Default_Model_Mapper_Pages();
         $select = $pageMapper->getDbTable()->select();
         $pages = $pageMapper->fetchAll($select);
         if (!empty($pages)) {
             foreach ($pages as $page) {
                 if ($page->getPath() != '') {
                     $url = $page->getPath() != 'home' ? $page->getPath() . '/' : '';
                     $sitemap->addPage(array('type' => 'uri', 'uri' => '/' . $url));
                 }
             }
         }
         $sitemap->addPages(array(array('type' => 'uri', 'uri' => '/search/')));
         $catalogCategoriesMapper = new Catalog_Model_Mapper_Categories();
         $this->_addPagesSitemap($sitemap, $catalogCategoriesMapper);
         $catalogProductsMapper = new Catalog_Model_Mapper_Products();
         $this->_addPagesSitemap($sitemap, $catalogProductsMapper);
         $manufactureCategoriesMapper = new Manufacture_Model_Mapper_ManufactureCategories();
         $this->_addPagesSitemap($sitemap, $manufactureCategoriesMapper);
         $manufactureMapper = new Manufacture_Model_Mapper_Manufacture();
         $this->_addPagesSitemap($sitemap, $manufactureMapper);
         $oilMapper = new Oil_Model_Mapper_Oil();
         $this->_addPagesSitemap($sitemap, $oilMapper);
         $sitemap->addPages(array(array('type' => 'uri', 'uri' => '/forum/question/'), array('type' => 'uri', 'uri' => '/forum/review/'), array('type' => 'uri', 'uri' => '/forum/gravamen/')));
         $mediaCategoriesMapper = new Media_Model_Mapper_MediaCategories();
         $this->_addPagesSitemap($sitemap, $mediaCategoriesMapper);
         $mediaMapper = new Media_Model_Mapper_Media();
         $this->_addPagesSitemap($sitemap, $mediaMapper);
         $cache->save($sitemap, $cacheName, array('sitemap'));
     }
     $this->view->navigation($sitemap);
     // Output the data.
     echo $this->view->navigation()->sitemap();
 }
Beispiel #18
0
 /**
  * Attempts to determine whether the request is referred from the same host
  *
  * @return boolean
  */
 protected function _isSelfReferer()
 {
     if ($referer = $this->_request->getServer('HTTP_REFERER')) {
         $refererParts = @parse_url($referer);
         if ($refererParts && !empty($refererParts['host'])) {
             $paths = XenForo_Application::get('requestPaths');
             $requestParts = @parse_url($paths['fullUri']);
             if ($requestParts && !empty($requestParts['host'])) {
                 if ($refererParts['host'] != $requestParts['host']) {
                     // referer is not the same as request host
                     return false;
                 }
             }
         }
     }
     // either we have the same host and referer, or we just don't know...
     return true;
 }
Beispiel #19
0
 public function checkstatusAction()
 {
     $this->_helper->getHelper('ViewRenderer')->setNoRender(true);
     $request = $this->getRequest();
     $id = $this->_helper->IdConvert->hexToStr($request->getParam('id'));
     if (empty($id)) {
         $this->_helper->messenger->error('Nie podano parametru ID');
         return null;
     }
     try {
         $smsInfo = $this->_model->getSmsInfo($id);
         $cfg = Zend_Registry::get('config');
         $config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $smsInfo->service_hash);
         $http = new Zend_Controller_Request_Http();
         $host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/';
         switch ($values['env_type']) {
             case '1':
                 $config['wsdl'] = $host . 'sms/?wsdl';
                 break;
             default:
                 $config['wsdl'] = $host . 'sms/?wsdl';
         }
         $sms = new SmsSoapClient($config);
         $sms->registerSmsIDManyRaw($smsInfo->smsid);
         $response = $sms->getSmsInfoMany();
         foreach ($response as $r) {
             if ($r->errorCode == 0) {
                 $message .= "SMS o ID:" . $r->smsId . " został wysłany";
             } else {
                 $message .= "SMS o ID: " . $r->smsId . " nie został wysłany: " . $r->errorMessage . '(' . $r->errorCode . ')';
             }
         }
         $this->_helper->messenger->info($message);
         $this->_redirect($this->getRequest()->getHeader('referer'));
         return;
     } catch (Exception $ex) {
         $this->_helper->messenger->error();
         $this->_redirect($this->getRequest()->getHeader('referer'));
     }
 }
Beispiel #20
0
 /**
  * See if the request has the proper remote address
  *
  * @param  Zend_Controller_Request_Http $request The request to check
  * @return boolean
  */
 public function isValid($request)
 {
     if (!empty($this->_ipAddresses)) {
         $remoteaddr = getremoteaddr();
         // Check for localhost IPv6
         if (empty($remoteaddr) and $request->getServer('REMOTE_ADDR') == '::1') {
             $remoteaddr = '127.0.0.1';
         }
         // Can get get the remote address ?
         if (empty($remoteaddr)) {
             $this->_setValue($request->getServer('REMOTE_ADDR'));
             $this->_error(self::NOT_FOUND);
             return false;
         }
         // Address valid ?
         if (!address_in_subnet($remoteaddr, $this->_ipAddresses)) {
             $this->_setValue($remoteaddr);
             $this->_error(self::NOT_VALID);
             return false;
         }
     }
     return true;
 }
Beispiel #21
0
 /**
  * Returns the common information available without data
  *
  * @param Zend_Controller_Request_Http $request Request data from the controller
  *
  * @return array commonData
  */
 protected function getUserData($request)
 {
     $server = $request->getServer();
     $agent = $server->get('HTTP_USER_AGENT');
     $parts = explode(' ', $this->getBrowser($agent));
     $browser = $parts[0];
     $version = isset($parts[1]) ? $parts[1] : '';
     return ['id' => uniqid('', true), 'datestamp' => substr(date('c', strtotime('now')), 0, -6) . 'Z', 'browser' => $browser, 'browserVersion' => $version, 'ipaddress' => $server->get('REMOTE_ADDR'), 'referrer' => $server->get('HTTP_REFERER') == null ? 'Manual' : $server->get('HTTP_REFERER'), 'url' => $server->get('REQUEST_URI'), 'session' => $this->sessId];
 }
 /** redirect of the user due to no action existing.
  */
 public function indexAction()
 {
     $this->_flashMessenger->addMessage('There is not a root action for jettons');
     $this->_redirect(Zend_Controller_Request_Http::getServer('referer'));
 }
 /**
  * Runs the request, handling from routing straight through to response output.
  * Primary method to be used by the external API.
  *
  * @return string|null Returns a string if {@link $_sendResponse} is false
  */
 public function run()
 {
     ob_start();
     XenForo_Application::set('fc', $this);
     $this->setup();
     $this->setRequestPaths();
     $showDebugOutput = $this->showDebugOutput();
     $this->_dependencies->preLoadData();
     XenForo_CodeEvent::fire('front_controller_pre_route', array($this));
     $routeMatch = $this->route();
     XenForo_CodeEvent::fire('front_controller_pre_dispatch', array($this, &$routeMatch));
     $controllerResponse = $this->dispatch($routeMatch);
     if (!$controllerResponse) {
         XenForo_Error::noControllerResponse($routeMatch, $this->_request);
         exit;
     }
     $viewRenderer = $this->_getViewRenderer($routeMatch->getResponseType());
     if (!$viewRenderer) {
         // note: should only happen if there's an error getting the default renderer, which should never happen :)
         XenForo_Error::noViewRenderer($this->_request);
         exit;
     }
     $containerParams = array('majorSection' => $routeMatch->getMajorSection(), 'minorSection' => $routeMatch->getMinorSection());
     XenForo_CodeEvent::fire('front_controller_pre_view', array($this, &$controllerResponse, &$viewRenderer, &$containerParams));
     $content = $this->renderView($controllerResponse, $viewRenderer, $containerParams);
     if ($showDebugOutput) {
         $content = $this->renderDebugOutput($content);
     }
     $bufferedContents = ob_get_contents();
     ob_end_clean();
     if ($bufferedContents !== '' && is_string($content)) {
         if (preg_match('#<body[^>]*>#sU', $content, $match)) {
             $content = str_replace($match[0], $match[0] . $bufferedContents, $content);
         } else {
             $content = $bufferedContents . $content;
         }
     }
     XenForo_CodeEvent::fire('front_controller_post_view', array($this, &$content));
     if ($this->_sendResponse) {
         $headers = $this->_response->getHeaders();
         $isText = false;
         foreach ($headers as $header) {
             if ($header['name'] == 'Content-Type') {
                 if (strpos($header['value'], 'text/') === 0) {
                     $isText = true;
                 }
                 break;
             }
         }
         if ($isText && is_string($content) && $content) {
             $extraHeaders = XenForo_Application::gzipContentIfSupported($content);
             foreach ($extraHeaders as $extraHeader) {
                 $this->_response->setHeader($extraHeader[0], $extraHeader[1], $extraHeader[2]);
             }
         }
         if (is_string($content) && $content && !ob_get_level() && XenForo_Application::get('config')->enableContentLength) {
             if ($this->_response->getHttpResponseCode() >= 400 && strpos($this->_request->getServer('HTTP_USER_AGENT', ''), 'IEMobile') !== false) {
                 // Windows mobile bug - 400+ errors cause the standard browser error
                 // to be output if a content length is sent. ...Err, what?
             } else {
                 $this->_response->setHeader('Content-Length', strlen($content), true);
             }
         }
         $this->_response->sendHeaders();
         if ($content instanceof XenForo_FileOutput) {
             $content->output();
         } else {
             echo $content;
         }
     } else {
         return $content;
     }
 }
Beispiel #24
0
 /**
  * return request params
  * 
  * @return array
  */
 protected function _getRequestParameters()
 {
     $result = array('protocolVersion' => $this->_request->getServer('HTTP_MS_ASPROTOCOLVERSION'), 'command' => $this->_request->getParam('Cmd'), 'deviceId' => $this->_request->getParam('DeviceId'), 'deviceType' => $this->_request->getParam('DeviceType'));
     return $result;
 }
Beispiel #25
0
 protected function _checkAkismet($content, array $extraParams, Zend_Controller_Request_Http $request)
 {
     $options = XenForo_Application::getOptions();
     $visitor = XenForo_Visitor::getInstance();
     $result = self::RESULT_ALLOWED;
     if ($options->akismetKey) {
         $akismetParams = array('user_ip' => $request->getClientIp(false), 'user_agent' => $request->getServer('HTTP_USER_AGENT', 'Unknown'), 'referrer' => $request->getServer('HTTP_REFERER'), 'comment_type' => 'comment', 'comment_author' => $visitor['username'], 'comment_author_email' => $visitor['email'], 'comment_author_url' => $visitor['homepage'], 'comment_content' => $content);
         if (isset($extraParams['permalink'])) {
             $akismetParams['permalink'] = $extraParams['permalink'];
         }
         $akismet = new Zend_Service_Akismet($options->akismetKey, $options->boardUrl);
         try {
             $this->_checkParams['akismetIsSpam'] = $akismet->isSpam($akismetParams);
             $this->_checkParams['akismet'] = $akismetParams;
             if ($this->_checkParams['akismetIsSpam']) {
                 $result = self::RESULT_MODERATED;
                 $this->_resultDetails[] = array('phrase' => 'akismet_matched');
             }
         } catch (Zend_Http_Exception $e) {
         } catch (Zend_Service_Exception $e) {
         }
     }
     return $result;
 }
Beispiel #26
0
 /**
  * Returns the common information available without data
  *
  * @param Zend_Controller_Request_Http $request Request data from the controller
  *
  * @return array commonData
  */
 protected function getUserData($request)
 {
     $server = $request->getServer();
     $agent = $server->get('HTTP_USER_AGENT');
     list($browser, $version) = explode(' ', $this->getBrowser($agent));
     return array('id' => uniqid('', true), 'datestamp' => substr(date('c', strtotime('now')), 0, -6) . 'Z', 'browser' => $browser, 'browserVersion' => $version, 'ipaddress' => $server->get('REMOTE_ADDR'), 'referrer' => $server->get('HTTP_REFERER') == null ? 'Manual' : $server->get('HTTP_REFERER'), 'url' => $server->get('REQUEST_URI'), 'session' => $this->getServiceLocator()->get('SessionManager')->getId());
 }
Beispiel #27
0
 /**
  * Analyze user-agent information to override custom design settings
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 protected function _applyUserAgentDesignException($request)
 {
     $userAgent = $request->getServer('HTTP_USER_AGENT');
     if (empty($userAgent)) {
         return false;
     }
     try {
         $expressions = Mage::getStoreConfig('design/theme/ua_regexp');
         if (!$expressions) {
             return false;
         }
         $expressions = unserialize($expressions);
         foreach ($expressions as $rule) {
             if (preg_match($rule['regexp'], $userAgent)) {
                 $this->_getDesign()->setDesignTheme($rule['value']);
                 return true;
             }
         }
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return false;
 }
Beispiel #28
0
 /**
  * Gets the request paths from the specified request object.
  *
  * @param Zend_Controller_Request_Http $request
  *
  * @return array Keys: basePath, host, protocol, fullBasePath, requestUri
  */
 public static function getRequestPaths(Zend_Controller_Request_Http $request)
 {
     $basePath = $request->getBasePath();
     if ($basePath === '' || substr($basePath, -1) != '/') {
         $basePath .= '/';
     }
     $host = $request->getServer('HTTP_HOST');
     if (!$host) {
         $host = $request->getServer('SERVER_NAME');
         $serverPort = intval($request->getServer('SERVER_PORT'));
         if ($serverPort && $serverPort != 80 && $serverPort != 443) {
             $host .= ':' . $serverPort;
         }
     }
     $protocol = $request->isSecure() ? 'https' : 'http';
     $requestUri = $request->getRequestUri();
     return array('basePath' => $basePath, 'host' => $host, 'protocol' => $protocol, 'fullBasePath' => $protocol . '://' . $host . $basePath, 'requestUri' => $requestUri, 'fullUri' => $protocol . '://' . $host . $requestUri);
 }
Beispiel #29
0
 /**
  * Do some checks before install.
  *
  * @throws Expeption If the server don't have the requirements.
  *
  * @return void
  */
 private function _checkServer()
 {
     // Check the server
     $checkServer = Phprojekt::checkExtensionsAndSettings();
     // Check the PHP version
     if (!$checkServer['requirements']['php']['checked']) {
         $missingRequirements[] = "You need the PHP Version " . $checkServer['requirements']['php']['required'] . " or newer. Follow this link for help: <a href=\"" . $checkServer['requirements']['php']['help'] . "\"" . " target=\"_new\">HELP</a>";
     }
     // Check required extension
     foreach ($checkServer['requirements']['extension'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "The '" . $name . "' extension must be enabled. Follow this link for help: " . "<a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>";
         }
     }
     // Check required settings
     foreach ($checkServer['requirements']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "The php.ini setting of '" . $name . "' has to be '" . $values['required'] . "'. Follow this link for help: <a href=\"" . $values['help'] . "\"" . " target=\"_new\">HELP</a>";
         }
     }
     // Checking if configuration.php exists
     $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']);
     if (file_exists($baseDir . "configuration.php")) {
         throw new Exception("Configuration file found. Please, delete it before run setup again.");
     }
     if (!empty($missingRequirements)) {
         $message = implode("\n", $missingRequirements);
         throw new Exception($message);
     }
     if (strncmp($_SERVER['SCRIPT_NAME'], '/setup.php', 10) != 0) {
         $this->_message[] = "It is recommend install PHProjekt 6 using a virtual host.<br />" . "You should try to generate an extra virtual host (or a sub-domain) to phprojekt/htdocs.";
         // Works the .htaccess?
         $response = new Zend_Controller_Request_Http();
         $webpath = $response->getHttpHost();
         $str = '';
         $sock = fsockopen($webpath, $response->getServer('SERVER_PORT'));
         $request = "GET " . str_replace('htdocs/setup.php', '', $response->getRequestUri()) . '/application/' . " HTTP/1.1\r\n" . "Host: " . $webpath . "\r\nConnection: close\r\n\r\n";
         fwrite($sock, $request);
         while ($buff = fread($sock, 1024)) {
             $str .= $buff;
         }
         $response = Zend_Http_Response::fromString($str);
         if ($response->getStatus() != '403') {
             $this->_message[] = "Please note that your webserver needs to support .htaccess files " . "to deny access to the configuration files.<br />" . "Running PHProjekt 6 without using the provided .htaccess files to deny access to " . "certain files and folders, might not be secure and is not recommended.";
         }
         fclose($sock);
     }
     foreach ($checkServer['recommendations']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $this->_message[] = "It is recommend to have '" . $name . "' set to '" . $values['required'] . "', but it is not required to run PHProjekt. Follow this link for help: <a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>";
         }
     }
 }
Beispiel #30
0
 /**
  * @return void
  */
 public function indexAction()
 {
     $form = new Logic_Ws_Sms_Tester_Form_Generic();
     $response = null;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $values = $form->getValues();
             $cfg = Zend_Registry::get('config');
             $config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $values['sms_account']);
             $http = new Zend_Controller_Request_Http();
             $host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/';
             switch ($values['env_type']) {
                 case '1':
                     $config['wsdl'] = $host . 'sms/?wsdl';
                     break;
                 default:
                     $config['wsdl'] = $host . 'sms/?wsdl';
             }
             $sms = new SmsSoapClient($config);
             if ($values['confidental_type'] == 'on') {
                 $sms->setConfidental(true);
             }
             try {
                 switch ($values['sms_mode']) {
                     case 'info':
                         $sms->registerSmsID($values['sms_id']);
                         $response = $this->_dump($sms->getSmsInfo());
                         break;
                     case 'infomany':
                         $sms->registerSmsIDManyRaw($values['sms_ids']);
                         $response = $this->_dump($sms->getSmsInfoMany());
                         break;
                     case 'package':
                         $sms->registerContent($values['sms_content'])->setPackageRecipients($this->_explode($values['package_recipients']));
                         $response = $this->_dump($sms->send());
                         break;
                     case 'packageinfo':
                         $sms->registerPackageID($values['package_id']);
                         $response = $this->_dump($sms->getPackageInfo());
                         break;
                     case 'template':
                         $sms->registerNumber($values['recipient_number'])->registerTemplate($values['template_name'], $values['sms_content'], $this->_explode($values['template_params']), $this->_explode($values['template_params_conf']));
                         switch ($values['template_mode']) {
                             case '1':
                                 $sms->setTemplateNew(true);
                                 break;
                             case '2':
                                 $sms->setTemplateForceUpdate(true);
                                 break;
                             default:
                         }
                         $response = $this->_dump($sms->send());
                         break;
                     case 'text':
                         $sms->registerNumber($values['recipient_number'])->registerContent($values['sms_content']);
                         $response = $this->_dump($sms->send());
                         break;
                     default:
                         // do nothing.
                 }
             } catch (Exception $e) {
                 $response = $this->_dump(array('Komunikat' => $e->getCode() . ':: ' . $e->getMessage()));
             }
         }
     }
     $this->view->form = $form;
     $this->view->response = $response;
 }