rating.php
1.36 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
<?php
set_time_limit(30);
@include_once(dirname ( __FILE__ )."/new_csv/mysql.class.php");
define ("DBHOST", "localhost");
define ("DBNAME", "extremstyle");
define ("DBUSER", "extremstyle");
define ("DBPASS", "Ry4PWmM6GCp3UCTf");
$db = new db;
$_IP = $db->safesql( $_SERVER['REMOTE_ADDR'] );
$pid = $db->safesql( $_REQUEST['pid'] );
$go_rate= $db->safesql( $_REQUEST['go_rate'] );
$row = $db->super_query( "SELECT pid FROM logs where pid ='$pid' AND id = '".$_IP."' LIMIT 1;" );
if( ! $row['pid'] AND count( explode( ".", $_IP ) ) == 4 ) {
$db->query( "UPDATE catalogs_products set rating=rating+'$go_rate', vote_num=vote_num+1 where id ='$pid'" );
$db->query( "INSERT INTO logs (pid, id) values ('$pid', '$_IP')" );
}
$row = $db->super_query( "SELECT id, rating, vote_num FROM catalogs_products where id ='$pid'" );
$buffer = ShowRating( $row['id'], $row['rating'], $row['vote_num'], false );
$db->close();
@header( "Content-type: text/css; charset=cp1251" );
echo $buffer;
function ShowRating($id, $rating, $vote_num, $allow = true) {
if( $rating ) $rating = round( ($rating / $vote_num), 0 );
else $rating = 0;
$rating = $rating * 17;
$rated = <<<HTML
<div class="rating">
<ul class="unit-rating">
<li class="current-rating" style="width:{$rating}px;">{$rating}</li>
</ul>
</div>
HTML;
return $rated;
}
?>