-
Notifications
You must be signed in to change notification settings - Fork 0
/
browseVideo.php
205 lines (166 loc) · 6.66 KB
/
browseVideo.php
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
/***************************************************************************
* Dolphin Smart Community Builder
* -----------------
* begin : Mon Mar 23 2006
* copyright : (C) 2006 BoonEx Group
* website : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/
require_once('inc/header.inc.php');
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'images.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'sharing.inc.php' );
$_page['name_index'] = 82;
$_page['css_name'] = 'viewVideo.css';
$oVotingView = new BxTemplVotingView('gvideo', 0, 0);
$_page['extra_js'] = $oVotingView->getExtraJs();
if ( !( $logged['admin'] = member_auth( 1, false ) ) )
{
if ( !( $logged['member'] = member_auth( 0, false ) ) )
{
if ( !( $logged['aff'] = member_auth( 2, false ) ) )
{
$logged['moderator'] = member_auth( 3, false );
}
}
}
$_page['header'] = _t( "_browseVideo" );
$_page['header_text'] = _t("_browseVideo");
$_ni = $_page['name_index'];
$member['ID'] = (int)$_COOKIE['memberID'];
$aWhere = array();
$aWhere[] = '1';
if (isset($_GET['userID']))
{
$iUser = (int)$_GET['userID'];
$aWhere[] = "`RayMovieFiles`.`Owner`=$iUser";
}
if (isset($_GET['tag']))
{
$sTag = htmlspecialchars_adv($_GET['tag']);
$aWhere[] = "`RayMovieFiles`.`Tags` like '%$sTag%'";
}
if (isset($_GET['action']))
{
$sAct = htmlspecialchars_adv($_GET['action']);
$sAddon = defineBrowseAction($sAct,'Video',$member['ID']);
}
$sqlWhere = "WHERE " . implode( ' AND ', $aWhere ).$sAddon." AND `Approved`= 'true'";
$iTotalNum = db_value( "SELECT COUNT( * ) FROM `RayMovieFiles` $sqlWhere" );
if( !$iTotalNum )
{
$_page_cont[$_ni]['page_main_code'] = _t( '_Sorry, nothing found' );
PageCode();
exit;
}
$iPerPage = (int)$_GET['per_page'];
if( !$iPerPage )
$iPerPage = 10;
$iTotalPages = ceil( $iTotalNum / $iPerPage );
$iCurPage = (int)$_GET['page'];
if( $iCurPage > $iTotalPages )
$iCurPage = $iTotalPages;
if( $iCurPage < 1 )
$iCurPage = 1;
$sLimitFrom = ( $iCurPage - 1 ) * $iPerPage;
$sqlOrderBy = 'ORDER BY `medDate` DESC';
if (isset($_GET['rate']))
{
$oVotingView = new BxTemplVotingView ('gvideo', 0, 0);
$aSql = $oVotingView->getSqlParts('`RayMovieFiles`', '`ID`');
$sHow = $_GET['rate'] == 'top' ? "DESC" : "ASC";
$sqlOrderBy = $oVotingView->isEnabled() ? "ORDER BY `voting_rate` $sHow, `voting_count` $sHow, `medDate` $sHow" : $sqlOrderBy ;
$sqlFields = $aSql['fields'];
$sqlLJoin = $aSql['join'];
}
$sqlLimit = "LIMIT $sLimitFrom, $iPerPage";
$sQuery = "
SELECT
`RayMovieFiles`.`ID` as `medID`,
`RayMovieFiles`.`Owner` as `medProfId`,
`RayMovieFiles`.`Title` as `medTitle`,
`RayMovieFiles`.`Date` as `medDate`,
`RayMovieFiles`.`Views` as `medViews`,
`Profiles`.`NickName`
$sqlFields
FROM `RayMovieFiles`
LEFT JOIN `Profiles` ON
`Profiles`.`ID` = `RayMovieFiles`.`Owner`
$sqlLJoin
$sqlWhere
$sqlOrderBy
$sqlLimit
";
$rData = db_res($sQuery);
$_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode();
PageCode();
function PageCompPageMainCode()
{
global $site;
global $rData;
global $iTotalPages;
global $iCurPage;
global $iPerPage;
global $member;
$sCode = '<div style="position: relative; float: left;">';
if (mysql_num_rows($rData))
{
while ($aData = mysql_fetch_array($rData))
{
$sProfLink = '<div>'._t("_By").': <a href="'.getProfileLink($aData['medProfId']).'">'.$aData['NickName'].'</a></div>';
$oVotingView = new BxTemplVotingView ('gvideo', $aData['medID']);
if( $oVotingView->isEnabled())
{
$sRate = $oVotingView->getSmallVoting (0);
$sShowRate = '<div class="galleryRate">'. $sRate . '</div>';
}
$sHref = $site['url'].'viewVideo.php?fileID='.$aData['medID'];
$sImg = '<a href="'.$sHref.'"><img src="'.$site['url'].'ray/modules/movie/files/'.$aData['medID'].'_small.jpg"></a>';
$sVidTitle = strlen($aData['medTitle']) > 0 ? $aData['medTitle'] : _t("_Untitled");
$sDelLink = $member['ID'] == $aData['medProfId'] ? '<div><a href="'.$_SERVER['PHP_SELF'].'?action=del&fileID='.$aData['medID'].'"
onClick="return confirm( \''._t("_are you sure?").'\');">'._t("_Delete").'</a></div>' : "" ;
$sCode .= '<div class="browseUnit">';
$sCode .= '<div class="lastFilesPic">'.$sImg.'</div>';
$sCode .= '<div><a href="'.$sHref.'"><b>'.$sVidTitle.'</b></a></div>';
$sCode .= $sProfLink;
$sCode .= '<div>'._t("_Added").': <b>'.defineTimeInterval($aData['medDate']).'</b></div>';
$sCode .= '<div>'._t("_Views").': <b>'.$aData['medViews'].'</b></div>';
$sCode .= $sShowRate;
$sCode .= $sDelLink;
$sCode .= '</div>';
}
}
$sCode .= '<div class="clear_both"></div>';
// generate pagination
if( $iTotalPages > 1)
{
$sRequest = $_SERVER['PHP_SELF'] . '?';
$aFields = array( 'userID', 'tag', 'rate' );
foreach( $aFields as $field )
if( isset( $_GET[$field] ) )
$sRequest .= "&{$field}=" . htmlentities( process_pass_data( $_GET[$field] ) );
$pagination = '<div style="text-align: center; position: relative;">'._t("_Results per page").':
<select name="per_page" onchange="window.location=\'' . $sRequest . '&per_page=\' + this.value;">
<option value="10"' . ( $iPerPage == 10 ? ' selected="selected"' : '' ) . '>10</option>
<option value="20"' . ( $iPerPage == 20 ? ' selected="selected"' : '' ) . '>20</option>
<option value="50"' . ( $iPerPage == 50 ? ' selected="selected"' : '' ) . '>50</option>
<option value="100"' . ( $iPerPage == 100 ? ' selected="selected"' : '' ) . '>100</option>
</select></div>' .
genPagination( $iTotalPages, $iCurPage, ( $sRequest . '&page={page}&per_page='.$iPerPage ) );
}
else
$pagination = '';
return $sCode . $pagination.'</div>';
}
?>