Index: trunk/extensions/ContributionReporting/cc-reporting.php |
— | — | @@ -9,16 +9,18 @@ |
10 | 10 | function handleLoad(){ |
11 | 11 | $cc_id = randomCookie(); |
12 | 12 | |
13 | | - if(!isset($_COOKIE['cc-cookie'])){ |
14 | | - $cc_id = $_REQUEST['cc-cookie']; |
| 13 | + if(isset($_COOKIE['cc-cookie'])){ |
| 14 | + $cc_id = $_COOKIE['cc-cookie']; |
15 | 15 | } |
16 | 16 | else{ |
17 | 17 | //set cookie to expire in maybe about a year or so... 300 days |
18 | 18 | setcookie('cc-cookie', $cc_id, time() + (60 * 60 * 24 * 300), '/', "payments.wikimedia.org"); |
19 | 19 | } |
20 | 20 | |
21 | | - //if not exist insert into DB |
22 | | - //via REQUEST['utm_src'] |
| 21 | + $cc_id = addslashes($cc_id); |
| 22 | + $utm_src = isset($_REQUEST['utm_src']) ? |
| 23 | + addslashes($_REQUEST['utm_src']) : "unknown"; |
| 24 | + $sql = "INSERT IGNORE INTO cc-track (cookie_id, utm_src, contribs) VALUES ('$cc_id','$utm_src', 0)"; |
23 | 25 | } |
24 | 26 | |
25 | 27 | function handleSubmit(){ |
— | — | @@ -27,7 +29,8 @@ |
28 | 30 | $cc_id = $_COOKIE['cc-cookie']; |
29 | 31 | } |
30 | 32 | |
31 | | - //donations++ |
| 33 | + $cc_id = addslashes($cc_id); |
| 34 | + $sql = "UPDATE cc-track SET contribs=contribs+1 WHERE cookie_id = '$cc_id'"; |
32 | 35 | } |
33 | 36 | |
34 | 37 | function randomCookie(){ |