space_share.php
3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: space_share.php 28049 2012-02-21 09:30:06Z zhengqingpeng $
 */
if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
$page = empty($_GET['page'])?1:intval($_GET['page']);
if($page<1) $page=1;
$id = empty($_GET['id'])?0:intval($_GET['id']);
$_GET['type'] = in_array($_GET['type'], array('all', 'link', 'video', 'music', 'flash', 'blog', 'album', 'pic', 'poll', 'space', 'thread', 'article'))? $_GET['type'] : 'all';
if($id) {
	if(!IS_ROBOT) {
		$share = C::t('home_share')->fetch_by_sid_uid($id, $space['uid']);
		if(empty($share)) {
			showmessage('share_does_not_exist');
		}
		require_once libfile('function/share');
		$share = mkshare($share);
		$perpage = 50;
		$start = ($page-1)*$perpage;
		ckstart($start, $perpage);
		$list = array();
		$cid = empty($_GET['cid'])?0:intval($_GET['cid']);
		$csql = $cid?"cid='$cid' AND":'';
		$count = C::t('home_comment')->count_by_id_idtype($id, 'sid', $cid);
		if($count) {
			$query = C::t('home_comment')->fetch_all_by_id_idtype($id, 'sid', $start, $perpage, $cid);
			foreach($query as $value) {
				$list[] = $value;
			}
			$multi = multi($count, $perpage, $page, "home.php?mod=space&uid=$share[uid]&do=share&id=$id", '', 'comment_ul');
		}
		$diymode = intval($_G['cookie']['home_diymode']);
	}
	include_once template("diy:home/space_share_view");
} else {
	$perpage = 20;
	$start = ($page-1)*$perpage;
	ckstart($start, $perpage);
	$gets = array(
		'mod' => 'space',
		'uid' => $space['uid'],
		'do' => 'share',
		'view' => $_GET['view'],
		'from' => $_GET['from']
	);
	$navtheurl = $theurl = 'home.php?'.url_implode($gets);
	$theurl .= '&type='.$_GET['type'];
	if(!IS_ROBOT) {
		$f_index = '';
		$need_count = true;
		if(empty($_GET['view'])) $_GET['view'] = 'we';
		$uids = 0;
		$type = '';
		if($_GET['view'] == 'all') {
			$wheresql = "1";
		} elseif($_GET['view'] == 'we') {
			space_merge($space, 'field_home');
			if($space['feedfriend']) {
				$uids = explode(',', $space['feedfriend']);
				$f_index = 'USE INDEX(dateline)';
			} else {
				$need_count = false;
			}
		} else {
			if($_GET['from'] == 'space') $diymode = 1;
			$uids = $space['uid'];
		}
		$actives = array($_GET['view'] => ' class="a"');
		if($_GET['type'] && $_GET['type'] != 'all') {
			$sub_actives = array('type_'.$_GET['type'] => ' class="a"');
			$type = $_GET['type'];
		} else {
			$sub_actives = array('type_all' => ' class="a"');
		}
		$list = array();
		$pricount = 0;
		$sid = empty($_GET['sid'])?0:intval($_GET['sid']);
		if($need_count) {
			$count = C::t('home_share')->count_by_sid_uid_type($sid, $uids, $type);
			if($count) {
				require_once libfile('function/share');
				foreach(C::t('home_share')->fetch_all_by_sid_uid_type($sid, $uids, $type, $start, $perpage) as $value) {
					$value = mkshare($value);
					if($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1) {
						$list[] = $value;
					} else {
						$pricount ++;
					}
				}
				$multi = multi($count, $perpage, $page, $theurl);
			}
		}
	}
	dsetcookie('home_diymode', $diymode);
	$navtitle = lang('core', 'title_share_'.$_GET['type']);
	$navtitle .= lang('core', 'title_share');
	if($space['username']) {
		$navtitle = lang('space', 'sb_sharing', array('who' => $space['username']));
	}
	$metakeywords = $navtitle;
	$metadescription = $navtitle;
	include_once template("diy:home/space_share_list");
}
?>