Exemplo n.º 1
0
 /**
  * Build non-secure URL
  * @param string $rt
  * @param string $params
  * @param string $encode
  * @return string
  */
 public function getURL($rt, $params = '', $encode = '')
 {
     if (isset($this->registry->get('request')->server['HTTPS']) && ($this->registry->get('request')->server['HTTPS'] == 'on' || $this->registry->get('request')->server['HTTPS'] == '1')) {
         $server = HTTPS_SERVER;
     } else {
         //to prevent garbage session need to check constant HTTP_SERVER
         $server = defined('HTTP_SERVER') ? HTTP_SERVER : 'http://' . REAL_HOST . get_url_path($_SERVER['PHP_SELF']);
     }
     if ($this->registry->get('config')->get('storefront_template_debug') && isset($this->registry->get('request')->get['tmpl_debug'])) {
         $params .= '&tmpl_debug=' . $this->registry->get('request')->get['tmpl_debug'];
     }
     // add session id for crossdomain transition in secure mode
     if ($this->registry->get('config')->get('config_shared_session') && HTTPS === true) {
         $params .= '&session_id=' . session_id();
     }
     //add token for embed mode with forbidden 3dparty cookies
     if ($_SESSION['session_mode'] == 'embed_token') {
         $params .= '&' . EMBED_TOKEN_NAME . '=' . session_id();
     }
     $url = $server . INDEX_FILE . $this->url_encode($this->buildURL($rt, $params), $encode);
     return $url;
 }
Exemplo n.º 2
0
    $host = gpc('HTTP_HOST', 'S');
    //$schme = self::gpc('SERVER_PROTOCOL', 'S');
    $path = substr(gpc('PHP_SELF', 'S'), 0, strrpos(gpc('PHP_SELF', 'S'), '/'));
    return "http://{$host}{$portadd}{$path}/";
}
// 目录名
define('PATH', str_replace('\\', '/', dirname(__FILE__)) . '/');
if (is_file(PATH . 'core.php')) {
    header('Content-Type: text/html; charset=UTF-8');
    echo '请拷贝此文件到应用目录下,然后通过URL访问此文件。';
    exit;
}
$appname = strrchr(substr(PATH, 0, -1), '/');
$appname = str_replace('.', '_', substr($appname, 1));
$APP_PATH = strtoupper($appname . '_PATH');
$app_url = get_url_path();
$confdir = PATH . 'conf';
$logdir = PATH . 'log';
$tmpdir = PATH . 'tmp';
$viewdir = PATH . 'view';
$controldir = PATH . 'control';
$modeldir = PATH . 'model';
!is_dir($confdir) && mkdir($confdir, 0777);
!is_dir($logdir) && mkdir($logdir, 0777);
!is_dir($tmpdir) && mkdir($tmpdir, 0777);
!is_dir($viewdir) && mkdir($viewdir, 0777);
!is_dir($controldir) && mkdir($controldir, 0777);
!is_dir($modeldir) && mkdir($modeldir, 0777);
$conffile = PATH . 'conf/conf.php';
$indexfile = PATH . 'index.php';
$view_header_file = PATH . 'view/header.htm';
 private function _load_settings()
 {
     /**
      * @var ACache
      */
     $cache = $this->registry->get('cache');
     /**
      * @var ADB
      */
     $db = $this->registry->get('db');
     //detect URL for the store
     $url = str_replace('www.', '', $_SERVER['HTTP_HOST']) . get_url_path($_SERVER['PHP_SELF']);
     if (defined('INSTALL')) {
         $url = str_replace('install/', '', $url);
     }
     // Load default store settings
     $settings = $cache->force_get('settings', '', 0);
     if (empty($settings)) {
         // set global settings (without extensions settings)
         $sql = "SELECT se.*\n\t\t\t\t\tFROM " . $db->table("settings") . " se\n\t\t\t\t\tLEFT JOIN " . $db->table("extensions") . " e ON TRIM(se.`group`) = TRIM(e.`key`)\n\t\t\t\t\tWHERE se.store_id='0' AND e.extension_id IS NULL";
         $query = $db->query($sql);
         $settings = $query->rows;
         foreach ($settings as &$setting) {
             if ($setting['key'] == 'config_url') {
                 $parsed_url = parse_url($setting['value']);
                 $setting['value'] = 'http://' . $parsed_url['host'] . $parsed_url['path'];
             }
             if ($setting['key'] == 'config_ssl_url') {
                 $parsed_url = parse_url($setting['value']);
                 $setting['value'] = 'https://' . $parsed_url['host'] . $parsed_url['path'];
             }
             $this->cnfg[$setting['key']] = $setting['value'];
         }
         unset($setting);
         //unset temp reference
         //fix for rare issue on a database and creation of empty cache
         if (!empty($settings)) {
             $cache->force_set('settings', $settings, '', 0);
         }
     } else {
         foreach ($settings as $setting) {
             $this->cnfg[$setting['key']] = $setting['value'];
         }
     }
     // if storefront and not default store try to load setting for given URL
     /* Example: 
     			Specific store config -> http://localhost/abantecart123 
     			Generic config -> http://localhost
     		*/
     $config_url = preg_replace("(^https?://)", "", $this->cnfg['config_url']);
     $config_url = preg_replace("(^://)", "", $config_url);
     if (!is_int(strpos($config_url, $url)) && !is_int(strpos($url, $config_url))) {
         // if requested url not a default store URL - do check other stores.
         $cache_name = 'settings.store.' . md5('http://' . $url);
         $store_settings = $cache->force_get($cache_name);
         if (empty($store_settings)) {
             $sql = "SELECT se.`key`, se.`value`, st.store_id\n\t\t   \t\t\t  FROM " . $db->table('settings') . " se\n\t\t   \t\t\t  RIGHT JOIN " . $db->table('stores') . " st ON se.store_id=st.store_id\n\t\t   \t\t\t  LEFT JOIN " . $db->table('extensions') . " e ON TRIM(se.`group`) = TRIM(e.`key`)\n\t\t   \t\t\t  WHERE se.store_id = (SELECT DISTINCT store_id FROM " . $db->table('settings') . "\n\t\t   \t\t\t                       WHERE `group`='details'\n\t\t   \t\t\t                       AND\n\t\t   \t\t\t                       ( (`key` = 'config_url' AND (`value` LIKE '%" . $db->escape($url) . "'))\n\t\t   \t\t\t                       XOR\n\t\t   \t\t\t                       (`key` = 'config_ssl_url' AND (`value` LIKE '%" . $db->escape($url) . "')) )\n\t\t                                   LIMIT 0,1)\n\t\t   \t\t\t\t\tAND st.status = 1 AND e.extension_id IS NULL";
             $query = $db->query($sql);
             $store_settings = $query->rows;
             //fix for rare issue on a database and creation of empty cache
             if (!empty($store_settings)) {
                 $cache->force_set($cache_name, $store_settings);
             }
         }
         if ($store_settings) {
             //store found by URL, load settings
             foreach ($store_settings as $row) {
                 $value = $row['value'];
                 $this->cnfg[$row['key']] = $value;
             }
             $this->cnfg['config_store_id'] = $store_settings[0]['store_id'];
         } else {
             $warning = new AWarning('Warning: Accessing store with unconfigured or unknown domain ( ' . $url . ' ).' . "\n" . ' Check setting of your store domain URL in System Settings . Loading default store configuration for now.');
             $warning->toLog()->toMessages();
             //set config url to current domain
             $this->cnfg['config_url'] = 'http://' . REAL_HOST . get_url_path($_SERVER['PHP_SELF']);
         }
         if (!$this->cnfg['config_url']) {
             $this->cnfg['config_url'] = 'http://' . REAL_HOST . get_url_path($_SERVER['PHP_SELF']);
         }
     }
     //still no store? load default store or session based
     if (is_null($this->cnfg['config_store_id'])) {
         $this->cnfg['config_store_id'] = 0;
         if (IS_ADMIN) {
             //if admin and specific store selected
             $session = $this->registry->get('session');
             $store_id = $this->registry->get('request')->get['store_id'];
             if (has_value($store_id)) {
                 $this->cnfg['current_store_id'] = $this->cnfg['config_store_id'] = (int) $store_id;
             } else {
                 if (has_value($session->data['current_store_id'])) {
                     $this->cnfg['config_store_id'] = $session->data['current_store_id'];
                 }
             }
         }
         $this->_reload_settings($this->cnfg['config_store_id']);
     } else {
         $this->cnfg['current_store_id'] = $this->cnfg['config_store_id'];
     }
     //get template for storefront
     $tmpl_id = $this->cnfg['config_storefront_template'];
     // load extension settings
     $cache_suffix = IS_ADMIN ? 'admin' : $this->cnfg['config_store_id'];
     $settings = $cache->force_get('settings.extension.' . $cache_suffix);
     if (empty($settings)) {
         // all extensions settings of store
         $sql = "SELECT se.*, e.type as extension_type, e.key as extension_txt_id\n\t\t\t\t\tFROM " . $db->table('settings') . " se\n\t\t\t\t\tLEFT JOIN " . $db->table('extensions') . " e ON (TRIM(se.`group`) = TRIM(e.`key`))\n\t\t\t\t\tWHERE se.store_id='" . (int) $this->cnfg['config_store_id'] . "' AND e.extension_id IS NOT NULL\n\t\t\t\t\tORDER BY se.store_id ASC, se.group ASC";
         $query = $db->query($sql);
         foreach ($query->rows as $row) {
             //skip settings for non-active template except status (needed for extensions list in admin)
             if ($row['extension_type'] == 'template' && $tmpl_id != $row['group'] && $row['key'] != $row['extension_txt_id'] . '_status') {
                 continue;
             }
             $settings[] = $row;
         }
         //fix for rare issue on a database and creation of empty cache
         if (!empty($settings)) {
             $cache->force_set('settings.extension.' . $cache_suffix, $settings);
         }
     }
     //add encryption key to settings, overwise use from database (backwards compatability)
     if (defined('ENCRYPTION_KEY')) {
         $setting['encryption_key'] = ENCRYPTION_KEY;
     }
     foreach ($settings as $setting) {
         $this->cnfg[$setting['key']] = $setting['value'];
     }
 }
Exemplo n.º 4
0
define('WW_ROOT', $ww_root);
// check we got the root correct
if (WW_ROOT . "/ww_config/root_functions.php" != __FILE__) {
    echo "WARNING: Root configuration error:<br/>";
    echo "set_ww_root needs to be manually configured in ww_root.php<br/>";
    exit;
}
// now calculate the correct URL for this blog
/*
	root suffix is used later on for redirecting urls
	it is essentially the section of the URL path that follows the domain name
*/
$ww_web_root = !empty($set_bounce_html_root) ? clean_end_slash($set_ww_web_root) : get_url_path(__FILE__);
if (!empty($site['redirect_url'])) {
    $ww_web_root = clean_end_slash($site['redirect_url']);
    $ww_real_web_root = get_url_path(__FILE__);
    $host = substr($_SERVER['HTTP_HOST'], 0, 7) != "http://" ? "http://" . $_SERVER['HTTP_HOST'] : $_SERVER['HTTP_HOST'];
    $root_suffix = str_replace($host, '', $site['redirect_url']);
    $root_suffix = start_slash($root_suffix);
} else {
    $ww_web_root = $ww_web_root;
    $ww_real_web_root = $ww_web_root;
    $root_suffix = get_root_suffix(__FILE__);
}
define('WW_ROOT_SUFFIX', $root_suffix);
define('WW_WEB_ROOT', $ww_web_root);
define('WW_REAL_WEB_ROOT', $ww_real_web_root);
/**
 * -----------------------------------------------------------------------------
 * DEBUGGING
 * -----------------------------------------------------------------------------
function p404_header_code()
{
    p404_check_default_permalink();
    $css = get_url_path() . "style.css";
    echo '<link type="text/css" rel="stylesheet" href="' . $css . '"/>';
}