Example #1
0
	public function _home() {
		global $config, $user, $comments;

		$this->_artist();

		if (_button()) {
			$message = request_var('message', '');
			$message = $comments->prepare($message);

			$sql = 'UPDATE _artists SET bio = ?
				WHERE ub = ?';
			sql_query(sql_filter($sql, $message, $this->object['ub']));

			_style('updated');
		}

		$sql = 'SELECT bio
			FROM _artists
			WHERE ub = ?';
		$bio = sql_field(sql_filter($sql, $this->object['ub']), 'bio');

		v_style(array(
			'MESSAGE' => $bio)
		);

		return;
	}
Example #2
0
	public function run() {
		global $config, $user;

		$this->founders();
		$this->team();
		$this->recent_members();
		$this->birthdays();

		v_style(array(
			'MEMBERS_COUNT' => number_format($config['max_users']))
		);

		//
		// Online
		//
		$sql = 'SELECT u.user_id, u.username, u.username_base, u.user_type, u.user_hideuser, s.session_ip
			FROM _members u, _sessions s
			WHERE s.session_time >= ?
				AND u.user_id = s.session_user_id
			ORDER BY u.username ASC, s.session_ip ASC';
		$this->online(sql_filter($sql, ($user->time - (5 * 60))), 'online', 'MEMBERS_ONLINE');

		//
		// Today Online
		//
		$minutes = date('is', time());
		$timetoday = (time() - (60 * intval($minutes[0].$minutes[1])) - intval($minutes[2].$minutes[3])) - (3600 * $user->format_date(time(), 'H'));

		$sql = 'SELECT user_id, username, username_base, user_hideuser, user_type
			FROM _members
			WHERE user_type NOT IN (??)
				AND user_lastvisit >= ?
				AND user_lastvisit < ?
			ORDER BY username';
		$this->online(sql_filter($sql, USER_INACTIVE, $timetoday, ($timetoday + 86399)), 'online', 'MEMBERS_TODAY', 'MEMBERS_VISIBLE');

		return true;
	}
Example #3
0
    public function run($mod = false)
    {
        global $bio, $core, $file, $warning;
        if (!($rewrite = enable_rewrite())) {
            $warning->now('Enable mod_rewrite on Apache.');
        }
        require_once XFS . XCOR . 'modules.php';
        if ($mod === false) {
            $mod = request_var('module', '');
        }
        $mod = !empty($mod) ? $mod : 'home';
        if (!($_module = $core->cache->load('module_' . str_replace('/', '_', $mod)))) {
            $sql = 'SELECT *
				FROM _modules
				WHERE module_alias = ?';
            if (!($_module = $core->cache->store(sql_fieldrow(sql_filter($sql, $mod))))) {
                $warning->now('no_module');
            }
        }
        $_module->module_path = XFS . XMOD . $_module->module_path . $_module->module_basename;
        if (!@file_exists($_module->module_path)) {
            $warning->now('no_path: ' . $_module->module_path);
        }
        @(require_once $_module->module_path);
        $_object = '__' . $mod;
        if (!class_exists($_object)) {
            $warning->now();
        }
        $module = new $_object();
        $module->m($mod);
        if (@method_exists($module, 'install')) {
            $module->_install();
        }
        if (!defined('ULIB')) {
            define('ULIB', _link() . str_replace(w('../ ./'), '', LIB));
        }
        if (empty($this->input)) {
            $_input = array();
            if ($arg = request_var('args', '')) {
                foreach (explode('.', $arg) as $str_pair) {
                    $pair = explode(':', $str_pair);
                    if (isset($pair[0]) && isset($pair[1]) && !empty($pair[0])) {
                        $this->input[$pair[0]] = $pair[1];
                    }
                }
            }
            if (isset($_POST) && count($_POST)) {
                $_POST = _utf8($_POST);
                $this->input = array_merge($this->input, $_POST);
            }
        }
        $module->levels($this->input);
        if (!method_exists($module, $module->x(1))) {
            $warning->now();
        }
        if ($module->auth() && (!$module->x(1) || !in_array($module->x(1), $module->exclude))) {
            $module->signin();
        }
        //
        // All verifications passed, so start session for the request
        $bio->start(true);
        $bio->setup();
        if (!$module->auth_access() && $module->auth()) {
            $warning->now();
        }
        $module->navigation('home', '', '');
        $module->navigation($module->m(), '');
        if ($module->x(1) != 'home' && @method_exists($module, 'init')) {
            $module->init();
        }
        hook(array($module, $module->x(1)));
        if (!$module->_template()) {
            $module->_template($mod);
        }
        //
        // Output template
        $page_module = 'MODULE_' . $mod;
        if ($bio->is_lang($page_module)) {
            $module->page_title($page_module);
        }
        $browser_upgrade = false;
        if (!$core->v('skip_browser_detect') && ($list_browser = $file->read(XFS . XCOR . 'store/need_browser'))) {
            $browser_list = w();
            foreach ($list_browser as $row) {
                $e = explode(' :: ', $row);
                $browser_list[$e[0]] = $e[1];
            }
            foreach ($browser_list as $browser => $version) {
                if (_browser($browser) && _browser($browser, $version)) {
                    v_style(array('visual' => ULIB . LIB_VISUAL));
                    $module->_template('browsers');
                    $browser_upgrade = true;
                }
            }
        }
        $sv = array('X1' => $module->x(1), 'X2' => $module->x(2), 'NAVIGATION' => $module->get_navigation(), 'BROWSER_UPGRADE' => $browser_upgrade);
        _layout($module->_template(), $module->page_title(), $sv);
    }
Example #4
0
	public function _help_add() {
		global $user, $cache;
		
		$error = array();
		$sub = $this->control->get_var('sub', '');
		$submit = _button();
		
		$menu = array('module' => 'CONTROL_COMMENTS_HELP_MODULE', 'cat' => 'CATEGORY', 'faq' => 'FAQ');
		
		switch ($sub) {
			case 'cat':
				$module_id = 0;
				$help_es = '';
				$help_en = '';
				break;
			case 'faq':
				$help_id = 0;
				$question_es = '';
				$question_en = '';
				$answer_es = '';
				$answer_en = '';
				break;
			case 'module':
				$module_name = '';
				break;
			default:
				_style('menu');
				
				foreach ($menu as $url => $name) {
					_style('menu.item', array(
						'URL' => s_link_control('comments', array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $url)),
						'TITLE' => (isset($user->lang[$name])) ? $user->lang[$name] : $name)
					);
				}
				break;
		}
		
		if ($submit) {
			switch ($sub) {
				case 'cat':
					$module_id = $this->control->get_var('module_id', 0);
					$help_es = $this->control->get_var('help_es', '');
					$help_en = $this->control->get_var('help_en', '');
					
					if (empty($help_es) || empty($help_en)) {
						$error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
					}
					
					// Insert
					if (!sizeof($error)) {
						$sql_insert = array(
							'help_module' => (int) $module_id,
							'help_es' => $help_es,
							'help_en' => $help_en
						);
						
						$sql = 'INSERT INTO _help_cat' . sql_build('INSERT', $sql_insert);
					}
					break;
				case 'faq':
					$help_id = $this->control->get_var('help_id', 0);
					$question_es = $this->control->get_var('question_es', '');
					$question_en = $this->control->get_var('question_en', '');
					$answer_es = $this->control->get_var('answer_es', '');
					$answer_en = $this->control->get_var('answer_en', '');
					
					if (empty($question_es) || empty($question_en) || empty($answer_es) || empty($answer_en)) {
						$error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
					}
					
					if (!sizeof($error)) {
						$sql_insert = array(
							'help_id' => $help_id,
							'faq_question_es' => $question_es,
							'faq_question_en' => $question_en,
							'faq_answer_es' => $answer_es,
							'faq_answer_en' => $answer_en
						);
						$sql = 'INSERT INTO _help_faq' . sql_build('INSERT', $sql_insert);
					}
					break;
				case 'module':
					$module_name = $this->control->get_var('module_name', '');
					
					if (empty($module_name)) {
						$error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
					}
					
					if (!sizeof($error)) {
						$sql_insert = array(
							'module_name' => $module_name
						);
						$sql = 'INSERT INTO _help_modules' . sql_build('INSERT', $sql_insert);
					}
					break;
			}
			
			if (!sizeof($error)) {
				sql_query($sql);
				
				$cache->delete('help_cat help_faq help_modules');
				
				redirect(s_link_control('comments', array('mode' => $this->mode)));
			} else {
				_style('error', array(
					'MESSAGE' => parse_error($error))
				);
			}
		}
		
		$this->nav();
		$this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage), 'CONTROL_ADD');
		$this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub), (isset($user->lang[$menu[$sub]])) ? $user->lang[$menu[$sub]] : $menu[$sub]);
		
		$layout_vars = array(
			'SUB' => $sub,
			'S_HIDDEN' => s_hidden(array('module' => $this->control->module, 'mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub))
		);
		
		switch ($sub) {
			case 'cat':
				$sql = 'SELECT *
					FROM _help_modules
					ORDER BY module_id';
				$result = sql_rowset($sql);
				
				$select_mod = '';
				foreach ($result as $row) {
					$selected = ($row['module_id'] == $module_id);
					$select_mod .= '<option' . (($selected) ? ' class="bold"' : '') . ' value="' . $row['module_id'] . '"' . (($selected) ? ' selected' : '') . '>' . $row['module_name'] . '</option>';
				}
				
				$layout_vars += array(
					'MODULE' => $select_mod,
					'HELP_ES' => $help_es,
					'HELP_EN' => $help_en
				);
				break;
			case 'faq':
				$sql = 'SELECT *
					FROM _help_cat
					ORDER BY help_id';
				$result = sql_rowset($sql);
				
				$select_cat = '';
				foreach ($result as $row) {
					$selected = ($row['help_id'] == $help_id);
					$select_cat .= '<option' . (($selected) ? ' class="bold"' : '') . ' value="' . $row['help_id'] . '"' . (($selected) ? ' selected' : '') . '>' . $row['help_es'] . ' | ' . $row['help_en'] . '</option>';
				}
				
				$layout_vars += array(
					'CATEGORY' => $select_cat,
					'QUESTION_ES' => $question_es,
					'QUESTION_EN' => $question_en,
					'ANSWER_ES' => $answer_es,
					'ANSWER_EN' => $answer_en
				);
				break;
			case 'module':
				$layout_vars += array(
					'MODULE_NAME' => $module_name
				);
				break;
		}
		
		return v_style($layout_vars);
	}
Example #5
0
    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;
    }
Example #6
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);
	}
Example #7
0
	public function object() {
		global $user, $config, $comments;

		$offset = request_var('ps', 0);

		if ($this->data['poster_id'] != $user->d('user_id') && !$offset) {
			$sql = 'UPDATE _news SET post_views = post_views + 1
				WHERE news_id = ?';
			sql_query(sql_filter($sql, $this->data['news_id']));
		}

		$news_main = array(
			'MESSAGE' => $comments->parse_message($this->data['post_text']),
			'POST_TIME' => $user->format_date($this->data['post_time'])
		);

		$sql = 'SELECT user_id, username, username_base, user_avatar, user_posts, user_gender, user_rank
			FROM _members
			WHERE user_id = ?';
		$result = sql_fieldrow(sql_filter($sql, $this->data['poster_id']));

		$user_profile = $comments->user_profile($result);
		$news_main = array_merge($news_main, _style_uv($user_profile));

		_style('mainpost', $news_main);

		$comments_ref = s_link('news', $this->data['news_alias']);

		if ($this->data['post_replies']) {
			$comments->reset();
			$comments->ref = $comments_ref;

			$sql = 'SELECT p.*, m.user_id, m.username, m.username_base, m.user_avatar, m.user_rank, m.user_posts, m.user_gender, m.user_sig
				FROM _news_posts p, _members m
				WHERE p.news_id = ?
					AND p.post_active = 1
					AND p.poster_id = m.user_id
				ORDER BY p.post_time DESC
				LIMIT ??, ??';

			$comments->data = array(
				'SQL' => sql_filter($sql, $this->data['news_id'], $offset, $config['posts_per_page'])
			);

			$comments->view($offset, 'ps', $this->data['post_replies'], $config['posts_per_page'], '', '', 'TOPIC_');
		}

		v_style(array(
			'CAT_URL' => s_link('news', $this->data['cat_url']),
			'CAT_NAME' => $this->data['cat_name'],
			'POST_SUBJECT' => $this->data['post_subject'],
			'POST_REPLIES' => number_format($this->data['post_replies']))
		);

		//
		// Posting box
		//
		if ($user->is('member')) {
			_style('publish', array(
				'REF' => $comments_ref)
			);
		}

		$this->_template = 'news.view';
		$this->_title = $this->data['post_subject'];

		return;
	}
Example #8
0
	private function userpage() {
		global $user, $comments;

		$mode = request_var('mode', 'main');

		if ($user->d('user_id') != $this->data['user_id'] && !in_array($mode, w('friend ban'))) {
			$is_blocked = false;

			if (!$user->is('all', $this->data['user_id'])) {
				$sql = 'SELECT ban_id
					FROM _members_ban
					WHERE user_id = ?
						AND banned_user = ?';
				if ($banned_row = sql_fieldrow(sql_filter($sql, $user->d('user_id'), $this->data['user_id']))) {
					$is_blocked = true;
				}

				$banned_lang = ($is_blocked) ? 'REMOVE' : 'ADD';

				_style('block_member', array(
					'URL' => s_link('m', $this->data['username_base'], 'ban'),
					'LANG' => lang('blocked_member_' . $banned_lang))
				);
			}
		}

		$profile_fields = $comments->user_profile($this->data);

		switch ($mode) {
			case 'friend':
				$this->friend_add();
			break;
			case 'ban':
				$this->user_ban();
			break;
			case 'favs':
			break;
			case 'friends':
				$this->friend_list();
			break;
			case 'stats':
				$this->user_stats();
			break;
			case 'main':
			default:
				$this->user_main();
			break;
		}

		$panel_selection = array(
			'main' => array('L' => 'MAIN', 'U' => false)
		);

		if ($user->d('user_id') != $this->data['user_id']) {
			$panel_selection['start'] = array('L' => 'DCONV_START', 'U' => s_link('my dc start', $this->data['username_base']));
		} else {
			$panel_selection['dc'] = array('L' => 'DC', 'U' => s_link('my dc'));
		}

		$panel_selection += array(
			'friends' => array('L' => 'FRIENDS', 'U' => false)
		);

		foreach ($panel_selection as $link => $data) {
			_style('selected_panel', array(
				'LANG' => lang('userpage_' . $data['L']))
			);

			if ($mode == $link) {
				_style('selected_panel.strong');
				continue;
			}

			_style('selected_panel.a', array(
				'URL' => ($data['U'] !== false) ? $data['U'] : s_link('m', $this->data['username_base'], (($link != 'main') ? $link : '')))
			);
		}

		//
		// Check if friends
		//
		if ($user->d('user_id') != $this->data['user_id']) {
			$friend_add_lang = true;

			if ($user->is('member')) {
				$friend_add_lang = $this->is_friend($user->d('user_id'), $this->data['user_id']);
			}

			$friend_add_lang = ($friend_add_lang) ? 'friends_add' : 'friends_del';

			_style('friend', array(
				'U_FRIEND' => s_link('m', $this->data['username_base'], 'friend'),
				'L_FRIENDS_ADD' => lang($friend_add_lang))
			);
		}

		$online = false;

		//
		// Generate page
		//
		v_style(array(
			'USERNAME' => $this->data['username'],
			'POSTER_RANK' => $profile_fields['user_rank'],
			'AVATAR_IMG' => $profile_fields['user_avatar'],
			'USER_ONLINE' => $online,

			'PM' => s_link('my dc start', $this->data['username_base']),
			'WEBSITE' => $this->data['user_website'],
			'MSN' => $this->data['user_msnm']
		));

		$layout_file = 'userpage';

		$use_m_template = 'custom/profile_' . $this->data['username_base'];
		if (@file_exists(ROOT . 'template/' . $use_m_template . '.htm')) {
			$layout_file = $use_m_template;
		}

		$this->_title = $this->data['username'];
		$this->_template = $layout_file;

		return;
	}
Example #9
0
function username_search($search_match)
{
	global $config, $template, $lang, $images, $themeset, $starttime, $gen_simple_header, $admin_level, $level_prior;

	$gen_simple_header = true;

	$username_list = '';
	if (!empty($search_match)) {
		$username_search = preg_replace('/\*/', '%', get_username_base($search_match));

		$sql = 'SELECT username
			FROM _members
			WHERE username LIKE ?
				AND user_id <> ?
			ORDER BY username';
		if (!$result = sql_rowset(sql_filter($sql, $username_search, GUEST))) {
			$username_list .= '<option>' . $lang['No_match']. '</option>';
		}

		foreach ($result as $row) {
			$username_list .= '<option value="' . $row['username'] . '">' . $row['username'] . '</option>';
		}
	}

	$template->set_filenames(array(
		'body' => 'search_username.htm')
	);

	v_style(array(
		'USERNAME' => (!empty($search_match)) ? get_username_base($search_match) : '',

		'L_CLOSE_WINDOW' => $lang['Close_window'],
		'L_SEARCH_USERNAME' => $lang['Find_username'],
		'L_UPDATE_USERNAME' => $lang['Select_username'],
		'L_SELECT' => $lang['Select'],
		'L_SEARCH' => $lang['Search'],
		'L_SEARCH_EXPLAIN' => $lang['Search_author_explain'],
		'L_CLOSE_WINDOW' => $lang['Close_window'],

		'S_USERNAME_OPTIONS' => $username_list,
		'S_SEARCH_ACTION' => "search.php?mode=searchuser")
	);

	if ($username_list != '') {
		_style('switch_select_name');
	}

	return page_footer();
}
Example #10
0
    function _help_edit()
    {
        global $bio, $core;
        $error = array();
        $sub = $this->control->get_var('sub', '');
        $id = $this->control->get_var('id', 0);
        $submit = isset($_POST['submit']) ? true : false;
        switch ($sub) {
            case 'cat':
                $sql = 'SELECT c.*, m.*
					FROM _help_cat c, _help_modules m
					WHERE c.help_id = ' . (int) $id . '
						AND c.help_module = m.module_id';
                $result = $db->sql_query($sql);
                if (!($cat_data = $db->sql_fetchrow($result))) {
                    fatal_error();
                }
                $db->sql_freeresult($result);
                $order = $this->control->get_var('order', '');
                if (!empty($order)) {
                    if (preg_match('/_([0-9]+)/', $order)) {
                        $sig = '-';
                        $order = str_replace('_', '', $order);
                    } else {
                        $sig = '+';
                    }
                    $sql = 'UPDATE _help_cat
						SET help_order = help_order ' . $sig . ' ' . (int) $order . '
						WHERE help_id = ' . (int) $id;
                    $db->sql_query($sql);
                    $this->_help_edit_move();
                    $cache->unload('help_cat');
                    redirect(_link_control('comments', array('mode' => $this->mode)));
                }
                // IF order
                $module_id = $cat_data['help_module'];
                $help_es = $cat_data['help_es'];
                $help_en = $cat_data['help_en'];
                break;
            case 'faq':
                $sql = 'SELECT *
					FROM _help_faq
					WHERE faq_id = ' . (int) $id;
                $result = $db->sql_query($sql);
                if (!($faq_data = $db->sql_fetchrow($result))) {
                    fatal_error();
                }
                $db->sql_freeresult($result);
                $question_es = $faq_data['faq_question_es'];
                $question_en = $faq_data['faq_question_en'];
                $answer_es = $faq_data['faq_answer_es'];
                $answer_en = $faq_data['faq_answer_en'];
                $help_id = $faq_data['help_id'];
                break;
            default:
                redirect(_link_control('comments', array('mode' => $this->mode)));
                break;
        }
        // IF submit
        if ($submit) {
            switch ($sub) {
                case 'cat':
                    $module_id = $this->control->get_var('module_id', 0);
                    $help_es = $this->control->get_var('help_es', '');
                    $help_en = $this->control->get_var('help_en', '');
                    if (empty($help_es) || empty($help_en)) {
                        $error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
                    }
                    // Update
                    if (!sizeof($error)) {
                        $sql_update = array('help_es' => $help_es, 'help_en' => $help_en, 'help_module' => (int) $module_id);
                        $sql = 'UPDATE _help_cat
							SET ' . $db->sql_build_array('UPDATE', $sql_update) . '
							WHERE help_id = ' . (int) $id;
                        $db->sql_query($sql);
                        $cache->unload('help_cat');
                        redirect(_link_control('comments', array('mode' => $this->mode)));
                    }
                    break;
                case 'faq':
                    $question_es = $this->control->get_var('question_es', '');
                    $question_en = $this->control->get_var('question_en', '');
                    $answer_es = $this->control->get_var('answer_es', '');
                    $answer_en = $this->control->get_var('answer_en', '');
                    $help_id = $this->control->get_var('help_id', 0);
                    if (empty($question_es) || empty($question_en) || empty($answer_es) || empty($answer_en)) {
                        $error[] = 'CONTROL_COMMENTS_HELP_EMPTY';
                    }
                    if (!sizeof($error)) {
                        $sql = 'SELECT *
							FROM _help_cat
							WHERE help_id = ' . (int) $help_id;
                        $result = $db->sql_query($sql);
                        if (!($cat_data = $db->sql_fetchrow($result))) {
                            $error[] = 'CONTROL_COMMENTS_HELP_NOCAT';
                        }
                    }
                    // Update
                    if (!sizeof($error)) {
                        $sql_update = array('help_id' => (int) $help_id, 'faq_question_es' => $question_es, 'faq_question_en' => $question_en, 'faq_answer_es' => $answer_es, 'faq_answer_en' => $answer_en);
                        $sql = 'UPDATE _help_faq
							SET ' . $db->sql_build_array('UPDATE', $sql_update) . '
							WHERE faq_id = ' . (int) $id;
                        $db->sql_query($sql);
                        $cache->unload('help_faq');
                        redirect(_link_control('comments', array('mode' => $this->mode)));
                    }
                    break;
            }
            // switch
            if (sizeof($error)) {
                _style('error', array('MESSAGE' => parse_error($error)));
            }
        }
        $this->nav();
        $this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id), 'CONTROL_EDIT');
        $template_vars = array('SUB' => $sub, 'S_HIDDEN' => _hidden(array('module' => $this->control->module, 'mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id)));
        switch ($sub) {
            case 'cat':
                $sql = 'SELECT *
					FROM _help_modules
					ORDER BY module_id';
                $result = $db->sql_query($sql);
                $select_mod = '';
                while ($row = $db->sql_fetchrow($result)) {
                    $selected = $row['module_id'] == $module_id;
                    $select_mod .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['module_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['module_name'] . '</option>';
                }
                $db->sql_freeresult($result);
                $sv += array('MODULE' => $select_mod, 'HELP_ES' => $help_es, 'HELP_EN' => $help_en);
                break;
            case 'faq':
                $sql = 'SELECT *
					FROM _help_cat
					ORDER BY help_id';
                $result = $db->sql_query($sql);
                $select_cat = '';
                while ($row = $db->sql_fetchrow($result)) {
                    $selected = $row['help_id'] == $help_id;
                    $select_cat .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['help_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['help_es'] . ' | ' . $row['help_en'] . '</option>';
                }
                $db->sql_freeresult($result);
                $sv += array('CATEGORY' => $select_cat, 'QUESTION_ES' => $question_es, 'QUESTION_EN' => $question_en, 'ANSWER_ES' => $answer_es, 'ANSWER_EN' => $answer_en);
                break;
        }
        v_style($sv);
        return;
    }
Example #11
0
if (strstr($user->browser, 'compatible') || $is_firefox) {
	ob_start('ob_gzhandler');
}

// Headers
#header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
#header('Pragma: no-cache');
#header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60) . ' GMT');
header('Content-type: text/css; charset=utf-8');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (60 * 60 * 24 * 30)) . ' GMT');

//sql_report(false);
$template->replace_vars = false;

v_style(array(
	'FF' => $is_firefox,
	'IE' => $is_ie)
);

$template->set_filenames(array('body' => 'js/' . $filename . '.js'));
$template->assign_var_from_handle('EXT', 'body');
//$template->pparse('body');

sql_close();

$code = JSMin::minify($template->vars['EXT']);

echo $code;
exit;
Example #12
0
    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;
    }
Example #13
0
	public function object() {
		global $auth, $user, $config, $comments, $upload;

		$mode = request_var('mode', '');

		switch ($mode) {
			case 'view':
			case 'fav':
			case 'rsvp':
				$download_id = request_var('download_id', 0);
				if (!$download_id) {
					redirect(s_link('events', $this->v('event_alias')));
				}

				switch ($mode) {
					case 'view':
						$sql = 'SELECT e.*, COUNT(e2.image) AS prev_images
							FROM _events_images e, _events_images e2
							WHERE e.event_id = ?
								AND e.event_id = e2.event_id
								AND e.image = ?
								AND e2.image <= ?
							GROUP BY e.image
							ORDER BY e.image ASC';
						$sql = sql_filter($sql, $this->v('id'), $download_id, $download_id);
						break;
					case 'rsvp':
						$sql = '';
						break;
					default:
						$sql = 'SELECT e2.*
							FROM _events_images e2
							LEFT JOIN _events e ON e.id = e2.event_id
							WHERE e2.event_id = ?
								AND e2.image = ?';
						$sql = sql_filter($sql, $this->v('id'), $download_id);
						break;
				}

				if (!empty($sql)) {
					if (!$imagedata = sql_fieldrow($sql)) {
						redirect(s_link('events', $this->v('event_alias')));
					}
				}

				break;
		}

		switch ($mode) {
			case 'fav':
				if (!$user->is('member')) {
					do_login();
				}

				$sql = 'SELECT *
					FROM _events_fav
					WHERE event_id = ?
						AND image_id = ?
						AND member_id = ?';
				if ($row = sql_fieldrow(sql_filter($sql, $this->v('id'), $imagedata['image'], $user->d('user_id')))) {
					$sql = 'UPDATE _events_fav SET fav_date = ?
						WHERE event_id = ?
							AND image_id = ?';
					sql_query(sql_filter($sql, time(), $this->v('id'), $imagedata['image']));
				} else {
					$sql_insert = array(
						'event_id' => (int) $this->v('id'),
						'image_id' => (int) $imagedata['image'],
						'member_id' => (int) $user->d('user_id'),
						'fav_date' => time()
					);
					sql_insert('events_fav', $sql_insert);
				}

				redirect(s_link('events', $this->v('event_alias'), $imagedata['image'], 'view'));
				break;
			case 'rsvp':
				$choice = array_key(array_keys(request_var('choice', array(0 => ''))), 0);
				$topic_id = $this->v('event_topic');

				if (!$topic_id) {
					fatal_error();
				}

				if (!$choice) {
					redirect(s_link('events', $this->v('event_alias')));
				}

				if (!$user->is('member')) {
					do_login();
				}

				$sql = 'SELECT vd.vote_id
					FROM _poll_options vd, _poll_results vr
					WHERE vd.topic_id = ?
						AND vr.vote_id = vd.vote_id
						AND vr.vote_option_id = ?
					GROUP BY vd.vote_id';
				if (!$vote_id = sql_field(sql_filter($sql, $topic_id, $choice), 'vote_id', 0)) {
					fatal_error();
				}

				$sql = 'SELECT *
					FROM _poll_voters
					WHERE vote_id = ?
						AND vote_user_id = ?';
				if (!sql_fieldrow(sql_filter($sql, $vote_id, $user->d('user_id')))) {
					$sql = 'UPDATE _poll_results SET vote_result = vote_result + 1
						WHERE vote_id = ?
							AND vote_option_id = ?';
					sql_query(sql_filter($sql, $vote_id, $choice));

					$insert_vote = array(
						'vote_id' => (int) $vote_id,
						'vote_user_id' => (int) $user->d('user_id'),
						'vote_user_ip' => $user->ip,
						'vote_cast' => (int) $choice
					);
					sql_insert('poll_voters', $insert_vote);
				}

				redirect(s_link('events', $this->v('event_alias')));
				break;
			case 'view':
			default:
				/**
				* Generate thumbnail for events list.
				*/
				if ($user->is('colab') && !$this->v('images') && _button('create_thumbnail')) {
					$location_large = $config['events_path'] . 'future/' . $this->v('id') . '.jpg';
					$location_mini = $config['events_path'] . 'mini/' . $this->v('id') . '.jpg';

					$x1 = request_var('x1', 0);
					$y1 = request_var('y1', 0);
					$x2 = request_var('x2', 0);
					$y2 = request_var('y2', 0);
					$w = request_var('w', 0);
					$h = request_var('h', 0);

					//Scale the image to the thumb_width set above
					$scale = $config['events_thumb_width'] / $w;
					$cropped = $upload->resizeThumbnailImage($location_mini, $location_large, $w, $h, $x1, $y1, $scale);

					redirect(s_link('events'));
				}

				/**
				* Normal operations
				*/
				$t_offset = request_var('offset', 0);

				if ($mode == 'view') {
					$sql = 'UPDATE _events_images
						SET views = views + 1
						WHERE event_id = ?
							AND image = ?';
					sql_query(sql_filter($sql, $this->v('id'), $imagedata['image']));

					_style('selected', array(
						'IMAGE' => $config['events_url'] . 'gallery/' . $this->v('id') . '/' . $imagedata['image'] . '.jpg',
						'WIDTH' => $imagedata['width'],
						'HEIGHT' => $imagedata['height'],
						'FOOTER' => $imagedata['image_footer'])
					);

					if ($user->is('founder')) {
						_style('selected.update', array(
							'URL' => s_link('async eif'),
							'EID' => $this->v('id'),
							'PID' => $imagedata['image'])
						);
					}

					$is_fav = false;
					if ($user->is('member')) {
						$sql = 'SELECT member_id
							FROM _events_fav
							WHERE event_id = ?
								AND image_id = ?
								AND member_id = ?';
						if (sql_field(sql_filter($sql, $this->v('id'), $imagedata['image'], $user->d('user_id')), 'member_id', 0)) {
							$is_fav = true;
						}
					}

					if (!$is_fav || !$user->is('member')) {
						_style('selected.fav', array(
							'URL' => s_link('events', $this->v('id'), $imagedata['image'], 'fav'))
						);
					}
				} else {
					if (!$t_offset && $user->is('founder')) {
						$sql = 'UPDATE _events SET views = views + 1
							WHERE id = ?';
						sql_query(sql_filter($sql, $this->v('id')));
					}
				}

				$sql = 'SELECT t.topic_id, t.topic_title, t.topic_locked, t.topic_replies, t.topic_time, t.topic_important, t.topic_vote, t.topic_featured, t.topic_points, t.topic_last_post_id, f.forum_alias, f.forum_name, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote
					FROM _forum_topics t, _forums f
					WHERE t.topic_id = ?
						AND f.forum_id = t.forum_id';
				if (!$event_topic = sql_fieldrow(sql_filter($sql, $this->v('event_topic')))) {
					fatal_error();
				}

				$mod_auth = $user->is('mod');

				$error = w();
				$forum_id = $event_topic['forum_id'];
				$submit_reply = _button('post');
				$reply = request_var('reply', 0);

				if ($reply) {
					$post_reply = request_var('p', 0);

					$sql = 'SELECT p.*, u.user_id, u.username
						FROM _forum_posts p, _members u
						WHERE p.post_id = ?
							AND u.user_id = p.poster_id
							AND p.post_deleted = 0';
					if (!$post_data = sql_fieldrow(sql_filter($sql, $post_reply))) {
						redirect(s_link('events', $this->v('event_alias')));
					}
				}

				$is_auth = $auth->forum(AUTH_ALL, $forum_id, $event_topic);
				$u_event_alias = s_link('events', $this->v('event_alias'));
				$u_event_publish = ($reply) ? s_link('events', $this->v('event_alias'), $post_reply, 'reply') : $u_event_alias;

				if ($submit_reply) {
					$auth_key = 'auth_reply';

					if (((!$is_auth['auth_view'] || !$is_auth['auth_read'])) || !$is_auth[$auth_key]) {
						if (!$user->is('member')) {
							do_login();
						}

						$can_reply_closed = $auth->option(array('forum', 'topics', 'delete'));

						if (!$can_reply_closed && ($event_topic['forum_locked'] || $event_topic['topic_locked'])) {
							$error[] = 'TOPIC_LOCKED';
						}

						if (sizeof($error)) {
							redirect($u_event_alias);
						}
					}

					$post_message = request_var('message', '', true);

					if ($reply) {
						$post_reply_message = request_var('reply_message', '', true);
					}

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

					if (sizeof($error)) {
						redirect($u_event_alias);
					}

					if (!$mod_auth) {
						$sql = 'SELECT MAX(post_time) AS last_post_time
							FROM _forum_posts
							WHERE poster_id = ?';
						if ($last_post_time = sql_field(sql_filter($sql, $user->d('user_id')))) {
							if (intval($last_post_time) > 0 && ($current_time - intval($last_post_time)) < intval($config['flood_interval'])) {
								$error[] = 'FLOOD_ERROR';
							}
						}
					}

					if (sizeof($error)) {
						redirect($u_event_alias);
					}

					$update_topic = w();

					if (strstr($post_message, '-Anuncio-') && $user->is('mod')) {
						$topic_announce = 1;
						$post_message = str_replace('-Anuncio-', '', $post_message);
						$update_topic['topic_announce'] = $topic_announce;
					}

					if (strstr($post_message, '-Cerrado-') && $user->is('mod')) {
						$topic_locked = 1;
						$post_message = str_replace('-Cerrado-', '', $post_message);
						$update_topic['topic_locked'] = $topic_locked;
					}

					$post_message = $comments->prepare($post_message);

					if ($reply && $post_reply_message != '') {
						$post_reply_message = preg_replace('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#ie', '', $post_reply_message);
					}

					if ($reply && empty($post_reply_message)) {
						$post_reply_message = '...';
					}

					if ($reply && $post_reply_message != '') {
						$post_message = '<blockquote><strong>' . $post_data['username'] . "</strong>" . nr(false, 2) . $post_reply_message . '</blockquote><br /> ' . $post_message;
					} else {
						$reply = 0;
					}

					$insert_data = array(
						'topic_id' => (int) $this->v('event_topic'),
						'forum_id' => (int) $forum_id,
						'poster_id' => (int) $user->d('user_id'),
						'post_time' => time(),
						'poster_ip' => $user->ip,
						'post_text' => $post_message,
						'post_np' => ''
					);
					if ($reply) {
						$insert_data['post_reply'] = $post_reply;
					}

					$post_id = sql_insert('forum_posts', $insert_data);

					$user->delete_unread(UH_T, $this->v('event_topic'));
					$user->save_unread(UH_T, $this->v('event_topic'));

					//
					$a_list = forum_for_team_list($forum_id);
					if (count($a_list)) {
						$sql_delete_unread = 'DELETE FROM _members_unread
							WHERE element = ?
								AND item = ?
								AND user_id NOT IN (??)';
						sql_query(sql_filter($sql, 8, $this->v('event_topic'), implode(', ', $a_list)));
					}

					$update_topic['topic_last_post_id'] = $post_id;

					if ($topic_locked) {
						topic_feature($topic_id, 0);
					}

					$sql = 'UPDATE _forums SET forum_posts = forum_posts + 1, forum_last_topic_id = ?
						WHERE forum_id = ?';
					sql_query(sql_filter($sql, $this->v('event_topic'), $forum_id));

					$sql = 'UPDATE _forum_topics SET topic_replies = topic_replies + 1, ' . sql_build('UPDATE', $update_topic) . sql_filter('
						WHERE topic_id = ?', $this->v('event_topic'));
					sql_query($sql);

					$sql = 'UPDATE _members SET user_posts = user_posts + 1
						WHERE user_id = ?';
					sql_query(sql_filter($sql, $user->d('user_id')));

					redirect($u_event_alias);
				}

				// Get event thumbnails
				$t_per_page = 18;

				if ($mode == 'view' && $download_id) {
					$val = 1;

					$sql = 'SELECT MAX(image) AS total
						FROM _events_images
						WHERE event_id = ?';
					if ($maximage = sql_field(sql_filter($sql, $this->v('id')), 'total', 0)) {
						$val = ($download_id == $maximage) ? 2 : 1;
					}

					$t_offset = floor(($imagedata['prev_images'] - $val) / $t_per_page) * $t_per_page;
				}

				if ($this->v('images')) {
					$exception_sql = (isset($download_id) && $download_id) ? sql_filter(' AND g.image <> ? ', $download_id) : '';

					$sql = 'SELECT g.*
						FROM _events e, _events_images g
						WHERE e.id = ?
							AND e.id = g.event_id ' .
							$exception_sql . '
						ORDER BY g.image ASC
						LIMIT ??, ??';
					if (!$result = sql_rowset(sql_filter($sql, $this->v('id'), $t_offset, $t_per_page))) {
						redirect(s_link('events', $this->v('id')));
					}

					build_num_pagination(s_link('events', $this->v('id'), 's%d'), $this->v('images'), $t_per_page, $t_offset, 'IMG_');

					_style('thumbnails');

					foreach ($result as $row) {
						_style('thumbnails.item', array(
							'URL' => s_link('events', $this->v('event_alias'), $row['image'], 'view'),
							'IMAGE' => $config['events_url'] . 'gallery/' . $this->v('id') . '/thumbnails/' . $row['image'] . '.jpg',
							'RIMAGE' => $config['events_url'] . 'gallery/' . $this->v('id') . '/' . $row['image'] . '.jpg',
							'FOOTER' => $row['image_footer'],
							'WIDTH' => $row['width'],
							'HEIGHT' => $row['height'])
						);
					}

					// Credits
					$sql = 'SELECT *
						FROM _events_colab c, _members m
						WHERE c.colab_event = ?
							AND c.colab_uid = m.user_id
						ORDER BY m.username';
					if ($result = sql_rowset(sql_filter($sql, $this->v('id')))) {
						_style('collab');

						foreach ($result as $row) {
							_style('collab.row', array(
								'PROFILE' => s_link('m', $row['username_base']),
								'USERNAME' => $row['username'])
							);
						}
					}
				} else {
					_style('event_flyer', array(
						'IMAGE_SRC' => $config['events_url'] . 'future/' . $this->v('id') . '.jpg?u=' . $this->v('event_update'))
					);

					$location_mini = $config['events_path'] . 'mini/' . $this->v('id') . '.jpg';

					if ($user->is('colab') && !$this->v('images') && !@file_exists($location_mini)) {
						$large_filepath = $config['events_path'] . 'future/' . $this->v('id') . '.jpg';

						_style('event_flyer.thumbnail', array(
							'ACTION' => $u_event_alias,
							'SCALE' => ($config['events_thumb_height'] / $config['events_thumb_width']),
							'THUMB_WIDTH' => $config['events_thumb_width'],
							'THUMB_HEIGHT' => $config['events_thumb_height'],
							'LARGE_WIDTH' => $upload->getWidth($large_filepath),
							'LARGE_HEIGHT' => $upload->getHeight($large_filepath)
						));
					}
				}

				list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $user->timezone + $user->dst));
				$midnight = gmmktime(0, 0, 0, $m, $d, $y) - $user->timezone - $user->dst;

				$event_date = $user->format_date($this->v('date'), 'j F Y \a \l\a\s H:i') . ' horas.';

				if ($this->v('date') >= $midnight) {
					if ($this->v('date') >= $midnight && $this->v('date') < $midnight + 86400) {
						$event_date_format = lang('event_today');
					} else if ($this->v('date') >= $midnight + 86400 && $this->v('date') < $midnight + (86400 * 2)) {
						$event_date_format = lang('event_tomorrow');
					} else {
						$event_date_format = sprintf(lang('event_after'), $event_date);
					}
				} else {
					if ($this->v('date') >= ($midnight - 86400)) {
						$event_date_format = lang('event_yesterday');
					} else {
						$event_date_format = sprintf(lang('event_before'), $event_date);
					}
				}

				v_style(array(
					'EVENT_NAME' => $this->v('title'),
					'EVENT_DATE' => $event_date_format,
					'EVENT_URL' => $u_event_alias,
					'EVENT_PUBLISH' => $u_event_publish)
				);

				$posts_offset = request_var('ps', 0);
				$topic_id = $this->v('event_topic');

				// START RSVP
				if ($topic_id) {
					$sql = 'SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
						FROM _poll_options vd, _poll_results vr
						WHERE vd.topic_id = ?
							AND vr.vote_id = vd.vote_id
						ORDER BY vr.vote_option_order, vr.vote_option_id ASC';
					if ($vote_info = sql_rowset(sql_filter($sql, $topic_id))) {
						$sql = 'SELECT vote_id
							FROM _poll_voters
							WHERE vote_id = ?
								AND vote_user_id = ?';
						$user_voted = sql_field(sql_filter($sql, $vote_info[0]['vote_id'], $user->d('user_id')), 'vote_id', 0);
						$poll_expired = ($vote_info[0]['vote_length']) ? (($vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time()) ? true : false) : false;

						_style('poll', array(
							'POLL_TITLE' => $vote_info[0]['vote_text'])
						);

						if ($user_voted || $poll_expired) {
							_style('poll.results');

							foreach ($vote_info as $row) {
								if ($this->v('date') >= $midnight) {
									$caption = ($row['vote_result'] == 1) ? lang('rsvp_future_one') : lang('rsvp_future_more');
								} else {
									$caption = ($row['vote_result'] == 1) ? lang('rsvp_past_one') : lang('rsvp_past_more');
								}

								_style('poll.results.item', array(
									'CAPTION' => $caption,
									'RESULT' => $row['vote_result'])
								);
								break;
							}
						} else {
							_style('poll.options', array(
								'S_VOTE_ACTION' => s_link('events', $this->v('event_alias'), 1, 'rsvp'))
							);

							foreach ($vote_info as $row) {
								$caption = ($this->v('date') >= $midnight) ? lang('rsvp_future') : lang('rsvp_past');

								_style('poll.options.item', array(
									'ID' => $row['vote_option_id'],
									'CAPTION' => $caption)
								);
								break;
							}
						}
					}
				}
				// END RSVP

				$sql = 'SELECT p.*, u.user_id, u.username, u.username_base, u.user_avatar, u.user_posts, u.user_gender, u.user_rank
					FROM _forum_posts p, _members u
					WHERE p.topic_id = ?
						AND u.user_id = p.poster_id
						AND p.post_deleted = 0
					ORDER BY p.post_time DESC
					LIMIT ??, ??';
				if (!$messages = sql_rowset(sql_filter($sql, $topic_id, $posts_offset, $config['posts_per_page']))) {
					redirect(s_link('events', $this->v('event_alias')));
				}

				if (!$posts_offset) {
					//unset($messages[0]);
				}

				$i = 0;
				foreach ($messages as $row) {
					if (!$i) {
						$controls = w();
						$user_profile = w();
						$unset_user_profile = array('user_id', 'user_posts', 'user_gender');

						_style('messages');
					}

					if ($user->is('member')) {
						$controls[$row['post_id']]['reply'] = s_link('events', $this->v('event_alias'), $row['post_id'], 'reply');

						if ($mod_auth) {
							$controls[$row['post_id']]['edit'] = s_link('acp', array('forums_post_modify', 'msg_id' => $row['post_id']));
							$controls[$row['post_id']]['delete'] = s_link('acp', array('forums_post_delete', 'msg_id' => $row['post_id']));
						}
					}

					$user_profile[$row['user_id']] = $comments->user_profile($row, '', $unset_user_profile);

					$data = array(
						'POST_ID' => $row['post_id'],
						'DATETIME' => $user->format_date($row['post_time']),
						'MESSAGE' => $comments->parse_message($row['post_text']),
						'PLAYING' => $row['post_np'],
						'DELETED' => $row['post_deleted']
					);

					foreach ($user_profile[$row['user_id']] as $key => $value) {
						$data[strtoupper($key)] = $value;
					}

					_style('messages.row', $data);

					if (isset($controls[$row['post_id']])) {
						_style('messages.row.controls');

						foreach ($controls[$row['post_id']] as $item => $url) {
							_style('messages.row.controls.' . $item, array(
								'URL' => $url)
							);
						}
					}

					$i++;
				}

				build_num_pagination(s_link('events', $this->v('event_alias'), 'ps%d'), $event_topic['topic_replies'], $config['posts_per_page'], $posts_offset, 'MSG_');

				$publish_ref = ($posts_offset) ? s_link('events', $this->v('event_alias'), 's' . $t_offset) : s_link('events', $this->v('event_alias'));

				// Posting box
				if ($user->is('member')) {
					_style('publish', array(
						'REF' => $publish_ref)
					);

					if ($reply) {
						if (empty($post_reply_message)) {
							$post_reply_message = $comments->remove_quotes($post_data['post_text']);
						}

						if (!empty($post_reply_message)) {
							$rx = array('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#is', '#\[yt:[0-9a-zA-Z\-\=\_]+\]#is', '#\[sb\]#is', '#\[\/sb\]#is');
							$post_reply_message = preg_replace($rx, '', $post_reply_message);
						}

						if (empty($post_reply_message)) {
							$post_reply_message = '...';
						}

						_style('publish.reply', array(
							'MESSAGE' => $post_reply_message)
						);
					}
				}

				break;
		}

		$this->_title = $this->v('title');
		$this->_template = 'events.view';

		return true;
	}
Example #14
0
	public function _panel() {
		global $user, $config, $template;

		$this->data['layout'] = request_var('layout', '');
		$this->_auth();

		if (!$this->data['layout']) {
			$this->data['layout'] = 'main';
		}

		switch ($this->data['layout']) {
			case 'website':
			case 'favorites':
			case 'vote':
				$this->call_layout();
				break;
			default:
				$this->_make(true);

				/*
				Build nav menu
				*/
				/*$s_layout = w();
				$s_layout['a']['_01'] = true;
				$s_layout['a']['_02'] = ($this->data['bio'] != '') ? true : false;
				$s_layout['a']['_04'] = ($this->data['images'] > 1) ? true : false;
				$s_layout['a']['_06'] = ($this->data['lirics'] > 0) ? true : false;
				$s_layout['a']['_09'] = ($this->data['layout'] == 9) ? true : false;
				$s_layout['a']['_12'] = ($this->data['layout'] == 12) ? true : false;
				$s_layout['a']['_18'] = ($this->data['a_video'] > 0) ? true : false;
				*/

				$available = w();
				foreach ($this->layout as $i => $row) {
					if ($this->data['layout'] == $row['tpl']) {
						$this->data['template'] = $row['tpl'];
					}

					if ($this->{'_' . $row['tpl']}()) {
						$available[$row['tpl']] = true;

						_style('nav', array(
							'LANG' => lang($row['text']))
						);

						if ($this->data['layout'] == $row['tpl']) {
							_style('nav.strong');
						} else {
							$tpl = ($row['tpl'] == 'main') ? '' : $row['tpl'];

							_style('nav.a', array(
								'URL' => s_link('a', $this->data['subdomain'], $tpl))
							);
						}
					}
				}

				if (!isset($available[$this->data['layout']])) {
					redirect(s_link('a', $this->data['subdomain']));
				}

				$this->_make();

				//_pre($available, true);

				/*foreach ($this->layout as $item => $data) {
					$s_layout['x'][$item] = $data['code'];

					if ($data['text'] == '') {
						$s_layout['e'][$item] = $data['code'];
					}

					if (isset($s_layout['a'][$item]) && $s_layout['a'][$item] && $data['tpl'] != '') {
						$s_layout['s'][$data['code']] = $data;
					}

					if (($this->data['layout'] == $data['code']) && $data['tpl'] != '') {
						$this->data['template'] = $data['tpl'];
					}
				}

				if (!in_array($this->data['layout'], $s_layout['x']) || (!isset($s_layout['s'][$this->data['layout']]) && !in_array($this->data['layout'], $s_layout['e']))) {
					redirect(s_link('a', $this->data['subdomain']));
				}*/

				//
				// Call selected layout
				//
				$this->call_layout();

				//
				// Build nav
				//
				/*foreach ($s_layout['s'] as $data) {
					_style('nav', array(
						'LANG' => lang($data['text']))
					);

					if ($this->data['layout'] == $data['code']) {
						_style('nav.strong');
						continue;
					}

					if ($data['code'] === 1) $data['code'] = '';

					_style('nav.a', array(
						'URL' => s_link('a', $this->data['subdomain'], $data['code']))
					);
				}*/

				//
				// Update stats
				//
				if (!$this->auth['mod']) {
					$update_views = false;
					$current_time = time();
					$current_month = date('Ym', $current_time);

					if ($this->auth['user']) {
						$sql_viewers = array(
							'datetime' => (int) $current_time,
							'user_ip' => $user->ip
						);

						$sql_viewers2 = array(
							'ub' => (int) $this->data['ub'],
							'user_id' => (int) $user->d('user_id')
						);

						$sql = 'UPDATE _artists_viewers SET ??
							WHERE ??';
						sql_query(sql_filter($sql, sql_build('UPDATE', $sql_viewers), sql_build('SELECT', $sql_viewers2)));

						if (!sql_affectedrows()) {
							$update_views = true;
							$sql_stats = array('ub' => (int) $this->data['ub'], 'date' => (int) $current_month);

							sql_insert('artists_viewers', $sql_viewers + $sql_viewers2);

							$sql = 'UPDATE _artists_stats SET members = members + 1
								WHERE ??';
							sql_query(sql_filter($sql, sql_build('SELECT', $sql_stats)));

							if (!sql_affectedrows()) {
								$sql_insert = array(
									'members' => 1,
									'guests' => 0
								);
								sql_insert('artists_stats', $sql_stats + $sql_insert);
							}

							$sql = 'SELECT user_id
								FROM _artists_viewers
								WHERE ub = ?
								ORDER BY datetime DESC
								LIMIT 10, 1';
							if ($row = sql_fieldrow(sql_filter($sql, $this->data['ub']))) {
								$sql = 'DELETE FROM _artists_viewers
									WHERE ub = ?
										AND user_id = ?';
								sql_query(sql_filter($sql, $this->data['ub'], $row['user_id']));
							}
						}
					}

					$_ps = request_var('ps', 0);

					if ((($this->auth['user'] && $update_views) || (!$this->auth['user'] && $this->data['layout'] == 1)) && !$_ps) {
						$sql = 'UPDATE _artists SET views = views + 1
							WHERE ub = ?';
						sql_query(sql_filter($sql, $this->data['ub']));
						$this->data['views']++;

						if ((!$this->auth['user'] && $this->data['layout'] == 1) && !$_ps) {
							$sql_stats = array(
								'ub' => (int) $this->data['ub'],
								'date' => (int) $current_month
							);
							$sql = 'UPDATE _artists_stats SET guests = guests + 1
								WHERE ??';
							sql_query(sql_filter($sql, sql_build('SELECT', $sql_stats)));

							if (!sql_affectedrows()) {
								$sql_insert = array(
									'members' => 0,
									'guests' => 1
								);
								sql_insert('artists_stats', $sql_stats + $sql_insert);
							}
						}
					}
				}

				//
				// Own events
				//
				$timezone = $config['board_timezone'] * 3600;

				list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $user->timezone + $user->dst));
				$midnight = gmmktime(0, 0, 0, $m, $d, $y) - $user->timezone - $user->dst;

				$g = getdate($midnight);
				$week = mktime(0, 0, 0, $m, ($d + (7 - ($g['wday'] - 1)) - (!$g['wday'] ? 7 : 0)), $y) - $timezone;

				$sql = 'SELECT *
					FROM _events e, _artists_events ae
					WHERE ae.a_artist = ?
						AND ae.a_event = e.id
					ORDER BY e.date';
				$result = sql_rowset(sql_filter($sql, $this->data['ub']));

				$events = w();
				foreach ($result as $row) {
					if ($row['date'] >= $midnight) {
						if ($row['date'] >= $midnight && $row['date'] < $midnight + 86400) {
							$events['is_today'][] = $row;
						} else if ($row['date'] >= $midnight + 86400 && $row['date'] < $midnight + (86400 * 2)) {
							$events['is_tomorrow'][] = $row;
						} else if ($row['date'] >= $midnight + (86400 * 2) && $row['date'] < $week) {
							$events['is_week'][] = $row;
						} else {
							$events['is_future'][] = $row;
						}
					} else if ($row['images']) {
						$events['is_gallery'][] = $row;
					}
				}

				if (isset($events['is_gallery']) && sizeof($events['is_gallery'])) {
					$gallery = $events['is_gallery'];
					@krsort($gallery);

					_style('events_gallery');
					foreach ($gallery as $row) {
						_style('events_gallery.item', array(
							'URL' => s_link('events', $row['event_alias']),
							'TITLE' => $row['title'],
							'DATETIME' => $user->format_date($row['date'], lang('date_format')))
						);
					}

					unset($events['is_gallery']);
				}

				if (sizeof($events)) {
					_style('events_future');

					foreach ($events as $is_date => $data) {
						_style('events_future.set', array(
							'L_TITLE' => lang('ue_' . $is_date))
						);

						foreach ($data as $item) {
							_style('events_future.set.row', array(
								'ITEM_ID' => $item['id'],
								'TITLE' => $item['title'],
								'DATE' => $user->format_date($item['date']),
								'THUMBNAIL' => $config['events_url'] . 'future/thumbnails/' . $item['id'] . '.jpg',
								'SRC' => $config['events_url'] . 'future/' . $item['id'] . '.jpg')
							);
						}
					}
				}

				//
				// Poll
				//
				$user_voted = false;
				if ($this->auth['user'] && !$this->auth['mod']) {
					$sql = 'SELECT *
						FROM _artists_voters
						WHERE ub = ?
							AND user_id = ?';
					if (sql_fieldrow(sql_filter($sql, $this->data['ub'], $user->d('user_id')))) {
						$user_voted = true;
					}
				}

				_style('ub_poll');

				if ($this->auth['mod'] || !$this->auth['user'] || $user_voted) {
					$sql = 'SELECT option_id, vote_result
						FROM _artists_votes
						WHERE ub = ?
						ORDER BY option_id';
					$results = sql_rowset(sql_filter($sql, $this->data['ub']), 'option_id', 'vote_result');

					_style('ub_poll.results');

					foreach ($this->voting['ub'] as $item) {
						$vote_result = (isset($results[$item])) ? intval($results[$item]) : 0;
						$vote_percent = ($this->data['votes'] > 0) ? $vote_result / $this->data['votes'] : 0;

						_style('ub_poll.results.item', array(
							'CAPTION' => lang('ub_vc' . $item),
							'RESULT' => $vote_result,
							'PERCENT' => sprintf("%.1d", ($vote_percent * 100)))
						);
					}
				} else {
					_style('ub_poll.options', array(
						'S_VOTE_ACTION' => s_link('a', $this->data['subdomain'], 'vote'))
					);

					foreach ($this->voting['ub'] as $item) {
						_style('ub_poll.options.item', array(
							'ID' => $item,
							'CAPTION' => lang('ub_vc' . $item))
						);
					}
				}

				//
				// Downloads
				//
				if ($this->data['um'] || $this->data['uv']) {
					$sql = 'SELECT *
						FROM _dl
						WHERE ub = ?
						ORDER BY ud, title';
					$this->ud_song = sql_rowset(sql_filter($sql, $this->data['ub']), 'ud', false, true);

					foreach ($this->ud_song as $key => $data) {
						$download_type = $this->dl_type($key);
						_style('ud_block', array('LANG' => $download_type['lang']));

						foreach ($data as $song) {
							_style('ud_block.item', array(
								'TITLE' => $song['title'])
							);

							if (isset($this->dl_data['id']) && ($song['id'] == $this->dl_data['id'])) {
								_style('ud_block.item.strong');
								continue;
							}

							_style('ud_block.item.a', array(
								'URL' => s_link('a', $this->data['subdomain'], 'downloads', $song['id']))
							);
						}
					}
				}

				//
				// Fan count
				//
				$sql = 'SELECT COUNT(user_id) AS fan_count
					FROM _artists_fav
					WHERE ub = ?
					ORDER BY joined DESC';
				$fan_count = sql_field(sql_filter($sql, $this->data['ub']), 'fan_count', 0);

				//
				// Make fans
				//
				if (!$this->auth['mod'] && !$this->auth['smod']) {
					_style('make_fans', array(
						'FAV_URL' => s_link('a', $this->data['subdomain'], 'favorites'),
						'FAV_LANG' => ($this->auth['fav']) ? '' : lang('ub_fav_add'))
					);
				}

				//
				// Set template
				//
				v_style(array(
					'INACTIVE' => !$this->data['a_active'],
					'UNAME' => $this->data['name'],
					'GENRE' => $this->data['genre'],
					'POSTS' => number_format($this->data['posts']),
					'VOTES' => number_format($this->data['votes']),
					'FANS' => $fan_count,
					'L_FANS' => ($fan_count == 1) ? lang('fan') : lang('fans'),
					'LOCATION' => ($this->data['local']) ? (($this->data['location'] != '') ? $this->data['location'] . ', ' : '') . 'Guatemala' : $this->data['location'])
				);

				$template->set_filenames(array(
					'a_body' => 'artists.' . $this->data['template'] . '.htm')
				);
				$template->assign_var_from_handle('UB_BODY', 'a_body');
				break;
		}

		return;
	}
Example #15
0
	public function run() {
		global $config, $auth, $user, $comments;

		$topic_id = request_var('t', 0);
		$post_id = request_var('p', 0);

		if (!$topic_id && !$post_id) {
			fatal_error();
		}

		//
		// Get topic data
		//
		if ($post_id) {
			$sql_from = ', _forum_posts p, _forum_posts p2, _members m ';
			$sql_where = sql_filter('p.post_id = ? AND p.poster_id = m.user_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= ?', $post_id, $post_id);
			$sql_count = ', p.post_text, m.username AS reply_username, COUNT(p2.post_id) AS prev_posts, p.post_deleted';
			$sql_order = ' GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_locked, t.topic_replies, t.topic_time, t.topic_important, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote ORDER BY p.post_id ASC';
		} else {
			$sql_from = $sql_count = $sql_order = '';
			$sql_where = sql_filter('t.topic_id = ?', $topic_id);
		}

		$sql = 'SELECT t.*, f.*' . $sql_count . '
			FROM _forum_topics t, _forums f' . $sql_from . '
			WHERE ' . $sql_where . ' AND f.forum_id = t.forum_id' . $sql_order;
		if (!$topic_data = sql_fieldrow($sql)) {
			fatal_error();
		}

		switch ($topic_data['forum_alias']) {
			case 'events':
				$sql = 'SELECT event_alias
					FROM _events
					WHERE event_topic = ?';
				if ($event_alias = sql_field(sql_filter($sql, $topic_data['topic_id']), 'event_alias', '')) {
					redirect(s_link('events', $event_alias));
				}
				break;
		}

		//
		// Hide deleted posts
		if (isset($topic_data['post_deleted']) && $topic_data['post_deleted']) {
			fatal_error();
		}

		//
		// Check mod auth
		$mod_auth = $user->is('mod');

		//
		// Init vars
		//
		$forum_id = (int) $topic_data['forum_id'];
		$topic_id = (int) $topic_data['topic_id'];
		$topic_url = s_link('topic', $topic_id);

		$reply = request_var('reply', 0);
		$start = request_var('offset', 0);
		$submit_reply = _button('post');
		$submit_vote = _button('vote');

		$post_message = '';
		$post_reply_message = '';
		$post_np = '';
		$current_time = time();

		$error = $is_auth = w();

		if (!$post_id && $reply) {
			$reply = 0;
		}

		//
		// Start member auth
		//
		$is_auth = $auth->forum(AUTH_ALL, $forum_id, $topic_data);

		if ($submit_reply || $submit_vote) {
			$auth_key = ($submit_reply) ? 'auth_reply' : 'auth_vote';

			if (((!$is_auth['auth_view'] || !$is_auth['auth_read'])) || !$is_auth[$auth_key]) {
				if (!$user->is('member')) {
					do_login();
				}

				$can_reply_closed = $auth->option(w('forum topics delete'));

				if (!$can_reply_closed && ($topic_data['forum_locked'] || $topic_data['topic_locked'])) {
					$error[] = 'TOPIC_LOCKED';

					if ($submit_vote && !$topic_data['topic_vote']) {
						$error[] = 'POST_HAS_NO_POLL';
					}
				}

				if (!sizeof($error)) {
					redirect($topic_url);
				}
			}

			if (!sizeof($error)) {
				if ($submit_vote) {
					$vote_option = request_var('vote_id', 0);

					if ($vote_option) {
						$sql = 'SELECT vd.vote_id
							FROM _poll_options vd, _poll_results vr
							WHERE vd.topic_id = ?
								AND vr.vote_id = vd.vote_id
								AND vr.vote_option_id = ?
							GROUP BY vd.vote_id';
						if ($vote_id = sql_field(sql_filter($sql, $topic_id, $vote_option), 'vote_id', 0)) {
							$sql = 'SELECT *
								FROM _poll_voters
								WHERE vote_id = ?
									AND vote_user_id = ?';
							if (!sql_fieldrow(sql_filter($sql, $vote_id, $user->d('user_id')))) {
								$sql = 'UPDATE _poll_results SET vote_result = vote_result + 1
									WHERE vote_id = ?
										AND vote_option_id = ?';
								sql_query(sql_filter($sql, $vote_id, $vote_option));

								$insert_vote = array(
									'vote_id' => (int) $vote_id,
									'vote_user_id' => (int) $user->d('user_id'),
									'vote_user_ip' => $user->ip,
									'vote_cast' => (int) $vote_option
								);
								sql_insert('poll_voters', $insert_vote);
							}
						}
					}

					redirect(s_link('topic', $topic_id));
				} else {
					$post_message = request_var('message', '', true);
					$post_np = request_var('np', '');

					if ($reply) {
						$post_reply_message = request_var('reply_message', '', true);
					}

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

					if (!sizeof($error) && !$mod_auth)
					{
						$sql = 'SELECT MAX(post_time) AS last_post_time
							FROM _forum_posts
							WHERE poster_id = ?';
						if ($last_post_time = sql_field(sql_filter($sql, $user->d('user_id')))) {
							if (intval($last_post_time) > 0 && ($current_time - intval($last_post_time)) < intval($config['flood_interval'])) {
								$error[] = 'FLOOD_ERROR';
							}
						}
					}

					if (!sizeof($error)) {
						$update_topic = w();

						if (strstr($post_message, '-Anuncio-') && $user->is('mod')) {
							$topic_announce = 1;
							$post_message = str_replace('-Anuncio-', '', $post_message);
							$update_topic['topic_announce'] = $topic_announce;
						}

						if (strstr($post_message, '-Cerrado-') && $user->is('mod')) {
							$topic_locked = 1;
							$post_message = str_replace('-Cerrado-', '', $post_message);
							$update_topic['topic_locked'] = $topic_locked;
						}

						$post_message = $comments->prepare($post_message);

						if ($reply && $post_reply_message != '') {
							$post_reply_message = preg_replace('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#ie', '', $post_reply_message);
						}

						if ($reply && empty($post_reply_message)) {
							$post_reply_message = '...';
						}

						if ($reply && $post_reply_message != '') {
							$post_message = '<blockquote><strong>' . $topic_data['reply_username'] . "</strong>" . nr(false, 2) . $post_reply_message . '</blockquote><br /> ' . $post_message;
						} else {
							$reply = 0;
						}

						$insert_data = array(
							'topic_id' => (int) $topic_id,
							'forum_id' => (int) $forum_id,
							'poster_id' => (int) $user->d('user_id'),
							'post_time' => (int) $current_time,
							'poster_ip' => $user->ip,
							'post_text' => $post_message,
							'post_np' => $post_np
						);
						if ($reply) {
							$insert_data['post_reply'] = $post_id;
						}

						$post_id = sql_insert('forum_posts', $insert_data);

						$user->delete_unread(UH_T, $topic_id);
						$user->save_unread(UH_T, $topic_id);

						if (!in_array($forum_id, forum_for_team_array()) && $topic_data['topic_points']) {
							//$user->points_add(1);
						}

						//
						$a_list = forum_for_team_list($forum_id);
						if (count($a_list)) {
							$sql_delete_unread = 'DELETE FROM _members_unread
								WHERE element = ?
									AND item = ?
									AND user_id NOT IN (??)';
							sql_query(sql_filter($sql_delete_unread, 8, $topic_id, implode(', ', $a_list)));
						}

						$update_topic['topic_last_post_id'] = $post_id;

						if ($topic_locked) {
							topic_feature($topic_id, 0);
						}

						$sql = 'UPDATE _forums SET forum_posts = forum_posts + 1, forum_last_topic_id = ?
							WHERE forum_id = ?';
						sql_query(sql_filter($sql, $topic_id, $forum_id));

						$sql = 'UPDATE _forum_topics SET topic_replies = topic_replies + 1, ' . sql_build('UPDATE', $update_topic) . sql_filter('
							WHERE topic_id = ?', $topic_id);
						sql_query($sql);

						$sql = 'UPDATE _members SET user_posts = user_posts + 1
							WHERE user_id = ?';
						sql_query(sql_filter($sql, $user->d('user_id')));

						redirect(s_link('post', $post_id) . '#' . $post_id);
					}
				}
			}
		}

		if (!$is_auth['auth_view'] || !$is_auth['auth_read']) {
			if (!$user->is('member')) {
				do_login();
			}

			fatal_error();
		}

		if ($post_id) {
			$start = floor(($topic_data['prev_posts'] - 1) / (int) $config['posts_per_page']) * (int) $config['posts_per_page'];
			$user->d('user_topic_order', 0);
		}

		if ($user->is('member')) {
			//
			// Is user watching this topic?
			//
			$sql = 'SELECT notify_status
				FROM _forum_topics_fav
				WHERE topic_id = ?
					AND user_id = ?';
			if (!sql_field(sql_filter($sql, $topic_id, $user->d('user_id')), 'notify_status')) {
				if (_button('watch')) {
					$sql_insert = array(
						'user_id' => $user->d('user_id'),
						'topic_id' => $topic_id,
						'notify_status' => 0
					);
					sql_insert('forum_topics_fav', $sql_insert);

					redirect($topic_url . (($start) ? 's' . $start . '/' : ''));
				}

				_style('watch_topic');
			}
		}

		//
		// Get all data for the topic
		//
		$get_post_id = ($reply) ? 'post_id' : 'topic_id';
		$get_post_data['p.' . $get_post_id] = ${$get_post_id};

		if (!$user->is('founder')) {
			$get_post_data['p.post_deleted'] = 0;
		}

		$sql = 'SELECT p.*, u.user_id, u.username, u.username_base, u.user_avatar, u.user_posts, u.user_gender, u.user_rank, u.user_sig
			FROM _forum_posts p, _members u
			WHERE u.user_id = p.poster_id
				AND p.post_deleted = 0
				AND ' . sql_build('SELECT', $get_post_data) . '
			ORDER BY p.post_time ' . (($user->d('user_topic_order')) ? 'DESC' : 'ASC') .
			((!$reply) ? ' LIMIT ' . (int) $start . ', ' . (int) $config['posts_per_page'] : '');
		if (!$messages = sql_rowset($sql)) {
			if ($topic_data['topic_replies'] + 1) {
				fatal_error();
			}

			redirect(s_link('topic', $topic_id));
		}

		//
		// Re-count topic replies
		//
		if ($user->is('founder')) {
			$sql = 'SELECT COUNT(p.post_id) AS total
				FROM _forum_posts p, _members u
				WHERE p.topic_id = ?
					AND u.user_id = p.poster_id';
			if ($total = sql_field(sql_filter($sql, $topic_id), 'total')) {
				$topic_data['topic_replies2'] = $total - 1;
			}
		}

		//
		// Update the topic views
		//
		if (!$start && !$user->is('founder')) {
			$sql = 'UPDATE _forum_topics
				SET topic_views = topic_views + 1
				WHERE topic_id = ?';
			sql_query(sql_filter($sql, $topic_id));
		}

		//
		// If the topic contains a poll, then process it
		//
		if ($topic_data['topic_vote']) {
			$sql = 'SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
				FROM _poll_options vd, _poll_results vr
				WHERE vd.topic_id = ?
					AND vr.vote_id = vd.vote_id
				ORDER BY vr.vote_option_order, vr.vote_option_id ASC';
			if ($vote_info = sql_rowset(sql_filter($sql, $topic_id))) {
				$sql = 'SELECT vote_id
					FROM _poll_voters
					WHERE vote_id = ?
						AND vote_user_id = ?';
				$user_voted = sql_field(sql_filter($sql, $vote_info[0]['vote_id'], $user->d('user_id')), 'vote_id', 0);

				$poll_expired = ($vote_info[0]['vote_length']) ? (($vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < $current_time) ? true : 0) : 0;

				_style('poll', array(
					'POLL_TITLE' => $vote_info[0]['vote_text'])
				);

				if ($user_voted || $poll_expired || !$is_auth['auth_vote'] || $topic_data['topic_locked']) {
					$vote_results_sum = 0;
					foreach ($vote_info as $row) {
						$vote_results_sum += $row['vote_result'];
					}

					_style('poll.results');

					foreach ($vote_info as $row) {
						$vote_percent = ($vote_results_sum > 0) ? $row['vote_result'] / $vote_results_sum : 0;

						_style('poll.results.item', array(
							'CAPTION' => $row['vote_option_text'],
							'RESULT' => $row['vote_result'],
							'PERCENT' => sprintf("%.1d", ($vote_percent * 100)))
						);
					}
				} else {
					_style('poll.options', array(
						'S_VOTE_ACTION' => $topic_url)
					);

					foreach ($vote_info as $row) {
						_style('poll.options.item', array(
							'POLL_OPTION_ID' => $row['vote_option_id'],
							'POLL_OPTION_CAPTION' => $row['vote_option_text'])
						);
					}
				}
			}
		}

		//
		// Advanced auth
		//

		$controls = $user_profile = w();
		$unset_user_profile = w('user_id user_posts user_gender');

		_style('posts');

		foreach ($messages as $row) {
			if ($user->is('member')) {
				$poster = ($row['user_id'] != GUEST) ? $row['username'] : (($row['post_username'] != '') ? $row['post_username'] : lang('guest'));

				$controls[$row['post_id']]['reply'] = s_link('post', $row['post_id'], 'reply');

				if ($mod_auth) {
					$controls[$row['post_id']]['edit'] = s_link('acp', array('forums_post_modify', 'msg_id' => $row['post_id']));
					$controls[$row['post_id']]['delete'] = s_link('acp', array('forums_post_delete', 'msg_id' => $row['post_id']));
				}
			}

			$user_profile[$row['user_id']] = $comments->user_profile($row, '', $unset_user_profile);

			$data = array(
				'POST_ID' => $row['post_id'],
				'POST_DATE' => $user->format_date($row['post_time']),
				'MESSAGE' => $comments->parse_message($row['post_text']),
				'PLAYING' => $row['post_np'],
				'DELETED' => $row['post_deleted'],
				'UNREAD' => 0
			);

			foreach ($user_profile[$row['user_id']] as $key => $value) {
				$data[strtoupper($key)] = $value;
			}

			_style('posts.item', $data);
			_style('posts.item.' . (($row['user_id'] != GUEST) ? 'username' : 'guestuser'));

			if (isset($controls[$row['post_id']])) {
				_style('posts.item.controls');

				foreach ($controls[$row['post_id']] as $item => $url) {
					_style('posts.item.controls.'.$item, array('URL' => $url));
				}
			}
		}

		//
		// Display Member topic auth
		//
		/*
		if ($mod_auth) {
			$mod = array((($topic_data['topic_important']) ? 'important' : 'normal'), 'delete', 'move', ((!$topic_data['topic_locked']) ? 'lock' : 'unlock'), 'split', 'merge');

			$mod_topic = w();
			foreach ($mod as $item) {
				if ($auth->option(array('forum', 'topics', $item))) {
					$mod_topic[strtoupper($item)] = s_link('acp', array('topic', topic' => $topic_id, 'mode' => $item));
				}
			}

			if (sizeof($mod_topic)) {
				_style('auth');

				foreach ($mod_topic as $k => $v) {
					_style('auth.item', array(
						'URL' => $v,
						'LANG' => lang($k . '_topic'))
					);
				}
			}
		}
		*/
		build_num_pagination($topic_url . 's%d/', ($topic_data['topic_replies'] + 1), $config['posts_per_page'], $start, '', 'TOPIC_');

		//
		// Posting box
		if (sizeof($error)) {
			_style('post_error', array(
				'MESSAGE' => parse_error($error))
			);
		}

		$can_reply_closed = $auth->option(array('forum', 'topics', 'delete'));

		if ((!$topic_data['forum_locked'] && !$topic_data['topic_locked']) || $can_reply_closed) {
			if ($user->is('member')) {
				if ($is_auth['auth_reply']) {
					$s_post_action = (($reply) ? s_link('post', $post_id, 'reply') : $topic_url) . '#e';

					_style('post_box', array(
						'MESSAGE' => $post_message,
						'NP' => $post_np,
						'S_POST_ACTION' => $s_post_action)
					);

					if ($reply) {
						if (empty($post_reply_message)) {
							$post_reply_message = $comments->remove_quotes($topic_data['post_text']);
						}

						if (!empty($post_reply_message)) {
							$rx = array('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#is', '#\[yt:[0-9a-zA-Z\-\=\_]+\]#is', '#\[sb\]#is', '#\[\/sb\]#is');
							$post_reply_message = preg_replace($rx, '', $post_reply_message);
						}

						if (empty($post_reply_message)) {
							$post_reply_message = '...';
						}

						_style('post_box.reply', array(
							'MESSAGE' => $post_reply_message)
						);
					}
				}
			}
		}

		// MOD: Featured topic
		if ($user->is('mod')) {
			$v_lang = ($topic_data['topic_featured']) ? 'REM' : 'ADD';

			_style('feature', array(
				'U_FEAT' => s_link('acp', array('forums_topic_feature', 'msg_id', $topic_data['topic_id'])),
				'V_LANG' => lang('topic_featured_' . $v_lang))
			);
		}

		//
		// Send vars to template
		//
		v_style(array(
			'FORUM_NAME' => $topic_data['forum_name'],
			'TOPIC_TITLE' => $topic_data['topic_title'],
			'TOPIC_REPLIES' => $topic_data['topic_replies'],

			'S_TOPIC_ACTION' => $topic_url . (($start) ? 's' . $start . '/' : ''),
			'U_VIEW_FORUM' => s_link('forum', $topic_data['forum_alias']))
		);

		$layout_file = 'topic';
		if (@file_exists('./template/custom/topics_' . $forum_id . '.htm')) {
			$layout_file = 'custom/topics_' . $forum_id;
		}

		if (@file_exists('./template/custom/topic_' . $topic_id . '.htm')) {
			$layout_file = 'custom/topic_' . $topic_id;
		}

		$this->_title = $topic_data['topic_title'];
		$this->_template = $layout_file;

		return;
	}
Example #16
0
    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;
    }
Example #17
0
    function _edit_home()
    {
        global $user;
        $v = $this->__(array('id' => 0));
        $sql = 'SELECT *
			FROM _email
			WHERE email_id = ?';
        if (!($email = _fieldrow(sql_filter($sql, $v['id'])))) {
            $this->e('El registro de email no existe.');
        }
        if (_button()) {
            $v = array_merge($v, $this->__(w('subject message')));
            $sql = 'UPDATE _email SET ' . _build_array('UPDATE', prefix('email', $v)) . sql_filter('
				WHERE email_id = ?', $v['id']);
            _sql($sql);
            $this->e('El mensaje programado fue actualizado.');
        }
        v_style(array('SUBJECT' => $email['email_subject'], 'MESSAGE' => $email['email_message']));
    }
Example #18
0
	public function _home() {
		global $config, $user, $comments;

		$this->_artist();

		$sql = 'SELECT *, SUM(members + guests) AS total
			FROM _artists_stats
			WHERE ub = ?
			GROUP BY date
			ORDER BY date DESC';
		$stats = sql_rowset(sql_filter($sql, $this->object['ub']), 'date');

		$years_sum = w();
		$years_temp = w();
		$years = w();

		foreach ($stats as $date => $void) {
			$year = substr($date, 0, 4);

			if (!isset($years_temp[$year])) {
				$years[] = $year;
				$years_temp[$year] = true;
			}

			if (!isset($years_sum[$year])) {
				$years_sum[$year] = 0;
			}

			$years_sum[$year] += $void['total'];
		}
		unset($years_temp);

		if (sizeof($years)) {
			rsort($years);
		} else {
			$years[] = date('Y');
		}

		$total_graph = 0;
		foreach ($years as $year) {
			_style('year', array(
				'YEAR' => $year)
			);

			if (!isset($years_sum[$year])) {
				$years_sum[$year] = 0;
			}

			for ($i = 1; $i < 13; $i++) {
				$month = (($i < 10) ? '0' : '') . $i;
				$monthdata = (isset($stats[$year . $month])) ? $stats[$year . $month] : w();
				$monthdata['total'] = isset($monthdata['total']) ? $monthdata['total'] : 0;
				$monthdata['percent'] = ($years_sum[$year] > 0) ? $monthdata['total'] / $years_sum[$year] : 0;
				$monthdata['members'] = isset($monthdata['members']) ? $monthdata['members'] : 0;
				$monthdata['guests'] = isset($monthdata['guests']) ? $monthdata['guests'] : 0;
				$monthdata['unix'] = gmmktime(0, 0, 0, $i, 1, $year) - $user->timezone - $user->dst;
				$total_graph += $monthdata['total'];

				_style('year.month', array(
					'NAME' => $user->format_date($monthdata['unix'], 'F'),
					'TOTAL' => $monthdata['total'],
					'MEMBERS' => $monthdata['members'],
					'GUESTS' => $monthdata['guests'],
					'PERCENT' => sprintf("%.1d", ($monthdata['percent'] * 100)))
				);
			}
		}

		v_style(array(
			'BEFORE_VIEWS' => number_format($this->object['views']),
			'SHOW_VIEWS_LEGEND' => ($this->object['views'] > $total_graph))
		);

		return;
	}
Example #19
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;
    }
Example #20
0
	public function window() {
		global $user, $config;

		v_style(array(
			'CH_SID' => $this->data['session_id'],
			'CH_INT_NAME' => $this->data['ch_int_name'],
			'CH_NAME' => $this->data['ch_name'])
		);

		if ($user->d('user_id') === $this->data['ch_founder']) {
			// TEMP
			// _style('ch_manage');
		}
	}
Example #21
0
    protected function _topic_home()
    {
        global $bio;
        $v = $this->__(_array_keys(w('t p s'), 0));
        if (!$v->t && !$v->p) {
            $warning->now();
        }
        $sql_from = $sql_where = $sql_count = $sql_order = '';
        if ($v['p']) {
            $sql_count = ', COUNT(p2.post_id) AS prev_posts, p.post_deleted';
            $sql_from = ', _board_posts p, _board_posts p2, _bio b ';
            $sql_where = sql_filter('p.post_id = ? AND p.poster_id = b.bio_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= ?', $v->p, $v->p);
            $sql_order = ' GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_locked, t.topic_replies, t.topic_time, t.topic_important, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote ORDER BY p.post_id ASC';
        } else {
            $sql_where = sql_filter('t.topic_id = ?', $v->t);
        }
        $sql = 'SELECT t.*, f.*' . $sql_count . '
			FROM _board_topics t, _board_forums f' . $sql_from . '
			WHERE ' . $sql_where . ' AND f.forum_id = t.forum_id' . $sql_order;
        if (!($topic_data = sql_fieldrow($sql))) {
            _fatal();
        }
        $v->f = $topic_data->forum_id;
        $v->t = $topic_data->topic_id;
        //
        if ($v->p) {
            $v->s = floor(($topic_data->prev_posts - 1) / (int) $core->v('posts_per_page')) * (int) $core->v('posts_per_page');
        }
        //
        // Update the topic views
        /*
        if (!$v->offset && !$bio->v('auth_founder') && $bio->v('auth_member') && ($topic_data['topic_poster'] != $bio->v('bio_id')))
        {
        	$sql = 'UPDATE _forum_topics SET topic_views = topic_views + 1
        		WHERE topic_id = ?';
        	_sql(sql_filter($sql, $v->t));
        }
        */
        //
        // Get topic data
        $sql = 'SELECT p.*, b.bio_id, b.bio_alias, b.bio_name, b.bio_color, b.bio_avatar, b.bio_avatar_up, b.bio_sig
			FROM _board_posts p, _bio b
			WHERE p.post_topic = ?
				AND p.post_bio = b.bio_id
			ORDER BY p.post_time ASC
			LIMIT ??, ??';
        if (!($posts = sql_rowset(sql_filter($sql, $v->t, $v->offset, $core->v('posts_per_page'))))) {
            _fatal();
        }
        $allow_posts = !$topic_data->forum_locked;
        if ($allow_posts) {
            _style('publish');
        }
        foreach ($posts as $i => $row) {
            if (!$i) {
                _style('posts', _pagination(_link('board', array('topic', $v->t, 's%d')), $topic_data->topic_replies + 1, $core->v('posts_per_page'), $start));
            }
            $_row = array('ID' => $row->post_id, 'BIO' => $row->post_bio, 'TIME' => _format_date($row->post_time), 'CONTENT' => _message($row->post_content), 'PLAYING' => $row->post_playing);
            _style('posts.row', array_merge($_row, $this->_profile($row)));
            if ($allow_posts) {
                _style('posts.row.publish');
            }
        }
        $this->monetize();
        // TODO: Include social networks buttons
        $this->set_nav($v->f, $topic_data->forum_name, 'forum');
        $this->set_nav($v->t, $topic_data->topic_title, 'topic');
        //
        $_v = $v->p ? 'p' : 'f';
        $_w = $v->p ? 'p' : 't';
        v_style(array('U_PUBLISH' => _link('board publish'), 'H_PUBLISH' => _hidden(array($_v => $v[$_w]))));
        return;
    }
Example #22
0
    protected function _tos_home()
    {
        global $warning;
        $v = $this->__(array('view' => 'tos'));
        if (!($page = $this->page_query($v['view']))) {
            $warning->now();
        }
        $temporal_content = array('Pol&iacute;tica de Privacidad' => array('Con el acceso al servidor, el usuario manifiesta su total conformidad con los t&eacute;rminos de servicio establecidos en este documento y se compromete a observarlos durante su estad&iacute;a.', 'El usuario libera a RK Networks de cualquier responsabilidad, a&uacute;n la responsabilidad impl&iacute;cita de cualquier da&ntilde;o que pudiera surgir ya sea t&eacute;cnico, moral o de otra naturaleza, durante el tiempo en que &eacute;ste est&eacute; conectado al servidor.', 'Si el usuario no esta de acuerdo con estos t&eacute;rminos de uso deber&aacute; cerrar cualquier tipo de conexi&oacute;n que tenga con el servidor.', 'RK Networks se reserva el derecho de cambiar, modificar, agregar o quitar cualquier porci&oacute;n de estos t&eacute;rminos peri&oacute;dicamente. Tales modificaciones entrar&aacute;n en vigencia inmediatamente una vez que &eacute;ste sea publicado.', 'El usuario se compromete a utilizar los servicios de RK de forma diligente, correcta, l&iacute;cita, de conformidad con la Ley, as&iacute; como con la moral, buenas costumbres generalmente aceptadas y el orden p&uacute;blico.', 'RK Networks reconoce la importancia de la privacidad de las personas, por lo que sus sistemas est&aacute;n dise&ntilde;ados considerando la protecci&oacute;n de la informaci&oacute;n que es prove&iacute;da.', 'En RK no obtenemos su informaci&oacute;n personal sin consentimiento y lo que se obtiene es lo que el usuario nos proporciona y no exigimos proveerla.', 'RK no vende ni comparte informaci&oacute;n personal con alg&uacute;n otro sitio o empresa por ning&uacute;n motivo.', 'Los servicios que no requieren identificar al usuario, recolectan informaci&oacute;n general y no informaci&oacute;n personal, relativa al navegador que se utiliza, el tipo de conexi&oacute;n a Internet, el sistema operativo y otros elementos de configuraci&oacute;n destinados a mejorar nuestros servicios.', 'Algunos de nuestros servicios requieren expl&iacute;citamente que el usuario abra una cuenta, en virtud de la funcionalidad del sitio. En este caso, el sitio solicita datos para la cuenta como 
				nombre de usuario, direcci&oacute;n de correo, edad, sexo, entre otros. Esta informaci&oacute;n personal puede solicitarse al usuario al entrar a ciertas &aacute;reas.', 'RK toma las medidas necesarias para proteger la informaci&oacute;n personal y garantizar la seguridad de sus bases de datos, contra acceso o alteraci&oacute;n no autorizados, divulgaci&oacute;n o destrucci&oacute;n de informaci&oacute;n.'), 'T&eacute;rminos de servicio' => array('Obligaciones al crear una cuenta de usuario:' => array('Proporcionar informaci&oacute;n v&aacute;lida, exacta, actual y completa.', 'Mantener actualizada dicha informaci&oacute;n.', 'RK se reserva el derecho a deshabilitar y/o borrar si se encontrara que la informaci&oacute;n proporcionada por el usuario es falsa, inexacta o incompleta, denegando de esta forma al usuario cualquier tipo de comunicaci&oacute;n con el sitio.'), 'Est&aacute; prohibido publicar lo siguiente en las &aacute;reas de participaci&oacute;n de usuarios:' => array('Pornograf&iacute;a y material obsceno. Cualquier tipo de sexo explicito no est&aacute; permitido.', 'Lenguaje violento y/u ofensivo hacia la integridad de las personas.', 'Racismo o apolog&iacute;a del terrorismo.', 'Distribuci&oacute;n de materiales protegidos por derechos de autor.', 'Contenido de pirateo inform&aacute;tico.', 'Contenido de distribuci&oacute;n pirata, virus o mp3 ilegal.', 'Compartir contrase&ntilde;as, seriales o cracks de p&aacute;ginas o programas.', 'Juegos de apuesta y/o contenido relacionado con casinos.', 'Drogas ilegales o art&iacute;culos relacionados.', 'Cualquier contenido que promueva actividades ilegales.', 'Publicar contenido, falso, enga&ntilde;oso o ambiguo.', 'Contenido que viole los secretos empresariales de terceros.', 'Contenido de correos privados o mensajes privados sin el permiso expreso del usuario.', 'Contenido que pueda difamar, insultar, molestar, amenazar, acosar o violar en cualquier manera los derechos de otras personas.', 'Venta o promoci&oacute;n de armas, alcohol, tabaco, medicamentos o imitaciones de productos de marca.', 'Cualquier tipo de spam / env&iacute;o de correo no solicitado.', 'Cualquier tipo de invasi&oacute;n de la privacidad de terceras personas ni publicar datos personales sin consentimiento.'), 'El usuario se compromete a respetar a todos los usuarios dentro de la comunidad:' => array('No molestar ni amenazar a los usuarios.', 'Mostrar tolerancia hacia otras formas de pensar, tendencias musicales, de culturas, de credos y de conducta sexual.', 'Establecer conversaciones privadas &uacute;nicamente con el consentimiento del otro usuario.', 'Existe total libertad de conversaci&oacute;n en las conversaciones privadas, mientras sean establecidas con pleno consentimiento de ambos usuarios.'), 'Moderaci&oacute;n del foro:' => array('Los usuarios est&aacute;n obligados a seguir las indicaciones de los administradores y miembros del equipo de trabajo de RK.', 'No se permitir&aacute;n los mensajes que &uacute;nicamenete contengan emoticonos en los temas del foro.', 'No publicar t&iacute;tulos y/o mensajes del foro todo con may&uacute;sculas.', 'Los temas nuevos del foro relacionados con otros ya existentes ser&aacute;n unidos en un &uacute;nico tema.', 'Las im&aacute;genes que se publiquen en los mensajes y que no tengan relaci&oacute;n con el tema ser&aacute;n borradas del mensaje.', 'Si las firmas de usuarios contienen im&aacute;genes, &eacute;stas deben ser de dimensiones m&aacute;ximas de 600px de ancho por 200px de alto. Cualquier firma que exceda estas dimensiones ser&aacute; borrada, con o sin previo aviso.', 'Los moderadores pueden eliminar contenido inaceptable e impartir advertencias o excluirlo del foro, en este &uacute;ltimo dando aviso a un administrador.', 'Estas moderaciones comparar&aacute;n el contenido inaceptable publicado por el autor con su expediente disciplinario previo. La actitud del usuario con respecto a la publicaci&oacute;n, as&iacute; como las subsiguientes acciones con respecto al incidente ser&aacute;n tambi&eacute;n un factor a tener en cuenta para bloquear a un usuario.', 'Nunca se debe evitar de cualquier manera los comentarios de un moderador ya que tienen como prop&oacute;sito aplicar el reglamento de este foro.', 'Si cree que debe discutir cualquier asunto contactar a un miembro del equipo de moderadores, hacerlo exclusivamente por medio de conversaci&oacute;n privada.', 'Ning&uacute;n moderador debe alentar de cualquier forma una conversaci&oacute;n p&uacute;blica de contenido falso, violento, enga&ntilde;oso o ambiguo.', 'No se puede volver a publicar temas que hayan sido cerrados o borrados. No se puede volver a publicar contenido borrado por los moderadores.', 'Cada tema debe ser publicado en la categor&iacute;a que corresponde. No se puede publicar copias de temas en varias categor&iacute;as. Dichas copias ser&aacute;n borradas para mantener el orden.'), 'RK podr&aacute; bloquear el acceso al sitio al usuario que viole estos t&eacute;rminos de servicio sin previa notificaci&oacute;n.', 'Es responsabilidad del autor la informaci&oacute;n que se genera como texto, datos, software, m&uacute;sica, fotograf&iacute;as, im&aacute;genes, video, mensajes o cualquier otro material. El usuario es responsable por el contenido que publique.', 'RK se reserva el derecho a deshabilitar y/o borrar cualquier contenido que viole los t&eacute;rminos expuestos en este documento.', 'Queda absolutamente prohibido cualquier tipo de atentado contra la seguridad del sistema de RK. Si se da este caso se podr&aacute; bloquear al usuario, IP o conexi&oacute;n de origen por tiempo indefinido.', 'RK no se hace responsable por cualquier da&ntilde;o que pueda sufrir el equipo del usuario, al utilizar el sitio web y sus servicios.', 'Artistas y m&uacute;sicos' => array('Todo el material art&iacute;stico publicado en RK es propiedad de sus respectivos autores y est&aacute; cubierto por el acto de derechos de propiedad de Guatemala y por las leyes internacionales de derechos del autor.', 'Toda la informaci&oacute;n en la secci&oacute;n correspondiente al artista, puede ser modificada &uacute;nicamente por un miembro autorizado y administraci&oacute;n de RK, siendo el artista el &uacute;nico responsable de la informaci&oacute;n en las &aacute;reas de publicaci&oacute;n oficial.', 'El material no puede ser copiado, modificado, editado, distribuido o vendido sin previa autorizaci&oacute;n del artista o por el representante legal.')));
        return v_style(array('TOS_CONTENT' => _message($page->page_content)));
    }
Example #23
0
    protected function _analytics_home()
    {
        global $bio;
        $sql = 'SELECT *, SUM(stats_members + stats_guests) AS total
			FROM _bio_stats
			WHERE bio_id = ?
			GROUP BY date
			ORDER BY date DESC';
        $stats = sql_rowset(sql_filter($sql, $bio->v('bio_id')), 'stats_date');
        $years_sum = w();
        $years_temp = w();
        $years = w();
        foreach ($stats as $date => $void) {
            $year = substr($date, 0, 4);
            if (!isset($years_temp[$year])) {
                $years[] = $year;
                $years_temp[$year] = true;
            }
            if (!isset($years_sum[$year])) {
                $years_sum[$year] = 0;
            }
            $years_sum[$year] += $void['total'];
        }
        unset($years_temp);
        if (sizeof($years)) {
            rsort($years);
        } else {
            $years[] = date('Y');
        }
        $total_graph = 0;
        foreach ($years as $year) {
            _style('year', array('YEAR' => $year));
            if (!isset($years_sum[$year])) {
                $years_sum[$year] = 0;
            }
            for ($i = 1; $i < 13; $i++) {
                $month = ($i < 10 ? '0' : '') . $i;
                $monthdata = isset($stats[$year . $month]) ? $stats[$year . $month] : (object) w();
                $monthdata->total = isset($monthdata->total) ? $monthdata->total : 0;
                $monthdata->percent = $years_sum[$year] > 0 ? $monthdata->total / $years_sum[$year] : 0;
                $monthdata->members = isset($monthdata->members) ? $monthdata->members : 0;
                $monthdata->guests = isset($monthdata->guests) ? $monthdata->guests : 0;
                $monthdata->unix = _timestamp($i, 1, $year, 0, 0, 0);
                $total_graph += $monthdata->total;
                _style('year.month', array('NAME' => _format_date($monthdata->unix, 'F'), 'TOTAL' => $monthdata->total, 'MEMBERS' => $monthdata->members, 'GUESTS' => $monthdata->guests, 'PERCENT' => sprintf("%.1d", $monthdata->percent * 100)));
            }
        }
        v_style(array('BEFORE_VIEWS' => number_format($bio->v('bio_views')), 'SHOW_VIEWS_LEGEND' => $this->data['views'] > $total_graph));
        return;
    }
Example #24
0
function _layout($template, $page_title = false, $v_custom = false)
{
    global $core, $user, $style, $starttime;
    // GZip
    if (_browser('gecko')) {
        ob_start('ob_gzhandler');
    }
    // Headers
    if (!headers_sent()) {
        header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
        header('Expires: 0');
        header('Pragma: no-cache');
    }
    if ($page_title !== false) {
        if (!is_array($page_title)) {
            $page_title = w($page_title);
        }
        foreach ($page_title as $k => $v) {
            $page_title[$k] = _lang($v);
        }
        $page_title = implode(' . ', $page_title);
    }
    //
    _lib_define();
    $filename = strpos($template, '#') !== false ? str_replace('#', '.', $template) : $template . '.htm';
    $style->set_filenames(array('body' => $filename));
    // SQL History
    if ($core->v('show_sql_history')) {
        foreach (_sql_history() as $i => $row) {
            if (!$i) {
                _style('sql_history');
            }
            _style('sql_history.row', array('QUERY' => str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;'), $row)));
        }
    }
    //
    $v_assign = array('SITE_TITLE' => $core->v('site_title'), 'PAGE_TITLE' => $page_title, 'G_ANALYTICS' => $core->v('google_analytics'), 'S_REDIRECT' => $user->v('session_page'), 'F_SQL' => _sql_queries());
    if ($v_custom !== false) {
        $v_assign += $v_custom;
    }
    $mtime = explode(' ', microtime());
    $v_assign['F_TIME'] = sprintf('%.2f', $mtime[0] + $mtime[1] - $starttime);
    v_style($v_assign);
    $style->pparse('body');
    sql_close();
    exit;
}
Example #25
0
	public function _home() {
		global $config, $user, $cache, $comments;

		$this->id = request_var('msg_id', 0);

		$sql = 'SELECT *
			FROM _forum_posts
			WHERE post_id = ?';
		if (!$this->object->post = sql_fieldrow(sql_filter($sql, $this->id))) {
			fatal_error();
		}

		$this->object->post = (object) $this->object->post;

		$sql = 'SELECT *
			FROM _forum_topics
			WHERE topic_id = ?';
		if (!$this->object->topic = sql_fieldrow(sql_filter($sql, $this->object->post->topic_id))) {
			fatal_error();
		}

		$this->object->topic = (object) $this->object->topic;

		if (_button()) {
			$topic_title = request_var('topic_title', '');
			$post_message = $comments->prepare(request_var('message', '', true));

			if (!empty($topic_title) && $topic_title != $this->object->topic->topic_title) {
				$sql = 'UPDATE _forum_topics SET topic_title = ?
					WHERE topic_id = ?';
				sql_query(sql_filter($sql, $topic_title, $this->object->topic->topic_id));

				$sql = 'SELECT id
					FROM _events
					WHERE event_topic = ?';
				if ($this->object->event_id = sql_field(sql_filter($sql, $this->object->topic->topic_id), 'id', 0)) {
					$sql = 'UPDATE _events SET title = ?
						WHERE id = ?';
					sql_query(sql_filter($sql, $topic_title, $this->object->event_id));
				}
			}

			if ($post_message != $this->object->post->post_text) {
				$sql = 'UPDATE _forum_posts SET post_text = ?
					WHERE post_id = ?';
				sql_query(sql_filter($sql, $post_message, $this->id));

				$rev = array(
					'rev_post' => $this->id,
					'rev_uid' => $user->d('user_id'),
					'rev_time' => time(),
					'rev_ip' => $user->ip,
					'rev_text' => $this->object->post->post_text
				);
				sql_insert('forum_posts_rev', $rev);
			}

			redirect(s_link('post', $this->id));
		}

		v_style(array(
			'V_TOPIC' => ($user->is('founder')) ? $this->object->topic->topic_title : '',
			'V_MESSAGE' => $this->object->post->post_text)
		);
		//return page_layout('Editar', 'modcp.edit', $tv);
	}
Example #26
0
function _layout($template, $page_title = false, $v_custom = false)
{
    global $core, $bio, $style, $starttime;
    // GZip
    if (_browser('gecko')) {
        ob_start('ob_gzhandler');
    }
    // Headers
    if (!headers_sent()) {
        header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
        header('Expires: 0');
        header('Pragma: no-cache');
    }
    if ($page_title !== false) {
        if (!is_array($page_title)) {
            $page_title = w($page_title);
        }
        foreach ($page_title as $k => $v) {
            $page_title[$k] = $bio->_lang($v);
        }
        $page_title = implode(' . ', $page_title);
    }
    $sql = 'SELECT module_alias, module_name
		FROM _modules
		WHERE module_header = 1
			AND module_active = 1
		ORDER BY module_order';
    $header_menu = sql_rowset($sql);
    foreach ($header_menu as $i => $row) {
        if (!$i) {
            _style('nav');
        }
        _style('nav.menu', array('ACTIVE' => false, 'HREF' => _link($row->module_alias), 'NAME' => $row->module_name));
    }
    //
    $filename = strpos($template, '#') !== false ? str_replace('#', '.', $template) : $template . '.htm';
    $style->set_filenames(array('body' => $filename));
    // SQL History
    if ($core->v('show_sql_history')) {
        foreach (sql_history() as $i => $row) {
            if (!$i) {
                _style('sql_history');
            }
            _style('sql_history.row', array('QUERY' => str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;'), $row)));
        }
    }
    //_pre($bio, true);
    //
    $v_assign = array('USER_ID' => $bio->v('bio_id'), 'USER_NAME' => $bio->v('bio_name'), 'SITE_TITLE' => $core->v('site_title'), 'PAGE_TITLE' => $page_title, 'G_ANALYTICS' => $core->v('google_analytics'), 'S_REDIRECT' => $bio->v('session_page'), 'F_SQL' => sql_queries());
    if ($v_custom !== false) {
        $v_assign += $v_custom;
    }
    $mtime = explode(' ', microtime());
    $v_assign['F_TIME'] = sprintf('%.2f', $mtime[0] + $mtime[1] - $starttime);
    v_style($v_assign);
    $style->pparse('body');
    sql_close();
    exit;
}
Example #27
0
	public function dl_view() {
		global $user, $config, $comments;

		if (!$this->auth['adm'] && !$this->auth['mod']) {
			$sql = 'UPDATE _dl SET views = views + 1
				WHERE id = ?';
			sql_query(sql_filter($sql, $this->dl_data['id']));
		}

		$stats_text = '';
		foreach (array('views' => 'VIEW', 'downloads' => 'DL') as $item => $stats_lang) {
			$stats_text .= (($stats_text != '') ? ', ' : '') . '<strong>' . $this->dl_data[$item] . '</strong> ' . lang($stats_lang) . (($this->dl_data[$item] > 1) ? 's' : '');
		}

		v_style(array(
			'S_DOWNLOAD_ACTION' => s_link('a', $this->data['subdomain'], 'downloads', $this->dl_data['id'], 'save'),

			'DL_ID' => $this->dl_data['id'],
			'DL_A' => $this->data['ub'],
			'DL_TITLE' => $this->dl_data['title'],
			'DL_FORMAT' => $this->dl_data['av'],
			'DL_DURATION' => $this->dl_data['duration'],
			'DL_ALBUM' => $this->dl_data['album'],
			'DL_YEAR' => $this->dl_data['year'],
			'DL_POSTS' => $this->dl_data['posts'],
			'DL_VOTES' => $this->dl_data['votes'],
			'DL_FILESIZE' => $this->format_filesize($this->dl_data['filesize']),
			'DL_STATS' => $stats_text)
		);

		//
		// FAV
		//
		$is_fav = false;
		$sql = 'SELECT dl_id
			FROM _dl_fav
			WHERE dl_id = ?
				AND user_id = ?';
		if (sql_field(sql_filter($sql, $this->dl_data['id'], $user->d('user_id')), 'dl_id', 0)) {
			$is_fav = true;
		}

		if (!$is_fav) {
			_style('dl_fav', array(
				'URL' => s_link('a', $this->data['subdomain'], 'downloads', $this->dl_data['id'], 'fav'))
			);
		}

		//
		// UD POLL
		//
		$user_voted = false;
		if ($this->dl_data['votes'] && $this->auth['user'] && !$this->auth['adm'] && !$this->auth['mod']) {
			$sql = 'SELECT user_id
				FROM _dl_voters
				WHERE ud = ?
					AND user_id = ?';
			if (sql_field(sql_filter($sql, $this->dl_data['id'], $user->d('user_id')), 'user_id', 0)) {
				$user_voted = true;
			}
		}

		_style('ud_poll');

		if ($this->auth['adm'] || $this->auth['mod'] || !$this->auth['user'] || $user_voted) {
			$sql = 'SELECT option_id, vote_result
				FROM _dl_vote
				WHERE ud = ?
				ORDER BY option_id';
			$results = sql_rowset(sql_filter($sql, $this->dl_data['id']), 'option_id', 'vote_result');

			_style('ud_poll.results');

			for ($i = 0, $end = sizeof($this->voting['ud']); $i < $end; $i++) {
				$vote_result = (isset($this->voting['ub'][$i]) && isset($results[$this->voting['ub'][$i]])) ? (int) $results[$this->voting['ub'][$i]] : 0;
				$vote_percent = ($this->dl_data['votes'] > 0) ? $vote_result / $this->dl_data['votes'] : 0;

				_style('ud_poll.results.item', array(
					'CAPTION' => lang('ub_udv' . $this->voting['ud'][$i]),
					'RESULT' => $vote_result,
					'PERCENT' => sprintf("%.1d", ($vote_percent * 100)))
				);
			}
		} else {
			_style('ud_poll.options', array(
				'S_VOTE_ACTION' => s_link('a', $this->data['subdomain'], 'downloads', $this->dl_data['id'], 'vote'))
			);

			for ($i = 0, $end = sizeof($this->voting['ud']); $i < $end; $i++) {
				_style('ud_poll.options.item', array(
					'ID' => $this->voting['ud'][$i],
					'CAPTION' => lang('ub_udv' . $this->voting['ud'][$i]))
				);
			}
		}

		//
		// UD MESSAGES
		//
		$comments_ref = s_link('a', $this->data['subdomain'], 'downloads', $this->dl_data['id']);

		if ($this->dl_data['posts']) {
			$start = request_var('dps', 0);
			$comments->ref = $comments_ref;
			$comments->auth = $this->auth;

			$sql = 'SELECT p.*, u.user_id, u.username, u.username_base, u.user_avatar
				FROM _dl d, _dl_posts p, _artists a, _members u
				WHERE d.id = ?
					AND d.ub = ?
					AND d.id = p.download_id
					AND d.ub = a.ub
					AND p.post_active = 1
					AND p.poster_id = u.user_id
				ORDER BY p.post_time DESC
				LIMIT ??, ??';

			$comments->data = array(
				'SQL' => sql_filter($sql, $this->dl_data['id'], $this->data['ub'], $start, $config['s_posts'])
			);

			if ($this->auth['user']) {
				$comments->data['CONTROL']['reply'] = array(
					'REPLY' => array(
						'URL' => s_link('a', $this->data['subdomain'], 'comments', '%d', 'reply'),
						'ID' => 'post_id'
					)
				);
			}

			if ($this->auth['user'] && !$this->auth['adm'] && !$this->auth['mod']) {
				$comments->data['CONTROL']['report'] = array(
					'REPORT' => array(
						'URL' => s_link('a', $this->data['subdomain'], 'comments', '%d', 'report'),
						'ID' => 'post_id'
					)
				);
			}

			if ($this->auth['adm'] || $this->auth['mod']) {
				$comments->data['CONTROL']['auth'] = w();

				if ($this->auth['adm'] && $user->is('founder')) {
					$comments->data['CONTROL']['auth']['EDIT'] = array(
						'URL' => s_link('acp', array('artist_message', 'a' => $this->data['subdomain'], 'id' => '%d', 'action' => 'modify')),
						'ID' => 'post_id'
					);
				}

				$comments->data['CONTROL']['auth']['DELETE'] = array(
					'URL' => s_link('acp', array('artist_message', 'a' => $this->data['subdomain'], 'id' => '%d', 'action' => 'remove')),
					'ID' => 'post_id'
				);
			}

			//
			$comments->view($start, 'dps', $this->dl_data['posts'], $config['s_posts'], 'ud_posts', 'DMSG_', 'TOPIC_', false);
		}

		if ($this->auth['post']) {
			if ($this->auth['user']) {
				_style('dl_post_box', array(
					'REF' => $comments_ref,
					'NL' => (int) !$this->auth['user'])
				);
			} else {
				_style('dl_no_guest_posting', array(
					'LEGEND' => sprintf(lang('ub_no_guest_posting'), $this->data['name'], s_link('my register')))
				);
			}
		} else {
			_style('dl_no_post_auth');

			if ($this->auth['post_until']) {
				_style('dl_no_post_auth.until', array(
					'UNTIL_DATETIME' => $user->format_date($this->auth['post_until']))
				);
			}
		}

		return;
	}
Example #28
0
    protected function _search_field()
    {
        global $user;
        $v = $this->__(array('field' => 0));
        $sql = 'SELECT *
			FROM _search_relation
			WHERE relation_id = ?';
        if (!($field = _fieldrow(sql_filter($sql, $v['field'])))) {
            $this->_error('', false);
        }
        $special_select = array('_computer_fields cf', '_members_store ms');
        $e_tables = explode(',', trim($field['relation_tables']));
        foreach ($e_tables as $e_row) {
            if (in_array(trim($e_row), $special_select)) {
                if (preg_match('#.*?field_alias \\= \'(.*?)\'.*?#is', $field['relation_fields'], $e_cf)) {
                    $ee_row = explode('_', $e_row);
                    $sql = "SELECT *\n\t\t\t\t\t\tFROM _??_fields\n\t\t\t\t\t\tWHERE field_alias = ?";
                    if ($row_cf = _fieldrow(sql_filter($sql, $ee_row[1], $e_cf[1]))) {
                        if ($field['relation_input'] != 'calendar') {
                            $field['relation_input'] = $row_cf['field_type'];
                        }
                        $field['relation_select'] = $row_cf['field_relation'];
                    }
                }
            }
        }
        switch ($field['relation_input']) {
            case 'input':
            case 'checkbox':
            case 'textarea':
                break;
            case 'yesno':
                $yn = array(1 => _lang('YES'), 0 => _lang('NO'));
                $field['relation_input'] = 'select';
                $i = 0;
                foreach ($yn as $j => $row) {
                    if (!$i) {
                        _style('select');
                    }
                    _style('select.row', array('V_VALUE' => $j, 'V_NAME' => $row));
                    $i++;
                }
                break;
            case 'select':
                if (!f($field['relation_select'])) {
                    _fatal();
                }
                $e_select = explode('.', $field['relation_select']);
                $sql = 'SELECT ??, ??
					FROM _??
					ORDER BY ??';
                $table_relation = _rowset(sql_filter($sql, $e_select[1], $e_select[2], $e_select[0], $e_select[2]));
                foreach ($table_relation as $i => $row) {
                    if (!$i) {
                        _style('select');
                    }
                    _style('select.row', array('V_VALUE' => $row[$e_select[1]], 'V_NAME' => $row[$e_select[2]]));
                }
                break;
        }
        v_style(array('IN' => $field['relation_input']));
        return $this->_template('computer.search.select');
    }
Example #29
-1
function page_layout($page_title, $htmlpage, $custom_vars = false, $js_keepalive = true) {
	global $config, $user, $cache, $starttime, $template;

	//
	// gzip_compression
	//
	if (strstr($user->browser,'compatible') || strstr($user->browser,'Gecko')) {
		ob_start('ob_gzhandler');
	}

	monetize();

	// Get today items count
	$sql = 'SELECT COUNT(element) AS total
		FROM _members_unread
		WHERE user_id = ?';
	$today_count = sql_field(sql_filter($sql, $user->d('user_id')), 'total', 0);

	//
	// Send headers
	//
	header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
	header('Expires: 0');
	header('Pragma: no-cache');

	//
	// Footer
	//
	$u_session = ($user->is('member')) ? 'out' : 'in';

	if (preg_match('#.*?my/confirm.*?#is', $user->d('session_page'))) {
		$user->d('session_page', '');
	}

	$common_vars = array(
		'PAGE_TITLE'    => lang($page_title, $page_title),
		'_SELF'         => _page(),

		'U_REGISTER'    => s_link('signup'),
		'U_SESSION'     => s_link('sign' . $u_session),
		'U_PROFILE'     => s_link('m', $user->d('username_base')),
		'U_EDITPROFILE' => s_link('my profile'),
		'U_PASSWORD'    => s_link('signr'),
		'U_DC'          => s_link('my dc'),

		'U_HOME'        => s_link(),
		'U_FAQ'         => s_link('faq'),
		'U_WHATS_NEW'   => s_link('today'),
		'U_ARTISTS'	    => s_link('a'),
		'U_AWARDS'      => s_link('awards'),
		'U_RADIO'       => s_link('radio'),
		'U_BROADCAST'   => s_link('broadcast'),
		'U_NEWS'        => s_link('news'),
		'U_EVENTS'      => s_link('events'),
		'U_FORUM'       => s_link('board'),
		'U_COMMUNITY'   => s_link('community'),
		'U_ALLIES'      => s_link('allies'),
		'U_TOS'         => s_link('tos'),
		'U_HELP'        => s_link('help'),
		'U_RSS_NEWS'    => s_link('rss', 'news'),
		'U_RSS_ARTISTS' => s_link('rss', 'artists'),
		'U_COMMENTS'    => s_link('comments'),
		'U_EMOTICONS'   => s_link('emoticons'),
		'U_ACP'         => (isset($template->vars['U_ACP'])) ? $template->vars['U_ACP'] : ($user->is('artist') || $user->is('mod') ? s_link('acp') : ''),

		'S_YEAR'        => date('Y'),
		'S_UPLOAD'      => upload_maxsize(),
		'S_GIT'         => $config['git_push_time'],
		'S_KEYWORDS'    => $config['meta_keys'],
		'S_DESCRIPTION' => $config['meta_desc'],
		'S_SERVER'      => '//' . $config['server_name'],
		'S_ASSETS'      => $config['assets_url'],
		'S_DIST'        => '/dist/',
		'S_SQL'         => ($user->d('is_founder')) ? sql_queries() . 'q | ' : '',
		'S_REDIRECT'    => $user->d('session_page'),
		'S_USERNAME'    => $user->d('username'),
		'S_MEMBER'      => $user->is('member'),
		'S_TODAY_COUNT' => (($today_count == 1) ? sprintf(lang('unread_item_count'), $today_count) : sprintf(lang('unread_items_count'), $today_count))
	);

	if ($custom_vars !== false) {
		$common_vars += $custom_vars;
	}

	$mtime = explode(' ', microtime());
	$common_vars['S_TIME'] = sprintf('%.2f', ($mtime[0] + $mtime[1] - $starttime));

	v_style($common_vars);

	$template->set_filenames(array(
		'body' => $htmlpage . '.htm')
	);
	$template->pparse('body');

	sql_close();
	exit;
}
Example #30
-2
	public function run() {
		global $config, $auth, $user, $comments, $cache;

		$forum_id = request_var('f', '');
		$start = request_var('offset', 0);
		$submit_topic = _button('post');

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

		$is_int_forumid = false;
		if (preg_match('#^(\d+)$#is', $forum_id)) {
			$is_int_forumid = true;
			$forum_id = intval($forum_id);

			$sql = 'SELECT *
				FROM _forums
				WHERE forum_id = ?';
			$sql = sql_filter($sql, $forum_id);
		} else {
			$sql = 'SELECT *
				FROM _forums
				WHERE forum_alias = ?';
			$sql = sql_filter($sql, $forum_id);
		}

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

		if ($is_int_forumid) {
			redirect(s_link('forum', $forum_row['forum_alias']), true);
		}

		$forum_id = $forum_row['forum_id'];

		//
		// Start auth check
		//
		$is_auth = w();
		$is_auth = $auth->forum(AUTH_ALL, $forum_id, $forum_row);

		if (!$is_auth['auth_view'] || !$is_auth['auth_read']) {
			if (!$user->is('member')) {
				do_login();
			}

			fatal_error();
		}

		$error_msg = '';
		$post_title = '';
		$post_message = '';
		$post_np = '';
		$poll_title = '';
		$poll_options = '';
		$poll_length = '';
		$current_time = time();

		if ($submit_topic) {
			$topic_important = _button('topictype');
			$auth_key = ($topic_important) ? 'auth_announce' : 'auth_post';

			if ($forum_row['forum_locked'] && !$is_auth['auth_mod']) {
				$error_msg .= (($error_msg != '') ? '<br />' : '') . lang('forum_locked');
			}

			if (!$is_auth[$auth_key]) {
				if (!$user->is('member')) {
					do_login();
				}

				if (empty($error_msg)) {
					redirect($topic_url);
				}
			}

			if (empty($error_msg)) {
				$post_title = request_var('topic_title', '');
				$post_message = request_var('message', '', true);
				$post_np = request_var('np', '', true);
				$poll_title = '';
				$poll_options = '';
				$poll_length = 0;

				if ($is_auth['auth_pollcreate']) {
					$poll_title = request_var('poll_title', '');
					$poll_options = request_var('poll_options', '');
					$poll_length = request_var('poll_length', 0);
				}

				// Check subject
				if (empty($post_title)) {
					$error_msg .= (($error_msg != '') ? '<br />' : '') . lang('empty_subject');
				}

				// Check message
				if (empty($post_message)) {
					$error_msg .= (($error_msg != '') ? '<br />' : '') . lang('empty_message');
				}

				if (!empty($poll_options)) {
					$real_poll_options = w();
					$poll_options = explode(nr(), $poll_options);

					foreach ($poll_options as $option) {
						if ($option != '') {
							$real_poll_options[] = $option;
						}
					}

					$sizeof_poll_options = sizeof($real_poll_options);

					if ($sizeof_poll_options < 2) {
						$error_msg .= (($error_msg != '') ? '<br />' : '') . lang('few_poll_options');
					} else if ($sizeof_poll_options > $config['max_poll_options']) {
						$error_msg .= (($error_msg != '') ? '<br />' : '') . lang('many_poll_options');
					} else if ($poll_title == '') {
						$error_msg .= (($error_msg != '') ? '<br />' : '') . lang('empty_poll_title');
					}
				}

				if (empty($error_msg) && !$is_auth['auth_mod']) {
					$sql = 'SELECT MAX(post_time) AS last_post_time
						FROM _forum_posts
						WHERE poster_id = ?';
					if ($last_post_time = sql_field(sql_filter($sql, $user->d('user_id')))) {
						if (intval($last_post_time) > 0 && ($current_time - intval($last_post_time)) < intval($config['flood_interval'])) {
							$error_msg .= (($error_msg != '') ? '<br />' : '') . lang('flood_error');
						}
					}
				}

				if (empty($error_msg)) {
					$topic_announce = 0;
					$topic_locked = 0;

					if ((strstr($post_message, '-Anuncio-') && $user->is('all')) || in_array($forum_id, array(15, 16, 17))) {
						$topic_announce = 1;
						$post_message = str_replace('-Anuncio-', '', $post_message);
					}

					if (strstr($post_message, '-Cerrado-') && $user->is('mod')) {
						$topic_locked = 1;
						$post_message = str_replace('-Cerrado-', '', $post_message);
					}

					$post_message = $comments->prepare($post_message);
					$topic_vote = (!empty($poll_title) && $sizeof_poll_options >= 2) ? 1 : 0;

					if (!$user->is('founder')) {
						$post_title = strnoupper($post_title);
					}

					$insert_data['TOPIC'] = array(
						'topic_title' => $post_title,
						'topic_poster' => (int) $user->d('user_id'),
						'topic_time' => (int) $current_time,
						'forum_id' => (int) $forum_id,
						'topic_locked' => $topic_locked,
						'topic_announce' => $topic_announce,
						'topic_important' => (int) $topic_important,
						'topic_vote' => (int) $topic_vote,
						'topic_featured' => 1,
						'topic_points' => 1
					);
					$topic_id = sql_insert('forum_topics', $insert_data['TOPIC']);

					$insert_data['POST'] = array(
						'topic_id' => (int) $topic_id,
						'forum_id' => (int) $forum_id,
						'poster_id' => (int) $user->d('user_id'),
						'post_time' => (int) $current_time,
						'poster_ip' => $user->ip,
						'post_text' => $post_message,
						'post_np' => $post_np
					);
					$post_id = sql_insert('forum_posts', $insert_data['POST']);

					if ($topic_vote) {
						$insert_data['POLL'] = array(
							'topic_id' => (int) $topic_id,
							'vote_text' => $poll_title,
							'vote_start' => (int) $current_time,
							'vote_length' => (int) ($poll_length * 86400)
						);
						$poll_id = sql_insert('poll_options', $insert_data['POLL']);

						$poll_option_id = 1;
						foreach ($real_poll_options as $option) {
							$insert_data['POLLRESULTS'] = array(
								'vote_id' => (int) $poll_id,
								'vote_option_id' => (int) $poll_option_id,
								'vote_option_text' => $option,
								'vote_result' => 0
							);
							sql_insert('poll_results', $insert_data['POLLRESULTS']);

							$poll_option_id++;
						}

						if ($forum_id == $config['main_poll_f']) {
							$cache->delete('last_poll_id');
						}
					}

					$user->save_unread(UH_T, $topic_id);

					if (!in_array($forum_id, forum_for_team_array())) {
						//$user->points_add(2);
					}

					$a_list = forum_for_team_list($forum_id);
					if (count($a_list)) {
						$sql_delete_unread = 'DELETE FROM _members_unread
							WHERE element = ?
								AND item = ?
								AND user_id NOT IN (??)';
						sql_query(sql_filter($sql_delete_unread, 8, $topic_id, implode(', ', $a_list)));
					}

					if (count($a_list) || in_array($forum_id, array(20, 39))) {
						topic_feature($topic_id, 0);
						topic_arkane($topic_id, 0);
					}

					$sql = 'UPDATE _forums SET forum_posts = forum_posts + 1, forum_last_topic_id = ?, forum_topics = forum_topics + 1
						WHERE forum_id = ?';
					sql_query(sql_filter($sql, $topic_id, $forum_id));

					$sql = 'UPDATE _forum_topics SET topic_first_post_id = ?, topic_last_post_id = ?
						WHERE topic_id = ?';
					sql_query(sql_filter($sql, $post_id, $post_id, $topic_id));

					$sql = 'UPDATE _members SET user_posts = user_posts + 1
						WHERE user_id = ?';
					sql_query(sql_filter($sql, $user->d('user_id')));

					redirect(s_link('topic', $topic_id));
				}
			}
		}
		//
		// End Submit
		//

		$topics_count = ($forum_row['forum_topics']) ? $forum_row['forum_topics'] : 1;

		$topics = new stdClass();
		$total = new stdClass();

		//
		// All announcement data
		//
		$sql = 'SELECT t.*, u.user_id, u.username, u.username_base, u2.user_id as user_id2, u2.username as username2, u2.username_base as username_base2, p.post_time, p.post_username as post_username2
			FROM _forum_topics t, _members u, _forum_posts p, _members u2
			WHERE t.forum_id = ?
				AND t.topic_poster = u.user_id
				AND p.post_id = t.topic_last_post_id
				AND p.poster_id = u2.user_id
				AND t.topic_announce = 1
			ORDER BY t.topic_last_post_id DESC';
		$topics->important = sql_rowset(sql_filter($sql, $forum_id));
		$total->important = (is_array($topics->important)) ? count($topics->important) : 0;

		//
		// Grab all the topics data for this forum
		//
		$sql = 'SELECT t.*, u.user_id, u.username, u.username_base, u2.user_id as user_id2, u2.username as username2, u2.username_base as username_base2, p.post_username, p2.post_username AS post_username2, p2.post_time
			FROM _forum_topics t, _members u, _forum_posts p, _forum_posts p2, _members u2
			WHERE t.forum_id = ?
				AND t.topic_poster = u.user_id
				AND p.post_id = t.topic_first_post_id
				AND p2.post_id = t.topic_last_post_id
				AND u2.user_id = p2.poster_id
				AND t.topic_announce = 0
			ORDER BY t.topic_important DESC, /*t.topic_last_post_id*/p2.post_time DESC
			LIMIT ??, ??';
		$topics->normal = sql_rowset(sql_filter($sql, $forum_id, $start, $config['topics_per_page']));
		$total->normal = (is_array($topics->normal)) ? count($topics->normal) : 0;

		//
		// Total topics ...
		//
		//$total_topics += $total_announcements;
		//$total_topics = $total->important + $total->normal;

		//
		// Post URL generation for templating vars
		//
		if ($is_auth['auth_post'] || $is_auth['auth_mod']) {
			_style('topic_create', array(
				'L_POST_NEW_TOPIC' => ($forum_row['forum_locked']) ? lang('forum_locked') : lang('post_newtopic'))
			);
		}

		//
		// Dump out the page header and load viewforum template
		//
		v_style(array(
			'FORUM_ID' => $forum_id,
			'FORUM_NAME' => $forum_row['forum_name'],
			'U_VIEW_FORUM' => s_link('forum', $forum_row['forum_alias']))
		);
		//
		// End header
		//

		//
		// Let's build the topics
		//
		$i = 0;
		foreach ($topics as $alias => $list) {
			foreach ($list as $j => $row) {
				if (!$i) {
					_style('topics');

					$topics_count -= $total->important;

					build_num_pagination(s_link('forum', $forum_row['forum_alias'], 's%d'), $topics_count, $config['topics_per_page'], $start, '', 'TOPICS_');
				}

				if (!$j) {
					_style('topics.alias', array(
						'NAME' => lang('topic_' . $alias),
						'SHOW' => ($total->important && $total->normal > 1))
					);
				}

				$row = (object) $row;

				if ($row->user_id != GUEST) {
					$row->author = '<a  href="' . s_link('m', $row->username_base2) . '">' . $row->username2 . '</a>';
				} else {
					$row->author = '<span>*' . (($row->post_username2 != '') ? $row->post_username2 : lang('guest')) . '</span>';
				}

				if ($row->user_id2 != GUEST) {
					$row->poster = '<a href="' . s_link('m', $row->username_base2) . '">' . $row->username2 . '</a>';
				} else {
					$row->poster = '<span>*' . (($row->post_username2 != '') ? $row->post_username2 : lang('guest')) . '</span>';
				}

				_style('topics.alias.row', array(
					'FORUM_ID' => $forum_id,
					'TOPIC_ID' => $row->topic_id,
					'TOPIC_AUTHOR' => $row->author,
					'REPLIES' => $row->topic_replies,
					'VIEWS' => ($user->is('founder')) ? $row->topic_views : '',

					'TOPIC_TITLE' => $row->topic_title,
					'TOPIC_CREATION_TIME' => $user->format_date($row->topic_time),
					'LAST_POST_TIME' => $user->format_date($row->post_time),
					'LAST_POST_AUTHOR' => $row->poster,
					'U_TOPIC' => s_link('topic', $row->topic_id))
				);

				$i++;
			}
		}

		if (!$topics_count) {
			if ($start) {
				redirect(s_link('forum', $forum_row['forum_alias']), true);
			}
			_style('no_topics');
		}

		//
		// Posting box
		//
		if (!empty($error_msg) || (!$is_auth['auth_mod'] && $forum_row['forum_locked']) || (!$is_auth['auth_post'] && $forum_row['auth_post'] == AUTH_REG) || $is_auth['auth_post']) {
			if ($is_auth['auth_post']) {
				if (!empty($poll_options)) {
					$poll_options = implode(nr(), $poll_options);
				}

				_style('publish', array(
					'S_POST_ACTION' => s_link('forum', $forum_row['forum_alias']),

					'TOPIC_TITLE' => $post_title,
					'MESSAGE' => $post_message,
					'NP' => $post_np,

					'POLL_TITLE' => $poll_title,
					'POLL_OPTIONS' => $poll_options,
					'POLL_LENGTH' => $poll_length)
				);

				if ($is_auth['auth_pollcreate']) {
					_style('publish.poll');

					if (empty($poll_options)) {
						_style('publish.poll.hide');
					}
				}
			}

			if (!empty($error_msg)) {
				_style('publish.alert', array(
					'MESSAGE' => $error_msg)
				);
			}
		}

		$layout_file = 'topics';

		$use_m_template = 'custom/forum_' . $forum_id;
		if (@file_exists(ROOT . 'template/' . $use_m_template . '.htm')) {
			$layout_file = $use_m_template;
		}

		$this->_title = $forum_row['forum_name'];
		$this->_template = $layout_file;

		return;
	}