Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #9 from martijnhoekstra/escaped_usernames

refactored getWikiLink
  • Loading branch information...
commit be05b34782fda5c611adbad0217ace14ed950fea 2 parents d6d92c6 + b35e56b
@cdhowie cdhowie authored
View
6 public_html/appeal.php
@@ -319,11 +319,11 @@ function hideContextWindow() {
<ul>
<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("Special:Log/block", $user->getUseSecure(), "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: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(), 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: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>
</div>
Request timestamp: <?php echo $appeal->getTimestamp(); ?><br>
View
6 public_html/src/statsLib.php
@@ -85,7 +85,7 @@ function printAppealList(array $criteria = array(), $limit = "", $orderby = "",
$requests .= "\t<tr>\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: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) {
$requests .= "\t\t<td>" . $data['timestamp'] . "</td>\n";
}
@@ -188,7 +188,7 @@ function printRecentClosed() {
$requests .= "\t<tr>\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: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</tr>\n";
}
@@ -252,7 +252,7 @@ function printBacklog() {
$requests .= "\t<tr>\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: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</tr>\n";
}
View
30 public_html/src/unblocklib.php
@@ -241,24 +241,22 @@ function connectToDB($suppressOutput = false){
* Returns a URL to the given page on the English Wikipedia.
* @param String $page the page to link to, including namespace
* @param boolean $useSecure true to use the secure server
- * @param String $queryOptions query options, such as used on some log pages,
- * separated by (but not starting with) &'s.
+ * @param array $queryOptions query options, such as used on some log pages,
+ * as an associative array.
*/
-function getWikiLink($page, $useSecure = false, $queryOptions = ''){
- $url = "http";
- if($useSecure){
- $url .= "s";
+function getWikiLink($basepage, $useSecure = false, array $queryOptions = array()){
+ //trigger_error("basepage: $basepage");
+ //trigger_error("url encoded: " .urlencode($basepage));
+ $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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.