예제 #1
0
파일: _bio.php 프로젝트: nopticon/mag
    public function _gallery_create()
    {
        global $bio, $core;
        if (_button()) {
            $upload = _import('upload');
            // Start
            $sql = 'SELECT MAX(image_id) AS total
				FROM _bio_images
				WHERE image_bio = ?';
            $image = sql_field(sql_filter($sql, $this->a('bio_id')), 'total', 0) + 1;
            $upload->chmod(array(_lib(LIB_BIO . ' ' . $this->a('bio_id'))), 0777);
            $f = $upload->process(LIB . 'tmp/', request_var('files:picture'), w('jpg'), $core->v('max_upload'));
            if ($f === false && count($upload->error)) {
                $warning->set($upload->error);
            }
            if (!$warning->exist) {
                $total = 0;
                foreach ($f as $row) {
                    //$row = $upload->_row($gallery, $image);
                    $f2 = $upload->resize($row, LIB . 'tmp', LIB . 'events/future/', $v['e_id'], array(600, 400), false, false, true);
                    if ($f2 === false) {
                        continue;
                    }
                    $f3 = $upload->resize($row, LIB . 'events/future/', LIB . 'events/preview/', $v['e_id'], array(210, 210), false, false);
                    $total++;
                    //
                    $sql_insert = array('bio' => $bio->v('bio_id'), 'image' => $image, 'width' => $i_data['width'], 'height' => $i_data['height'], 'views' => 0, 'downloads' => 0, 'allow_dl' => (int) $allow_dl);
                    sql_put('_bio_images', prefix('image', $sql_insert));
                    $image++;
                }
                $sql = 'UPDATE _bio_store SET store_value = store_value + ??
					WHERE store_bio = ?';
                _sql(sql_filter($sql, $total, $bio->v('bio_id')));
            }
            if (!$error) {
                redirect(_link_control('a', array('a' => $bio->v('bio_alias'), 'x1' => $this->x(1))));
            }
        }
        return v_style(array('U_CREATE' => _link_bio($bio->v('bio_alias'), array('x1' => $this->x(1), 'x2' => $this->x(2))), 'MAX_FILESIZE' => $core - v('max_upload')));
    }
예제 #2
0
파일: _board.php 프로젝트: nopticon/mag
    protected function _publish_home()
    {
        global $bio;
        $v = $this->__(w('address key subject content playing f 0 p 0'));
        // TODO: Implement bio authorization
        $this->_bio_publish($v->address, $v->key);
        //
        if (!$v->forum && !$v->post) {
            $warning->now();
        }
        if ($v->forum) {
            if (empty($v->subject)) {
                $this->_error('NO_TOPIC_SUBJECT');
            }
            $sql = 'SELECT *
				FROM _board_forums
				WHERE forum_id = ?';
            if (!($forum = sql_fieldrow(sql_filter($sql, $v->forum)))) {
                $warning->now();
            }
            $v->subject = _subject($v->subject);
        } else {
            $sql = 'SELECT *
				FROM _board_posts
				WHERE post_id = ?';
            if (!($post = sql_fieldrow(sql_filter($sql, $v->post)))) {
                $warning->now();
            }
            $sql = 'SELECT *
				FROM _board_topics
				WHERE topic_id = ?';
            if (!($topic = sql_fieldrow(sql_filter($sql, $post->post_topic)))) {
                $warning->now();
            }
        }
        if ($v->forum) {
            if ($forum->forum_locked && !$this->auth_forum($forum, 'create')) {
                $warning->now();
            }
        }
        if (empty($v->content)) {
            $this->_error('NO_TOPIC_CONTENT');
        }
        $v->content = _prepare($v->content);
        // Start insert transaction
        sql_transaction();
        $sql_commit = false;
        if ($v->forum) {
            // Insert topic
            $sql_insert = array('forum' => $v->forum, 'subject' => $v->subject, 'author' => $bio->v('bio_id'), 'time' => time(), 'active' => $bio->v('bio_confirmed'));
            $v->topic_next = sql_put('_board_topics', prefix('topic', $sql_insert));
            // Insert post
            $sql_insert = array('forum' => $v->forum, 'topic' => $v->topic_next, 'parent' => 0, 'bio' => $bio->v('bio_id'), 'time' => time(), 'active' => $bio->v('bio_confirmed'), 'message' => $v->content, 'playing' => $v->playing);
            $v->post_next = sql_put('_board_posts', prefix('post', $sql_insert));
            if ($v->topic_next && $v->post_next) {
                $sql_commit = true;
            }
        } else {
            $sql_insert = array('forum' => $topic->topic_forum, 'topic' => $topic->topic_id, 'parent' => $v->post, 'bio' => $bio->v('bio_id'), 'time' => time(), 'active' => $bio->v('bio_confirmed'), 'message' => $v->content, 'playing' => $v->playing);
            $v->post_next = sql_put('_board_posts', prefix('post', $sql_insert));
            $sql_update = w();
            $sql = 'UPDATE _board_topics SET topic_replies = topic_replies + 1' . sql_build('UPDATE', $sql_update) . sql_filter('
				WHERE topic_id = ?', $topic->topic_id);
            $updated = sql_affected($sql);
            if ($v->post_next && $updated) {
                $sql_commit = true;
            }
        }
        if (!$sql_commit) {
            sql_transaction('rollback');
            $this->_error('ROLLBACK_MESSAGE');
        }
        sql_transaction('commit');
        if (is_ghost() && $v->post) {
            if ($bio->v('bio_confirmed')) {
                $response = array('show' => 1, 'parent' => $v->post, 'post' => $v->post_next, 'content' => _message($v->content), 'time' => _format_date(), 'profile' => array('link' => _link_bio($bio->v('bio_alias')), 'name' => $bio->v('bio_name')));
            } else {
                $response = array('show' => 0, 'legend' => _lang('PUBLISH_TOPIC_GUEST'));
            }
            $this->output(json_encode($response));
        }
        return redirect(_link('board', array('topic', $v->topic)));
    }
예제 #3
0
파일: _events.php 프로젝트: nopticon/mag
    protected function _view_home()
    {
        global $core, $bio;
        $v = $this->__(array('alias', 't' => 0, 'p' => 0));
        if (!f($v['alias'])) {
            _fatal();
        }
        $v['field'] = !is_numb($v['alias']) ? 'alias' : 'id';
        $sql = 'SELECT *
			FROM _events
			WHERE event_?? = ?';
        if (!($event = _fieldrow(sql_filter($sql, $v['field'], $v['alias'])))) {
            _fatal();
        }
        if ($v['field'] == 'id' && f($event['event_alias'])) {
            redirect(_link($this->m(), $event['event_alias']) . _linkp(array('t' => $v['t'], 'p' => $v['p']), true));
        }
        // Get images
        $sql = 'SELECT *
			FROM _events_images
			WHERE image_event = ?
			ORDER BY image ASC
			LIMIT ??, ??';
        $event_images = _rowset(sql_filter($sql, $event['event_id'], $v['t'], $core->v('thumbs_per_page')));
        foreach ($event_images as $i => $row) {
            if (!$i) {
                _style('thumbnails', _pagination(_link($this->m(), $event['event_alias']), 't:%d', $event['event_images'], $core->v('thumbs_per_page'), $v['t']));
            }
            _style('thumbnails.row', array('U_THUMBNAIL' => _lib(w(LIB_EVENT . ' thumbnail ' . $event['event_id'], $row['image'], 'jpg')), 'U_IMAGE' => _lib(w(LIB_EVENT . ' gallery ' . $event['event_id'], $row['image'], 'jpg')), 'V_FOOTER' => $row['image_footer']));
        }
        if (is_ghost()) {
            return;
        }
        // Statistics
        if (!$v['t'] && !$bio->v('auth_founder')) {
            $this->_stats_store();
        }
        $is_future = $row['event_end'] > time() ? true : false;
        if (!$is_future) {
            // Star for favourites
            if (!($star_type = $core->cache_load('star_type'))) {
                $sql = 'SELECT type_id, type_name
					FROM _events_star_type
					ORDER BY type_order';
                $types = $core->cache_store('star_type', _rowset($sql, 'type_id', 'type_name'));
            }
            $i = 0;
            foreach ($types as $type_id => $type_name) {
                if (!$i) {
                    _style('star_type');
                }
                _style('star_type.row', array('TYPE_ID' => $type_id, 'TYPE_NAME' => $type_name));
                $i++;
            }
        } else {
            $sql = 'SELECT *
				FROM _events_reviews r, _bio b
				WHERE r.review_event = ?
					AND r.review_uid = b.bio_id
				ORDER BY r.review_avg
				LIMIT 0, 5';
            $reviews = _rowset(sql_filter($sql, $event['event_id']), 'review_id');
            $sql = 'SELECT *
				FROM _events_reviews_rate r, _events_reviews_fields f
				WHERE r.rate_review IN (??)
					AND r.rate_field = f.field_id
				ORDER BY f.field_order';
            $reviews_rate = _rowset(sql_filter($sql, _implode(',', array_keys($reviews))), 'rate_review', false, true);
            $i = 0;
            foreach ($reviews as $row) {
                if (!$i) {
                    _style('reviews');
                }
                _style('reviews.row', array('REVIEW_CONTENT' => $row['review_content'], 'REVIEW_' => $row['review_']));
                if (isset($reviews_rate[$row['review_id']])) {
                    foreach ($reviews_rate[$row['review_id']] as $j => $rate) {
                        if (!$j) {
                            _style('reviews.row.rate');
                        }
                        _style('reviews.row.rate.field', array('FIELD' => $rate['field_name'], 'RATE' => $rate['rate_value']));
                    }
                }
                $i++;
            }
        }
        // Who attend
        $sql = 'SELECT at.type_id, at.type_name_next, at.type_name_prev, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up
			FROM _events_attend a, _events_attend_type at, _bio b
			WHERE a.attend_event = ?
				AND a.attend_type = at.type_id
				AND a.attend_uid = b.bio_id
			ORDER BY a.attend_time';
        $attend = _rowset(sql_filter($sql, $event['event_id']), 'type_id', false, true);
        $i = 0;
        foreach ($attend as $type_name => $rows) {
            if (!$i) {
                _style('attend');
            }
            $type_name = $is_future ? 'next' : 'prev';
            _style('attend.type', array('TYPE_NAME' => $rows[0]['type_name_' . $type_name]));
            foreach ($rows as $row) {
                _style('attend.type.row', array('BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row)));
            }
            $i++;
        }
        // Messages
        $ref = _link('events', $event['event_alias']);
        if ($event['event_publish']) {
            if ($event['event_comments']) {
                $sql = 'SELECT c.comment_id, c.comment_time, c.comment_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up
					FROM _events_comments c, _bio b
					WHERE c.comment_event = ?
						AND c.comment_active = ?
						AND c.comment_bio = b.bio_id
					ORDER BY c.comment_time DESC
					LIMIT ??, ??';
                $comments = _rowset(sql_filter($sql, $event['event_id'], 1, $v['p'], $core->v('events_comments')));
                foreach ($comments as $i => $row) {
                    if (!$i) {
                        _style('comment_area', _pagination(_link($this->m(), array($event['event_alias'], $v['t'], 's%d')), $topic_data['topic_replies'] + 1, $core->v('posts_per_page'), $start));
                    }
                    _style('comment_area.row', array('BIO_ALIAS' => _link_bio($row['bio_alias']), 'BIO_NAME' => $row['bio_name'], 'BIO_AVATAR' => _avatar($row), 'COMMENT_ID' => $row['comment_id'], 'COMMENT_TIME' => _format_date($row['comment_time']), 'COMMENT_TEXT' => _message($row['comment_text'])));
                }
            }
            _style('comment_publish', array('U_PUBLISH' => _link()));
        }
        //
        if ($event['event_posts']) {
            $reply = array('ref' => $ref, 'start' => $v['p'], 'start_f' => 's', 'rows' => $event['event_posts'], 'rows_page' => $core->v('s_posts'), 'block' => 'posts', 'sql' => 'SELECT p.post_id, p.post_time, p.post_text, b.bio_id, b.bio_alias, b.bio_name, b.bio_avatar, b.bio_avatar_up, b.bio_sig
					FROM _events_posts p, _bio b
					WHERE p.post_event = ?
						AND p.post_active = 1 
						AND p.post_uid = b.bio_id
					ORDER BY p.post_time DESC
					LIMIT {START}, {ROWS_PAGE}');
            $reply['sql'] = sql_filter($reply['sql'], $event['event_id']);
            $this->_replies($reply);
        }
        v_style(_vs(array('SUBJECT' => $event['event_subject'], 'IMAGES' => $event['event_images'], 'START' => _format_date($event['event_start'], 'd F Y'), 'END' => _format_date($event['event_end'], 'd F Y'), 'COMMENTS' => $event['event_posts']), 'event'));
        return;
    }
예제 #4
0
파일: _ext.php 프로젝트: nopticon/npt
    protected function _corp_home()
    {
        $sql = 'SELECT *
			FROM _groups
			WHERE group_special = ?
			ORDER BY group_order';
        $groups = sql_rowset(sql_filter($sql, 1));
        $sql = 'SELECT g.group_id, b.bio_alias, b.bio_name, b.bio_firstname, b.bio_lastname, b.bio_life, b.bio_avatar, b.bio_avatar_up
			FROM _groups g, _group_joint j, _bio b
			WHERE g.group_id = j.joint_group
				AND j.joint_bio = b.bio_id
			ORDER BY j.joint_order, b.bio_alias';
        $members = sql_rowset($sql, 'group_id', false, true);
        $i = 0;
        foreach ($groups as $row) {
            if (!isset($members[$row->group_id])) {
                continue;
            }
            if (!$i) {
                _style('groups');
            }
            _style('groups.list', array('GROUP_NAME' => $row->group_name));
            foreach ($members[$row->group_id] as $row2) {
                _style('groups.list.member', _vs(array('LINK' => _link_bio($row2->bio_alias), 'NAME' => $row2->bio_name, 'REALNAME' => _fullname($row2), 'BIO' => _message($row2->bio_life), 'AVATAR' => _avatar($row2))), 'USER');
            }
            $i++;
        }
        if ($corp = $this->page_query('corp')) {
            v_style(array('CORP_CONTENT' => _message($corp->page_content)));
        }
        return;
    }
예제 #5
0
파일: _ac.php 프로젝트: nopticon/mag
 private function f_connected($sql)
 {
     static $bots;
     if (!isset($bots)) {
         $bots = get_bots();
     }
     $fields = array('last_bio_id' => 0, 'users_visible' => 0, 'users_hidden' => 0, 'users_guests' => 0, 'users_bots' => 0, 'users_online' => 0, 'last_ip' => '');
     foreach ($fields as $k => $v) {
         ${$k} = $v;
     }
     _style($block, array('L_TITLE' => _lang($block_title)));
     _style($block . '.members');
     $online = sql_rowset($sql);
     foreach ($online as $row) {
         // Guest
         if ($row->bio_id == 1) {
             if ($row->session_ip != $last_ip) {
                 $users_guests++;
             }
             $last_ip = $row->session_ip;
             continue;
         }
         // Member
         if ($row->bio_id != $last_bio_id) {
             $is_bot = isset($user_bots[$row->bio_id]);
             if ($row->bio_show) {
                 $username = $row->bio_name;
                 if (!$is_bot) {
                     $users_visible++;
                 }
             } else {
                 $username = '******' . $row->bio_name;
                 $users_hidden++;
             }
             if (($row->bio_show || $bio->v('auth_founder')) && !$is_bot || $is_bot && $bio->v('auth_founder')) {
                 _style($block . '.members.item', array('USERNAME' => $username, 'PROFILE' => _link_bio($row->bio_alias)));
             }
         }
         $last_bio_id = $row->bio_id;
     }
     $users_total = (int) $users_visible + $users_hidden + $users_guests + $users_bots;
     if (!($users_visible + $users_hidden) || !$users_visible && $users_hidden) {
         _style($block . '.members.none');
     }
     if (!$users_visible) {
         _style($block . '.members.none');
     }
     _style($block . '.legend');
     $online_ary = array('MEMBERS_TOTAL' => $users_total, 'MEMBERS_VISIBLE' => $users_visible, 'MEMBERS_GUESTS' => $users_guests, 'MEMBERS_HIDDEN' => $users_hidden, 'MEMBERS_BOT' => $users_bots);
     if ($unset_legend !== false) {
         unset($online_ary[$unset_legend]);
     }
     foreach ($online_ary as $lk => $vk) {
         if (!$vk && $lk != 'MEMBERS_TOTAL') {
             continue;
         }
         _style($block . '.legend.item', array('L_MEMBERS' => _lang($lk . ($vk != 1 ? '2' : '')), 'ONLINE_VALUE' => $vk));
     }
     return;
 }
예제 #6
0
파일: _contest.php 프로젝트: nopticon/mag
    protected function _view_home()
    {
        global $core, $bio;
        $v = $this->__(w('alias'));
        if (!f($v['alias'])) {
            _fatal();
        }
        $sql = 'SELECT *
			FROM _contest
			WHERE contest_alias = ?';
        if (!($contest = _fieldrow(sql_filter($sql, $v['alias'])))) {
            _fatal();
        }
        $contest['expired'] = time() > $contest['contest_end'];
        $is_contestant = false;
        if ($bio->v('auth_member')) {
            $sql = 'SELECT contestant_id
				FROM _contest_contestant
				WHERE contestant_contest = ?
					AND contestant_uid = ?';
            if (_fieldrow(sql_filter($sql, $contest['contest_id'], $bio->v('bio_id')))) {
                $is_contestant = true;
            }
        }
        if ($bio->v('auth_contest_view_stock')) {
            $sql = 'SELECT *
				FROM _contest_stock
				WHERE stock_contest = ?
				ORDER BY stock_name';
            $stock = _rowset(sql_filter($sql, $contest['contest_id']));
            $sql = 'SELECT *
				FROM _contest_contestant c, _bio b
				WHERE contestant_contest = ?
					AND contestant_uid = b.bio_id
				ORDER BY b.bio_alias';
            $contestants = _rowset(sql_filter($sql, $contest['contest_id']));
            foreach ($contestants as $i => $row) {
                if (!$i) {
                    _style('contestants');
                }
                _style('contestants.row', array());
            }
        }
        if ($contest['expired']) {
            if ($contest['contest_auto_win'] && !$contest['contest_has_win']) {
            }
        } else {
        }
        $sql = 'SELECT *
			FROM _contest_stock
			WHERE stock_contest = ?
			ORDER BY stock_name';
        $stock = _rowset(sql_filter($sql, $contest['contest_id']));
        $sql = 'SELECT b.bio_alias, b.bio_name
			FROM _contest_contestant c, _bio b
			WHERE c.contestant_contest = ?
				AND c.contestant_stock > 0
				AND c.contestant_uid=  b.bio_id
			ORDER BY c.contestant_stock';
        $contestant = _rowset(sql_filter($sql, $content['contest_id']), 'contestant_stock', false, true);
        foreach ($stock as $i => $row) {
            if (!$i) {
                _style('stock');
            }
            _style('stock.row', array('NAME' => $row['stock_name'], 'VALUE' => $row['stock_value']));
            if ($v['expired'] && isset($contestant[$row['stock_id']])) {
                foreach ($contestant[$row['stock_id']] as $j => $row_contestant) {
                    if (!$j) {
                        _style('stock.row.contestant');
                    }
                    _style('stock.row.contestant.uid', array('NAME' => $row_contestant['bio_name'], 'LINK' => _link_bio($row_contestant['bio_alias'])));
                }
            }
        }
        v_style(array('CONTEST_SUBJECT' => $contest['contest_subject'], 'CONTEST_CONTENT' => _message($contest['contest_content'])));
        return;
    }