r60794 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60793‎ | r60794 | r60795 >
Date:17:25, 7 January 2010
Author:demon
Status:ok
Tags:
Comment:
Per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59183#c4712, these were proof of concept and can go away. Resolves fixmes on r59162, r59183, r59184
Modified paths:
  • /trunk/extensions/ContributionReporting/cc-reporting.js (deleted) (history)
  • /trunk/extensions/ContributionReporting/cc-reporting.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/cc-reporting.php
@@ -1,48 +0,0 @@
2 -<?php
3 -
4 -//handle request
5 -if(isset ($_REQUEST['load'])){
6 - handleLoad();
7 -}
8 -else if(isset ($_REQUEST['submit'])){
9 - handleSubmit();
10 -}
11 -
12 -//handle load
13 -function handleLoad(){
14 - $cc_id = randomCookie();
15 -
16 - //already have a cookie? use it, else set randomly generated one
17 - if(isset($_COOKIE['cc-cookie'])){
18 - $cc_id = $_COOKIE['cc-cookie'];
19 - }
20 - else{
21 - //set cookie to expire in maybe about a year or so... 300 days
22 - setcookie('cc-cookie', $cc_id, time() + (60 * 60 * 24 * 300), '/', "payments.wikimedia.org");
23 - }
24 -
25 - //add into DB
26 - $cc_id = addslashes($cc_id);
27 - $utm_src = isset($_REQUEST['utm_src']) ?
28 - addslashes($_REQUEST['utm_src']) : "unknown";
29 - $sql = "INSERT IGNORE INTO cc-track (cookie_id, utm_src, contribs) VALUES ('$cc_id','$utm_src', 0)";
30 -}
31 -
32 -//handle submit
33 -function handleSubmit(){
34 -
35 - //for people with cookies turned off, track them via "NULL" cookie
36 - $cc_id = "NULL";
37 - if(isset($_COOKIE['cc-cookie'])){
38 - $cc_id = $_COOKIE['cc-cookie'];
39 - }
40 -
41 - //update in DB
42 - $cc_id = addslashes($cc_id);
43 - $sql = "UPDATE cc-track SET contribs=contribs+1 WHERE cookie_id = '$cc_id'";
44 -}
45 -
46 -//random cookie
47 -function randomCookie(){
48 - return md5(mt_rand() + time());
49 -}
\ No newline at end of file
Index: trunk/extensions/ContributionReporting/cc-reporting.js
@@ -1,25 +0,0 @@
2 -
3 -runOnloadHook = function(){
4 - sendReq("cc-reporting.php?load=1&utm_src=" + document.payment.utm_source.value);
5 -}
6 -
7 -//replace "validate_form" call with this
8 -submitForm = function(){
9 - sendReq("cc-reporting.php?submit=1&utm_src="+ document.payment.utm_source.value);
10 - return validate_form(document.payment);
11 -}
12 -
13 -sendReq = function(sendRequest){
14 - if (window.XMLHttpRequest)
15 - {
16 -   xhttp=new XMLHttpRequest();
17 -   }
18 - else // Internet Explorer 5/6
19 - {
20 - xhttp=new ActiveXObject("Microsoft.XMLHTTP");
21 - }
22 - xhttp.open("GET",sendRequest ,false);
23 - xhttp.send("");
24 - dummyVar=xhttp.responseXML;
25 -}
26 -

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59162cc-reporting JS supportnimishg00:47, 17 November 2009
r59183cc-reporting bordering functional nownimishg22:00, 17 November 2009
r59184commentsnimishg22:29, 17 November 2009

Status & tagging log