Page Menu
Home
Wolfplex
Search
Configure Global Search
Log In
Files
F408386
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/pads/index.php b/pads/index.php
index f885160..aab475a 100644
--- a/pads/index.php
+++ b/pads/index.php
@@ -1,58 +1,58 @@
<?php
require '../_includes/core.php';
require '../_includes/SecurityData.php';
/**
* Gets the pads
*
* @return Array the pads list
*/
function get_pads () {
//Queries API
$apiUrl = "http://pad.wolfplex.be/api/1.2.1/listAllPads";
$key = SecurityData::getSecret('etherpad.api.key');
$url = $apiUrl . "?apikey=" . $key;
try {
$api_reply = json_decode(file_get_contents($url));
} catch (ErrorException $ex) {
//Logs error, but removes sensitive information
$errorMessage = str_replace($url, "$apiUrl?…", $ex->getMessage());
Logger::getLogger("pads")->fatal($errorMessage);
return [];
}
//Check reply sanity
- if (!property_exists('code', $api_reply)) {
+ if (!property_exists($api_reply, 'code')) {
Logger::getLogger("pads")->fatal("Unexpected API reply.");
return [];
}
if ($api_reply->code === 0) {
return $api_reply->data->padIDs;
}
//If an error occurs, we log the error and returns an empty array instead.
Logger::getLogger("pads")->fatal("API fatal error: $api_reply->message");
return [];
}
$format = array_key_exists('format', $_GET) ? $_GET['format'] : '';
switch ($format) {
case "":
case "json":
echo json_encode(get_pads());
break;
case "raw":
echo implode("\n", get_pads());
break;
case "txt":
header("Content-Type: text/plain");
foreach (get_pads() as $pad) {
echo "* $pad\n";
}
break;
default:
die("Unknown format: $format");
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Jun 9, 12:04 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
46265
Default Alt Text
(1 KB)
Attached To
rAPI Wolfplex API
Event Timeline
Log In to Comment