예제 #1
0
파일: _tree.php 프로젝트: nopticon/noptc
    protected function _comments_home()
    {
        global $user;
        $tree = $this->valid_tree();
        if (!$tree['tree_allow_comments']) {
            _fatal();
        }
        $sql = 'SELECT *
			FROM _comments c, _members m
			WHERE c.comment_tree = ?
				AND c.comment_uid = m.user_id
			ORDER BY comment_time DESC';
        $comments = _rowset(sql_filter($sql, $tree['tree_id']));
        foreach ($comments as $i => $row) {
            if (!$i) {
                _style('comments');
            }
            _style('comments.row', array('ID' => $row['comment_id'], 'USERNAME' => $row['comment_username'], 'EMAIL' => $row['comment_email'], 'WEBSITE' => $row['comment_website'], 'IP' => $row['comment_ip'], 'STATUS' => $row['comment_status'], 'TIME' => _format_date($row['comment_time']), 'MESSAGE' => $row['comment_message'], 'U_VALIDATION' => _link(_rewrite($tree), array('x1' => 'comments', 'x2' => 'validation'))));
        }
        if (!count($comments)) {
            _style('no_comments');
        }
        return $this->_template('tree_comments');
    }
예제 #2
0
파일: _ext.php 프로젝트: nopticon/npt
    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;
    }
예제 #3
0
파일: _ext.php 프로젝트: nopticon/noptc
    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;
    }
예제 #4
0
파일: _cp.php 프로젝트: nopticon/noptc
    protected function _create_home()
    {
        global $user;
        $v = $tree = $this->init();
        $z = $this->__(w('zmode'));
        if (_button()) {
            $v_ary = array('subject', 'content');
            if ($user->v('is_founder')) {
                $v_ary = array_merge($v_ary, array('node' => 0, 'parent' => 0, 'level' => 0, 'module' => 0, 'alias', 'child_hide' => 0, 'child_order', 'nav' => 0, 'nav_hide' => 0, 'css_parent' => 0, 'css_var', 'quickload' => 0, 'dynamic' => 0, 'tags', 'template', 'redirect', 'description', 'allow_comments' => 0, 'approve_comments' => 0, 'form' => 0, 'form_email', 'published', 'move'));
            }
            $v = $this->__($v_ary);
            /*
            $v = $this->__(array(
            	'node' => 0,
            	'parent' => 0,
            	'level' => 0,
            	'module' => 0,
            	'alias',
            	'child_hide' => 0,
            	'child_order',
            	'nav' => 0,
            	'nav_hide' => 0,
            	'css_parent' => 0,
            	'css_var',
            	'quickload' => 0,
            	'dynamic' => 0,
            	'tags',
            	'template',
            	'redirect',
            	'subject',
            	'content',
            	'description',
            	'allow_comments' => 0,
            	'approve_comments' => 0,
            	'form' => 0,
            	'form_email',
            	'published',
            	'move'
            ));
            */
            //
            $v['edited'] = time();
            foreach (w('node level parent module') as $row) {
                $v[$row] = $tree['tree_' . $row];
            }
            if ($z['zmode'] == 'create') {
                $v['parent'] = $tree['tree_id'];
                $v['level']++;
                if (!$v['node']) {
                    $v['node'] = $v['parent'];
                }
            }
            // Parse vars
            foreach ($v as $row_k => $row_v) {
                switch ($row_k) {
                    case 'subject':
                        $row_v = $this->html($row_v, 'strong');
                        break;
                    case 'content':
                        $row_v = $this->html($row_v);
                        break;
                    case 'alias':
                        $row_v = _alias($row_v, w('_'), '-');
                        break;
                    case 'checksum':
                        $row_v = _hash($v['content']);
                        break;
                    case 'published':
                        $row_v = dvar($row_v, date('d m Y'));
                        $e_date = explode(' ', $row_v);
                        $row_v = _timestamp($e_date[1], $e_date[0], $e_date[2]);
                        break;
                }
                $v[$row_k] = $row_v;
            }
            if ($z['zmode'] == 'modify' && $tree['tree_alias'] == 'home' && $v['alias'] != 'home') {
                $v['alias'] = 'home';
            }
            if (f($v['alias'])) {
                $sql = 'SELECT tree_id
					FROM _tree
					WHERE tree_alias = ?
						AND tree_id <> ?';
                if (_fieldrow(sql_filter($sql, $v['alias'], $tree['tree_id']))) {
                    $this->_error('#ALIAS_IN_USE');
                }
            }
            if ($z['zmode'] == 'modify') {
                if ($v['move']) {
                    $mv_field = !is_numb($v['move']) ? 'alias' : 'id';
                    $sql = 'SELECT *
						FROM _tree
						WHERE tree_?? = ?';
                    if ($mv_tree = _fieldrow(sql_filter($sql, $mv_field, $v['move']))) {
                        $mv_insert = array('module' => $mv_tree['module_id'], 'node' => $mv_tree['tree_node'], 'parent' => $mv_tree['tree_id'], 'level' => $mv_tree['tree_level'] + 1);
                        $sql = 'UPDATE _tree SET ' . _build_array('UPDATE', prefix('tree', $mv_insert)) . sql_filter('
							WHERE article_id = ?', $tree['tree_id']);
                        _sql($sql);
                        $sql = 'UPDATE _tree SET tree_childs = tree_childs - 1
							WHERE tree_id = ?';
                        _sql(sql_filter($sql, $tree['tree_parent']));
                        $sql = 'UPDATE _tree SET tree_childs = tree_childs + 1
							WHERE tree_id = ?';
                        _sql(sql_filter($sql, $mv_tree['tree_id']));
                    }
                }
                unset($v['move']);
                // Check input values against database
                foreach ($v as $row_k => $row_v) {
                    if ($tree['tree_' . $row_k] == $row_v) {
                        unset($v[$row_k]);
                    }
                }
                if (!(count($v) - 1)) {
                    unset($v['edited']);
                }
            } else {
                unset($v['move']);
            }
            //
            $u_tree = _rewrite($tree);
            if (count($v)) {
                if (isset($v['content']) && $v['content']) {
                    $v['content'] = str_replace(w('&lt; &gt;'), w('< >'), $v['content']);
                }
                if ($z['zmode'] == 'create') {
                    $sql = 'INSERT INTO _tree' . _build_array('INSERT', prefix('tree', $v));
                } else {
                    $sql = 'UPDATE _tree SET ' . _build_array('UPDATE', prefix('tree', $v)) . sql_filter('
						WHERE tree_id = ?', $tree['tree_id']);
                }
                _sql($sql);
                if ($z['zmode'] == 'create') {
                    $u_tree = f($v['alias']) ? $v['alias'] : _nextid();
                    $sql = 'UPDATE _tree
						SET tree_childs = tree_childs + 1
						WHERE tree_id = ?';
                    _sql(sql_filter($sql, $tree['tree_id']));
                }
            }
            redirect(_link($u_tree));
        }
        //
        // Show fieldset
        /*$v_fieldset = array(
        			'subject',
        			'content',
        			'description',
        			'alias',
        			'child_hide' => 0,
        			'child_order',
        			'nav' => 0,
        			'nav_hide' => 0,
        			'css_parent',
        			'css_var',
        			'quickload' => 0,
        			'dynamic' => 0,
        			'tags',
        			'template',
        			'redirect',
        			'allow_comments' => 0,
        			'approve_comments' => 0,
        			'form' => 0,
        			'form_email',
        			'published'
        		);
        		*/
        $v_fieldset = array('subject', 'content');
        if ($user->v('is_founder')) {
            $v_fieldset = array_merge($v_fieldset, array('description', 'alias', 'child_hide' => 0, 'child_order', 'nav' => 0, 'nav_hide' => 0, 'css_parent', 'css_var', 'quickload' => 0, 'dynamic' => 0, 'tags', 'template', 'redirect', 'allow_comments' => 0, 'approve_comments' => 0, 'form' => 0, 'form_email', 'published'));
        }
        $is_modify = $z['zmode'] == 'modify';
        foreach (_array_keys($v_fieldset, '') as $k => $row) {
            $name = 'tree_' . $k;
            $cp_lang = _lang('CP_' . $k);
            $value = $is_modify ? isset($v[$k]) ? $v[$k] : (isset($tree[$name]) ? $tree[$name] : '') : '';
            $checked = is_numb($row) && $is_modify && $tree[$name] ? ' checked="checked"' : '';
            if (f($value)) {
                switch ($k) {
                    case 'published':
                        $value = date('d m Y', $value);
                        break;
                }
            }
            $type = 'text';
            if (is_numb($row)) {
                $value = 1;
                $type = 'checkbox';
            }
            $tag = 'input';
            if ($k == 'content') {
                $tag = 'textarea';
            }
            _style('field', array('NAME' => $k, 'ID' => $k, 'TAG' => $tag, 'TYPE' => $type, 'VALUE' => $value, 'LANG' => $cp_lang, 'CHECKED' => $checked));
            if ($k == 'template') {
                $i = 0;
                $fp = @opendir('./style/custom/');
                while ($row_d = @readdir($fp)) {
                    if (_extension($row_d) != 'htm') {
                        continue;
                    }
                    if (!$i) {
                        _style('field.templated');
                        _style('field.templated.row', array('V' => '', 'FILE' => _lang('NONE')));
                    }
                    $v_file = str_replace('.htm', '', $row_d);
                    _style('field.templated.row', array('V' => $v_file, 'FILE' => $v_file));
                    $i++;
                }
                @closedir($fp);
            }
            //
        }
        $cp_format = !$is_modify ? 'CREATE' : 'MODIFY';
        v_style(array('CP_PAGE' => sprintf(_lang('CP_PAGE_' . $cp_format), $tree['tree_subject'])));
        return;
    }