r59184 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59183‎ | r59184 | r59185 >
Date:22:29, 17 November 2009
Author:nimishg
Status:resolved (Comments)
Tags:
Comment:
comments
Modified paths:
  • /trunk/extensions/ContributionReporting/cc-reporting.js (modified) (history)
  • /trunk/extensions/ContributionReporting/cc-reporting.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/cc-reporting.php
@@ -1,4 +1,6 @@
22 <?php
 3+
 4+//handle request
35 if(isset ($_REQUEST['load'])){
46 handleLoad();
57 }
@@ -6,9 +8,11 @@
79 handleSubmit();
810 }
911
 12+//handle load
1013 function handleLoad(){
1114 $cc_id = randomCookie();
1215
 16+ //already have a cookie? use it, else set randomly generated one
1317 if(isset($_COOKIE['cc-cookie'])){
1418 $cc_id = $_COOKIE['cc-cookie'];
1519 }
@@ -17,22 +21,28 @@
1822 setcookie('cc-cookie', $cc_id, time() + (60 * 60 * 24 * 300), '/', "payments.wikimedia.org");
1923 }
2024
 25+ //add into DB
2126 $cc_id = addslashes($cc_id);
2227 $utm_src = isset($_REQUEST['utm_src']) ?
2328 addslashes($_REQUEST['utm_src']) : "unknown";
2429 $sql = "INSERT IGNORE INTO cc-track (cookie_id, utm_src, contribs) VALUES ('$cc_id','$utm_src', 0)";
2530 }
2631
 32+//handle submit
2733 function handleSubmit(){
 34+
 35+ //for people with cookies turned off, track them via "NULL" cookie
2836 $cc_id = "NULL";
2937 if(isset($_COOKIE['cc-cookie'])){
3038 $cc_id = $_COOKIE['cc-cookie'];
3139 }
3240
 41+ //update in DB
3342 $cc_id = addslashes($cc_id);
3443 $sql = "UPDATE cc-track SET contribs=contribs+1 WHERE cookie_id = '$cc_id'";
3544 }
3645
 46+//random cookie
3747 function randomCookie(){
3848 return md5(mt_rand() + time());
3949 }
\ No newline at end of file
Index: trunk/extensions/ContributionReporting/cc-reporting.js
@@ -3,6 +3,7 @@
44 sendReq("cc-reporting.php?load=1&utm_src=" + document.payment.utm_source.value);
55 }
66
 7+//replace "validate_form" call with this
78 submitForm = function(){
89 sendReq("cc-reporting.php?submit=1&utm_src="+ document.payment.utm_source.value);
910 return validate_form(document.payment);

Follow-up revisions

RevisionCommit summaryAuthorDate
r60794Per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59183#c4712, these w...demon17:25, 7 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   23:17, 8 December 2009

I don't think repeating the function name as a doc comment, except with spaces instead of camel case, really adds anything to the readability of the code. If I saw such comments during a refactor I would remove them. Instead, please explain what the function does.

Status & tagging log