コード例 #1
0
ファイル: _press.php プロジェクト: nopticon/mag
    protected function _check_home()
    {
        global $bio, $warning;
        $v = $this->__(w('id 0'));
        $sql = 'SELECT *
			FROM _press
			WHERE press_id = ?';
        if (!($press = sql_fieldrow(sql_filter($sql, $v->id)))) {
            $warning->now();
        }
        foreach (w('lastvisit start end') as $k) {
            $k = 'press_' . $k;
            $press->{$k} = !empty($press->{$k}) ? $user->format_date($press->{$k}) : '';
        }
        foreach ($press as $k => $v) {
            if (is_numb($k)) {
                unset($press->{$k});
            }
        }
        $warning->list($press);
    }
コード例 #2
0
ファイル: events.php プロジェクト: nopticon/rockr
	public function run() {
		$event_alias = request_var('alias', '');

		if (empty($event_alias)) {
			return $this->all();
		}

		if (!preg_match('#[a-z0-9\_\-]+#i', $event_alias)) {
			fatal_error();
		}

		$event_field = (!is_numb($event_alias)) ? 'event_alias' : 'id';

		$sql = 'SELECT *
			FROM _events
			WHERE ?? = ?';
		if (!$this->data = sql_fieldrow(sql_filter($sql, $event_field, $event_alias))) {
			fatal_error();
		}

		return $this->object();
	}
コード例 #3
0
ファイル: _tree.php プロジェクト: nopticon/noptc
    public function home()
    {
        global $core, $user;
        $tree = $this->valid_tree();
        $v = $this->__(_array_keys(w('is_comment is_form'), 0));
        // Form posting enabled and form submitted
        if ($v['is_form'] && _button()) {
            if (!is_ghost()) {
                _fatal(405);
            }
            if (!$tree['tree_form']) {
                _fatal();
            }
            $sql_fields = 'SELECT form_alias, form_required, form_legend, form_regex, 
				FROM _form_fields
				WHERE form_tree = ?
				ORDER BY form_order';
            if (!($form = _rowset(sql_filter($sql_fields, $tree['tree_id']), 'form_alias'))) {
                $form = _rowset(sql_filter($sql_fields, 0), 'form_alias');
            }
            $form['secure'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'secure', 'form_type' => 'text', 'form_legend' => _lang('XCF_LEGEND'));
            foreach ($form as $row) {
                $v = array_merge($v, $this->__(array($row['form_alias'])));
                if (!f($v[$row['form_alias']])) {
                    if ($row['form_required']) {
                        $this->_error(sprintf(_lang('E_COMMENT_FIELD_EMPTY'), $row['form_legend']), false);
                    }
                    continue;
                }
                if (f($row['form_regex']) && !preg_match('#' . $row['form_regex'] . '#is', $v[$row['form_alias']])) {
                    $this->_error(sprintf(_lang('E_COMMENT_FIELD_BAD'), $row['form_legend']), false);
                    if ($row['form_alias'] == 'secure') {
                        $v[$row['form_alias']] = '';
                    }
                }
            }
            require_once XFS . 'core/xcf.php';
            $xcf = new captcha();
            if ($xcf->check($v['secure']) === false) {
                $v['secure'] = '';
                $this->_error('#E_COMMENT_INVALID_CAPTCHA');
            }
            unset($xcf);
            require_once XFS . 'core/emailer.php';
            $emailer = new emailer();
            $emailer->set_decode(true);
            $emailer->format('plain');
            $emailer->from($v['address']);
            $emailer->set_subject(_rm_acute($v['subject']));
            $emailer->use_template('contact_email');
            if (f($core->v('default_email'))) {
                $tree['tree_form_email'] .= (f($tree['tree_form_email']) ? ';' : '') . $core->v('default_email');
            }
            $form_addresses = array_map('trim', array_unique(explode(';', $tree['tree_form_email'])));
            foreach ($form_addresses as $i => $address) {
                $row_f = !$i ? 'email_address' : 'cc';
                $emailer->{$row_f}($address);
            }
            unset($v['secure']);
            $content = w();
            foreach ($form as $row) {
                if (!f($v[$row['form_alias']])) {
                    continue;
                }
                $content[] = $row['form_legend'] . ":\n" . $v[$row['form_alias']];
            }
            $emailer->assign_vars(array('CONTENT' => implode("\n\n", $content), 'FORM_ARTICLE' => $tree['tree_subject']));
            $emailer->send();
            $emailer->reset();
            $response = array('lang' => _lang('FORM_SUCCESS'));
            $this->e(json_encode($response));
        }
        // Comment posting enabled and form submitted.
        if ($v['is_comment'] && _button()) {
            if (!$tree['tree_allow_comments']) {
                _fatal();
            }
            $cv = $this->__(w('comment_username comment_address comment_website comment_message comment_security'));
            $comment_time = time();
            if (!$user->v('is_member')) {
                foreach ($cv as $cv_k => $cv_v) {
                    if (!f($cv_v)) {
                        $this->error('E_COMMENT_FILL_FIELDS');
                        break;
                    }
                }
                if (!$this->errors()) {
                    $sql = 'SELECT comment_time
						FROM _comments
						WHERE comment_ip = ?
							AND comment_status = 0';
                    if ($row_flood = _fieldrow(sql_filter($sql, $user->ip))) {
                        if ($comment_time - $row_flood['comment_time'] < 30) {
                            $this->error('E_COMMENT_FLOOD_TIME');
                        }
                    }
                }
                // CAPTCHA verification
                require_once XFS . 'core/xcf.php';
                $xcf = new captcha();
                if ($xcf->check($cv['comment_security']) === false) {
                    $cv['comment_security'] = '';
                    $this->error('E_COMMENT_INVALID_CAPTCHA');
                }
                unset($xcf);
            }
            if (!$this->errors()) {
                $approve_comments = !$user->v('is_member') ? $tree['tree_approve_comments'] : 1;
                $sql_insert = array('tree' => (int) $tree['tree_id'], 'uid' => (int) $user->v('user_id'), 'username' => $cv['comment_username'], 'email' => $cv['comment_address'], 'website' => $cv['comment_website'], 'ip' => $user->ip, 'status' => (int) $approve_comments, 'time' => (int) $comment_time, 'message' => $cv['comment_message']);
                $sql = 'INSERT INTO _comments' . _build_array('INSERT', prefix('comment', $sql_insert));
                _sql($sql);
                if ($approve_comments) {
                    $sql = 'UPDATE _tree SET tree_comments = tree_comments + 1
						WHERE tree_id = ?';
                    _sql(sql_filter($sql, $tree['tree_id']));
                }
                // Send new comment email notification for approval.
                if (!$approve_comments) {
                    unset($cv['comment_security']);
                    require_once XFS . 'core/emailer.php';
                    $emailer = new emailer();
                    $emailer->from($cv['comment_address']);
                    $emailer->use_template('comment_approval');
                    if (f($tree['tree_form_email'])) {
                        $tree['tree_form_email'] = $core->v('default_comments_email');
                    }
                    foreach (explode(';', $tree['tree_form_email']) as $i => $row) {
                        $row_f = !$i ? 'email_address' : 'cc';
                        $emailer->{$row_f}($row);
                    }
                    $input = w();
                    foreach ($cv as $row_k => $row_v) {
                        if (!f($row_v)) {
                            continue;
                        }
                        if ($row_k == 'comment_message') {
                            $row_v = str_replace("\r\n", '<br />', $row_v);
                        }
                        $input[] = '&lt; ' . $row_v;
                    }
                    $emailer->assign_vars(array('U_APPROVAL' => _link(_rewrite($tree), array('x1' => 'comments')), 'INPUT_FIELDS' => implode('<br /><br />', $input), 'FROM_USERNAME' => $cv['comment_username']));
                    $emailer->send();
                    $emailer->reset();
                }
                redirect(_link(_rewrite($tree)));
            }
            if ($this->errors()) {
                if (is_ghost()) {
                    $this->e('!');
                }
                _style('comments_error', array('MESSAGE' => $this->get_errors()));
            }
        }
        //
        if (f($tree['tree_redirect'])) {
            if (preg_match('#^[a-z0-9\\-\\_]+$#is', $tree['tree_redirect'])) {
                $tree['tree_redirect'] = _link($tree['tree_redirect']);
            }
            redirect($tree['tree_redirect']);
        }
        //
        if ($tree['tree_parent']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ?';
            $parent = _fieldrow(sql_filter($sql, $tree['tree_parent']));
            if ($tree['tree_level'] > 2) {
                $sql = 'SELECT *
					FROM _tree
					WHERE tree_id = ?';
                $subparent = _fieldrow(sql_filter($sql, $parent['tree_parent']));
            }
        }
        if ($tree['tree_node']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ?';
            $node = _fieldrow(sql_filter($sql, $tree['tree_node']));
        }
        //
        if (@method_exists($this, 'cf_' . _rewrite($tree))) {
            $this->{'cf_' . _rewrite($tree)}($tree);
        }
        //
        $sql = 'SELECT *
			FROM _tree
			WHERE tree_parent = ?
				AND tree_child_hide = 0
			ORDER BY ??';
        $childs = _rowset(sql_filter($sql, $tree['tree_id'], $this->child_order($tree)));
        foreach ($childs as $i => $row) {
            if (!$i) {
                $sql = 'SELECT image_id, image_tree, image_extension
					FROM _images
					WHERE image_tree IN (??)
					ORDER BY RAND()';
                $images_child = _rowset(sql_filter($sql, _implode(',', array_keys($childs))), 'tree_id');
                _style('tree_child1', array('ORDER_URL' => _link($tree['tree_id'], array('order', 0, 0, 0, 0))));
            }
            _style('tree_child.row', array('ITEM' => $row['tree_id'], 'URL' => _link(_rewrite($row)), 'SUBJECT' => $row['tree_subject'], 'CONTENT' => $row['tree_content'], 'EDITED' => _format_date($row['tree_edited']), 'IMAGE' => isset($images_child[$row['tree_id']]) ? $images_child[$row['tree_id']]['image_id'] . '.' . $images_child[$row['tree_id']]['image_extension'] : 'default.gif'));
        }
        // Comments
        if ($tree['tree_allow_comments'] && $tree['tree_comments']) {
            $sql = 'SELECT c.comment_id, c.comment_username, c.comment_website, c.comment_time, c.comment_message, m.user_username
				FROM _comments c, _members m
				WHERE c.comment_tree = ?
					AND c.comment_status = 1
					AND c.comment_uid = m.user_id
				ORDER BY c.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'], 'SUSERNAME' => $row['user_username'], 'USERNAME' => $row['comment_username'], 'WEBSITE' => $row['comment_website'], 'TIME' => _format_date($row['comment_time']), 'MESSAGE' => str_replace("\n", '<br />', $row['comment_message'])));
            }
        }
        //
        if ($this->css_parent($tree)) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_parent = ?
					AND tree_child_hide = 0
				ORDER BY ??';
            $childs_parent = _rowset(sql_filter($sql, $this->css_var($tree), $this->child_order($tree)));
            foreach ($childs_parent as $i => $row) {
                if (!$i) {
                    $sql = 'SELECT image_id, image_tree, image_extension
						FROM _images
						WHERE image_tree IN (??)
						ORDER BY RAND()';
                    $images_child_parent = _rowset(sql_filter($sql, _implode(',', array_keys($childs_parent))), 'tree_id');
                    _style('tree_child', array('ORDER_URL' => _link($tree['tree_id'], array('order', 0, 0, 0, 0))));
                }
                _style('tree_child_parent.row', array('ITEM' => $row['tree_id'], 'URL' => _link(_rewrite($row)), 'TITLE' => $row['tree_subject'], 'IMAGE' => isset($images_child_parent[$row['tree_id']]) ? $images_child_parent[$row['tree_id']]['image_id'] . '.' . $images_child_parent[$row['tree_id']]['image_extension'] : 'default.gif'));
            }
        }
        if ($tree['tree_downloads']) {
            $sql = 'SELECT *
				FROM _downloads
				WHERE download_tree = ?
				ORDER BY download_order';
            $downloads = _rowset(sql_filter($sql, $tree['tree_id']));
            foreach ($downloads as $i => $row) {
                if (!$i) {
                    _style('downloads', array('ORDER_URL' => _link($tree['tree_id'], array('orderd', 0, 0, 0, 0))));
                }
                _style('downloads.row', array('ITEM' => $row['download_id'], 'DOWNLOAD' => _link('get', $row['download_alias'] . '.' . $row['download_extension']), 'TITLE' => $row['download_title']));
            }
        }
        //
        if ($tree['tree_form']) {
            $sql = 'SELECT *
				FROM _form_fields
				WHERE form_tree = ?
				ORDER BY form_order';
            $form = _rowset(sql_filter($sql, $tree['tree_id']), 'form_alias');
            if (!count($form)) {
                $sql = 'SELECT *
					FROM _form_fields
					WHERE form_tree = 0
					ORDER BY form_order';
                $form = _rowset($sql, 'form_alias');
            }
            $form['secure'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'secure', 'form_type' => 'text', 'form_legend' => 'Imagen de seguridad');
            _style('form', array('URL' => _link(_rewrite($tree))));
            foreach ($form as $row) {
                _style('form.row', array('ALIAS' => $row['form_alias'], 'REQUIRED' => $row['form_required'], 'LEGEND' => _lang($row['form_legend']), 'TYPE' => $row['form_type'], 'PAGE' => $tree['tree_alias']));
                foreach ($row as $row_k => $row_v) {
                    if (preg_match('#^form_(alias|type)$#is', $row_k)) {
                        if ($row_k == 'form_alias') {
                            $row_k = 'name';
                        }
                        _style('form.row.attrib', array('ATTRIB' => str_replace('form_', '', $row_k), 'VALUE' => $row_v));
                    }
                }
            }
        }
        $s_css_page = '';
        if (@file_exists('./style/css/_tree_' . _rewrite($tree) . '.css')) {
            $s_css_page = _rewrite($tree) . '/';
        } elseif ($this->css_parent($tree)) {
            if (!f($tree['tree_css_var'])) {
                $tree['tree_css_var'] = 'parent';
            }
            $ary_css_var = false;
            switch ($tree['tree_css_var']) {
                case 'parent':
                case 'subparent':
                case 'node':
                    $ary_css_var = ${$tree['tree_css_var']};
                    break;
                default:
                    if (is_numb($tree['tree_css_var'])) {
                        $sql = 'SELECT *
							FROM _tree
							WHERE tree_id = ?';
                        if ($css_var_row = _fieldrow(sql_filter($sql, $tree['tree_css_var']))) {
                            $ary_css_var = $css_var_row;
                        }
                    }
                    break;
            }
            if ($ary_css_var !== false) {
                $s_css_page = _rewrite($ary_css_var) . '/';
            }
        }
        v_style(array('S_IMAGES' => $core->v('address') . 'container/images/a_' . ($this->css_parent($tree) ? $this->css_var($tree) : $tree['tree_id']) . '/', 'V_TREE' => $tree['tree_id'], 'V_CSS' => $s_css_page, 'V_SUBJECT' => $tree['tree_subject'], 'V_CONTENT' => _message($tree['tree_content']), 'V_COMMENTS' => $tree['tree_comments'], 'V_ALLOW_COMMENTS' => $tree['tree_allow_comments'], 'V_ALLOW_FORM' => $tree['tree_form'], 'U_COMMENTS' => _link(_rewrite($tree)), 'U_XCF' => _link(_rewrite($tree) . '-xs.jpg', false, false)));
        $tree['tree_subject'] = strip_tags($tree['tree_subject']);
        //
        if ($tree['tree_alias'] != 'home') {
            if ($node['tree_id'] != $parent['tree_id']) {
                $this->navigation($node['tree_subject'], _rewrite($node));
            }
            if ($tree['tree_level'] > 2) {
                if ($parent['tree_id'] && $node['tree_id'] && $tree['tree_level'] > 3) {
                    $this->navigation('...');
                }
                $this->navigation($subparent['tree_subject'], _rewrite($subparent));
            }
            if ($parent['tree_id']) {
                $this->navigation($parent['tree_subject'], _rewrite($parent));
            }
            $this->navigation($tree['tree_subject'], _rewrite($tree));
        }
        if ($user->v('is_member')) {
            $tree['tree_cp'] = 1;
            $i = 0;
            $auth_tree = array('create', 'modify', 'remove');
            foreach ($auth_tree as $row) {
                if (_auth_get('cp_' . $row)) {
                    if (!$i) {
                        _style('auth');
                    }
                    _style('auth.row', array('U_AUTH' => _link('cp', array($row, _rewrite($tree))), 'V_NAME' => _lang('CP_AUTH_' . $row)));
                    $i++;
                }
            }
        }
        //
        $this->_template('tree');
        if (f($tree['tree_template']) && @file_exists('./style/custom/' . $tree['tree_template'] . '.htm')) {
            $this->_template('custom/' . $tree['tree_template']);
        }
        // TODO: 304 header response
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $tree['tree_edited']) . ' GMT');
        return;
    }
コード例 #4
0
ファイル: project.php プロジェクト: nopticon/mag
    protected final function bio_exists($bio)
    {
        $f = is_numb($bio) ? 'id' : 'alias';
        $sql = 'SELECT bio_id
			FROM _bio
			WHERE bio_?? = ?
				AND bio_status = ?';
        if (!sql_field(sql_filter($sql, $f, $bio), 'bio_id', 1)) {
            return false;
        }
        return true;
    }
コード例 #5
0
ファイル: _email.php プロジェクト: nopticon/jade
	function _check_home() {
		global $user;
		
		$v = $this->__(array('id' => 0));
		
		$sql = 'SELECT *
			FROM _email
			WHERE email_id = ?';
		if (!$email = sql_fieldrow(sql_filter($sql, $v['id']))) {
			$this->e('El registro de email no existe.');
		}
		
		foreach (w('start end') as $k) {
			$email['email_' . $k] = ($email['email_' . $k]) ? $user->format_date($email['email_' . $k]) : '';
		}
		
		foreach ($email as $k => $v) {
			if (is_numb($k)) unset($email[$k]);
		}
		
		$this->e($email);
	}
コード例 #6
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;
    }
コード例 #7
0
ファイル: bio.php プロジェクト: nopticon/npt
    public function auth_field($f)
    {
        $ff = is_numb($f) ? 'id' : 'alias';
        $sql = 'SELECT *
			FROM _bio_auth_field
			WHERE field_?? = ?';
        if (!($field = _fieldrow(sql_filter($sql, $ff, $f)))) {
            return false;
        }
        return $field;
    }
コード例 #8
0
ファイル: _events.php プロジェクト: nopticon/mag
    protected function _view_home()
    {
        global $core, $bio;
        $v = $this->__(array('alias', 't' => 0, 'p' => 0));
        if (!f($v['alias'])) {
            _fatal();
        }
        $v['field'] = !is_numb($v['alias']) ? 'alias' : 'id';
        $sql = 'SELECT *
			FROM _events
			WHERE event_?? = ?';
        if (!($event = _fieldrow(sql_filter($sql, $v['field'], $v['alias'])))) {
            _fatal();
        }
        if ($v['field'] == 'id' && f($event['event_alias'])) {
            redirect(_link($this->m(), $event['event_alias']) . _linkp(array('t' => $v['t'], 'p' => $v['p']), true));
        }
        // Get images
        $sql = 'SELECT *
			FROM _events_images
			WHERE image_event = ?
			ORDER BY image ASC
			LIMIT ??, ??';
        $event_images = _rowset(sql_filter($sql, $event['event_id'], $v['t'], $core->v('thumbs_per_page')));
        foreach ($event_images as $i => $row) {
            if (!$i) {
                _style('thumbnails', _pagination(_link($this->m(), $event['event_alias']), 't:%d', $event['event_images'], $core->v('thumbs_per_page'), $v['t']));
            }
            _style('thumbnails.row', array('U_THUMBNAIL' => _lib(w(LIB_EVENT . ' thumbnail ' . $event['event_id'], $row['image'], 'jpg')), 'U_IMAGE' => _lib(w(LIB_EVENT . ' gallery ' . $event['event_id'], $row['image'], 'jpg')), 'V_FOOTER' => $row['image_footer']));
        }
        if (is_ghost()) {
            return;
        }
        // Statistics
        if (!$v['t'] && !$bio->v('auth_founder')) {
            $this->_stats_store();
        }
        $is_future = $row['event_end'] > time() ? true : false;
        if (!$is_future) {
            // Star for favourites
            if (!($star_type = $core->cache_load('star_type'))) {
                $sql = 'SELECT type_id, type_name
					FROM _events_star_type
					ORDER BY type_order';
                $types = $core->cache_store('star_type', _rowset($sql, 'type_id', 'type_name'));
            }
            $i = 0;
            foreach ($types as $type_id => $type_name) {
                if (!$i) {
                    _style('star_type');
                }
                _style('star_type.row', array('TYPE_ID' => $type_id, 'TYPE_NAME' => $type_name));
                $i++;
            }
        } else {
            $sql = 'SELECT *
				FROM _events_reviews r, _bio b
				WHERE r.review_event = ?
					AND r.review_uid = b.bio_id
				ORDER BY r.review_avg
				LIMIT 0, 5';
            $reviews = _rowset(sql_filter($sql, $event['event_id']), 'review_id');
            $sql = 'SELECT *
				FROM _events_reviews_rate r, _events_reviews_fields f
				WHERE r.rate_review IN (??)
					AND r.rate_field = f.field_id
				ORDER BY f.field_order';
            $reviews_rate = _rowset(sql_filter($sql, _implode(',', array_keys($reviews))), 'rate_review', false, true);
            $i = 0;
            foreach ($reviews as $row) {
                if (!$i) {
                    _style('reviews');
                }
                _style('reviews.row', array('REVIEW_CONTENT' => $row['review_content'], 'REVIEW_' => $row['review_']));
                if (isset($reviews_rate[$row['review_id']])) {
                    foreach ($reviews_rate[$row['review_id']] as $j => $rate) {
                        if (!$j) {
                            _style('reviews.row.rate');
                        }
                        _style('reviews.row.rate.field', array('FIELD' => $rate['field_name'], 'RATE' => $rate['rate_value']));
                    }
                }
                $i++;
            }
        }
        // Who attend
        $sql = 'SELECT at.type_id, at.type_name_next, at.type_name_prev, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up
			FROM _events_attend a, _events_attend_type at, _bio b
			WHERE a.attend_event = ?
				AND a.attend_type = at.type_id
				AND a.attend_uid = b.bio_id
			ORDER BY a.attend_time';
        $attend = _rowset(sql_filter($sql, $event['event_id']), 'type_id', false, true);
        $i = 0;
        foreach ($attend as $type_name => $rows) {
            if (!$i) {
                _style('attend');
            }
            $type_name = $is_future ? 'next' : 'prev';
            _style('attend.type', array('TYPE_NAME' => $rows[0]['type_name_' . $type_name]));
            foreach ($rows as $row) {
                _style('attend.type.row', array('BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row)));
            }
            $i++;
        }
        // Messages
        $ref = _link('events', $event['event_alias']);
        if ($event['event_publish']) {
            if ($event['event_comments']) {
                $sql = 'SELECT c.comment_id, c.comment_time, c.comment_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up
					FROM _events_comments c, _bio b
					WHERE c.comment_event = ?
						AND c.comment_active = ?
						AND c.comment_bio = b.bio_id
					ORDER BY c.comment_time DESC
					LIMIT ??, ??';
                $comments = _rowset(sql_filter($sql, $event['event_id'], 1, $v['p'], $core->v('events_comments')));
                foreach ($comments as $i => $row) {
                    if (!$i) {
                        _style('comment_area', _pagination(_link($this->m(), array($event['event_alias'], $v['t'], 's%d')), $topic_data['topic_replies'] + 1, $core->v('posts_per_page'), $start));
                    }
                    _style('comment_area.row', array('BIO_ALIAS' => _link_bio($row['bio_alias']), 'BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row), 'COMMENT_ID' => $row['comment_id'], 'COMMENT_TIME' => _format_date($row['comment_time']), 'COMMENT_TEXT' => _message($row['comment_text'])));
                }
            }
            _style('comment_publish', array('U_PUBLISH' => _link()));
        }
        //
        if ($event['event_posts']) {
            $reply = array('ref' => $ref, 'start' => $v['p'], 'start_f' => 's', 'rows' => $event['event_posts'], 'rows_page' => $core->v('s_posts'), 'block' => 'posts', 'sql' => 'SELECT p.post_id, p.post_time, p.post_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up, b.bio_sig
					FROM _events_posts p, _bio b
					WHERE p.post_event = ?
						AND p.post_active = 1 
						AND p.post_uid = b.bio_id
					ORDER BY p.post_time DESC
					LIMIT {START}, {ROWS_PAGE}');
            $reply['sql'] = sql_filter($reply['sql'], $event['event_id']);
            $this->_replies($reply);
        }
        v_style(_vs(array('SUBJECT' => $event['event_subject'], 'IMAGES' => $event['event_images'], 'START' => _format_date($event['event_start'], 'd F Y'), 'END' => _format_date($event['event_end'], 'd F Y'), 'COMMENTS' => $event['event_posts']), 'event'));
        return;
    }
コード例 #9
0
ファイル: functions.php プロジェクト: nopticon/npt
function array_row($a)
{
    $w = w();
    foreach ($a as $k => $v) {
        if (!is_numb($k)) {
            $w[$k] = $v;
        }
    }
    return $w;
}
コード例 #10
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;
    }
コード例 #11
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;
    }
コード例 #12
0
ファイル: artists.php プロジェクト: nopticon/rockr
	public function _list() {
		global $user, $config;

		$sql = 'SELECT *
			FROM _artists
			ORDER BY local DESC, name ASC';
		$result = sql_rowset($sql);

		$alphabet = w();
		foreach ($result as $row) {
			$this->adata[$row['local']][$row['ub']] = $row;

			$alpha_id = strtolower($row['name']);
			$alpha_id = $alpha_id{0};
			if (!isset($alphabet[$alpha_id])) {
				if (is_numb($alpha_id)) {
					$alpha_id = '#';
				}
				$alphabet[$alpha_id] = true;
			}
		}

		$selected_char = '';
		$s_alphabet = request_var('alphabet', 0);

		if ($s_alphabet) {
			$selected_char = chr(octdec($s_alphabet));
			if (!preg_match('/([\#a-z])/', $selected_char)) {
				redirect(s_link('a'));
			}
		}

		if ($s_alphabet) {
			$sql_where = (($selected_char == '#') ? "name NOT RLIKE '^[a-z]'" : sql_filter('name LIKE ?', $selected_char . '%'));
		} else {
			$sql_where = 'images > 1';
		}

		$sql_order = (!$s_alphabet) ? 'RAND() LIMIT 12' : 'name';

		$sql = 'SELECT *
			FROM _artists
			WHERE ' . $sql_where . '
			ORDER BY ' . $sql_order;
		if (!$selected_artists = sql_rowset($sql, 'ub')) {
			redirect(s_link('a'));
		}

		$sql = 'SELECT *
			FROM _artists_images
			WHERE ub IN (??)
			ORDER BY RAND()';
		$result = sql_rowset(sql_filter($sql, implode(',', array_keys($selected_artists))));

		$random_images = w();
		foreach ($result as $row) {
			if (!isset($random_images[$row['ub']])) {
				$random_images[$row['ub']] = $row['image'];
			}
		}

		_style('search_match');

		if (!$s_alphabet) {
			_style('search_match.ajx');
			$this->ajx = false;
		}

		foreach ($selected_artists as $ub => $data) {
			$image = '';

			if (isset($random_images[$ub])) {
				$image = $ub . '/thumbnails/' . $random_images[$ub] . '.jpg';
			}

			_style('row', array(
				'NAME' => $data['name'],
				'IMAGE' => $config['artists_url'] . $image,
				'URL' => s_link('a', $data['subdomain']),
				'LOCATION' => ($data['local']) ? 'Guatemala' : $data['location'],
				'GENRE' => $data['genre'])
			);
		}

		ksort($alphabet);

		foreach ($alphabet as $key => $null) {
			_style('alphabet_item', array(
				'CHAR' => strtoupper($key),
				'URL' => s_link('a', '_' . decoct(ord($key))))
			);
		}

		v_style(array(
			'TOTAL_A' => $config['max_artists'],
			'SELECTED_LETTER' => ($selected_char) ? strtoupper($selected_char) : '')
		);

		return;
	}
コード例 #13
0
ファイル: comments.php プロジェクト: nopticon/rockr
	public function store() {
		global $user, $config;

		$this->param = explode('/', array_key(explode('//', $this->ref), 1));
		$this->param = array_splice($this->param, 1, -1);

		$sql = '';
		$id = (isset($this->param[3])) ? (int) $this->param[3] : 0;

		switch ($this->param[0]) {
			case 'a':
				if ($this->param[2] == 9) {
					$sql = 'SELECT *
						FROM _dl d, _artists a
						WHERE d.id = ?
							AND a.subdomain = ?
							AND d.ub = a.ub';
					$sql = sql_filter($sql, $id, $this->param[1]);

					$this->data = array(
						'DATA_TABLE' => '_dl',
						'POST_TABLE' => 'dl_posts',
						'HISTORY' => UH_M
					);
				} else {
					$sql = 'SELECT *
						FROM _artists
						WHERE subdomain = ?';
					$sql = sql_filter($sql, $this->param[1]);

					$this->data = array(
						'DATA_TABLE' => '_artists',
						'POST_TABLE' => 'artists_posts',
						'HISTORY' => UH_C
					);
				}
				break;
			case 'events':
				$event_field = (is_numb($this->param[1])) ? 'id' : 'event_alias';

				$sql = 'SELECT *
					FROM _events
					WHERE ?? = ?';
				$sql = sql_filter($sql, $event_field, $this->param[1]);

				$this->data = array(
					'DATA_TABLE' => '_events',
					'POST_TABLE' => 'events_posts',
					'HISTORY' => UH_EP
				);
				break;
			case 'news':
				$sql = 'SELECT *
					FROM _news
					WHERE news_id = ?';
				$sql = sql_filter($sql, $this->param[1]);

				$this->data = array(
					'DATA_TABLE' => '_news',
					'POST_TABLE' => 'news_posts',
					'HISTORY' => UH_NP
				);
				break;
			case 'art':
				$sql = 'SELECT *
					FROM _art
					WHERE art_id = ?';
				$sql = sql_filter($sql, $this->param[1]);

				$this->data = array(
					'DATA_TABLE' => '_art',
					'POST_TABLE' => 'art_posts',
					'HISTORY' => UH_W
				);
				break;
			case 'm':
				$sql = 'SELECT *
					FROM _members
					WHERE username_base = ?';
				$sql = sql_filter($sql, $this->param[1]);

				$this->data = array(
					'DATA_TABLE' => '_members',
					'POST_TABLE' => 'members_posts',
					'HISTORY' => UH_UPM
				);
				break;
			default:
				fatal_error();
				break;
		}

		if (empty($sql)) {
			fatal_error();
		}

		if (!$post_data = sql_fieldrow($sql)) {
			fatal_error();
		}

		$post_reply = 0;
		$error = w();
		$update_sql = '';
		$current_time = time();

		$this->auth['user'] = $user->is('member');
		$this->auth['adm'] = $user->is('founder');

		/*
		//
		// Flood control
		//
		if (!$this->auth['adm'] && !$this->auth['mod'])
		{
			$where_sql = (!$this->auth['user']) ? "post_ip = '$user_ip'" : "poster_id = " . $userdata['user_id'];
			$sql = "SELECT MAX(post_time) AS last_datetime
				FROM " . $this->data['POST_TABLE'] . "
				WHERE $where_sql";
		 if ($row = sql_fieldrow($sql)) {
		 	if ((intval($row['last_datetime']) > 0) && ($current_time - intval($row['last_datetime'])) < 10)
			{
				$error[] = 'CHAT_FLOOD_CONTROL';
			}
		 }
		}
		*/

		//
		// Check if message is empty
		//
		if (!sizeof($error)) {
			$message = request_var('message', '', true);

			// Check message
			if (empty($message)) {
				$error[] = 'EMPTY_MESSAGE';
			}
		}

		//
		// Insert processed data
		//
		if (!sizeof($error)) {
			$update_sql = '';
			$post_reply = (isset($this->param[4]) && $this->param[4] == 'reply') ? $id : 0;
			$message = $this->prepare($message);

			$insert_data = array(
				'post_reply' => (int) $post_reply,
				'post_active' => 1,
				'poster_id' => (int) $user->d('user_id'),
				'post_ip' => (string) $user->ip,
				'post_time' => (int) $current_time,
				'post_text' => (string) $message
			);

			switch ($this->param[0]) {
				case 'a':
					switch ($this->param[2]) {
						case 9:
							$insert_data['download_id'] = (int) $post_data['id'];
							$update_sql = sql_filter('posts = posts + 1 WHERE id = ?', $post_data['id']);

							$this->data['HISTORY_EXTRA'] = $post_data['ub'];
							break;
						case 12:
						default:
							$insert_data['post_ub'] = (int) $post_data['ub'];
							$update_sql = sql_filter('posts = posts + 1 WHERE ub = ?', $post_data['ub']);

							$this->data['HISTORY_EXTRA'] = $post_data['ub'];
							$this->data['REPLY_TO_SQL'] = sql_filter('SELECT p.poster_id, m.user_id
								FROM _artists_posts p, _members m
								WHERE p.post_id = ?
									AND p.poster_id = m.user_id
									AND m.user_type NOT IN (??)', $post_reply, USER_INACTIVE);
							break;
					}
					break;
				case 'events':
					$insert_data['event_id'] = (int) $post_data['id'];
					$update_sql = sql_filter('posts = posts + 1 WHERE id = ?', $post_data['id']);
					break;
				case 'news':
					$insert_data['news_id'] = (int) $post_data['news_id'];
					$update_sql = sql_filter('post_replies = post_replies + 1 WHERE news_id = ?', $post_data['news_id']);
					break;
				case 'art':
					$insert_data['art_id'] = (int) $post_data['art_id'];
					$update_sql = sql_filter('posts = posts + 1 WHERE art_id = ?', $post_data['art_id']);
					break;
				case 'm':
					$insert_data['userpage_id'] = (int) $post_data['user_id'];
					$update_sql = sql_filter('userpage_posts = userpage_posts + 1 WHERE user_id = ?', $post_data['user_id']);

					$this->data['HISTORY_EXTRA'] = $post_data['user_id'];
					break;
			}

			$post_id = sql_insert($this->data['POST_TABLE'], $insert_data);

			if ($update_sql != '') {
				$sql = 'UPDATE ' . $this->data['DATA_TABLE'] . ' SET ' . $update_sql;
				sql_query($sql);
			}

			$reply_to = 0;
			$history_extra = isset($this->data['HISTORY_EXTRA']) ? $this->data['HISTORY_EXTRA'] : 0;

			if ($post_reply && isset($this->data['REPLY_TO_SQL'])) {
				if ($reply_row = sql_fieldrow($this->data['REPLY_TO_SQL'])) {
					$reply_to = ($reply_row['user_id'] != GUEST) ? $reply_row['user_id'] : 0;
				}

				$user->delete_unread($this->data['HISTORY'], $post_reply);
			}

			$notify = true;
			if ($this->param[0] == 'm' && $user->d('user_id') == $post_data['user_id']) {
				$notify = false;
			}

			if ($notify) {
				if ($this->param[0] == 'm') {
					$emailer = new emailer();

					$emailer->from('info');
					$emailer->use_template('user_message');
					$emailer->email_address($post_data['user_email']);
					$emailer->set_subject($user->d('username') . ' te envio un mensaje en Rock Republik');

					$emailer->assign_vars(array(
						'USERNAME_TO' => $post_data['username'],
						'USERNAME_FROM' => $user->d('username'),
						'USER_MESSAGE' => entity_decode($message),
						'U_PROFILE' => s_link('m', $user->d('username_base')))
					);
					$emailer->send();
					$emailer->reset();

					$user->save_unread($this->data['HISTORY'], $post_id, $history_extra, $post_data['user_id']);
				} else {
					$user->save_unread($this->data['HISTORY'], $post_id, $history_extra, $reply_to, false);

					// Points
					//$user->points_add(1);
				}
			}

			// Userpage messages
			if ($this->param[0] == 'm') {
				$sql = 'SELECT post_id
					FROM _members_posts p, _members_unread u
						WHERE u.item = p.post_id
							AND p.userpage_id = ?
							AND p.poster_id = ?';
				if ($rows = sql_rowset(sql_filter($sql, $user->d('user_id'), $post_data['user_id']), false, 'post_id')) {
					$sql = 'DELETE FROM _members_unread
						WHERE user_id = ?
							AND element = ?
							AND item IN (??)';
					sql_query(sql_filter($sql, $user->d('user_id'), UH_UPM, implode(',', $rows)));
				}
			}
		} else {
			$user->setup();

			$return_message = parse_error($error) . '<br /><br /><br /><a href="' . $ref . '">' . lang('click_return_lastpage') . '</a>';
			trigger_error($return_message);
		}

		return;
	}
コード例 #14
0
ファイル: functions.php プロジェクト: nopticon/rockr
function get_artist($id, $force = false) {
	$artist_field = (is_numb($id) && !$force) ? 'ub' : 'subdomain';

	$sql = 'SELECT *
		FROM _artists
		WHERE ?? = ?';
	if (!$data = sql_fieldrow(sql_filter($sql, $artist_field, $id))) {
		return false;
	}

	return $data;
}
コード例 #15
0
ファイル: _contacts.php プロジェクト: nopticon/tts
    protected function _value_modify()
    {
        gfatal();
        global $user, $core;
        $v = $this->__(array('field', 'uid' => 0));
        $ev = explode('_', $v['field']);
        $v['a'] = $ev[0];
        unset($ev[0]);
        $v['field'] = implode('_', $ev);
        $field = w();
        $field_store = true;
        if (is_numb($v['field'])) {
            $sql = 'SELECT *
				FROM _members_store
				WHERE a_field = ?
					AND a_assoc = ?';
            if (!($value = _fieldrow(sql_filter($sql, $v['field'], $v['a'])))) {
                $this->_error('#COMPUTER_FIELD_NODATA');
            }
            $sql = 'SELECT *
				FROM _members_fields
				WHERE field_id = ?';
            if (!($field = _fieldrow(sql_filter($sql, $value['a_field'])))) {
                $this->_error('#COMPUTER_FIELD_NOEXISTS');
            }
        } else {
            $sql = 'SELECT *
				FROM _members
				WHERE user_id = ?';
            if (!($value = _fieldrow(sql_filter($sql, $v['a'])))) {
                $this->_error('#COMPUTER_FIELD_NODATA');
            }
            if (!isset($value['user_' . $v['field']])) {
                $this->_error('#COMPUTER_FIELD_NOEXISTS');
            }
            $field_store = false;
            $field_lang = array('name_show' => 'CONTACT_FIELDS_NAME_SHOW', 'firstname' => 'CONTACT_FIELDS_FIRSTNANE', 'lastname' => 'CONTACT_FIELDS_LASTNAME', 'username' => 'CONTACT_FIELDS_USERNAME');
            $field = array('field_type' => 'text', 'field_id' => $v['field'], 'field_alias' => $v['field'], 'field_display' => _lang($field_lang[$v['field']]), 'field_value' => $value['user_' . $v['field']]);
            $value['a_value'] = $value['user_' . $v['field']];
        }
        $v = array_merge($v, $this->__(array($field['field_alias'])));
        $v['value'] = $v[$field['field_alias']];
        if ($field_store) {
            switch ($field['field_alias']) {
                case 'status':
                    $sql = 'SELECT status_ext
						FROM _members_status
						WHERE status_id = ?';
                    $status_ext = _field(sql_filter($sql, $v['value']), 'status_ext', 0);
                    $sql = 'UPDATE _members SET user_active = ?
						WHERE user_id = ?';
                    _sql(sql_filter($sql, $status_ext, $v['uid']));
                    break;
                case 'carnet':
                    if (!($field_ctype = $core->cache_load('members_field_ctype'))) {
                        $sql = 'SELECT field_id
							FROM _members_fields
							WHERE field_alias = ?';
                        $field_ctype = $core->cache_store(_field(sql_filter($sql, 'ctype'), 'field_id'));
                    }
                    $sql = 'SELECT a_value
						FROM _members_store
						WHERE a_assoc = ?
							AND a_field = ?';
                    if (!($uid_ctype = _field(sql_filter($sql, $v['uid'], $field_ctype), 'a_value'))) {
                        $this->_error('#FIELD_FIRST_CTYPE');
                    }
                    $sql = 'SELECT a_assoc
						FROM _members_store
						WHERE a_field = ?
							AND a_value = ?
							AND a_assoc <> ?';
                    if ($a_assoc = _field(sql_filter($sql, $v['field'], $v['value'], $v['uid']), 'a_assoc')) {
                        $sql = 'SELECT a_id
							FROM _members_store
							WHERE a_assoc = ?
								AND a_field = ?
								AND a_value = ?';
                        if ($field_ctype = _field(sql_filter($sql, $a_assoc, $field_ctype, $uid_ctype), 'a_id')) {
                            $this->_error('#FIELD_DUPLICATE');
                        }
                    }
                    break;
            }
            $this->parse_calendar($field['field_type'], $v['value']);
            $sql = 'UPDATE _members_store SET a_value = ?
				WHERE a_id = ?';
            _sql(sql_filter($sql, $v['value'], $value['a_id']));
        } else {
            if ($field['field_alias'] == 'username' && $v['value'] != $value['user_username']) {
                $sql = 'SELECT *
					FROM _members
					WHERE user_username = ?';
                if (_fieldrow(sql_filter($sql, $v['value']))) {
                    $this->_error('#CONTACT_CREATE_EXISTS');
                }
            }
            $sql = 'UPDATE _members SET user_?? = ?
				WHERE user_id = ?';
            _sql(sql_filter($sql, $field['field_alias'], $v['value'], $value['user_id']));
        }
        return $this->e('~OK');
    }