r59183 MediaWiki - Code Review archive

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

Diff [purge]

Index: trunk/extensions/ContributionReporting/cc-reporting.php
@@ -9,16 +9,18 @@
1010 function handleLoad(){
1111 $cc_id = randomCookie();
1212
13 - if(!isset($_COOKIE['cc-cookie'])){
14 - $cc_id = $_REQUEST['cc-cookie'];
 13+ if(isset($_COOKIE['cc-cookie'])){
 14+ $cc_id = $_COOKIE['cc-cookie'];
1515 }
1616 else{
1717 //set cookie to expire in maybe about a year or so... 300 days
1818 setcookie('cc-cookie', $cc_id, time() + (60 * 60 * 24 * 300), '/', "payments.wikimedia.org");
1919 }
2020
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)";
2325 }
2426
2527 function handleSubmit(){
@@ -27,7 +29,8 @@
2830 $cc_id = $_COOKIE['cc-cookie'];
2931 }
3032
31 - //donations++
 33+ $cc_id = addslashes($cc_id);
 34+ $sql = "UPDATE cc-track SET contribs=contribs+1 WHERE cookie_id = '$cc_id'";
3235 }
3336
3437 function randomCookie(){

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:11, 8 December 2009

Please add:

require( dirname(__FILE__).'/../../includes/WebStart.php' );

to the top of the file. Then use the regular MediaWiki functions like wfGetDB() and $wgRequest->getVal() instead of going your own way with $_REQUEST and addslashes(). As I said to you previously, any code that calls addslashes() is insecure and unsuitable for deployment.

#Comment by Nimish Gautam (talk | contribs)   23:20, 8 December 2009

These were more 'proof-of-concept' files for fundraising, and we ended up using different methods later. Both cc-reporting.php and cc-reporting.js can be removed from deployment.

#Comment by 😂 (talk | contribs)   14:35, 11 December 2009

Remove them from trunk then.

Status & tagging log