Skip to content

Commit

Permalink
Merge pull request #9 from martijnhoekstra/escaped_usernames
Browse files Browse the repository at this point in the history
refactored getWikiLink
  • Loading branch information
cdhowie committed Apr 16, 2012
2 parents d6d92c6 + b35e56b commit be05b34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
6 changes: 3 additions & 3 deletions public_html/appeal.php
Expand Up @@ -319,11 +319,11 @@ function hideContextWindow() {
<ul> <ul>
<li><a href="<?php echo getWikiLink($appeal->getUserPage(), $user->getUseSecure()); ?>" target="_blank">User Page</a></li> <li><a href="<?php echo getWikiLink($appeal->getUserPage(), $user->getUseSecure()); ?>" target="_blank">User Page</a></li>
<li><a href="<?php echo getWikiLink("User_talk:" . $appeal->getCommonName(), $user->getUseSecure()); ?>" target="_blank">User Talk Page</a></li> <li><a href="<?php echo getWikiLink("User_talk:" . $appeal->getCommonName(), $user->getUseSecure()); ?>" target="_blank">User Talk Page</a></li>
<li><a href="<?php echo getWikiLink("Special:Log/block", $user->getUseSecure(), "page=User:" . $appeal->getCommonName()); ?>" target="_blank">Block Log</a></li> <li><a href="<?php echo getWikiLink("Special:Log/block", $user->getUseSecure(), array('page' => "User:" . $appeal->getCommonName())); ?>" target="_blank">Block Log</a></li>
<li><a href="<?php echo getWikiLink("Special:BlockList", $user->getUseSecure(), "wpTarget=" . $appeal->getCommonName() . "&limit=50"); ?>" target="_blank">Find block</a></li> <li><a href="<?php echo getWikiLink("Special:BlockList", $user->getUseSecure(), array('wpTarget' => $appeal->getCommonName(), 'limit' => '50')); ?>" target="_blank">Find block</a></li>
<li><a href="<?php echo getWikiLink("Special:Contributions/" . $appeal->getCommonName(), $user->getUseSecure()); ?>" target="_blank">Contribs</a></li> <li><a href="<?php echo getWikiLink("Special:Contributions/" . $appeal->getCommonName(), $user->getUseSecure()); ?>" target="_blank">Contribs</a></li>
<li><a href="<?php echo getWikiLink("Special:Unblock/" . $appeal->getCommonName(), $user->getUseSecure()); ?>" target="_blank">Unblock</a></li> <li><a href="<?php echo getWikiLink("Special:Unblock/" . $appeal->getCommonName(), $user->getUseSecure()); ?>" target="_blank">Unblock</a></li>
<li><a href="<?php echo getWikiLink("Special:UserLogin", $user->getUseSecure(), "type=signup"); ?>" target="_blank">Create Account</a></li> <li><a href="<?php echo getWikiLink("Special:UserLogin", $user->getUseSecure(), array('type'=>"signup")); ?>" target="_blank">Create Account</a></li>
</ul> </ul>
</div> </div>
Request timestamp: <?php echo $appeal->getTimestamp(); ?><br> Request timestamp: <?php echo $appeal->getTimestamp(); ?><br>
Expand Down
6 changes: 3 additions & 3 deletions public_html/src/statsLib.php
Expand Up @@ -85,7 +85,7 @@ function printAppealList(array $criteria = array(), $limit = "", $orderby = "",
$requests .= "\t<tr>\n"; $requests .= "\t<tr>\n";
$requests .= "\t\t<td>" . $appeal->getID() . ".</td>\n"; $requests .= "\t\t<td>" . $appeal->getID() . ".</td>\n";
$requests .= "\t\t<td><a style=\"color:green\" href='appeal.php?id=" . $appeal->getID() . "'>Zoom</a></td>\n"; $requests .= "\t\t<td><a style=\"color:green\" href='appeal.php?id=" . $appeal->getID() . "'>Zoom</a></td>\n";
$requests .= "\t\t<td><a style=\"color:blue\" href='" . getWikiLink($appeal->getUserPage(), $secure) . "' target='_NEW'>" . $appeal->getCommonName() . "</a></td>\n"; $requests .= "\t\t<td><a style=\"color:blue\" href='" . getWikiLink("user:".$appeal->getCommonName(), $secure) . "' target='_NEW'>" . $appeal->getCommonName() . "</a></td>\n";
if ($timestamp == 1) { if ($timestamp == 1) {
$requests .= "\t\t<td>" . $data['timestamp'] . "</td>\n"; $requests .= "\t\t<td>" . $data['timestamp'] . "</td>\n";
} }
Expand Down Expand Up @@ -188,7 +188,7 @@ function printRecentClosed() {
$requests .= "\t<tr>\n"; $requests .= "\t<tr>\n";
$requests .= "\t\t<td>" . $appeal->getID() . ".</td>\n"; $requests .= "\t\t<td>" . $appeal->getID() . ".</td>\n";
$requests .= "\t\t<td><a style=\"color:green\" href='appeal.php?id=" . $appeal->getID() . "'>Zoom</a></td>\n"; $requests .= "\t\t<td><a style=\"color:green\" href='appeal.php?id=" . $appeal->getID() . "'>Zoom</a></td>\n";
$requests .= "\t\t<td><a style=\"color:blue\" href='" . getWikiLink($appeal->getUserPage(), $secure) . "' target='_NEW'>" . $appeal->getCommonName() . "</a></td>\n"; $requests .= "\t\t<td><a style=\"color:blue\" href='" . getWikiLink("user:" . $appeal->getCommonName(), $secure) . "' target='_NEW'>" . $appeal->getCommonName() . "</a></td>\n";
$requests .= "\t\t<td>" . $data['timestamp'] . "</td>\n"; $requests .= "\t\t<td>" . $data['timestamp'] . "</td>\n";
$requests .= "\t</tr>\n"; $requests .= "\t</tr>\n";
} }
Expand Down Expand Up @@ -252,7 +252,7 @@ function printBacklog() {
$requests .= "\t<tr>\n"; $requests .= "\t<tr>\n";
$requests .= "\t\t<td>" . $appeal->getID() . ".</td>\n"; $requests .= "\t\t<td>" . $appeal->getID() . ".</td>\n";
$requests .= "\t\t<td><a style=\"color:green\" href='appeal.php?id=" . $appeal->getID(). "'>Zoom</a></td>\n"; $requests .= "\t\t<td><a style=\"color:green\" href='appeal.php?id=" . $appeal->getID(). "'>Zoom</a></td>\n";
$requests .= "\t\t<td><a style=\"color:blue\" href='" . getWikiLink($appeal->getUserPage(), $secure) . "' target='_NEW'>" . $appeal->getCommonName() . "</a></td>\n"; $requests .= "\t\t<td><a style=\"color:blue\" href='" . getWikiLink("user:" .$appeal->getCommonName(), $secure) . "' target='_NEW'>" . $appeal->getCommonName() . "</a></td>\n";
$requests .= "\t\t<td> " . $data['since_last_action'] . " days since last action</td>\n"; $requests .= "\t\t<td> " . $data['since_last_action'] . " days since last action</td>\n";
$requests .= "\t</tr>\n"; $requests .= "\t</tr>\n";
} }
Expand Down
30 changes: 14 additions & 16 deletions public_html/src/unblocklib.php
Expand Up @@ -241,24 +241,22 @@ function connectToDB($suppressOutput = false){
* Returns a URL to the given page on the English Wikipedia. * Returns a URL to the given page on the English Wikipedia.
* @param String $page the page to link to, including namespace * @param String $page the page to link to, including namespace
* @param boolean $useSecure true to use the secure server * @param boolean $useSecure true to use the secure server
* @param String $queryOptions query options, such as used on some log pages, * @param array $queryOptions query options, such as used on some log pages,
* separated by (but not starting with) &'s. * as an associative array.
*/ */
function getWikiLink($page, $useSecure = false, $queryOptions = ''){ function getWikiLink($basepage, $useSecure = false, array $queryOptions = array()){
$url = "http"; //trigger_error("basepage: $basepage");
if($useSecure){ //trigger_error("url encoded: " .urlencode($basepage));
$url .= "s"; $prefix = $useSecure ? "https:" : "http:";
$url = sprintf("%s//en.wikipedia.org/wiki/%s", $prefix, urlencode($basepage));
$first = true;
foreach($queryOptions as $key => $value){
$savekey = urlencode($key);
$savevalue = urlencode($value);
$separator = $first ? '?' : '&';
$url .= "$separator$savekey=$savevalue";
$first = false;
} }

$url .= "://en.wikipedia.org/";

if($queryOptions){
$url .= "w/index.php?title=" . $page . "&" . $queryOptions;
}
else{
$url .= 'wiki/' . $page;
}

return $url; return $url;
} }


Expand Down

0 comments on commit be05b34

Please sign in to comment.