示例#1
0
文件: _bio.php 项目: nopticon/mag
    protected function _gallery_remove()
    {
        global $bio, $warning;
        if (_button()) {
            $v = $this->__(array('picture' => array(0)));
            if (!count($v->picture)) {
                $warning->now();
            }
            $sql = 'SELECT *
				FROM _bio_images
				WHERE image_bio = ?
					AND image_assoc IN (??)
				ORDER BY image_id';
            if (!($images = sql_rowset(sql_filter($sql, $bio->v('bio_id'), _implode(',', $v->picture))))) {
                $warning->now();
            }
            $filepath = array('original' => _lib(), 'thumbnail' => _lib());
            foreach ($images as $row) {
                foreach ($filepath as $path) {
                }
            }
        }
        if ($submit) {
            $v = $this->__(array('s_images' => array(0)));
            $s_images = $v->s_images;
            if (sizeof($s_images)) {
                if ($row = $db->sql_fetchrow($result)) {
                    $delete_images = w();
                    do {
                        $gfile = array($gallery_path . $row['image'] . '.jpg', $thumbs_path . $row['image'] . '.jpg');
                        foreach ($gfile as $image) {
                            if (@is_file($image) && @is_readable($image)) {
                                @chmod($image, 0777);
                                if (@unlink($image)) {
                                    if (!@file_exists($image)) {
                                        if (!isset($delete_images[$row['image']])) {
                                            $delete_images[$row['image']] = true;
                                        }
                                    }
                                }
                            }
                        }
                    } while ($row = $db->sql_fetchrow($result));
                    if (sizeof($delete_images)) {
                        $sql = 'DELETE FROM _bio_pictures 
							WHERE picture_bio = ?
								AND picture_id IN (??)';
                        sql_query(sql_filter($sq, $bio->v('bio_id'), _implode(',', array_keys($delete_images))));
                        if ($deleted_count = sql_affectedrows()) {
                            $sql = 'UPDATE _bio_store
								SET store_value = store_value - ??
								WHERE store_bio = ?';
                            sql_query(sql_filter($sql, $deleted_count, $bio->v('bio_id')));
                        }
                    }
                }
                $db->sql_freeresult($result);
            }
        }
        if (!$error) {
            redirect(_link_control('a', array('a' => $bio->v('bio_alias'), 'x1' => $this->x(1))));
        }
    }
示例#2
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;
    }
示例#3
0
文件: project.php 项目: nopticon/mag
    protected function announce($block = false)
    {
        global $bio, $core;
        if (!($announce = $core->cache_load('announce'))) {
            $sql = 'SELECT *
				FROM _announce a, _announce_block b
				WHERE a.announce_block = b.block_id
				ORDER BY a.announce_order';
            $announce = $core->cache_store(sql_rowset($sql));
        }
        $i = 0;
        foreach ($announce as $row) {
            if ($block != $row['block_alias']) {
                continue;
            }
            if (!$i) {
                _style('announce');
                _style('announce.' . $row['block_alias']);
            }
            _style('announce.' . $row['block_alias'] . '.row', _vs(array('URL' => _link('announce', $row['announce_alias']), 'IMAGE' => _lib(LIB_BASE, $row['banner_id'], 'gif'), 'ALT' => $row['announce_alt']), 'v'));
            $i++;
        }
        return;
    }
示例#4
0
文件: _ext.php 项目: nopticon/npt
    protected function _emoticon_home()
    {
        global $core;
        if (!($emoticons = $core->cache->load('emoticon'))) {
            $sql = 'SELECT *
				FROM _smilies
				ORDER BY LENGTH(code) DESC';
            $emoticons = $core->cache->store(sql_rowset($sql));
        }
        foreach ($emoticons as $i => $row) {
            if (!$i) {
                _style('emoticons');
            }
            _style('emoticons.row', array('CODE' => $row->code, 'IMAGE' => _lib(LIB_VISUAL . '/emoticons', $rowsmile_url), 'DESC' => $row->emoticon));
        }
        return;
    }