forked from geokrety/geokrety-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
czy_obserwowany.php
72 lines (61 loc) · 2.58 KB
/
czy_obserwowany.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
<?php
// sprawdza obserwacje geokreta ݦⳳߟ śćńółź
// $userid=$longin_status['userid'];
function czy_obserwowany($id, $userid)
{
include 'templates/konfig.php';
//if(!function_exists(longin_chceck)) include("longin_chceck.php");
//$longin_status = longin_chceck();
//$userid=$longin_status['userid'];
if ($userid != null) {
$link = DBConnect();
$result = mysqli_query($link, "SELECT `userid` FROM `gk-obserwable` WHERE `userid`='$userid' AND `id`='$id' LIMIT 1");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
if (empty($row)) {
$OUT = 0;
} // if not observed
else {
$OUT = 1;
}
// if this is my geokreta
$result = mysqli_query($link, "SELECT `owner` FROM `gk-geokrety` WHERE `id`='$id' LIMIT 1");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
if ($row[0] == $userid) {
$OUT = 3;
} // if my geokret
$result = mysqli_query($link, "SELECT COUNT(*) FROM `gk-obserwable` WHERE `id`='$id' LIMIT 1");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
$observers = $row[0];
if ($observers > 0) {
$observers_link = "<a class='cb2' href='obserwuj.php?list=$id'>$observers</a>";
} else {
$observers_link = "$observers";
}
$observers_html = "<span class='xs' title='"._('Number of users who are watching this geokret')."'>($observers_link)</span>";
if ($OUT == 0) { // if not observed
$return['plain'] = 0;
$return['html'] = "<a href='obserwuj.php?id=$id'>"._('Watch this GeoKret')."</a> $observers_html";
$return['icon'] = CONFIG_CDN_ICONS.'/watch_y.png';
} elseif ($OUT == 1) { // if observed
$return['plain'] = 1;
$return['html'] = "<a href='obserwuj.php?id=$id'>"._('Stop watching this GeoKret')."</a> $observers_html";
$return['icon'] = CONFIG_CDN_ICONS.'/watch_n.png';
} elseif ($OUT == 3) { // if my
$return['plain'] = 3;
if ($observers > 0) {
$return['html'] = "<a class='cb2' href='obserwuj.php?list=$id'>"._('Users watching it').": $observers</a>";
} else {
$return['html'] = _('Users watching this GeoKret').': 0';
}
$return['icon'] = CONFIG_CDN_ICONS.'/watch_y.png';
}
return $return;
} else {
$return['plain'] = 10;
$return['html'] = '-';
return $return;
}
}