No regular expressions were active.
1 |
|
<?php
|
|
1 |
|
<?php
|
2 |
|
|
|
2 |
|
|
3 |
|
require_on
ce( BX_DIR
ECTORY_PAT
H_CLASSES
. 'BxDolDb
.php' );
|
|
3 |
|
require_on
ce( BX_DIR
ECTORY_PAT
H_CLASSES
. 'BxDolDb
.php' );
|
4 |
|
|
|
4 |
|
|
5 |
|
class BxDo
lVotingQue
ry extends
BxDolDb
|
|
5 |
|
class BxDo
lVotingQue
ry extends
BxDolDb
|
6 |
|
{
|
|
6 |
|
{
|
7 |
|
var $_
aSystem; /
/ current
voting sys
tem
|
|
7 |
|
var $_
aSystem; /
/ current
voting sys
tem
|
8 |
|
|
|
8 |
|
|
9 |
|
functi
on BxDolVo
tingQuery(
&$aSystem)
|
|
9 |
|
functi
on BxDolVo
tingQuery(
&$aSystem)
|
10 |
|
{
|
|
10 |
|
{
|
11 |
|
$t
his->_aSys
tem = &$aS
ystem;
|
|
11 |
|
$t
his->_aSys
tem = &$aS
ystem;
|
12 |
|
pa
rent::BxDo
lDb();
|
|
12 |
|
pa
rent::BxDo
lDb();
|
13 |
|
}
|
|
13 |
|
}
|
14 |
|
|
|
14 |
|
|
15 |
|
functi
on getVot
e ($iId)
|
|
15 |
|
functi
on getVot
e ($iId)
|
16 |
|
{
|
|
16 |
|
{
|
17 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
|
17 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
18 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
|
18 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
19 |
|
|
|
19 |
|
|
20 |
|
re
turn $this
->getRow("
SELECT `{$
sPre}ratin
g_count` a
s `count`,
(`{$sPre}
rating_sum
` / `{$sPr
e}rating_c
ount`) AS
`rate` FRO
M {$sTable
} WHERE `{
$sPre}id`
= '$iId' L
IMIT 1");
|
|
20 |
|
re
turn $this
->getRow("
SELECT `{$
sPre}ratin
g_count` a
s `count`,
(`{$sPre}
rating_sum
` / `{$sPr
e}rating_c
ount`) AS
`rate` FRO
M {$sTable
} WHERE `{
$sPre}id`
= '$iId' L
IMIT 1");
|
21 |
|
}
|
|
21 |
|
}
|
22 |
|
|
|
22 |
|
|
23 |
|
functi
on putVot
e ($iId, $
sIp, $iRat
e)
|
|
23 |
|
functi
on putVot
e ($iId, $
sIp, $iRat
e)
|
24 |
|
{
|
|
24 |
|
{
|
25 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
|
25 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
26 |
|
|
|
26 |
|
|
27 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
|
27 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
28 |
|
|
|
28 |
|
|
|
|
29 |
|
//
'A' preven
t voting f
or own pro
file
|
|
|
30 |
|
if
($sTable
== 'profil
e_rating'
&& (int)$_
COOKIE['me
mberID']==
$iId) {
|
|
|
31 |
|
return;
|
|
|
32 |
|
}
|
|
|
33 |
|
//
'A' preven
t voting f
or own gal
lery pics
|
|
|
34 |
|
if
($sTable
== 'media_
rating' &&
(int)$_CO
OKIE['memb
erID']== d
b_value("S
ELECT `med
_prof_id`
FROM `medi
a` WHERE `
med_id`='{
$iId}'"))
{
|
|
|
35 |
|
return;
|
|
|
36 |
|
}
|
|
|
37 |
|
|
29 |
|
if
($this->g
etOne("SEL
ECT `{$sPr
e}id` FROM
$sTable W
HERE `{$sP
re}id` = '
$iId' LIMI
T 1"))
|
|
38 |
|
if
($this->g
etOne("SEL
ECT `{$sPr
e}id` FROM
$sTable W
HERE `{$sP
re}id` = '
$iId' LIMI
T 1"))
|
30 |
|
{
|
|
39 |
|
{
|
31 |
|
$ret = $
this->quer
y ("UPDATE
{$sTable}
SET `{$s
Pre}rating
_count` =
`{$sPre}ra
ting_count
` + 1, `{$
sPre}ratin
g_sum` = `
{$sPre}rat
ing_sum` +
'$iRate'
WHERE `{$s
Pre}id` =
'$iId'");
|
|
40 |
|
$ret = $
this->quer
y ("UPDATE
{$sTable}
SET `{$s
Pre}rating
_count` =
`{$sPre}ra
ting_count
` + 1, `{$
sPre}ratin
g_sum` = `
{$sPre}rat
ing_sum` +
'$iRate'
WHERE `{$s
Pre}id` =
'$iId'");
|
32 |
|
}
|
|
41 |
|
}
|
33 |
|
el
se
|
|
42 |
|
el
se
|
34 |
|
{
|
|
43 |
|
{
|
35 |
|
$ret = $
this->quer
y ("INSERT
INTO {$sT
able} SET
`{$sPre}id
` = '$iId'
, `{$sPre}
rating_cou
nt` = '1',
`{$sPre}r
ating_sum`
= '$iRate
'");
|
|
44 |
|
$ret = $
this->quer
y ("INSERT
INTO {$sT
able} SET
`{$sPre}id
` = '$iId'
, `{$sPre}
rating_cou
nt` = '1',
`{$sPre}r
ating_sum`
= '$iRate
'");
|
36 |
|
|
|
45 |
|
|
37 |
|
}
|
|
46 |
|
}
|
38 |
|
if
(!$ret) r
eturn $ret
;
|
|
47 |
|
if
(!$ret) r
eturn $ret
;
|
39 |
|
|
|
48 |
|
|
40 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
|
49 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
41 |
|
re
turn $this
->query ("
INSERT INT
O {$sTable
} SET `{$s
Pre}id` =
'$iId', `{
$sPre}ip`
= '$sIp',
`{$sPre}da
te` = NOW(
)");
|
|
50 |
|
re
turn $this
->query ("
INSERT INT
O {$sTable
} SET `{$s
Pre}id` =
'$iId', `{
$sPre}ip`
= '$sIp',
`{$sPre}da
te` = NOW(
)");
|
42 |
|
}
|
|
51 |
|
}
|
43 |
|
|
|
52 |
|
|
44 |
|
functi
on isDubli
cateVote (
$iId, $sIp
)
|
|
53 |
|
functi
on isDubli
cateVote (
$iId, $sIp
)
|
45 |
|
{
|
|
54 |
|
{
|
46 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
|
55 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
47 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
|
56 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
48 |
|
$i
Sec = $thi
s->_aSyste
m['is_dupl
icate'];
|
|
57 |
|
$i
Sec = $thi
s->_aSyste
m['is_dupl
icate'];
|
49 |
|
|
|
58 |
|
|
50 |
|
re
turn $this
->getOne (
"SELECT `{
$sPre}id`
FROM {$sTa
ble} WHERE
`{$sPre}i
p` = '$sIp
' AND `{$s
Pre}id` =
'$iId' AND
UNIX_TIME
STAMP() -
UNIX_TIMES
TAMP(`{$sP
re}date`)
< $iSec");
|
|
59 |
|
re
turn $this
->getOne (
"SELECT `{
$sPre}id`
FROM {$sTa
ble} WHERE
`{$sPre}i
p` = '$sIp
' AND `{$s
Pre}id` =
'$iId' AND
UNIX_TIME
STAMP() -
UNIX_TIMES
TAMP(`{$sP
re}date`)
< $iSec");
|
51 |
|
|
|
60 |
|
|
52 |
|
}
|
|
61 |
|
}
|
53 |
|
|
|
62 |
|
|
54 |
|
functi
on getSqlP
arts ($sMa
ilTable, $
sMailField
)
|
|
63 |
|
functi
on getSqlP
arts ($sMa
ilTable, $
sMailField
)
|
55 |
|
{
|
|
64 |
|
{
|
56 |
|
if
($sMailTa
ble)
|
|
65 |
|
if
($sMailTa
ble)
|
57 |
|
$sMailTa
ble .= '.'
;
|
|
66 |
|
$sMailTa
ble .= '.'
;
|
58 |
|
|
|
67 |
|
|
59 |
|
if
($sMailFi
eld)
|
|
68 |
|
if
($sMailFi
eld)
|
60 |
|
$sMailFi
eld = $sMa
ilTable.$s
MailField;
|
|
69 |
|
$sMailFi
eld = $sMa
ilTable.$s
MailField;
|
61 |
|
|
|
70 |
|
|
62 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
|
71 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
63 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
|
72 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
64 |
|
|
|
73 |
|
|
65 |
|
re
turn array
(
|
|
74 |
|
re
turn array
(
|
66 |
|
'fields'
=> ",$sTa
ble.`{$sPr
e}rating_c
ount` as `
voting_cou
nt`, ($sTa
ble.`{$sPr
e}rating_s
um` / $sTa
ble.`{$sPr
e}rating_c
ount`) AS
`voting_ra
te` ",
|
|
75 |
|
'fields'
=> ",$sTa
ble.`{$sPr
e}rating_c
ount` as `
voting_cou
nt`, ($sTa
ble.`{$sPr
e}rating_s
um` / $sTa
ble.`{$sPr
e}rating_c
ount`) AS
`voting_ra
te` ",
|
67 |
|
//'field
s' => ",34
as `votin
g_count`,
2.5 AS `vo
ting_rate`
",
|
|
76 |
|
//'field
s' => ",34
as `votin
g_count`,
2.5 AS `vo
ting_rate`
",
|
68 |
|
'join' =
> " LEFT J
OIN $sTabl
e ON ({$sT
able}.`{$s
Pre}id` =
$sMailFiel
d) "
|
|
77 |
|
'join' =
> " LEFT J
OIN $sTabl
e ON ({$sT
able}.`{$s
Pre}id` =
$sMailFiel
d) "
|
69 |
|
);
|
|
78 |
|
);
|
70 |
|
}
|
|
79 |
|
}
|
71 |
|
|
|
80 |
|
|
72 |
|
functi
on deleteV
otings ($i
Id)
|
|
81 |
|
functi
on deleteV
otings ($i
Id)
|
73 |
|
{
|
|
82 |
|
{
|
74 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
|
83 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
75 |
|
|
|
84 |
|
|
76 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
|
85 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
77 |
|
$t
his->query
("DELETE
FROM {$sTa
ble} WHERE
`{$sPre}i
d` = '$iId
'");
|
|
86 |
|
$t
his->query
("DELETE
FROM {$sTa
ble} WHERE
`{$sPre}i
d` = '$iId
'");
|
78 |
|
|
|
87 |
|
|
79 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
|
88 |
|
$s
Table = $t
his->_aSys
tem['table
_rating'];
|
80 |
|
re
turn $this
->query ("
DELETE FRO
M {$sTable
} WHERE `{
$sPre}id`
= '$iId'")
;
|
|
89 |
|
re
turn $this
->query ("
DELETE FRO
M {$sTable
} WHERE `{
$sPre}id`
= '$iId'")
;
|
81 |
|
}
|
|
90 |
|
}
|
82 |
|
|
|
91 |
|
|
83 |
|
functi
on getTopV
otedItem (
$iDays, $s
JoinTable
= '', $sJo
inField =
'', $sWher
e = '')
|
|
92 |
|
functi
on getTopV
otedItem (
$iDays, $s
JoinTable
= '', $sJo
inField =
'', $sWher
e = '')
|
84 |
|
{
|
|
93 |
|
{
|
85 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
|
94 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
86 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
|
95 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
87 |
|
|
|
96 |
|
|
88 |
|
$s
Join = $sJ
oinTable &
& $sJoinFi
eld ? " IN
NER JOIN $
sJoinTable
ON ({$sJo
inTable}.{
$sJoinFiel
d} = $sTab
le.`{$sPre
}id`) " :
'';
|
|
97 |
|
$s
Join = $sJ
oinTable &
& $sJoinFi
eld ? " IN
NER JOIN $
sJoinTable
ON ({$sJo
inTable}.{
$sJoinFiel
d} = $sTab
le.`{$sPre
}id`) " :
'';
|
89 |
|
|
|
98 |
|
|
90 |
|
re
turn $this
->getOne (
"SELECT $s
Table.`{$s
Pre}id`, C
OUNT($sTab
le.`{$sPre
}id`) AS `
voting_cou
nt` FROM {
$sTable} $
sJoin WHER
E TO_DAYS(
NOW()) - T
O_DAYS($sT
able.`{$sP
re}date`)
<= $iDays
$sWhere GR
OUP BY $sT
able.`{$sP
re}id` HAV
ING `votin
g_count` >
2 ORDER B
Y `voting_
count` DES
C LIMIT 1"
);
|
|
99 |
|
re
turn $this
->getOne (
"SELECT $s
Table.`{$s
Pre}id`, C
OUNT($sTab
le.`{$sPre
}id`) AS `
voting_cou
nt` FROM {
$sTable} $
sJoin WHER
E TO_DAYS(
NOW()) - T
O_DAYS($sT
able.`{$sP
re}date`)
<= $iDays
$sWhere GR
OUP BY $sT
able.`{$sP
re}id` HAV
ING `votin
g_count` >
2 ORDER B
Y `voting_
count` DES
C LIMIT 1"
);
|
91 |
|
}
|
|
100 |
|
}
|
92 |
|
|
|
101 |
|
|
93 |
|
functi
on getVote
dItems ($s
Ip)
|
|
102 |
|
functi
on getVote
dItems ($s
Ip)
|
94 |
|
{
|
|
103 |
|
{
|
95 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
|
104 |
|
$s
Pre = $thi
s->_aSyste
m['row_pre
fix'];
|
96 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
|
105 |
|
$s
Table = $t
his->_aSys
tem['table
_track'];
|
97 |
|
$i
Sec = $thi
s->_aSyste
m['is_dupl
icate'];
|
|
106 |
|
$i
Sec = $thi
s->_aSyste
m['is_dupl
icate'];
|
98 |
|
|
|
107 |
|
|
99 |
|
re
turn $this
->getAll (
"SELECT `{
$sPre}id`
FROM {$sTa
ble} WHERE
`{$sPre}i
p` = '$sIp
' AND UNIX
_TIMESTAMP
() - UNIX_
TIMESTAMP(
`{$sPre}da
te`) < $iS
ec");
|
|
108 |
|
re
turn $this
->getAll (
"SELECT `{
$sPre}id`
FROM {$sTa
ble} WHERE
`{$sPre}i
p` = '$sIp
' AND UNIX
_TIMESTAMP
() - UNIX_
TIMESTAMP(
`{$sPre}da
te`) < $iS
ec");
|
100 |
|
}
|
|
109 |
|
}
|
101 |
|
|
|
110 |
|
|
102 |
|
}
|
|
111 |
|
}
|
103 |
|
|
|
112 |
|
|
104 |
|
|
|
113 |
|
|
105 |
|
?>
|
|
114 |
|
?>
|