public function execute() { $this->view->assign('title', $this->getTitle()); $this->view->assign('title_style', $this->getTitleStyle()); $this->view->setOptions(array('left_delimiter' => '{', 'right_delimiter' => '}')); if ($this->template === null) { if (waRequest::isMobile()) { $this->setLayout(null); $this->template = 'LoginMobile.html'; } else { $this->template = 'Login.html'; } $template_file = wa()->getDataPath('templates/' . $this->template, false, 'webasyst'); if (file_exists($template_file)) { $this->template = 'file:' . $template_file; } else { $this->template = wa()->getAppPath('templates/actions/login/', 'webasyst') . $this->template; } } $this->view->assign('login', waRequest::post('login', $this->getStorage()->read('auth_login'))); parent::execute(); if ($this->layout) { $this->layout->assign('error', $this->view->getVars('error')); } $ref = waRequest::server('HTTP_REFERER'); if (waRequest::get('back_to') && $ref) { $this->getStorage()->write('login_back_on_cancel', $ref); } else { if (!$ref) { $this->getStorage()->remove('login_back_on_cancel'); } } $this->view->assign('back_on_cancel', wa()->getStorage()->read('login_back_on_cancel')); }
public function __construct() { $this->view = waSystem::getInstance()->getView(); if (wa()->getEnv() == 'frontend') { // save utm to cookie $utm = array(); foreach (waRequest::get() as $k => $v) { if (substr($k, 0, 4) == 'utm_') { $utm[substr($k, 4)] = $v; } } if ($utm) { // save utm to cookie wa()->getResponse()->setCookie('utm', json_encode($utm), time() + 30 * 86400, null, '', false, true); } // save referer if ($ref = waRequest::server('HTTP_REFERER')) { $ref_host = @parse_url($ref, PHP_URL_HOST); if ($ref_host != waRequest::server('HTTP_HOST')) { wa()->getResponse()->setCookie('referer', waRequest::server('HTTP_REFERER'), time() + 30 * 86400, null, '', false, true); } } // save landing page if (!waRequest::cookie('landing')) { wa()->getResponse()->setCookie('landing', waRequest::server('REQUEST_URI'), 0, null, '', false, true); } } }
public function execute() { $this->response['files'] = array(); $this->getStorage()->close(); if (waRequest::server('HTTP_X_FILENAME')) { $name = waRequest::server('HTTP_X_FILE_NAME'); $size = waRequest::server('HTTP_X_FILE_SIZE'); $file_path = wa()->getTempPath('shop/upload/') . $name; $append_file = is_file($file_path) && $size > filesize($file_path); clearstatcache(); file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0)); try { $this->response['files'][] = $this->save($file); } catch (Exception $e) { $this->response['files'][] = array('error' => $e->getMessage()); } } else { $files = waRequest::file($this->name); foreach ($files as $file) { if ($file->error_code != UPLOAD_ERR_OK) { $this->response['files'][] = array('error' => $file->error); } else { try { $this->response['files'][] = $this->save($file); } catch (Exception $e) { $this->response['files'][] = array('name' => $file->name, 'error' => $e->getMessage()); } } } } }
public function defaultAction() { if (strpos(waRequest::server('HTTP_REFERER'), wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl() . '/logs') !== 0) { //on first app access, show latest updated files $this->redirect('?action=files&mode=updatetime'); } else { //otherwise default view mode is root log directory $this->execute('directory'); } }
public function execute() { if (wa()->getEnv() == 'frontend' && ($currency = waRequest::get("currency"))) { if ($this->getConfig()->getCurrencies(array($currency))) { wa()->getStorage()->set('shop/currency', $currency); wa()->getStorage()->remove('shop/cart'); } $url = $this->getConfig()->getCurrentUrl(); $url = preg_replace('/[\\?&]currency=' . $currency . '/i', '', $url); $this->redirect($url); } // save referer // @todo: save keywords for referers from search if (wa()->getEnv() == 'frontend' && ($ref = waRequest::server('HTTP_REFERER'))) { // check $ref domain $ref_parts = parse_url($ref); if ($ref_parts['host'] != waRequest::server('HTTP_HOST')) { wa()->getStorage()->set('shop/referer', waRequest::server('HTTP_REFERER')); } } $this->view->assign('action', waRequest::param('action', 'default')); $this->setThemeTemplate('index.html'); /** * @event frontend_head * @return array[string]string $return[%plugin_id%] html output */ $this->view->assign('frontend_head', wa()->event('frontend_head')); /** * @event frontend_header * @return array[string]string $return[%plugin_id%] html output */ $this->view->assign('frontend_header', wa()->event('frontend_header')); if (!$this->view->getVars('frontend_nav')) { /** * @event frontend_nav * @return array[string]string $return[%plugin_id%] html output for navigation section */ $this->view->assign('frontend_nav', wa()->event('frontend_nav')); } /** * @event frontend_footer * @return array[string]string $return[%plugin_id%] html output */ $this->view->assign('frontend_footer', wa()->event('frontend_footer')); $this->view->assign('currencies', $this->getConfig()->getCurrencies()); // set globals $params = waRequest::param(); foreach ($params as $k => $v) { if (in_array($k, array('url', 'module', 'action', 'meta_keywords', 'meta_description', 'private', 'url_type', 'type_id', 'payment_id', 'shipping_id', 'currency', 'stock_id'))) { unset($params[$k]); } } $this->view->getHelper()->globals($params); }
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 execute() { parent::execute(); $return_url = waRequest::get('return_url', waRequest::server('HTTP_REFERER')); if ($return_hash = waRequest::get('return_hash')) { if ($return_hash = preg_replace('@^#@', '', $return_hash)) { $return_url .= '#' . $return_hash; } } $this->view->assign('top', !!preg_match('@^[^/]+$@', waRequest::get('slug')) && !waRequest::get('filter')); $this->view->assign('return_url', $return_url); }
public function execute() { if (!$this->getRights('upload')) { throw new waRightsException(_w("You don't have sufficient access rights")); } $this->response['files'] = array(); $this->model = new photosPhotoModel(); $album_rights_model = new photosAlbumRightsModel(); // rights for photos $this->status = waRequest::post('status', 0, 'int'); $this->groups = waRequest::post('groups', array(), waRequest::TYPE_ARRAY_INT); if (!$this->groups) { $this->status = -1; // only author have access to this photo $this->groups = array(-$this->getUser()->getId()); } // work with album $this->album_id = waRequest::post('album_id'); $this->album_id = (int) $this->album_id; if ($this->album_id > 0 && !$album_rights_model->checkRights($this->album_id, true)) { $this->response['files'][] = array('error' => _w("You don't have sufficient access rights")); return; } $this->getStorage()->close(); if (waRequest::server('HTTP_X_FILE_NAME')) { $name = waRequest::server('HTTP_X_FILE_NAME'); $size = waRequest::server('HTTP_X_FILE_SIZE'); $file_path = wa()->getTempPath('photos/upload/') . $name; $append_file = is_file($file_path) && $size > filesize($file_path); clearstatcache(); file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0)); try { $this->response['files'][] = $this->save($file); } catch (Exception $e) { $this->response['files'][] = array('error' => $e->getMessage()); } } else { $files = waRequest::file('files'); foreach ($files as $file) { if ($file->error_code != UPLOAD_ERR_OK) { $this->response['files'][] = array('error' => $file->error); } else { try { $this->response['files'][] = $this->save($file); } catch (Exception $e) { $this->response['files'][] = array('name' => $file->name, 'error' => $e->getMessage()); } } } } }
protected function saveReferer() { $referer = waRequest::server('HTTP_REFERER'); $root_url = wa()->getRootUrl(true); if ($root_url != substr($referer, 0, strlen($root_url))) { $this->getStorage()->del('auth_referer'); return; } $referer = substr($referer, strlen($this->getConfig()->getHostUrl())); if (!in_array($referer, array(wa()->getRouteUrl('/login'), wa()->getRouteUrl('/forgotpassword'), wa()->getRouteUrl('/signup')))) { $this->getStorage()->set('auth_referer', $referer); } }
public function execute() { $url = waRequest::param('url'); $domain = waRequest::server('HTTP_HOST'); $model = new waModel(); // $main_domain = $model->query("SELECT value FROM wa_app_settings WHERE app_id = 'webasyst' AND name = 'url'")->fetchField(); $app_settings_model = new waAppSettingsModel(); $main_domain = trim(str_replace(array('https', 'http', '://'), '', $app_settings_model->get('webasyst', 'url')), "/"); $data = $model->query("\nSELECT\n shop_deliveryshop_city_description.*\n, shop_deliveryshop_city.city\n, shop_deliveryshop_city.region\nFROM\n shop_deliveryshop_city_description\nLEFT JOIN\n shop_deliveryshop_city ON shop_deliveryshop_city_description.cityCode = shop_deliveryshop_city.cityCode\nLEFT JOIN\n wa_region ON wa_region.code = shop_deliveryshop_city.region AND wa_region.country_iso3='rus'\nWHERE\n (url = '{$url}' OR city = '{$url}')\nAND\n domain IN ('{$domain}', '{$main_domain}')\nLIMIT 1\n ")->fetchAssoc(); // Уменьшаем стоимость доставки на сумму указанную в настройках плагина $delivery_compensation = $model->query("SELECT price FROM shop_deliveryshop_delivery WHERE domain = '" . $domain . "'")->fetchField(); $delivery_compensation = intval($delivery_compensation); $delivery_price = intval($data['delivery_price']); $courier_price = intval($data['courier_price']); if ($delivery_price > $delivery_compensation) { $data['delivery_price'] = (int) (($delivery_price - $delivery_compensation) / 50) * 50; //Уменьшаем до ближайшего полтинника } else { $data['delivery_price'] = 0; } if ($courier_price > $delivery_compensation) { $data['courier_price'] = (int) (($courier_price - $delivery_compensation) / 50) * 50; //Уменьшаем до ближайшего полтинника } else { $data['courier_price'] = 0; } foreach (array('meta_title' => $main_domain, 'meta_description' => '', 'meta_keywords' => '', 'delivery_time' => '', 'courier_time' => '') as $key => $value) { $data[$key] = isset($data[$key]) ? $data[$key] : $value; } wa()->getResponse()->setTitle($data['meta_title']); wa()->getResponse()->setMeta('description', $data['meta_description']); wa()->getResponse()->setMeta('keywords', $data['meta_keywords']); $city_code = isset($data['cityCode']) ? $data['cityCode'] : 0; $pvz = $model->query("\nSELECT\n shop_deliveryshop_pvz.*\nFROM\n shop_deliveryshop_pvz\nWHERE\n cityCode = {$city_code}\nAND\n status = 'completed'\nAND\n (domain IN ('{$domain}', '{$main_domain}') OR domain IS NULL)\n")->fetchAll(); //$site_model = new siteDomainModel(); //$domain_id = $site_model->getByName($domain); $domain_id = $model->query("SELECT id FROM site_domain WHERE name = '" . $domain . "'")->fetchField(); $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $domain_id . '.html', false, 'shop', true); if (!file_exists($template_path)) { $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', false, 'shop', true); } if (!file_exists($template_path)) { $template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop'); } $this->view->assign('data', $data); $this->view->assign('pvz', $pvz); $this->view->assign('page', array('id' => null, 'name' => '', 'content' => $this->view->fetch($template_path))); $this->setThemeTemplate('page.html'); waSystem::popActivePlugin(); }
private function init() { $url = parse_url($r = waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(update|apps|plugins)($|&)/', $url, $matches)) { $this->module = $matches[2]; } if (installerHelper::isDeveloper()) { if (waRequest::request('install')) { $msg = _w('Unable to install application (developer version is on)'); } else { $msg = _w('Unable to install application (developer version is on)'); } $this->redirect(array('module' => $this->module, 'msg' => installerMessage::getInstance()->raiseMessage($msg, 'fail'))); } }
public static function getFilesFromPost() { if (waRequest::server('HTTP_X_FILE_NAME')) { $name = waRequest::server('HTTP_X_FILE_NAME'); $size = waRequest::server('HTTP_X_FILE_SIZE'); $safe_name = trim(preg_replace('~[^a-z\\.]~', '', waLocale::transliterate($name)), ". \n\t\r"); $safe_name || ($safe_name = uniqid('p')); $file_path = wa()->getTempPath('photos/upload/') . $safe_name; $append_file = is_file($file_path) && $size > filesize($file_path); clearstatcache(); file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0)); return array($file); } else { return waRequest::file('files'); } }
/** * @return mixed * @throws waException */ protected function getCategory() { $category_model = $this->getModel(); $url_field = waRequest::param('url_type') == 1 ? 'url' : 'full_url'; if (waRequest::param('category_id')) { $category = $category_model->getById(waRequest::param('category_id')); if ($category) { $category_url = wa()->getRouteUrl('/frontend/category', array('category_url' => $category[$url_field])); if (urldecode(wa()->getConfig()->getRequestUrl(false, true)) !== $category_url) { $q = waRequest::server('QUERY_STRING'); $this->redirect($category_url . ($q ? '?' . $q : ''), 301); } } } else { $category = $category_model->getByField($url_field, waRequest::param('category_url')); if ($category && $category[$url_field] !== urldecode(waRequest::param('category_url'))) { $q = waRequest::server('QUERY_STRING'); $this->redirect(wa()->getRouteUrl('/frontend/category', array('category_url' => $category[$url_field])) . ($q ? '?' . $q : ''), 301); } } $route = wa()->getRouting()->getDomain(null, true) . '/' . wa()->getRouting()->getRoute('url'); if ($category) { $category_routes_model = new shopCategoryRoutesModel(); $routes = $category_routes_model->getRoutes($category['id']); } if (!$category || $routes && !in_array($route, $routes)) { throw new waException('Category not found', 404); } $category['subcategories'] = $category_model->getSubcategories($category, $route); $category_url = wa()->getRouteUrl('shop/frontend/category', array('category_url' => '%CATEGORY_URL%')); foreach ($category['subcategories'] as &$sc) { $sc['url'] = str_replace('%CATEGORY_URL%', waRequest::param('url_type') == 1 ? $sc['url'] : $sc['full_url'], $category_url); } unset($sc); // params $category_params_model = new shopCategoryParamsModel(); $category['params'] = $category_params_model->get($category['id']); // smarty description if ($this->getConfig()->getOption('can_use_smarty') && $category['description']) { $category['description'] = wa()->getView()->fetch('string:' . $category['description']); } return $category; }
public function execute() { $this->response['files'] = array(); $this->model = new photosPhotoModel(); $data = array('contact_id' => wa()->getUser()->getId(), 'status' => 1, 'groups' => array(0), 'source' => 'publicgallery'); $plugin = wa()->getPlugin('publicgallery'); if ($plugin->getSettings('need_moderation')) { $data['moderation'] = 0; } else { $data['moderation'] = 1; } if ($data['moderation'] <= 0) { $data['status'] = 0; } $this->getStorage()->close(); if (waRequest::server('HTTP_X_FILE_NAME')) { $name = waRequest::server('HTTP_X_FILE_NAME'); $size = waRequest::server('HTTP_X_FILE_SIZE'); $file_path = wa()->getTempPath('photos/upload/') . $name; $append_file = is_file($file_path) && $size > filesize($file_path); clearstatcache(); file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); $file = new waRequestFile(array('name' => $name, 'type' => waRequest::server('HTTP_X_FILE_TYPE'), 'size' => $size, 'tmp_name' => $file_path, 'error' => 0)); try { $this->response['files'][] = $this->save($file, $data); } catch (Exception $e) { $this->response['files'][] = array('error' => $e->getMessage()); } } else { $files = waRequest::file('files'); foreach ($files as $file) { if ($file->error_code != UPLOAD_ERR_OK) { $this->response['files'][] = array('error' => $file->error); } else { try { $this->response['files'][] = $this->save($file, $data); } catch (Exception $e) { $this->response['files'][] = array('name' => $file->name, 'error' => $e->getMessage()); } } } } }
protected function afterAuth() { $referer = waRequest::server('HTTP_REFERER'); $referer = substr($referer, strlen($this->getConfig()->getHostUrl())); $checkout_url = wa()->getRouteUrl('shop/frontend/checkout'); if ($referer && !strncasecmp($referer, $checkout_url, strlen($checkout_url))) { $url = $referer; } elseif ($referer != wa()->getRouteUrl('/login')) { $url = $this->getStorage()->get('auth_referer'); } if (empty($url)) { if (waRequest::param('secure')) { $url = $this->getConfig()->getCurrentUrl(); } else { $url = wa()->getRouteUrl('shop/frontend/my'); } } $this->getStorage()->del('auth_referer'); $this->getStorage()->del('shop/cart'); $this->redirect($url); }
public function __toString() { $message = nl2br($this->getMessage()); if (wa()->getApp()) { $app = wa()->getAppInfo(); $backend_url = waSystem::getInstance()->getConfig()->getBackendUrl(true); } else { $app = array(); } if (!waSystem::getInstance()->getConfig()->isDebug()) { $env = wa()->getEnv(); $file = $code = $this->getCode(); if (!$code || !file_exists(dirname(__FILE__) . '/data/' . $code . '.php')) { $file = 'error'; } include dirname(__FILE__) . '/data/' . $file . '.php'; exit; } if (waSystem::getInstance()->getEnv() == 'cli') { return date("Y-m-d H:i:s") . " php " . implode(" ", waRequest::server('argv')) . "\n" . "Error: {$this->getMessage()}\nwith code {$this->getCode()} in '{$this->getFile()}' around line {$this->getLine()}:{$this->getFileContext()}\n" . $this->getTraceAsString() . "\n"; } elseif ($this->code == 404) { $response = new waResponse(); $response->setStatus(404); $response->sendHeaders(); } $result = <<<HTML <div style="width:99%; position:relative"> <h2 id='Title'>{$message}</h2> <div id="Context" style="display: block;"><h3>Error with code {$this->getCode()} in '{$this->getFile()}' around line {$this->getLine()}:</h3><pre>{$this->getFileContext()}</pre></div> <div id="Trace"><h2>Call stack</h2><pre>{$this->getTraceAsString()}</pre></div> <div id="Request"><h2>Request</h2><pre> HTML; $result .= var_export($_REQUEST, true); $result .= "</pre></div></div>\n<div><h2>Params</h2><pre>"; $result .= var_export(waRequest::param(), true); $result .= "</pre></div></div>"; return $result; }
function smarty_function_wa_pagination($params, &$smarty) { $total = $params['total']; $page = isset($params['page']) ? $params['page'] : waRequest::get('page', 1); if ($page < 1) { $page = 1; } if ($total < 2) { return ''; } $url = isset($params['url']) ? $params['url'] : ''; $html = '<ul'; $attrs = isset($params['attrs']) ? $params['attrs'] : array(); foreach ($attrs as $k => $v) { $html .= ' ' . $k . '="' . $v . '"'; } $html .= '>'; $p = 1; $n = 1; $nb = 1; while ($p <= $total) { if ($p > $nb && $total - $p > $nb && abs($page - $p) > $n && ($p < $page ? $page - $n - $p > 1 : $total - $nb > $p)) { $p = $p < $page ? $page - $n : $total - $nb + 1; $html .= '<li>...</li>'; } else { $url_params = preg_replace('/&?page=[0-9]+?/i', '', waRequest::server('QUERY_STRING', '')); if (substr($url_params, -1) == '&') { $url_params = substr($url_params, 0, -1); } $page_url = $url . ($url && $p == 1 ? $url_params ? '?' . $url_params : '' : '?page=' . $p . ($url_params ? '&' . $url_params : '')); $html .= '<li' . ($p == $page ? ' class="selected"' : '') . '><a href="' . $page_url . '">' . $p . '</a></li>'; $p++; } } $html .= '</ul>'; return $html; }
private function init() { $url = parse_url($r = waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(themes|plugins)($|&)/', $url, $matches)) { $this->extras_type = $matches[2]; } elseif (preg_match('/^installer(\\w+)RemoveAction$/', get_class($this), $matches)) { $this->extras_type = strtolower($matches[1]); } if (installerHelper::isDeveloper()) { switch ($this->extras_type) { case 'themes': $msg = _w("Unable to delete application's themes (developer version is on)"); break; case 'plugins': $msg = _w("Unable to delete application's plugins (developer version is on)"); break; default: $msg = '???'; break; } $msg = installerMessage::getInstance()->raiseMessage($msg, installerMessage::R_FAIL); $this->redirect('?msg=' . $msg . '#/' . $this->extras_type . '/'); } }
public function userAgent($type = null) { $user_agent = waRequest::server('HTTP_USER_AGENT'); if (!$type) { return $user_agent; } elseif ($type == 'isMobile') { return waRequest::isMobile(false); } elseif ($type == 'platform' || $type == 'os') { $patterns = array('android' => 'android', 'blackberry' => 'blackberry', 'linux' => 'Linux', 'ios' => '(ipad|iphone|ipod)', 'mac' => '(Macintosh|Mac\\sOS)', 'windows' => 'Windows'); } elseif ($type == 'device') { $patterns = array('ipad' => 'ipad', 'ipod' => 'ipod', 'iphone' => 'iphone', 'android' => 'android'); } foreach ($patterns as $id => $pattern) { if (preg_match('/' . $pattern . '/i', $user_agent)) { return $id; } } return ''; }
function execute() { $module = 'apps'; $url = parse_url(waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(update|apps|plugins)($|&)/', $url, $matches)) { $module = $matches[2]; } $app_ids = waRequest::get('app_id'); try { if (!$app_ids || !is_array($app_ids)) { throw new waException(_w('Application not found')); } $vendors = array(); foreach ($app_ids as $app_id => &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } $vendors[] = $info['vendor']; unset($info); } $vendors = array_unique($vendors); $apps = new waInstallerApps(); $app_list = $apps->getApplicationsList(true, $vendors); $deleted_apps = array(); if (installerHelper::isDeveloper()) { throw new waException(_w('Unable to delete application (developer version is on)')); } foreach ($app_list as $info) { $app_id = $info['slug']; if (isset($app_ids[$app_id]) && $app_ids[$app_id]['vendor'] == $info['vendor']) { if (isset($info['system']) && $info['system']) { throw new waException(sprintf(_w('Can not delete system application "%s"'), $info['name'])); } $apps->updateRoutingConfig($app_id, false); $apps->updateAppConfig($app_id, null); //remove db tables and etc $paths = array(); $app_instance = waSystem::getInstance($app_id); $plugins = $app_instance->getConfig()->getPlugins(); foreach ($plugins as $plugin_id => $plugin) { if ($plugin && ($plugin_instance = $app_instance->getPlugin($plugin_id))) { $plugin_instance->uninstall(); } $apps->updateAppPluginsConfig($app_id, $plugin_id, null); //wa-apps/$app_id/plugins/$slug $paths[] = wa()->getAppPath("plugins/{$plugin_id}", $app_id); foreach ($paths as $path) { waFiles::delete($path, true); } $paths = array(); } $app_instance->getConfig()->uninstall(); //XXX called at uninstall //$paths[] = wa()->getAppCachePath(null, $app_id);//wa-cache/apps/$app_id/ $paths[] = wa()->getTempPath(null, $app_id); //wa-cache/temp/$app_id/ $paths[] = wa()->getAppCachePath(null, $app_id); //wa-cache/apps/$app_id/ $paths[] = wa()->getDataPath(null, true, $app_id); //wa-data/public/$app_id/ $paths[] = wa()->getDataPath(null, false, $app_id); //wa-data/protected/$app_id/ //XXX uncomplete code //$paths[] = wa()-> null, false, $app_id);//wa-log/$app_id/ //XXX uncomplete code //$paths[] = wa()->getAppPath(null, $app_id);//wa-config/$app_id/ $paths[] = wa()->getAppPath(null, $app_id); //wa-apps/$app_id/ foreach ($paths as $path) { waFiles::delete($path, true); } $deleted_apps[] = $info['name']; } } if (!$deleted_apps) { throw new waException(_w('Application not found')); } $message = _w('Application %s has been deleted', 'Applications %s have been deleted', min(2, count($deleted_apps)), false); $message = sprintf($message, implode(', ', $deleted_apps)); $msg = installerMessage::getInstance()->raiseMessage($message); $this->redirect(array('module' => $module, 'msg' => $msg)); } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect(array('module' => $module, 'msg' => $msg)); } }
public function getDomain($domain = null, $check = false) { if ($domain) { return $domain; } if ($this->domain === null) { $this->domain = waRequest::server('HTTP_HOST'); if ($this->domain === null) { return null; } $u = trim($this->system->getRootUrl(), '/'); if ($u) { $this->domain .= '/' . $u; } } if ($check) { if (!isset($this->routes[$this->domain])) { if (substr($this->domain, 0, 4) == 'www.') { $domain = substr($this->domain, 4); } else { $domain = 'www.' . $this->domain; } if (wa()->getEnv() == 'frontend' && isset($this->routes[$domain])) { $https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''; $url = 'http' . (strtolower($https) == 'on' ? 's' : '') . '://'; $url .= $this->getDomainUrl($domain) . '/' . wa()->getConfig()->getRequestUrl(); wa()->getResponse()->redirect($url); } return $domain; } } return $this->domain; }
public function execute() { $code = waRequest::cookie('shop_cart'); if (!$code) { $code = md5(uniqid(time(), true)); // header for IE wa()->getResponse()->addHeader('P3P', 'CP="NOI ADM DEV COM NAV OUR STP"'); // set cart cookie wa()->getResponse()->setCookie('shop_cart', $code, time() + 30 * 86400, null, '', false, true); } $this->cart = new shopCart($code); $this->cart_model = new shopCartItemsModel(); $data = waRequest::post(); $this->is_html = waRequest::request('html'); // add service if (isset($data['parent_id'])) { $this->addService($data); return; } // add sku $sku_model = new shopProductSkusModel(); $product_model = new shopProductModel(); if (!isset($data['product_id'])) { $sku = $sku_model->getById($data['sku_id']); $product = $product_model->getById($sku['product_id']); } else { $product = $product_model->getById($data['product_id']); if (isset($data['sku_id'])) { $sku = $sku_model->getById($data['sku_id']); } else { if (isset($data['features'])) { $product_features_model = new shopProductFeaturesModel(); $sku_id = $product_features_model->getSkuByFeatures($product['id'], $data['features']); if ($sku_id) { $sku = $sku_model->getById($sku_id); } else { $sku = null; } } else { $sku = $sku_model->getById($product['sku_id']); if (!$sku['available']) { $sku = $sku_model->getByField(array('product_id' => $product['id'], 'available' => 1)); } if (!$sku) { $this->errors = _w('This product is not available for purchase'); return; } } } } $quantity = waRequest::post('quantity', 1); if ($product && $sku) { // check quantity if (!wa()->getSetting('ignore_stock_count')) { $c = $this->cart_model->countSku($code, $sku['id']); if ($sku['count'] !== null && $c + $quantity > $sku['count']) { $quantity = $sku['count'] - $c; $name = $product['name'] . ($sku['name'] ? ' (' . $sku['name'] . ')' : ''); if (!$quantity) { $this->errors = sprintf(_w('Only %d pcs of %s are available, and you already have all of them in your shopping cart.'), $sku['count'], $name); return; } else { $this->response['error'] = sprintf(_w('Only %d pcs of %s are available, and you already have all of them in your shopping cart.'), $sku['count'], $name); } } } $services = waRequest::post('services', array()); if ($services) { $variants = waRequest::post('service_variant'); $temp = array(); $service_ids = array(); foreach ($services as $service_id) { if (isset($variants[$service_id])) { $temp[$service_id] = $variants[$service_id]; } else { $service_ids[] = $service_id; } } if ($service_ids) { $service_model = new shopServiceModel(); $temp_services = $service_model->getById($service_ids); foreach ($temp_services as $row) { $temp[$row['id']] = $row['variant_id']; } } $services = $temp; } $item_id = null; $item = $this->cart_model->getItemByProductAndServices($code, $product['id'], $sku['id'], $services); if ($item) { $item_id = $item['id']; $this->cart->setQuantity($item_id, $item['quantity'] + $quantity); } if (!$item_id) { $data = array('create_datetime' => date('Y-m-d H:i:s'), 'product_id' => $product['id'], 'sku_id' => $sku['id'], 'quantity' => $quantity, 'type' => 'product'); if ($services) { $data_services = array(); foreach ($services as $service_id => $variant_id) { $data_services[] = array('service_id' => $service_id, 'service_variant_id' => $variant_id); } } else { $data_services = array(); } $item_id = $this->cart->addItem($data, $data_services); } if (waRequest::isXMLHttpRequest()) { $this->response['item_id'] = $item_id; $this->response['total'] = $this->currencyFormat($this->cart->total()); $this->response['discount'] = $this->currencyFormat($this->cart->discount()); $this->response['count'] = $this->cart->count(); } else { $this->redirect(waRequest::server('HTTP_REFERER')); } } else { throw new waException('product not found'); } }
public function isValid($code = null) { $response = recaptcha_check_answer($this->options['privatekey'], waRequest::server("REMOTE_ADDR"), waRequest::post("recaptcha_challenge_field"), waRequest::post("recaptcha_response_field")); return $response->is_valid; }
public function execute() { $this->setLayout(new shopFrontendLayout()); if ($this->params) { $product = $this->params; } else { $product_model = new shopProductModel(); $product = $product_model->getByField('url', waRequest::param('product_url')); } if (!$product) { throw new waException(_w('Product not found'), 404); } if ($types = waRequest::param('type_id')) { if (!in_array($product['type_id'], (array) $types)) { throw new waException(_w('Product not found'), 404); } } $is_cart = waRequest::get('cart'); if ($is_cart) { $this->setLayout(null); } $product = new shopProduct($product); if (!$is_cart) { $this->getBreadcrumbs($product); } // check url $product['num'] = 141; if ($product['url'] !== urldecode(waRequest::param('product_url'))) { $url_params = array('product_url' => $product['url']); if ($product['category_id']) { $url_params['category_url'] = $product['category_url']; } $q = waRequest::server('QUERY_STRING'); $this->redirect(wa()->getRouteUrl('/frontend/product', $url_params) . ($q ? '?' . $q : ''), 301); } $this->prepareProduct($product); $this->addCanonical(); // get services $type_services_model = new shopTypeServicesModel(); $services = $type_services_model->getServiceIds($product['type_id']); $service_model = new shopServiceModel(); $product_services_model = new shopProductServicesModel(); $services = array_merge($services, $product_services_model->getServiceIds($product['id'])); $services = array_unique($services); $services = $service_model->getById($services); $variants_model = new shopServiceVariantsModel(); $rows = $variants_model->getByField('service_id', array_keys($services), true); foreach ($rows as $row) { if (!$row['price']) { $row['price'] = $services[$row['service_id']]['price']; } $services[$row['service_id']]['variants'][$row['id']] = $row; } $rows = $product_services_model->getByField('product_id', $product['id'], true); $skus_services = array(); foreach ($product['skus'] as $sku) { $skus_services[$sku['id']] = array(); } foreach ($rows as $row) { if (!$row['sku_id']) { // remove disabled services and variantsimg if (!$row['status']) { unset($services[$row['service_id']]['variants'][$row['service_variant_id']]); } elseif ($row['price'] !== null) { // update price $services[$row['service_id']]['variants'][$row['service_variant_id']]['price'] = $row['price']; } if ($row['status'] == shopProductServicesModel::STATUS_DEFAULT) { // update default $services[$row['service_id']]['variant_id'] = $row['service_variant_id']; } } else { if (!$row['status']) { $skus_services[$row['sku_id']][$row['service_id']][$row['service_variant_id']] = false; } else { $skus_services[$row['sku_id']][$row['service_id']][$row['service_variant_id']] = $row['price']; } } } foreach ($skus_services as $sku_id => &$sku_services) { $sku_price = $product['skus'][$sku_id]['price']; foreach ($services as $service_id => $service) { if (isset($sku_services[$service_id])) { if ($sku_services[$service_id]) { foreach ($service['variants'] as $v) { if (!isset($sku_services[$service_id][$v['id']]) || $sku_services[$service_id][$v['id']] === null) { $sku_services[$service_id][$v['id']] = array($v['name'], $this->getPrice($v['price'], $service['currency'], $sku_price, $product['currency'])); } elseif ($sku_services[$service_id][$v['id']]) { $sku_services[$service_id][$v['id']] = array($v['name'], $this->getPrice($sku_services[$service_id][$v['id']], $service['currency'], $sku_price, $product['currency'])); } } } } else { foreach ($service['variants'] as $v) { $sku_services[$service_id][$v['id']] = array($v['name'], $this->getPrice($v['price'], $service['currency'], $sku_price, $product['currency'])); } } } } unset($sku_services); // disable service if all variants disabled foreach ($skus_services as $sku_id => $sku_services) { foreach ($sku_services as $service_id => $service) { if (is_array($service)) { $disabled = true; foreach ($service as $v) { if ($v !== false) { $disabled = false; break; } } if ($disabled) { $skus_services[$sku_id][$service_id] = false; } } } } foreach ($services as $s_id => &$s) { if (!$s['variants']) { unset($services[$s_id]); continue; } if ($s['currency'] == '%') { foreach ($s['variants'] as $v_id => $v) { $s['variants'][$v_id]['price'] = $v['price'] * $product['skus'][$product['sku_id']]['price'] / 100; } $s['currency'] = $product['currency']; } if (count($s['variants']) == 1) { $v = reset($s['variants']); if ($v['name']) { $s['name'] .= ' ' . $v['name']; } $s['variant_id'] = $v['id']; $s['price'] = $v['price']; unset($s['variants']); foreach ($skus_services as $sku_id => $sku_services) { if (isset($sku_services[$s_id]) && isset($sku_services[$s_id][$v['id']])) { $skus_services[$sku_id][$s_id] = $sku_services[$s_id][$v['id']][1]; } } } } unset($s); uasort($services, array('shopServiceModel', 'sortServices')); $this->view->assign('sku_services', $skus_services); $this->view->assign('services', $services); $compare = waRequest::cookie('shop_compare', array(), waRequest::TYPE_ARRAY_INT); $this->view->assign('compare', in_array($product['id'], $compare) ? $compare : array()); if (!$is_cart) { $this->view->assign('reviews', $this->getTopReviews($product['id'])); $this->view->assign('rates', $this->reviews_model->getProductRates($product['id'])); $this->view->assign('reviews_total_count', $this->getReviewsTotalCount($product['id'])); $meta_fields = $this->getMetafields($product); $title = $meta_fields['meta_title'] ? $meta_fields['meta_title'] : $product['name']; wa()->getResponse()->setTitle($title); wa()->getResponse()->setMeta('keywords', $meta_fields['meta_keywords']); wa()->getResponse()->setMeta('description', $meta_fields['meta_description']); $feature_codes = array_keys($product->features); $feature_model = new shopFeatureModel(); $features = $feature_model->getByCode($feature_codes); $this->view->assign('features', $features); } $this->view->assign('currency_info', $this->getCurrencyInfo()); /** * @event frontend_product * @param shopProduct $product * @return array[string][string]string $return[%plugin_id%]['menu'] html output * @return array[string][string]string $return[%plugin_id%]['cart'] html output * @return array[string][string]string $return[%plugin_id%]['block_aux'] html output * @return array[string][string]string $return[%plugin_id%]['block'] html output */ $this->view->assign('frontend_product', wa()->event('frontend_product', $product, array('menu', 'cart', 'block_aux', 'block'))); $sku_stocks = array(); foreach ($product->skus as $sku) { $sku_stocks[$sku_id] = array($sku['count'], $sku['stock']); } $stock_model = new shopStockModel(); $this->view->assign('stocks', $stock_model->getAll('id')); $duble = db_query("SELECT * FROM shop_product where id=" . $product['id']); $dubles = mysql_fetch_assoc($duble); $dubles_sku = db_query("SELECT * FROM shop_product_skus where product_id=" . $product['id'] . " and id=" . $dubles['sku_id']); $dubl_sku = mysql_fetch_assoc($dubles_sku); $dubles_prod = db_query("SELECT * FROM shop_product_skus where product_id!=" . $product['id'] . " and sku='" . $dubl_sku['sku'] . "' Group by product_id"); while ($dubl_product = mysql_fetch_array($dubles_prod)) { $dubles_img_pr = db_query("SELECT * FROM shop_product p, shop_product_images img where p.id=" . $dubl_product['product_id'] . " and img.product_id=" . $dubl_product['product_id'] . ""); $dubles_img = mysql_fetch_assoc($dubles_img_pr); if ($dubles_img['status'] != 0) { $koldz = substr($dubles_img['product_id'], -2, 2); $kolds = str_replace($koldz, '', $dubles_img['product_id']); if (preg_match_all("#\\d#", $kolds) < 2) { $kolds = '0' . $kolds; } if ($kolds == 0) { $kolds = '00'; } $alt_test = db_query("SELECT * FROM shop_product_features_selectable where feature_id=12 and product_id=" . $dubles_img['product_id'] . ""); $alt_t = mysql_fetch_assoc($alt_test); $alt_value = db_query("SELECT * FROM shop_feature_values_color where id=" . $alt_t['value_id'] . ""); $alt = mysql_fetch_assoc($alt_value); $dubl_p = $dubl_p . ' <a class="duble_prod" href="http://' . $_SERVER['HTTP_HOST'] . '/index.php/' . $dubles_img['url'] . '" > <img alt="' . $alt['value'] . '" title="' . $alt['value'] . '" style="width:50px" src="/wa-data/public/shop/products/' . $koldz . '/' . $kolds . '/' . $dubles_img['product_id'] . '/images/' . $dubles_img['id'] . '/' . $dubles_img['id'] . '.96x96.jpg"/></a>'; $dubl_p2 = $dubl_p2 . '<a onclick="doubl(' . $dubles_img['product_id'] . ')" class="duble_prod" > <img alt="' . $alt['value'] . '" title="' . $alt['value'] . '" style="width:50px" src="/wa-data/public/shop/products/' . $koldz . '/' . $kolds . '/' . $dubles_img['product_id'] . '/images/' . $dubles_img['id'] . '/' . $dubles_img['id'] . '.96x96.jpg"/></a>'; } $dubl_p = $dubl_p; $dubl_p2 = $dubl_p2; } $this->view->assign('duble', $dubl_p); $this->view->assign('duble2', $dubl_p2); $this->view->assign('duble_list', $dubl_p); $product['num'] = $_GET['num']; $this->view->assign('numis', $_GET['num']); $this->setThemeTemplate($is_cart ? 'product.cart.html' : 'product.html'); }
public function getDomain() { $domain = waRequest::server('HTTP_HOST'); $u = trim(waSystem::getInstance()->getRootUrl(false, true), '/'); if ($u) { $domain .= '/' . $u; } return $domain; }
/** * @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; }
public function getDomain($domain = null, $check = false) { if ($domain) { return $domain; } if ($this->domain === null) { $this->domain = waRequest::server('HTTP_HOST'); if ($this->domain === null) { return null; } $u = trim($this->system->getRootUrl(), '/'); if ($u) { $this->domain .= '/' . $u; } } if ($check) { if (!isset($this->routes[$this->domain])) { if (substr($this->domain, 0, 4) == 'www.') { $domain = substr($this->domain, 4); } else { $domain = 'www.' . $this->domain; } return $domain; } } return $this->domain; }
public function execute() { $module = 'update'; $url = parse_url(waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(update|apps|plugins)($|&)/', $url, $matches)) { $module = $matches[2]; } try { $updater = new waInstaller(waInstaller::LOG_TRACE); $state = $updater->getState(); if (!isset($state['stage_status']) || $state['stage_name'] != waInstaller::STAGE_NONE && $state['heartbeat'] > waInstaller::TIMEOUT_RESUME + 5 || $state['stage_name'] == waInstaller::STAGE_UPDATE && $state['heartbeat'] || $state['stage_status'] == waInstaller::STATE_ERROR && $state['heartbeat'] || $state['stage_name'] == waInstaller::STAGE_NONE && $state['heartbeat'] === false) { $updater->setState(); $this->view->assign('action', 'update'); $app_ids = waRequest::request('app_id'); $default_info = array('vendor' => waInstallerApps::VENDOR_SELF, 'edition' => ''); $vendors = array(); if ($app_ids && is_array($app_ids)) { foreach ($app_ids as $app_id => &$info) { if (!is_array($info)) { if (strpos($info, ':') === false) { $vendor = $info; $edition = ''; } else { list($vendor, $edition) = explode(':', $info, 2); } $info = array('vendor' => $vendor, 'edition' => $edition); } else { $info = array_merge($info, $default_info); } $vendors[] = $info['vendor']; unset($info); } } else { $app_ids = array(); } $vendors = array_unique($vendors); if (!$vendors) { $vendors = array(); } $model = new waAppSettingsModel(); $license = $model->get('webasyst', 'license', false); $locale = wa()->getLocale(); $apps = new waInstallerApps($license, $locale); $app_list = $vendors ? $apps->getApplicationsList(false, $vendors) : array(); $model->ping(); $queue_apps = array(); foreach ($app_list as &$info) { $app_id = $info['slug']; if ($app_id == 'installer') { $info['name'] = _w('Webasyst Framework'); } if (isset($app_ids[$app_id])) { if (installerHelper::equals($app_ids[$app_id], $info)) { $queue_apps[] = $info; } } if (!empty($info['extras'])) { foreach ($info['extras'] as $type => &$extras) { foreach ($extras as $extra_id => &$extras_info) { $extras_id = $extras_info['slug']; $extras_info['name'] .= " ({$info['name']})"; if (isset($app_ids[$extras_id]) && installerHelper::equals($app_ids[$extras_id], $extras_info)) { $queue_apps[] = $extras_info; } } unset($extras_info); } unset($extras); } unset($info); } $system_list = $apps->getSystemList(); foreach ($system_list as $item) { if (!empty($item['subject']) && $item['subject'] == 'systemplugins' && isset($app_ids[$item['slug']])) { $queue_apps[] = $item; } } if (!$queue_apps) { throw new waException(_w('Please select items for update')); } $this->view->assign('queue_apps', $queue_apps); $this->view->assign('apps', $app_list); $this->view->assign('install', waRequest::request('install')); $this->view->assign('title', _w('Updates')); } else { $this->redirect(array('module' => $module, 'msg' => installerMessage::getInstance()->raiseMessage(_w('Update is already in progress. Please wait while previous update session is finished before starting update session again.'), 'fail'))); } } catch (Exception $ex) { $this->redirect(array('module' => $module, 'msg' => installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL))); } }
/** * Reads file contents and outputs it to browser with appropriate headers. * * @param string $file File to path * @param string|null $attach Name, which will be suggested to user when he requests to download the file. * If not specified, browser's auto-suggestion will be used. * @param bool $exit Flag requiring to send file transfer headers to user's browser. By default (true) headers are sent. * @param bool $md5 Flag requiring to send the Content-MD5 header. By default (false) this header is not sent. * @throws waException If file does not exist */ public static function readFile($file, $attach = null, $exit = true, $md5 = false) { if (file_exists($file)) { $response = wa()->getResponse(); $file_type = self::getMimeType($attach ? $attach : $file); if ($md5) { $md5 = base64_encode(pack('H*', md5_file($file))); } @ini_set('async_send', 1); wa()->getStorage()->close(); if ($attach !== null) { $send_as = str_replace('"', '\\"', is_string($attach) ? $attach : basename($file)); $send_as = preg_replace('~[\\n\\r]+~', ' ', $send_as); $x_accel_redirect = waSystemConfig::systemOption('x_accel_redirect'); $file_size = filesize($file); $response->setStatus(200); if (empty($x_accel_redirect)) { $from = $to = false; if ($http_range = waRequest::server('HTTP_RANGE')) { // multi range support incomplete list($dimension, $range) = explode("=", $http_range, 2); $ranges = explode(',', $range); $intervals = array(); foreach ($ranges as $range) { $range = trim($range); if (preg_match('/^(\\d+)-(\\d+)$/', $range, $matches)) { $intervals[] = array('from' => intval($matches[1]), 'to' => intval($matches[2])); } elseif (preg_match('/^(\\d+)-$/', $range, $matches)) { $intervals[] = array('from' => intval($matches[1]), 'to' => $file_size - 1); } elseif (preg_match('/^-(\\d+)$/', $range, $matches)) { $intervals[] = array('from' => $file_size - intval($matches[1]), 'to' => $file_size - 1); } else { throw new waException('Requested range not satisfiable', 416); } } foreach ($intervals as $interval) { if ($from === false) { $from = $interval['from']; } if ($to === false) { $to = $interval['to']; } else { if ($to + 1 == $interval['from']) { $to = $interval['to']; } else { //hole at interval throw new waException('Requested range not satisfiable', 416); } } } if ($from < 0 || $to + 1 > $file_size) { throw new waException('Requested range not satisfiable', 416); } $range_length = $to - $from + 1; $response->setStatus(206); $response->addHeader("Content-Length", $range_length); $response->addHeader("Content-Range", "bytes {$from}-{$to}/{$file_size}"); } else { $response->addHeader("Content-Length", $file_size); if ($md5) { $response->addHeader("Content-MD5", $md5); } } $response->addHeader("Cache-Control", "no-cache, must-revalidate"); $response->addHeader("Content-type", "{$file_type}"); $response->addHeader("Content-Disposition", "attachment; filename=\"{$send_as}\""); $response->addHeader("Last-Modified", filemtime($file)); $response->addHeader("Accept-Ranges", "bytes"); $response->addHeader("Connection", "close"); $fp = fopen($file, 'rb'); if ($from) { fseek($fp, $from); } $response->sendHeaders(); $response = null; //TODO: adjust chunk size $chunk = 1048576; //1M while (!feof($fp) && $chunk && connection_status() == 0) { if ($to) { $chunk = min(1 + $to - @ftell($fp), $chunk); } if ($chunk) { print @fread($fp, $chunk); @flush(); } } @fclose($fp); } else { $response->addHeader("Content-type", $file_type); //RFC 6266 $response->addHeader("Content-Disposition", "attachment; filename=\"{$send_as}\""); $response->addHeader("Accept-Ranges", "bytes"); $response->addHeader("Content-Length", $file_size); $response->addHeader("Expires", "0"); $response->addHeader("Cache-Control", "no-cache, must-revalidate", false); $response->addHeader("Pragma", "public"); $response->addHeader("Connection", "close"); if ($md5) { $response->addHeader("Content-MD5", $md5); } $response->addHeader("X-Accel-Redirect", $file); $response->sendHeaders(); $response = null; //@future //$response->addHeader("X-Accel-Limit-Rate", $rate_limit); } } else { $response->addHeader("Content-type", $file_type); $response->addHeader("Last-Modified", filemtime($file)); if ($md5) { $response->addHeader("Content-MD5", $md5); } $response->sendHeaders(); $response = null; @readfile($file); } if ($exit) { if (!empty($response)) { /** * @var waResponse $response */ $response->sendHeaders(); } exit; } } else { throw new waException("File not found", 404); } }
/** Description of all framework settlements. */ public static function getDomains($hash, $photo = null) { $domains = array(); // Params for getRouteUrl() based on $hash or $photo if ($photo) { $route_module_action = 'photos/frontend/photo'; $route_url_params = array('url' => $photo['url'] . (isset($photo['status']) && ($photo['status'] <= 0 && !empty($photo['hash'])) ? ':' . $photo['hash'] : '')); } else { $route_module_action = 'photos/frontend'; $route_url_params = array(); $hash = trim($hash, '#/'); $hash = explode('/', $hash); if (count($hash) >= 2) { if ($hash[0] == 'album') { $route_module_action = 'photos/frontend/album'; $route_url_params = array('url' => photosCollection::frontendAlbumHashToUrl('album/' . $hash[1])); } else { $route_url_params[$hash[0]] = $hash[1]; } } else { if (count($hash) == 1) { $route_url_params[$hash[0]] = $hash[0]; } } } // Domains with Photos frontend foreach (wa()->getRouting()->getByApp('photos') as $domain => $params) { $domain_url = 'http://' . rtrim(wa()->getRouting()->getDomainUrl($domain), '/') . '/'; $domains[$domain_url] = array('url' => $domain_url, 'frontend_url' => wa()->getRouteUrl($route_module_action, $route_url_params, true, $domain)); } // Other domains foreach (array_merge(wa()->getRouting()->getDomains(), array(waRequest::server('HTTP_HOST') . wa()->getConfig()->getRootUrl())) as $domain) { $domain_url = 'http://' . rtrim(wa()->getRouting()->getDomainUrl($domain), '/') . '/'; if (empty($domains[$domain_url])) { $domains[$domain_url] = array('url' => $domain_url, 'frontend_url' => ''); } } return $domains; }