Ejemplo n.º 1
0
function _browser($a_browser = false, $a_version = false, $name = false, $d_name = false)
{
    $browser_list = 'nokia motorola samsung sonyericsson blackberry iphone htc ';
    $browser_list .= 'flock firefox konqueror lobo msie netscape navigator mosaic netsurf lynx amaya omniweb ';
    $browser_list .= 'googlebot googlebot-image feedfetcher-google gigabot msnbot thunderbird fennec minimo ';
    $browser_list .= 'minefield chrome wget cheshire safari avant camino seamonkey aol bloglines ';
    $browser_list .= 'wii playstation netfront opera mozilla gecko ubuntu';
    $browser_type = array('mobile' => 'nokia motorola samsung sonyericsson blackberry iphone fennec minimo htc', 'console' => 'wii playstation', 'bot' => 'googlebot googlebot-image feedfetcher-google gigabot msnbot bloglines');
    $platforms = array('linux' => w('linux'), 'mac' => array('macintosh', 'mac platform x', 'mac os x'), 'windows' => w('windows win32'));
    $user_browser = strtolower(v_server('HTTP_USER_AGENT'));
    $this_version = $this_browser = $this_platform = '';
    if ($a_browser == '*') {
        $a_browser = $a_version = $name = false;
        $d_name = true;
    }
    if ($a_browser === false && $a_version === false && $name === false && $d_name !== false) {
        return $user_browser;
    }
    foreach (w('user_browser a_browser a_version name d_name') as $row) {
        $vrow = ${$row};
        if (is_string($vrow)) {
            ${$row} = strtolower($vrow);
        }
    }
    $browser_limit = strlen($user_browser);
    foreach (w($browser_list) as $row) {
        $row = $a_browser !== false ? $a_browser : $row;
        $n = stristr($user_browser, $row);
        if (!$n || f($this_browser)) {
            continue;
        }
        $this_browser = $row;
        $j = strpos($user_browser, $row) + strlen($row);
        $j2 = substr($user_browser, $j, 1);
        if (preg_match('#[\\/\\_\\-\\ ]#', $j2)) {
            $j += 1;
        }
        for (; $j <= $browser_limit; $j++) {
            $s = trim(substr($user_browser, $j, 1));
            if (!preg_match('/[\\w\\.\\-]/', $s)) {
                break;
            }
            $this_version .= $s;
        }
    }
    if ($a_browser !== false && ($d_name === false || $name === true)) {
        $ret = false;
        if (strtolower($a_browser) == $this_browser) {
            $ret = true;
            if ($a_version !== false) {
                if (f($this_version)) {
                    $a_sign = explode(' ', $a_version);
                    if (version_compare($this_version, $a_sign[1], $a_sign[0]) === false) {
                        $ret = false;
                        $vf = true;
                    }
                } else {
                    $ret = false;
                }
            }
        }
        if ($name !== true) {
            return $ret;
        }
    }
    foreach ($platforms as $os => $match) {
        foreach ($match as $os_name) {
            if (strpos($user_browser, $os_name) !== false) {
                $this_platform = $os;
                break 2;
            }
        }
    }
    $this_type = '';
    if (f($this_browser)) {
        foreach ($browser_type as $type => $browsers) {
            foreach (w($browsers) as $row) {
                if (strpos($this_browser, $row) !== false) {
                    $this_type = $type;
                    break 2;
                }
            }
        }
        if (!$this_type) {
            $this_type = 'desktop';
        }
    }
    if ($name !== false) {
        if ($a_browser !== false && $a_version !== false && $ret === false) {
            return false;
        }
        $s_browser = '';
        $s_data = array($this_type, $this_platform, $this_browser, $this_version);
        foreach ($s_data as $row) {
            if (f($row)) {
                $s_browser .= ($s_browser != '' ? ' ' : '') . $row;
            }
        }
        return $s_browser;
    }
    return array('browser' => $this_browser, 'version' => $this_version, 'platform' => $this_platform, 'type' => $this_type, 'useragent' => $user_browser);
}
Ejemplo n.º 2
0
	public function run() {
		$this->module = request_var('module', '');

		if (empty($this->module)) {
			return $this->rights();
		}

		if (!preg_match('#[a-z\_]+#i', $this->module)) {
			fatal_error();
		}

		$this->filepath = ROOT . 'acp/' . $this->module . '.php';

		if (!@file_exists($this->filepath)) {
			fatal_error();
		}

		require_once($this->filepath);

		$_object = '__' . $this->module;
		if (!class_exists($_object)) {
			fatal_error();
		}

		$module = new $_object();

		$module->url = s_link() . substr(v_server('REQUEST_URI'), 1);
		$module->alias = $this->module;

		$module->_home();

		if (!isset($module->template)) {
			$module->template = 'acp/' . $this->module;
		}

		$local_tv = array(
			'MODULE_URL' => $module->url
		);

		if (isset($module->tv)) {
			$local_tv = array_merge($local_tv, $module->tv);
		}

		$this->_title = $this->module;
		$this->_template = $module->template;

		return v_style($local_tv);
	}
Ejemplo n.º 3
0
Archivo: bio.php Proyecto: nopticon/npt
 /**
  * Sets a cookie
  *
  * Sets a cookie of the given name with the specified data for the given length of time.
  */
 public function set_cookie($name, $cookiedata, $cookietime, $onlyhttp = false)
 {
     global $core;
     $name = $core->v('cookie_name') . '_' . $name;
     $domain = $core->v('cookie_domain') != 'localhost' ? $core->v('cookie_domain') : '';
     $secure = v_server('SERVER_PORT') === 443 ? true : false;
     setcookie($name, $cookiedata, $cookietime, $core->v('cookie_path'), $domain, $secure, $onlyhttp);
     return true;
 }
Ejemplo n.º 4
0
    public function home()
    {
        global $user;
        $v = $this->__(w('f e'));
        if (array_empty($v)) {
            _fatal();
        }
        $location = './style/' . $v['e'] . '/';
        $filename = _filename($v['f'], $v['e']);
        if (!@is_dir($location)) {
            _fatal();
        }
        if ($v['e'] == 'css' && $v['f'] != 'default') {
            $v['field'] = !is_numb($v['f']) ? 'alias' : 'id';
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_?? = ?
				LIMIT 1';
            if (!($tree = _fieldrow(sql_filter($sql, $v['field'], $v['f'])))) {
                _fatal();
            }
            $filetree = _rewrite($tree);
            $filename = _filename('_tree_' . $filetree, $v['e']);
        }
        // 304 Not modified response header
        if (@file_exists($location . $filename)) {
            $f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT';
            $http_if_none_match = v_server('HTTP_IF_NONE_MATCH');
            $http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE');
            header('Last-Modified: ' . $f_last_modified);
            if ($f_last_modified == $http_if_modified_since) {
                header('HTTP/1.0 304 Not Modified');
                header('Content-Length: 0');
                exit;
            }
        }
        switch ($v['e']) {
            case 'css':
                if ($v['f'] != 'default') {
                    $filetree = _rewrite($tree);
                    $filename = _filename('_tree_' . $filetree, $v['e']);
                    if (!@file_exists($location . $filename)) {
                        _fatal();
                    }
                }
                $browser = _browser();
                if (f($browser['browser'])) {
                    $custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']);
                    foreach ($custom as $row) {
                        $handler = _filename('_tree_' . $row, 'css');
                        if (@file_exists($location . $handler)) {
                            _style('includes', array('CSS' => _style_handler('css/' . $handler)));
                        }
                    }
                }
                break;
            case 'js':
                if (!@file_exists($location . $filename)) {
                    _fatal();
                }
                _style_vreplace(false);
                break;
        }
        v_style(array('SPATH' => LIBD . 'visual'));
        sql_close();
        $ext = _style_handler($v['e'] . '/' . $filename);
        switch ($v['e']) {
            case 'css':
                $content_type = 'text/css; charset=utf-8';
                $ext = preg_replace('#(border-radius\\-?.*?)\\: ?(([0-9]+)px;)#is', _browser('firefox') || _browser('namoroka') ? '-moz-\\1: \\2' : '', $ext);
                $ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext);
                $ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext);
                $ext = str_replace(array("\r\n", "\n", "\t"), '', $ext);
                break;
            case 'js':
                $content_type = 'application/x-javascript';
                require_once XFS . 'core/jsmin.php';
                $ext = JSMin::minify($ext);
                break;
        }
        ob_start('ob_gzhandler');
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 30) . ' GMT');
        header('Content-type: ' . $content_type);
        echo $ext;
        exit;
    }
Ejemplo n.º 5
0
function _page()
{
    return get_protocol() . get_host() . v_server('REQUEST_URI');
}
Ejemplo n.º 6
0
    public function home()
    {
        global $warning, $bio, $core, $warning;
        $v = $this->__(w('path ext'));
        if (array_empty($v)) {
            $warning->now();
        }
        $location = XFS . XHTM . _tbrowser() . '/' . $v->ext . '/';
        if (!@is_dir($location)) {
            $warning->now();
        }
        $filename = _filename($v->path, $v->ext);
        if ($v->ext == 'css' && $v->path != 'default') {
            $v->field = !is_numb($v->path) ? 'alias' : 'id';
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_?? = ?
				LIMIT 1';
            if (!($tree = sql_fieldrow(sql_filter($sql, $v->field, $v->path)))) {
                $warning->now();
            }
            $filetree = _rewrite($tree);
            $filename = _filename('_tree_' . $filetree, $v->ext);
        }
        //
        // 304 Not modified response header
        if (@file_exists($location . $filename)) {
            $f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT';
            $http_if_none_match = v_server('HTTP_IF_NONE_MATCH');
            $http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE');
            header('Last-Modified: ' . $f_last_modified);
            if ($f_last_modified == $http_if_modified_since) {
                header('HTTP/1.0 304 Not Modified');
                header('Content-Length: 0');
                exit;
            }
        }
        switch ($v->ext) {
            case 'css':
                if ($v->path != 'default') {
                    $filetree = _rewrite($tree);
                    $filename = _filename('_tree_' . $filetree, $v->ext);
                    if (!@file_exists($location . $filename)) {
                        $warning->now();
                    }
                }
                $browser = _browser();
                if (!empty($browser['browser'])) {
                    $custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']);
                    foreach ($custom as $row) {
                        $handler = _filename('_tree_' . $row, 'css');
                        if (@file_exists($location . $handler)) {
                            _style('includes', array('CSS' => _style_handler('css/' . $handler)));
                        }
                    }
                }
                _style_vreplace(false);
                break;
            case 'js':
                if (!@file_exists($location . $filename)) {
                    $warning->now();
                }
                _style_vreplace(false);
                break;
        }
        v_style(array('DOMAIN' => 'media'));
        sql_close();
        //
        // Headers
        $ext = _style_handler($v->ext . '/' . $filename);
        switch ($v->ext) {
            case 'css':
                $content_type = 'text/css; charset=utf-8';
                //$ext = preg_replace('#(border-radius\-?.*?)\: ?(([0-9]+)px;)#is', ((_browser('firefox')) ? '-moz-\1: \2' : ''), $ext);
                $ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext);
                $ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext);
                $ext = str_replace(array("\r\n", "\n", "\t"), '', $ext);
                break;
            case 'js':
                $content_type = 'application/x-javascript';
                require_once XFS . XCOR . 'jsmin.php';
                $ext = JSMin::minify($ext);
                break;
        }
        ob_start('ob_gzhandler');
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT');
        // 30 days = 60 * 60 * 24 * 30
        header('Content-type: ' . $content_type);
        echo $ext;
        exit;
    }
Ejemplo n.º 7
0
$filename = request_var('filename', '');
if (empty($filename) || !preg_match('#[a-z\_]+#i', $filename)) {
	fatal_error();
}

$filepath = ROOT . 'template/js/' . $filename . '.js';
if (!@file_exists($filepath)) {
	fatal_error();
}

// 304 Not modified response header
$last_modified = filemtime($filepath);
$f_last_modified = gmdate('D, d M Y H:i:s', $last_modified) . ' GMT';

$http_if_none_match = v_server('HTTP_IF_NONE_MATCH');
$http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE');

$etag_server = etag($filepath);
$etag_client = str_replace('-gzip', '', $http_if_none_match);

header('Last-Modified: ' . $f_last_modified);
header('ETag: ' . $etag_server);

if ($etag_client == $etag_server && $f_last_modified == $http_if_modified_since) {
	header('HTTP/1.0 304 Not Modified');
	header('Content-Length: 0');
	exit;
}

require_once(ROOT . 'interfase/jsmin.php');
Ejemplo n.º 8
0
	public function check_ref($block_ud = false, $auto_block = false) {
		global $config;

		$url = (getenv('HTTP_REFERER')) ? trim(getenv('HTTP_REFERER')) : v_server('HTTP_REFERER');
		$url = $this->clean_value($url);
		if ($url == '') {
			return;
		}

		$domain = explode('?', str_replace(array('http://', 'https://'), '', $url));
		$domain = trim($domain[0]);
		$domain = explode('/', $domain);
		$excref = $domain[0] . '/' . $domain[1];
		$domain = trim($domain[0]);

		if (($domain == '') || preg_match('#^.*?' . $config['server_name'] . '.*?$#i', $domain)) {
			return;
		}

		if (is_array($this->config['exclude_refs'])) {
			$this->config['exclude_refs'] = $this->config['exclude_refs'][0];
		}

		if ($this->config['exclude_refs'] != '') {
			$this->config['exclude_refs'] = explode(nr(), $this->config['exclude_refs']);

			foreach ($this->config['exclude_refs'] as $e_domain) {
				if (strstr($e_domain, 'www.')) {
					$this->config['exclude_refs'][] = str_replace('www.', '', $e_domain);
				}
			}
		}

		if (in_array($excref, $this->config['exclude_refs'])) {
			return;
		}

		$not_allowed_ref = true;
		if (in_array($excref, $this->config['exclude_refs'])) {
			$domain = $excref;
			$not_allowed_ref = false;
		}

		$request = $this->clean_value(v_server('REQUEST_URI'));
		$auto_block = ($auto_block) ? 1 : 0;

		$insert = true;
		$update = false;
		$banned = false;
		$group_id = '';
		$datetime = time();

		$sql = 'SELECT *
			FROM _ref
			WHERE domain = ?
				OR url = ?
			ORDER BY url';
		$result = sql_rowset(sql_filter($sql, $domain, $url));

		foreach ($result as $row) {
			if ($group_id == '') {
				$group_id = $row['group_id'];
			}

			if ($row['banned']) {
				$banned = true;
			}

			if (($row['url'] == $url) && !$update) {
				$sql_banned = '';
				$update = true;
				$insert = false;

				if (!$banned) {
					$sql_banned = ", banned = " . intval($auto_block);
				}

				$sql = 'UPDATE _ref SET request = ?' . $sql_banned . ', views = views + 1, last_datetime = ?, last_ip = ?
					WHERE domain = ?
						AND url = ?';
				sql_query(sql_filter($sql, $request, $datetime, $user_ip, $domain, $url));
			}
		}

		if ($insert) {
			if ($group_id == '') {
				$group_id = md5(uniqid(time()));
			}

			$sql_insert = array(
				'group_id' => $group_id,
				'domain' => $domain,
				'url' => $url,
				'request' => $request,
				'banned' => $auto_block,
				'views' => 1,
				'datetime' => $datetime,
				'last_datetime' => $datetime,
				'last_ip' => $user_ip
			);
			sql_insert('ref', $sql_insert);
		}

		if ($not_allowed_ref) {
			if ($banned) {
				fatal_error();
			}

			if ($block_ud) {
				redirect(s_link());
			}
		}

		return;
	}
Ejemplo n.º 9
0
$module = request_var('module', '');

if (!empty($module) && preg_match('#^([a-z\_]+)$#i', $module)) {
	$module_path = ROOT . 'objects/cron/' . $module . '.php';

	if (@file_exists($module_path)) {
		$user->setup();

		@require_once($module_path);
		return;
	}
}

$file_content = @file('./template/exceptions/missing.htm');

$matches = array(
	'<!--#echo var="HTTP_HOST" -->' => v_server('HTTP_HOST'),
	'<!--#echo var="REQUEST_URI" -->' => v_server('REQUEST_URI')
);

$orig = $repl = array();

foreach ($matches as $row_k => $row_v) {
	$orig[] = $row_k;
	$repl[] = $row_v;
}

echo str_replace($orig, $repl, implode('', $file_content));
exit;