forked from geokrety/geokrety-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclaim.php
131 lines (100 loc) · 3.79 KB
/
claim.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
<?php
require_once '__sentry.php';
// tutaj przypisujemy niczyje krety do ich nowych wlascicieli
// w pierwszej wersji potrzebny jest tracking code i owner code.
// wpisujemy i "poszlo!", szczesliwy kret ma szczesliwego ownera.
// smarty cache
$smarty_cache_this_page = 0; // this page should be cached for n seconds
require_once 'smarty_start.php';
require_once 'defektoskop.php';
$db = new db();
$TYTUL = 'Claiming a GeoKret'; // _("");
$visitorid = $longin_status['userid'];
// tylko zalogowani moga przywlaszczac krety
if ($visitorid == null) {
$TRESC = _('Please login.');
include_once 'smarty.php';
exit;
}
//import_request_variables('g', 'g_');
$g_id = $_GET['id'];
$p_oc = $_POST['oc'];
// autopoprawione...
$p_tc = $_POST['tc'];
// autopoprawione...import_request_variables('p', 'p_');
if (isset($p_tc)) {
$p_tc = trim($p_tc);
}
if (isset($p_oc)) {
$p_oc = trim($p_oc);
}
if (isset($p_tc) && !ctype_alnum($p_tc)) {
$errors[] = 'Invalid Tracking Code!';
}
if (isset($p_oc) && !ctype_alnum($p_oc)) {
$errors[] = 'Invalid Owner Code!';
}
if (!empty($errors)) {
include_once 'defektoskop.php';
$TRESC = defektoskop($errors, true, 'podczas proby przywlaszczenia kreta podano bledny lub pusty TC i/lub OC', 7, 'claim');
include_once 'smarty.php';
exit;
}
// $result = mysqli_query($link, "SELECT id, nr, nazwa, owner, us.user
// FROM `gk-geokrety` gk
// LEFT JOIN `gk-users` us ON gk.owner = us.userid
// WHERE gk.id='$g_id' LIMIT 1");
// // jak nie ma takiego kreta to lepiej zakonczyc dzialanie :)
// if (mysqli_num_rows($result) == 0)
// {
// $errors[] = _("No such GeoKret!");
// include_once("defektoskop.php"); $TRESC = defektoskop($errors); include_once('smarty.php'); exit;
// }
// list($id, $tc, $nazwa, $ownerid, $ownername) = mysqli_fetch_array($result);
// mysqli_free_result($result);
// if (!mysqli_num_rows(mysqli_query($link, "SELECT own.kret_id FROM `gk-owner-codes` own INNER JOIN `gk-geokrety` gk ON (own.kret_id = gk.id) WHERE own.kret_id='$g_id' AND own.user_id='0'")))
// {
// $errors[] = "Cannot claim this GeoKret!";
// include_once("defektoskop.php"); $TRESC = defektoskop($errors); include_once('smarty.php'); exit;
// }
if (ctype_alnum($p_oc) && ctype_alnum($p_tc)) {
//obsluga formy
$row = $db->exec_fetch_row("SELECT id, nazwa FROM `gk-geokrety` WHERE owner='0' AND nr='$p_tc' LIMIT 1", $num_rows, 0);
if ($num_rows < 1) {
$errors[] = 'Incorrect data!';
include_once 'defektoskop.php';
$TRESC = defektoskop($errors);
include_once 'smarty.php';
exit;
}
list($id, $nazwa) = $row;
include 'owner_code.fn.php';
include_once 'defektoskop.php';
if (claimGeoKret($id, $p_oc, $p_tc, $visitorid)) {
$TRESC = "Congratulations, you are now the owner of <b><a href='konkret.php?id=$id'>$nazwa</a></b>";
errory_add($TRESC, 0);
} else {
$errors[] = 'Operation failed!';
$TRESC = defektoskop($errors);
}
} else {
//forma
errory_add('formularz przywlaszczania', 0, 'claim_form');
$TRESC = '<form action="'.$_SERVER['PHP_SELF'].'" method="post" />
<table style="border-spacing:3px 3px;">
<tr >
<td colspan="2"><hr noshade="noshade" size="2" /></td>
</tr>
<tr >
<td colspan="2" style="padding:5px 0 12px 10px">To claim a GeoKret, please provide its Tracking Code and Owner Code:</td>
</tr>
<tr style="height:2em"><td class="right" style="width:16%"><b>Tracking code:</b></td><td><input type="text" name="tc"></td></tr>
<tr style="height:2em"><td class="right"><b>Owner code:</b></td><td><input type="text" name="oc"></td></tr>
<tr >
<td colspan="2"><hr noshade="noshade" size="2" /></td>
</tr>
<tr style="height:2em"><td class="right"></td><td><input type="submit" value="Claim this GeoKret" /></td></tr>
</table>
</form>';
}
require_once 'smarty.php';