public function checkRights($module, $action) { if ($module == 'frontend' && waRequest::param('ssl') && (strpos($action, 'my') === 0 || $action === 'checkout')) { if (!waRequest::isHttps()) { $url = 'https://' . waRequest::server('HTTP_HOST') . wa()->getConfig()->getCurrentUrl(); wa()->getResponse()->redirect($url, 301); } } elseif ($module == 'order' || $module == 'orders') { return wa()->getUser()->getRights('shop', 'orders'); } return true; }
public function getHostUrl() { if (waRequest::isHttps()) { $url = 'https://'; } else { $url = 'http://'; } $url .= waRequest::server('HTTP_HOST'); return $url; }
/** * @static * @param array $route * @param string $domain * @return string */ public static function getUrlByRoute($route, $domain = null) { $url = self::clearUrl($route['url']); if ($domain) { if (parse_url($domain, PHP_URL_HOST) == waRequest::server('HTTP_HOST')) { $https = waRequest::isHttps(); } else { $https = false; } return 'http' . ($https ? 's' : '') . '://' . self::getDomainUrl($domain) . '/' . $url; } return $url; }
/** * Prepare favicon and robots.txt * * @param string $domain */ protected function getStaticFiles($domain) { $path = wa()->getDataPath(null, true) . '/data/' . $domain . '/favicon.ico'; if (file_exists($path)) { $favicon = wa()->getDataUrl('data/' . $domain . '/favicon.ico', true); } else { $favicon = 'http' . (waRequest::isHttps() ? 's' : '') . '://' . $domain . '/favicon.ico'; } $path = wa()->getDataPath(null, true) . '/data/' . $domain . '/apple-touch-icon.png'; if (file_exists($path)) { $touchicon = wa()->getDataUrl('data/' . $domain . '/apple-touch-icon.png', true); } else { $touchicon = false; } $path = wa()->getDataPath(null, true) . '/data/' . $domain . '/robots.txt'; if (file_exists($path)) { $robots = file_get_contents($path); } else { $robots = ''; } $this->view->assign('robots', $robots); $this->view->assign('favicon', $favicon); $this->view->assign('touchicon', $touchicon); if (strpos($domain, '/') !== false) { $this->view->assign('touchicon_message', sprintf(_w('Touch icon you upload here will not take effect for you website %s because your website is set for a subfolder on a domain. Touch icon uploaded using the form above will be set only for websites set from the domain root folder.'), $domain)); $this->view->assign('favicon_message', sprintf(_w('Favicon image you upload here will not take effect for you website %s because your website is set for a subfolder on a domain. Favicon uploaded using the form above will be set only for websites set from the domain root folder.'), $domain)); $this->view->assign('robots_message', sprintf(_w('Rules you set above for robots.txt will not take effect for you website %s because your website is set for a subfolder on a domain. Rules for robots.txt from the form above will be effective only for websites set to the domain root folder.'), $domain)); } else { $root_path = $this->getConfig()->getRootPath(); if (file_exists($root_path . '/favicon.ico')) { $this->view->assign('favicon_message', _w('File favicon.ico exists in the Webasyst framework installation folder. The favicon you upload here will be overridden by the icon uploaded as file unless you delete this file.')); } if (file_exists($root_path . '/apple-touch-icon.png')) { $this->view->assign('touchicon_message', _w('File apple-touch-icon.png exists in the Webasyst framework installation folder. The touch icon you upload here will be overridden by the icon uploaded as file unless you delete this file.')); } if (file_exists($root_path . '/robots.txt')) { $this->view->assign('robots_message', _w('File robots.txt exists in the Webasyst framework installation folder. Rules for robots.txt you specify above will not take effect unless you delete this file.')); } } }