Пример #1
0
 public function preDispatch()
 {
     $this->Front()->Plugins()->ViewRenderer()->setNoRender();
     // todo@bc set url in shopware specific way
     $serverUrlHelper = new Zend_View_Helper_ServerUrl();
     $this->apiBaseUrl = $serverUrlHelper->serverUrl() . $this->Request()->getBaseUrl() . '/api/';
 }
 public function rejestracjaAction()
 {
     $form = new Form_Register();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $data = $form->getValues();
             $model = new Model_User();
             $model->setFirstname($data['firstname']);
             $model->setLastname($data['lastname']);
             $model->setUsername($data['username']);
             $model->setPassword(md5($data['password']));
             $model->setEmail($data['email']);
             $mapper = Model_UserMapper::getInstance();
             $mapper->save($model);
             $this->createConfig($data['username']);
             $server = new Zend_View_Helper_ServerUrl();
             $server->setScheme('http');
             $this->_redirect($server->serverUrl($this->view->url(array('controller' => 'autentykacja', 'action' => 'logowanie'))));
             //                $this->_redirect('/autentykacja/logowanie');
         } else {
             $this->view->errorMessage = 'Nie uzupełniono wymaganych pól.';
         }
     }
     $this->view->form = $form;
 }
 public function wylogowanieAction()
 {
     Zend_Auth::getInstance()->clearIdentity();
     $server = new Zend_View_Helper_ServerUrl();
     $server->setScheme('http');
     $this->_redirect($server->serverUrl($this->view->url(array('controller' => 'index', 'action' => 'index'))));
     //        $this->_redirect('/');
 }
Пример #4
0
 /**
  * Construct current server URL (optionally with request data)
  *
  * @param array $userParams Options passed by a user used to override parameters
  */
 public static function getAbsoluteUrl(array $userParams = array())
 {
     $helper = new Zend_View_Helper_ServerUrl();
     $url = $helper->serverUrl();
     if ($userParams) {
         $router = Zend_Controller_Front::getInstance()->getRouter();
         $url = rtrim($url, '/') . '/' . ltrim($router->assemble($userParams, null, true), '/');
     }
     return $url;
 }
Пример #5
0
 /**
  * Initialize registry
  *
  * @return bool
  */
 protected function _initRegistry()
 {
     Zend_Registry::set('config', new Zend_Config($this->getOptions(), true));
     Zend_Registry::set('version', Rexmac\Zyndax\Version\Version::VERSION);
     Zend_Registry::set('build', Rexmac\Zyndax\Version\Version::BUILD);
     Zend_Registry::set('siteName', $this->getOption('siteName'));
     Zend_Registry::set('staticSalt', $this->getOption('staticSalt'));
     $view = new Zend_View_Helper_ServerUrl();
     Zend_Registry::set('siteDomain', preg_replace('/^https?:\\/\\//', '', $view->serverUrl()));
     return true;
 }
 public function getAkismetData()
 {
     $serverUrlHelper = new Zend_View_Helper_ServerUrl();
     $permalink = $serverUrlHelper->serverUrl() . $this->path;
     $data = array('user_ip' => $this->ip, 'user_agent' => $this->user_agent, 'permalink' => $permalink, 'comment_type' => 'comment', 'comment_author_email' => $this->author_email, 'comment_content' => $this->body);
     if ($this->author_url) {
         $data['comment_author_url'] = $this->author_url;
     }
     if ($this->author_name) {
         $data['comment_author_name'] = $this->author_name;
     }
     return $data;
 }
Пример #7
0
/**
 * 2016-03-09
 * Портировал из РСМ.
 * @param int|string|null|bool|StoreInterface $store [optional]
 * @return string|null
 */
function df_domain($store = null)
{
    return dfcf(function ($store = null) {
        /** @var string $result */
        $store = df_store($store);
        /** @var string|null $baseUrl */
        // Может вернуть null, если в БД отсутствует значение соответствующей опции.
        $baseUrl = $store->getBaseUrl();
        if ($baseUrl) {
            try {
                $result = df_zuri($baseUrl)->getHost();
                df_assert_string_not_empty($result);
            } catch (Exception $e) {
            }
        }
        if (!$result) {
            /** @var \Zend_View_Helper_ServerUrl $helper */
            $helper = new \Zend_View_Helper_ServerUrl();
            /** @var string|null $result */
            // Может вернуть null, если Magento запущена с командной строки (
            // например, планировщиком задач)
            $result = $helper->getHost();
        }
        return $result;
    }, func_get_args());
}
Пример #8
0
 private function _update_robots()
 {
     $serverUrlHelper = new Zend_View_Helper_ServerUrl();
     $serverUrl = $serverUrlHelper->serverUrl();
     $sitemap_uri = $serverUrl . public_url('sitemap.xml');
     //update the site robots.txt file so it lists the sitemap
     // options for robots file
     $mapdef = "\n#START XML-SITEMAP-PLUGIN\n";
     $mapdef .= "Sitemap: " . $sitemap_uri . "\n";
     $mapdef .= "#END XML-SITEMAP-PLUGIN\n";
     // open file
     $robotspath = BASE_DIR . "/robots.txt";
     if (is_writeable($robotspath)) {
         $robotsfile = fopen($robotspath, 'a');
         //write to file
         fwrite($robotsfile, $mapdef);
         //close file
         fclose($robotsfile);
     } else {
         echo "Robots.txt file is not writeable";
     }
 }
Пример #9
0
 public function toRdf($forOAI = false)
 {
     $helper = new Zend_View_Helper_ServerUrl();
     $about = $helper->serverUrl('/api/institution/' . $this->code);
     $data = array();
     foreach ($this as $key => $val) {
         $data[$key] = htmlspecialchars($val);
     }
     $doc = self::getRdfDocument($forOAI);
     $rootNode = true === $forOAI ? $doc->documentElement->firstChild : $doc->documentElement;
     $VCard = $rootNode->appendChild($doc->createElement('v:Vcard'));
     $VCard->setAttribute('rdf:about', $about);
     $VCard->appendChild($doc->createElement('v:fn', $data['name']));
     if ($this->website) {
         $VCard->setAttribute('v:url', $this->website);
     }
     $node = $VCard->appendChild($doc->createElement('rdf:Description'));
     $node->appendChild($doc->createElement('v:organisation-name', $data['name']));
     if ($this->organisationUnit) {
         $node->appendChild($doc->createElement('v:organisation-unit', $data['organisationUnit']));
     }
     if ($this->email) {
         $VCard->appendChild($doc->createElement('v:email'))->setAttribute('rdf:about', 'mailto:' . $this->email);
     }
     $adr = $doc->createElement('v:adr');
     foreach (array('street-address', 'locality', 'postal-code', 'country-name') as $name) {
         $dbName = preg_replace_callback('/\\-([a-z])/', create_function('$matches', 'return strtoupper($matches[1]);'), $name);
         if ($this->{$dbName}) {
             $adr->appendChild($doc->createElement('v:' . $name, $data[$dbName]));
         }
     }
     if ($adr->childNodes->length) {
         $VCard->appendChild($adr);
     }
     return $doc;
 }
Пример #10
0
/**
 * Get an absolute URL.
 *
 * This is necessary because Zend_View_Helper_Url returns relative URLs, though
 * absolute URLs are required in some contexts. Instantiates view helpers
 * directly because a view may not be registered.
 *
 * @package Omeka\Function\View\Navigation
 * @uses Zend_View_Helper_ServerUrl::serverUrl()
 * @uses Omeka_View_Helper_Url::url()
 * @param mixed $options If a string is passed it is treated as an
 *  Omeka-relative link. So, passing 'items' would create a link to the items
 *  page. If an array is passed (or no argument given), it is treated as options
 *  to be passed to Omeka's routing system.
 * @param string $route The route to use if an array is passed in the first argument.
 * @param mixed $queryParams A set of query string parameters to append to the URL
 * @param bool $reset Whether Omeka should discard the current route when generating the URL.
 * @param bool $encode Whether the URL should be URL-encoded
 * @return string HTML
 */
function absolute_url($options = array(), $route = null, $queryParams = array(), $reset = false, $encode = true)
{
    $serverUrlHelper = new Zend_View_Helper_ServerUrl();
    $urlHelper = new Omeka_View_Helper_Url();
    return $serverUrlHelper->serverUrl() . $urlHelper->url($options, $route, $queryParams, $reset, $encode);
}
Пример #11
0
 /**
  * Returns href for this page
  *
  * This method uses {@link Zend_Controller_Action_Helper_Url} to assemble
  * the href based on the page's properties.
  *
  * @return string  page href
  */
 public function getHref()
 {
     if ($this->_hrefCache) {
         return $this->_hrefCache;
     }
     if (null === self::$_urlHelper) {
         self::$_urlHelper = \Zend_Controller_Action_HelperBroker::getStaticHelper('Url');
     }
     $params = $this->getParams();
     if ($param = $this->getModule()) {
         $params['module'] = $param;
     }
     if ($param = $this->getController()) {
         $params['controller'] = $param;
     }
     if ($param = $this->getAction()) {
         $params['action'] = $param;
     }
     $url = self::$_urlHelper->url($params, $this->getRoute(), $this->getResetParams(), $this->getEncodeUrl());
     // Use scheme?
     $scheme = $this->getScheme();
     if (null !== $scheme) {
         if (null === self::$_schemeHelper) {
             self::$_schemeHelper = new \Zend_View_Helper_ServerUrl();
         }
         $url = self::$_schemeHelper->setScheme($scheme)->serverUrl($url);
     }
     // Add the fragment identifier if it is set
     $fragment = $this->getFragment();
     if (null !== $fragment) {
         $url .= '#' . $fragment;
     }
     return $this->_hrefCache = $url;
 }
Пример #12
0
 /**
  * @group ZF-9919
  */
 public function testServerUrlWithPort()
 {
     $_SERVER['SERVER_PORT'] = 443;
     $_SERVER['HTTP_HOST'] = 'example.com';
     $url = new Zend_View_Helper_ServerUrl();
     $this->assertEquals('https://example.com', $url->serverUrl());
 }
Пример #13
0
 public function testServerUrlWithObject()
 {
     $_SERVER['HTTPS'] = 'off';
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['REQUEST_URI'] = '/foo.html';
     $url = new Zend_View_Helper_ServerUrl();
     $this->assertEquals('http://example.com', $url->serverUrl(new stdClass()));
 }
 /**
  * Accessible via formList as defined in the menu and standard for openRosa clients
  */
 public function formlistAction()
 {
     //first create the baseurl of the form http(s)://projecturl/openrosa/download/form/
     $helper = new \Zend_View_Helper_ServerUrl();
     $baseUrl = $helper->serverUrl() . \Zend_Controller_Front::getInstance()->getBaseUrl() . '/openrosa/download/form/';
     //As we don't have forms defined yet, we pass in an array, but ofcourse this should be dynamic
     //and come from a helper method
     $model = $this->getModel();
     $rawForms = $model->load(array('gof_form_active' => 1));
     foreach ($rawForms as $form) {
         $forms[] = array('formID' => $form['gof_form_id'], 'name' => $form['gof_form_title'], 'version' => $form['gof_form_version'], 'hash' => md5($form['gof_form_id'] . $form['gof_form_version']), 'downloadUrl' => $baseUrl . $form['gof_form_xml']);
     }
     //Now make it a rosaresponse
     $this->makeRosaResponse();
     $xml = $this->getXml('xforms xmlns="http://openrosa.org/xforms/xformsList"');
     foreach ($forms as $form) {
         $xform = $xml->addChild('xform');
         foreach ($form as $key => $value) {
             $xform->addChild($key, $value);
         }
     }
     echo $xml->asXML();
 }
 /**
  * Gets configured OAuth2 Client Provider.
  * @param string $provider
  * @return \League\OAuth2\Client\Provider\Google
  */
 protected function _getOAuth2Provider()
 {
     $request = $this->getRequest();
     $serverUrl = new Zend_View_Helper_ServerUrl();
     // When provider is google - we are using the normal oAuth2.0 endpoint for google.
     // We do not use OpenId Connect endpoint at that point. It constantly was giving "limit reached" errors.
     // A GoogleOpenId provider with the openIdConnect endpoints can be created to replace the normal oAuth provider if needed.
     $provider = $request->getParam('provider');
     $oAuth2Options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('oAuth2');
     if (!isset($oAuth2Options[$provider]) || !isset($oAuth2Options[$provider]['clientId']) || !isset($oAuth2Options[$provider]['clientSecret'])) {
         throw new \Exception('OAuth 2.0 configuration for provider "' . $provider . '" not found in application.ini or is wrong.');
     }
     $providerClass = '\\League\\OAuth2\\Client\\Provider\\' . ucfirst($provider);
     return new $providerClass(['clientId' => $oAuth2Options[$provider]['clientId'], 'clientSecret' => $oAuth2Options[$provider]['clientSecret'], 'scopes' => ['email'], 'redirectUri' => $serverUrl->serverUrl() . $this->getHelper('url')->url(['module' => 'editor', 'controller' => 'login', 'action' => 'oauth2-callback', 'provider' => $provider, 'rememberme' => $request->getParam('rememberme', 0)], 'default', true)]);
 }
Пример #16
0
 public function preDispatch()
 {
     $this->Front()->Plugins()->ViewRenderer()->setNoRender();
     $serverUrlHelper = new Zend_View_Helper_ServerUrl();
     $this->apiBaseUrl = $serverUrlHelper->serverUrl() . $this->Request()->getBaseUrl() . '/api/';
 }
Пример #17
0
 public function resetpasswordAction()
 {
     /* @var $translate Zend_Translate */
     $translate = Zend_Registry::get('Zend_Translate');
     try {
         $frmAccount = new Acl_Form_Account();
         $this->view->frmAccount = $frmAccount;
         $frmAccount->removeElement('fullname');
         $frmAccount->removeElement('email_alternative');
         $frmAccount->removeElement('role_id');
         $frmAccount->getElement('email')->removeValidator('Db_NoRecordExists');
         $frmAccount->getElement('submit')->setLabel('ACL_SEND');
         $change = intval($this->getRequest()->getParam('change', 0));
         if ($change == 1) {
             $hashtoken = $frmAccount->createElement('textarea', 'ht');
             $hashtoken->setAttrib('cols', 10);
             $hashtoken->setAttrib('rows', 5);
             $hashtoken->setLabel('ACL_VERIFICATION_CODE');
             $hashtoken->addFilter(new Zend_Filter_StringTrim());
             $hashtoken->addFilter(new Zend_Filter_Alnum());
             $hashtoken->addValidator(new Zend_Validate_Alnum());
             $hashtoken->addValidator(new Zend_Validate_NotEmpty());
             $hashtoken->setOrder($frmAccount->getElement('email')->getOrder() + 1);
             $frmAccount->addElement($hashtoken);
             $frmAccount->getElement('password')->setLabel("ACL_NEW_PASSWORD");
             $frmAccount->setAction($this->_request->getBaseUrl() . "/changepassword");
         } else {
             $frmAccount->removeElement('password');
             $frmAccount->removeElement('password2');
             $frmAccount->setAction($this->_request->getBaseUrl() . "/resetpassword");
         }
         if ($this->getRequest()->isPost()) {
             if ($frmAccount->isValid($_POST)) {
                 $mdlAccount = new Acl_Model_Account();
                 $account = $mdlAccount->getByEmail($frmAccount->getValue('email'));
                 if ($account) {
                     if ($change == 0) {
                         $salt = hash('SHA512', md5($account->email . '.' . uniqid(rand(), TRUE)) . time() . '.' . $account->id);
                         $account->recoverpwdtoken = $salt;
                         $account->save();
                         $options = Zend_Registry::get('options');
                         $projectName = $options['resources']['layout']['projectname'];
                         $emailSupport = $options['resources']['layout']['email_support'];
                         $emailSupportName = $options['resources']['layout']['email_support_name'];
                         $serverurl = new Zend_View_Helper_ServerUrl();
                         $msg = sprintf($translate->translate("ACL_PASSWORD_RESET_REQUEST_BODY"), $projectName, $serverurl->serverUrl() . '/changepassword', $salt, $emailSupport);
                         $mail = new Zend_Mail();
                         $mail->setBodyHtml($msg);
                         $mail->setFrom($emailSupport, $emailSupportName);
                         $mail->addTo($account->email, $account->fullname);
                         $mail->setSubject($translate->translate('ACL_PASSWORD_RESET_EMAIL_SUBJECT'));
                         $mail->send();
                         $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("ACL_VALIDATION_CODE_SENT_MESSAGE")));
                         $this->_helper->redirector("changepassword", "account", "acl");
                     } else {
                         if (strcasecmp($account->recoverpwdtoken, $frmAccount->getValue('ht')) == 0) {
                             $account->password = crypt($frmAccount->getValue('password'), '$6$5000$' . $salt . '$');
                             $account->recoverpwdtoken = "";
                             $account->save();
                             $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("ACL_PASSWORD_CHANGED")));
                             $this->_helper->redirector("login", "authentication", "acl");
                         } else {
                             $account->recoverpwdtoken = "";
                             $account->save();
                             $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $translate->translate("ACL_VALIDATION_CODE_INVALID")));
                             $this->_helper->redirector("resetpassword", "account", "acl");
                         }
                     }
                 } else {
                     throw new Exception("");
                 }
             }
         }
     } catch (Exception $e) {
         #echo $e->getMessage();
         $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $translate->translate("ACL_ERROR_ON_RESET_PASSWORD")));
         $this->_helper->redirector("resetpassword", "account", "acl");
     }
     return;
 }
Пример #18
0
 public function toRdf($withCreator = true)
 {
     $helper = new Zend_View_Helper_ServerUrl();
     $about = $helper->serverUrl('/api/collection/' . $this->getId());
     $data = array();
     foreach ($this as $key => $val) {
         $data[$key] = htmlspecialchars($val);
     }
     $doc = self::getRdfDocument();
     $root = $doc->documentElement->appendChild($doc->createElement('rdf:Description'));
     $root->setAttribute('rdf:about', $about);
     $root->appendChild($doc->createElement('rdf:type'))->setAttribute('rdf:resource', 'http://www.w3.org/2002/07/owl#Ontology');
     $root->appendChild($doc->createElement('dcterms:title', $data['dc_title']));
     if ($data['dc_description']) {
         $root->appendChild($doc->createElement('dcterms:description', $data['dc_description']));
     }
     if ($data['license_name'] || $data['license_url']) {
         $node = $root->appendChild($doc->createElement('dcterms:licence', @$data['license_name']));
         if ($data['license_url']) {
             $node->setAttribute('rdf:about', $data['license_url']);
         }
     }
     if ($data['website']) {
         $doc->documentElement->setAttribute('xmlns:owl', 'http://www.w3.org/2002/07/owl#');
         $node = $doc->createElement('owl:sameAs');
         $node->setAttribute('rdf:about', $data['website']);
         $root->appendChild($node);
     }
     if ($withCreator) {
         $tenant = $this->getTenant();
         $root->appendChild($doc->createElement('dcterms:creator', htmlspecialchars($tenant->name)))->setAttribute('rdf:about', $helper->serverUrl('/api/institution/' . $tenant->code));
     }
     return $doc;
 }