// For each pad in the object // This should really be ordered based on last modified $padname = explode("\$", $pad); $padname = $padname[1]; $padContents = $instance->getText($pad); // Get the pad contents $contents = $padContents->text; $pad = urlencode($pad); echo "<div class='pad'>"; echo "<h1><a href={$host}/p/{$pad}>{$padname}</a></h1>"; echo " - <h2><a onClick='\$(\"#contents{$count}\").slideDown();'>Preview</a></h2><br/>"; echo "<div class='contents' id=contents{$count}>{$contents}</div>"; echo "<h3><a href=/users.php?action=deletePad&name={$pad}>Delete Pad</a></h3>"; echo "<h3><a href={$host}/p/{$pad}>Edit Pad</a></h3>"; $readOnlyID = $instance->getReadOnlyID($pad); $readOnlyID = $readOnlyID->readOnlyID; echo "<h3><a href={$host}/ro/{$readOnlyID}>Read only view</a>"; $getpublicStatus = $instance->getPublicStatus($pad); // get Security status of the pad if ($getpublicStatus->publicStatus === false) { echo "<h3><a href=/users.php?action=makePublic&name={$pad}>Make pad public</a></h3>"; } else { echo "<h3><a href=/users.php?action=makePrivate&name={$pad}>Make pad private</a></h3>"; } echo "</div>"; $count++; } echo "</div>"; ?> </body>
try { $instance->createPad('testPad', 'Hello world'); } catch (Exception $e) { // the pad already exists or something else went wrong echo "Failed with message " . $e->getMessage(); } /* Example: Get Ready Only ID of a pad */ try { $readOnlyID = $instance->getReadOnlyID('testPad'); echo "The read only ID of this pad is: {$readOnlyID->readOnlyID}\n\n"; } catch (Exception $e) { echo "\n\ngetReadOnlyID Failed with message " . $e->getMessage(); } /* Example: Get Public Status of a pad and include some logic -- This only works for group pads */ try { $getpublicStatus = $instance->getPublicStatus('testPad'); if ($getpublicStatus->publicStatus === false) { echo "This Pad is not public\n\n"; } else { echo "This Pad is public\n\n"; } } catch (Exception $e) { // the pad already exists or something else went wrong echo "\n\ngetPublicStatus Failed with message " . $e->getMessage(); } /* Example: Set Public Status of a pad -- This only works for group pads */ try { $instance->setPublicStatus('testPad', true); // true or false } catch (Exception $e) { // the pad already exists or something else went wrong
$tags = array(); foreach ($pads->padIDs as $padID) { $parts = explode('$', $padID); $padname = $parts[1]; $delQuery .= " AND pad_name<>" . $db->quote($padname); //cache content $result = $instance->getText($padID); $fn = DATA_DIR . "/index/" . urlencode($group) . "/" . urlencode($padname) . ".txt"; @mkdir(DATA_DIR . "/index"); @mkdir(dirname($fn)); file_put_contents($fn, $result->text); if ($verbose) { echo "."; } $insertQ->execute(array($group, $groupID, $padname, isset($passwords[$padID]) ? $passwords[$padID] : null, isset($shortlinks[$padID]) ? $shortlinks[$padID] : null)); $tmpTimest = $instance->getLastEdited($padID); $tmpPublic = $instance->getPublicStatus($padID); $updateQ->execute(array($groupID, floor($tmpTimest->lastEdited / 1000), $tmpPublic->publicStatus ? 1 : 0, $group, $padname)); $getTagsQ->execute(array($group, $padname)); $tagstr = trim($getTagsQ->fetchColumn()); if ($tagstr) { $thistags = explode(" ", $tagstr); $tags = array_merge($tags, $thistags); } } $db->exec($delQuery); $insertGroupQ->execute(array($group, $groupID, implode(" ", array_unique($tags)))); if ($verbose) { echo " OK \n"; } }