add speedie.gq wiki
This commit is contained in:
commit
0843d76b49
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2013 Steven Frank
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
173
config.php
Normal file
173
config.php
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* W2
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2009 Steven Frank <http://stevenf.com/>
|
||||||
|
* Code may be re-used as long as the above copyright notice is retained.
|
||||||
|
* See README.txt for full details.
|
||||||
|
*
|
||||||
|
* Written with Coda: <http://panic.com/coda/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// Site layout settings
|
||||||
|
// --------------------
|
||||||
|
|
||||||
|
// BASE_PATH
|
||||||
|
//
|
||||||
|
// The base system path to W2. You only need to change this if we guess wrong.
|
||||||
|
// You should not use a trailing slash.
|
||||||
|
|
||||||
|
define('BASE_PATH', getcwd());
|
||||||
|
|
||||||
|
// PAGES_PATH
|
||||||
|
//
|
||||||
|
// The path to the raw text documents maintained by W2
|
||||||
|
// You should not use a trailing slash.
|
||||||
|
|
||||||
|
define('PAGES_PATH', BASE_PATH . '/pages');
|
||||||
|
|
||||||
|
// BASE_URI
|
||||||
|
//
|
||||||
|
// The base URI for this W2 installation. You only need to change this if we guess wrong.
|
||||||
|
// You should not use a trailing slash.
|
||||||
|
|
||||||
|
define('BASE_URI', str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']));
|
||||||
|
|
||||||
|
// SELF
|
||||||
|
//
|
||||||
|
// The path component of the URL to the main script, such as: /w2/index.php
|
||||||
|
|
||||||
|
define('SELF', $_SERVER['SCRIPT_NAME']);
|
||||||
|
|
||||||
|
// VIEW
|
||||||
|
//
|
||||||
|
// Needed only if your web server spawns PHP as a CGI instead of an internal module.
|
||||||
|
// For example: define('VIEW', '?action=view&page=');
|
||||||
|
|
||||||
|
define('VIEW', '');
|
||||||
|
|
||||||
|
// DEFAULT_PAGE
|
||||||
|
//
|
||||||
|
// The name of the page to show as the "Home" page.
|
||||||
|
// Value is a string, the title of a page (case-sensitive!)
|
||||||
|
|
||||||
|
define('DEFAULT_PAGE', 'Home');
|
||||||
|
|
||||||
|
// CSS_FILE
|
||||||
|
//
|
||||||
|
// The CSS file to load to style the wiki, relative to BASE_URI
|
||||||
|
|
||||||
|
define('CSS_FILE', 'index.css');
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// File upload settings
|
||||||
|
// --------------------
|
||||||
|
|
||||||
|
// DISABLE_UPLOADS
|
||||||
|
//
|
||||||
|
// Globally enable/disable file uploads
|
||||||
|
|
||||||
|
define('DISABLE_UPLOADS', false);
|
||||||
|
|
||||||
|
// VALID_UPLOAD_TYPES
|
||||||
|
//
|
||||||
|
// Acceptable file types for file uploads. This is a good idea for security.
|
||||||
|
// Value is a comma-separated string of MIME types.
|
||||||
|
|
||||||
|
define('VALID_UPLOAD_TYPES', 'image/jpeg,image/pjpeg,image/png,image/gif,application/pdf,application/zip,application/x-diskcopy');
|
||||||
|
|
||||||
|
// VALID_UPLOAD_EXTS
|
||||||
|
//
|
||||||
|
// Acceptable filename extensions for file uploads
|
||||||
|
// Value is a comma-separated string of filename extensions (case-sensitive!)
|
||||||
|
|
||||||
|
define('VALID_UPLOAD_EXTS', 'jpg,jpeg,png,gif,pdf,zip,dmg');
|
||||||
|
|
||||||
|
// ------------------
|
||||||
|
// Interface settings
|
||||||
|
// ------------------
|
||||||
|
|
||||||
|
// TITLE_DATE
|
||||||
|
//
|
||||||
|
// The format to use when displaying page modification times.
|
||||||
|
// See the manual for the PHP 'date()' function for the specification:
|
||||||
|
// http://php.net/manual/en/function.date.php
|
||||||
|
|
||||||
|
define('TITLE_DATE', 'j-M-Y g:i A');
|
||||||
|
define('TITLE_DATE_NO_TIME', 'j-M-Y');
|
||||||
|
|
||||||
|
// EDIT_ROWS
|
||||||
|
//
|
||||||
|
// Default size of the text editing area in text rows.
|
||||||
|
|
||||||
|
define('EDIT_ROWS', 18);
|
||||||
|
|
||||||
|
// AUTOLINK_PAGE_TITLES
|
||||||
|
//
|
||||||
|
// Automatically converts any page titles appearing in text into links
|
||||||
|
// to the named page. This might degrade performance if you have many
|
||||||
|
// thousands of pages.
|
||||||
|
|
||||||
|
define('AUTOLINK_PAGE_TITLES', false);
|
||||||
|
|
||||||
|
// COLORIZE_MISSING_PAGES
|
||||||
|
//
|
||||||
|
// Automatically highlights as red links, any linked pages which are
|
||||||
|
// not yet written. Existing but blank pages are not colorized. This
|
||||||
|
// might degrade performance if you have thousands of links on a page.
|
||||||
|
|
||||||
|
define('COLORIZE_MISSING_PAGES', true);
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// Security and session settings
|
||||||
|
// -----------------------------
|
||||||
|
|
||||||
|
// REQUIRE_PASSWORD
|
||||||
|
//
|
||||||
|
// Is a password required to access this wiki?
|
||||||
|
|
||||||
|
define('REQUIRE_PASSWORD', false);
|
||||||
|
|
||||||
|
// W2_PASSWORD
|
||||||
|
//
|
||||||
|
// The password for the wiki, if REQUIRE_PASSWORD is true
|
||||||
|
// Replace 'secret' with your password to set your password.
|
||||||
|
|
||||||
|
define('W2_PASSWORD', 'secret');
|
||||||
|
|
||||||
|
// W2_PASSWORD_HASH
|
||||||
|
//
|
||||||
|
// Alternate (more secure) password storage.
|
||||||
|
// To use a hashed password, Comment out the W2_PASSWORD definition above and uncomment
|
||||||
|
// this one, using the result of sha1('your_password') as the value.
|
||||||
|
//
|
||||||
|
// In Mac OS X, you can do this from the Terminal:
|
||||||
|
// echo -n 'your_password' | openssl sha1
|
||||||
|
//
|
||||||
|
// define('W2_PASSWORD_HASH', 'e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4');
|
||||||
|
|
||||||
|
define('W2_PASSWORD_HASH', '');
|
||||||
|
|
||||||
|
// allowedIPs
|
||||||
|
//
|
||||||
|
// A whitelist of IP addresses that are allowed access to the wiki.
|
||||||
|
// If empty, all IPs are allowed.
|
||||||
|
|
||||||
|
$allowedIPs = array();
|
||||||
|
|
||||||
|
// W2_SESSION_LIFETIME
|
||||||
|
//
|
||||||
|
// How long before a login session expires? Default is 30 days
|
||||||
|
|
||||||
|
define('W2_SESSION_LIFETIME', 60 * 60 * 24 * 30);
|
||||||
|
|
||||||
|
// W2_SESSION_NAME
|
||||||
|
//
|
||||||
|
// Name for session (used in the cookie)
|
||||||
|
|
||||||
|
define('W2_SESSION_NAME', 'W2');
|
||||||
|
|
||||||
|
?>
|
184
index.css
Normal file
184
index.css
Normal file
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
* W2
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2011 Steven Frank <http://stevenf.com/>
|
||||||
|
*
|
||||||
|
* Code may be re-used as long as the above copyright notice is retained.
|
||||||
|
* See README.txt for full details.
|
||||||
|
*
|
||||||
|
* Written with Coda: <http://panic.com/coda/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
.main {
|
||||||
|
background-color: #000000;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
font-family: Monospace;
|
||||||
|
font-size: 11px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #6666ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
background-color: #0f070f;
|
||||||
|
margin: 0px 0px 12px 20px;
|
||||||
|
padding-top: 4px 10px 4px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
line-height: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border-top: 1px solid #222222;
|
||||||
|
border-bottom: 0;
|
||||||
|
border-left: 0;
|
||||||
|
border-right: 0;
|
||||||
|
margin-top: 12px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
padding-left: 12px;
|
||||||
|
margin-left: 12px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
list-style-position: inside;
|
||||||
|
}
|
||||||
|
|
||||||
|
ol {
|
||||||
|
margin-left: 12px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding-left: 12px;
|
||||||
|
list-style-position: inside;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 12px 12px 12px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: Monospace, monospace;
|
||||||
|
font-size: 11px;
|
||||||
|
margin-left: 12px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
|
||||||
|
/* stroke each browser so that they wrap lines in the pre tag */
|
||||||
|
white-space: pre-wrap; /* css-3 */
|
||||||
|
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||||
|
white-space: -pre-wrap; /* Opera 4-6 */
|
||||||
|
white-space: -o-pre-wrap; /* Opera 7 */
|
||||||
|
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: Monospace, monospace;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
table, td {
|
||||||
|
background-color: #000000;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
font-family: Monospace, Courier, monospace;
|
||||||
|
font-size: 11px;
|
||||||
|
width: 99%;
|
||||||
|
background-color: #000011;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note {
|
||||||
|
background-color: #000011;
|
||||||
|
padding: 4px;
|
||||||
|
margin: 0 8px 8px 8px;
|
||||||
|
color: #9999bb;
|
||||||
|
border: solid 1px #9999bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titlebar {
|
||||||
|
background-color: #111111;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titledate {
|
||||||
|
font-size: 10px;
|
||||||
|
color: #777777;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar {
|
||||||
|
background-color: #222222;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
font-size: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.tool {
|
||||||
|
font-size: 11px;
|
||||||
|
margin-right: 8px;
|
||||||
|
color: #eeeeee;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.missing-link {
|
||||||
|
color: #ed123e;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
background-color: #111111;
|
||||||
|
color: #ffffff;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
input.tool {
|
||||||
|
font-size: 11px;
|
||||||
|
background-color: #222222;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 50%;
|
||||||
|
height: auto;
|
||||||
|
}
|
555
index.php
Normal file
555
index.php
Normal file
|
@ -0,0 +1,555 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* W2
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2011 Steven Frank <http://stevenf.com/>
|
||||||
|
*
|
||||||
|
* Code may be re-used as long as the above copyright notice is retained.
|
||||||
|
* See README.txt for full details.
|
||||||
|
*
|
||||||
|
* Written with Coda: <http://panic.com/coda/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Install PSR-4-compatible class autoloader
|
||||||
|
spl_autoload_register(function($class){
|
||||||
|
require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Get Markdown class
|
||||||
|
use mdlibs\MarkdownExtra;
|
||||||
|
|
||||||
|
|
||||||
|
// User configurable options:
|
||||||
|
|
||||||
|
include_once "config.php";
|
||||||
|
|
||||||
|
ini_set('session.gc_maxlifetime', W2_SESSION_LIFETIME);
|
||||||
|
|
||||||
|
session_set_cookie_params(W2_SESSION_LIFETIME);
|
||||||
|
session_name(W2_SESSION_NAME);
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if ( count($allowedIPs) > 0 )
|
||||||
|
{
|
||||||
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
$accepted = false;
|
||||||
|
|
||||||
|
foreach ( $allowedIPs as $allowed )
|
||||||
|
{
|
||||||
|
if ( strncmp($allowed, $ip, strlen($allowed)) == 0 )
|
||||||
|
{
|
||||||
|
$accepted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$accepted )
|
||||||
|
{
|
||||||
|
print "<html><body>Access from IP address $ip is not allowed";
|
||||||
|
print "</body></html>";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( REQUIRE_PASSWORD && !isset($_SESSION['password']) )
|
||||||
|
{
|
||||||
|
if ( !defined('W2_PASSWORD_HASH') || W2_PASSWORD_HASH == '' )
|
||||||
|
define('W2_PASSWORD_HASH', sha1(W2_PASSWORD));
|
||||||
|
|
||||||
|
if ( (isset($_POST['p'])) && (sha1($_POST['p']) == W2_PASSWORD_HASH) )
|
||||||
|
$_SESSION['password'] = W2_PASSWORD_HASH;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
|
||||||
|
print "<html>\n";
|
||||||
|
print "<head>\n";
|
||||||
|
print "<link rel=\"apple-touch-icon\" href=\"apple-touch-icon.png\"/>";
|
||||||
|
print "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=false\" />\n";
|
||||||
|
|
||||||
|
print "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . BASE_URI . "/" . CSS_FILE ."\" />\n";
|
||||||
|
print "<title>Log In</title>\n";
|
||||||
|
print "</head>\n";
|
||||||
|
print "<body><form method=\"post\">";
|
||||||
|
print "<input type=\"password\" name=\"p\">\n";
|
||||||
|
print "<input type=\"submit\" value=\"Go\"></form>";
|
||||||
|
print "</body></html>";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support functions
|
||||||
|
|
||||||
|
function _handle_links($match)
|
||||||
|
{
|
||||||
|
$link = $match[1];
|
||||||
|
if ( COLORIZE_MISSING_PAGES ) {
|
||||||
|
$link_page = sanitizeFilename($link);
|
||||||
|
$link_filename = PAGES_PATH . "/$link_page.txt";
|
||||||
|
$link_page_exists = file_exists($link_filename);
|
||||||
|
} else {
|
||||||
|
$link_page_exists = true;
|
||||||
|
}
|
||||||
|
if ($link_page_exists)
|
||||||
|
return "<a href=\"" . SELF . VIEW . "/" . htmlentities($link) . "\">" . htmlentities($link) . "</a>";
|
||||||
|
else
|
||||||
|
return "<a href=\"" . SELF . VIEW . "/" . htmlentities($link) . "\" class=\"missing-link\">" . htmlentities($link) . "</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _handle_images($match)
|
||||||
|
{
|
||||||
|
return "<img src=\"" . BASE_URI . "/images/" . htmlentities($match[1]) . "\" alt=\"" . htmlentities($match[1]) . "\" />";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _handle_message($match)
|
||||||
|
{
|
||||||
|
return "[<a href=\"message:" . htmlentities($match[1]) . "\">email</a>]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function printToolbar()
|
||||||
|
{
|
||||||
|
global $upage, $page, $action;
|
||||||
|
|
||||||
|
print "<div class=\"toolbar\">";
|
||||||
|
print "<a class=\"tool first\" href=\"" . SELF . "?action=edit&page=$upage\">Edit</a> ";
|
||||||
|
print "<a class=\"tool\" href=\"" . SELF . "?action=new\">New</a> ";
|
||||||
|
|
||||||
|
if ( !DISABLE_UPLOADS )
|
||||||
|
print "<a class=\"tool\" href=\"" . SELF . VIEW . "?action=upload\">Upload</a> ";
|
||||||
|
|
||||||
|
print "<a class=\"tool\" href=\"" . SELF . "?action=all_name\">All</a> ";
|
||||||
|
print "<a class=\"tool\" href=\"" . SELF . "?action=all_date\">Recent</a> ";
|
||||||
|
print "<a class=\"tool\" href=\"" . SELF . "\">". DEFAULT_PAGE . "</a>";
|
||||||
|
|
||||||
|
if ( REQUIRE_PASSWORD )
|
||||||
|
print '<a class="tool" href="' . SELF . '?action=logout">Exit</a>';
|
||||||
|
|
||||||
|
print "<form method=\"post\" action=\"" . SELF . "?action=search\">\n";
|
||||||
|
print "<input class=\"tool\" placeholder=\"Search\" size=\"6\" id=\"search\" type=\"text\" name=\"q\" /></form>\n";
|
||||||
|
|
||||||
|
print "</div>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function descLengthSort($val_1, $val_2)
|
||||||
|
{
|
||||||
|
$retVal = 0;
|
||||||
|
|
||||||
|
$firstVal = strlen($val_1);
|
||||||
|
$secondVal = strlen($val_2);
|
||||||
|
|
||||||
|
if ( $firstVal > $secondVal )
|
||||||
|
$retVal = -1;
|
||||||
|
|
||||||
|
else if ( $firstVal < $secondVal )
|
||||||
|
$retVal = 1;
|
||||||
|
|
||||||
|
return $retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toHTML($inText)
|
||||||
|
{
|
||||||
|
global $page;
|
||||||
|
|
||||||
|
$inText = preg_replace("/<[\/]*script>/", "", $inText);
|
||||||
|
|
||||||
|
$dir = opendir(PAGES_PATH);
|
||||||
|
while ( $filename = readdir($dir) )
|
||||||
|
{
|
||||||
|
if ( $filename[0] == '.' )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$filename = preg_replace("/(.*?)\.txt/", "\\1", $filename);
|
||||||
|
$filenames[] = $filename;
|
||||||
|
}
|
||||||
|
closedir($dir);
|
||||||
|
|
||||||
|
uasort($filenames, "descLengthSort");
|
||||||
|
|
||||||
|
if ( AUTOLINK_PAGE_TITLES )
|
||||||
|
{
|
||||||
|
foreach ( $filenames as $filename )
|
||||||
|
{
|
||||||
|
$inText = preg_replace("/(?<![\>\[\/])($filename)(?!\]\>)/im", "<a href=\"" . SELF . VIEW . "/$filename\">\\1</a>", $inText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$inText = preg_replace_callback("/\[\[(.*?)\]\]/", '_handle_links', $inText);
|
||||||
|
$inText = preg_replace_callback("/\{\{(.*?)\}\}/", '_handle_images', $inText);
|
||||||
|
$inText = preg_replace_callback("/message:(.*?)\s/", '_handle_message', $inText);
|
||||||
|
|
||||||
|
$html = MarkdownExtra::defaultTransform($inText);
|
||||||
|
$inText = htmlentities($inText);
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sanitizeFilename($inFileName)
|
||||||
|
{
|
||||||
|
return str_replace(array('..', '~', '/', '\\', ':'), '-', $inFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy_session()
|
||||||
|
{
|
||||||
|
if ( isset($_COOKIE[session_name()]) )
|
||||||
|
setcookie(session_name(), '', time() - 42000, '/');
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
unset($_SESSION["password"]);
|
||||||
|
unset($_SESSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support PHP4 by defining file_put_contents if it doesn't already exist
|
||||||
|
|
||||||
|
if ( !function_exists('file_put_contents') )
|
||||||
|
{
|
||||||
|
function file_put_contents($n, $d)
|
||||||
|
{
|
||||||
|
$f = @fopen($n, "w");
|
||||||
|
|
||||||
|
if ( !$f )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fwrite($f, $d);
|
||||||
|
fclose($f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Support PHP 8.1 by setting two predefined variables to empty strings if
|
||||||
|
// not already defined. Fixes a bunch of deprecation warnings.
|
||||||
|
|
||||||
|
if (!isset($_SERVER["PATH_INFO"]))
|
||||||
|
$_SERVER["PATH_INFO"] = '';
|
||||||
|
if (!isset($_REQUEST['page']))
|
||||||
|
$_REQUEST['page'] = '';
|
||||||
|
|
||||||
|
|
||||||
|
// Main code
|
||||||
|
|
||||||
|
if ( isset($_REQUEST['action']) )
|
||||||
|
$action = $_REQUEST['action'];
|
||||||
|
else
|
||||||
|
$action = 'view';
|
||||||
|
|
||||||
|
// Look for page name following the script name in the URL, like this:
|
||||||
|
// http://stevenf.com/w2demo/index.php/Markdown%20Syntax
|
||||||
|
//
|
||||||
|
// Otherwise, get page name from 'page' request variable.
|
||||||
|
|
||||||
|
if ( preg_match('@^/@', @$_SERVER["PATH_INFO"]) )
|
||||||
|
$page = sanitizeFilename(substr($_SERVER["PATH_INFO"], 1));
|
||||||
|
else
|
||||||
|
$page = sanitizeFilename(@$_REQUEST['page']);
|
||||||
|
|
||||||
|
$upage = urlencode($page);
|
||||||
|
|
||||||
|
if ( $page == "" )
|
||||||
|
$page = DEFAULT_PAGE;
|
||||||
|
|
||||||
|
$filename = PAGES_PATH . "/$page.txt";
|
||||||
|
|
||||||
|
if ( file_exists($filename) )
|
||||||
|
{
|
||||||
|
$text = file_get_contents($filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( $action != "save" && $action != "all_name" && $action != "all_date" && $action != "upload" && $action != "new" && $action != "logout" && $action != "uploaded" && $action != "search" && $action != "view" )
|
||||||
|
{
|
||||||
|
$action = "edit";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $action == "edit" || $action == "new" )
|
||||||
|
{
|
||||||
|
$formAction = SELF . (($action == 'edit') ? "/$page" : "");
|
||||||
|
$html = "<form id=\"edit\" method=\"post\" action=\"$formAction\">\n";
|
||||||
|
|
||||||
|
if ( $action == "edit" )
|
||||||
|
$html .= "<input type=\"hidden\" name=\"page\" value=\"$page\" />\n";
|
||||||
|
else
|
||||||
|
$html .= "<p>Title: <input id=\"title\" type=\"text\" name=\"page\" /></p>\n";
|
||||||
|
|
||||||
|
if ( $action == "new" )
|
||||||
|
$text = "";
|
||||||
|
|
||||||
|
$html .= "<p><textarea id=\"text\" name=\"newText\" rows=\"" . EDIT_ROWS . "\">$text</textarea></p>\n";
|
||||||
|
$html .= "<p><input type=\"hidden\" name=\"action\" value=\"save\" />";
|
||||||
|
$html .= "<input id=\"save\" type=\"submit\" value=\"Save\" />\n";
|
||||||
|
$html .= "<input id=\"cancel\" type=\"button\" onclick=\"history.go(-1);\" value=\"Cancel\" /></p>\n";
|
||||||
|
$html .= "</form>\n";
|
||||||
|
}
|
||||||
|
else if ( $action == "logout" )
|
||||||
|
{
|
||||||
|
destroy_session();
|
||||||
|
header("Location: " . SELF);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else if ( $action == "upload" )
|
||||||
|
{
|
||||||
|
if ( DISABLE_UPLOADS )
|
||||||
|
{
|
||||||
|
$html = "<p>Image uploading has been disabled on this installation.</p>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$html = "<form id=\"upload\" method=\"post\" action=\"" . SELF . "\" enctype=\"multipart/form-data\"><p>\n";
|
||||||
|
$html .= "<input type=\"hidden\" name=\"action\" value=\"uploaded\" />";
|
||||||
|
$html .= "<input id=\"file\" type=\"file\" name=\"userfile\" />\n";
|
||||||
|
$html .= "<input id=\"upload\" type=\"submit\" value=\"Upload\" />\n";
|
||||||
|
$html .= "<input id=\"cancel\" type=\"button\" onclick=\"history.go(-1);\" value=\"Cancel\" />\n";
|
||||||
|
$html .= "</p></form>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( $action == "uploaded" )
|
||||||
|
{
|
||||||
|
if ( !DISABLE_UPLOADS )
|
||||||
|
{
|
||||||
|
$dstName = sanitizeFilename($_FILES['userfile']['name']);
|
||||||
|
$fileType = $_FILES['userfile']['type'];
|
||||||
|
preg_match('/\.([^.]+)$/', $dstName, $matches);
|
||||||
|
$fileExt = isset($matches[1]) ? $matches[1] : null;
|
||||||
|
|
||||||
|
if (in_array($fileType, explode(',', VALID_UPLOAD_TYPES)) &&
|
||||||
|
in_array($fileExt, explode(',', VALID_UPLOAD_EXTS)))
|
||||||
|
{
|
||||||
|
$errLevel = error_reporting(0);
|
||||||
|
|
||||||
|
if ( move_uploaded_file($_FILES['userfile']['tmp_name'],
|
||||||
|
BASE_PATH . "/images/$dstName") === true )
|
||||||
|
{
|
||||||
|
$html = "<p class=\"note\">File '$dstName' uploaded</p>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$html = "<p class=\"note\">Upload error</p>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
error_reporting($errLevel);
|
||||||
|
} else {
|
||||||
|
$html = "<p class=\"note\">Upload error: invalid file type</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= toHTML($text);
|
||||||
|
}
|
||||||
|
else if ( $action == "save" )
|
||||||
|
{
|
||||||
|
$newText = $_REQUEST['newText'];
|
||||||
|
|
||||||
|
$errLevel = error_reporting(0);
|
||||||
|
$success = file_put_contents($filename, $newText);
|
||||||
|
error_reporting($errLevel);
|
||||||
|
|
||||||
|
if ( $success )
|
||||||
|
$html = "<p class=\"note\">Saved</p>\n";
|
||||||
|
else
|
||||||
|
$html = "<p class=\"note\">Error saving changes! Make sure your web server has write access to " . PAGES_PATH . "</p>\n";
|
||||||
|
|
||||||
|
$html .= toHTML($newText);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
else if ( $action == "rename" )
|
||||||
|
{
|
||||||
|
$html = "<form id=\"rename\" method=\"post\" action=\"" . SELF . "\">";
|
||||||
|
$html .= "<p>Title: <input id=\"title\" type=\"text\" name=\"page\" value=\"" . htmlspecialchars($page) . "\" />";
|
||||||
|
$html .= "<input id=\"rename\" type=\"submit\" value=\"Rename\">";
|
||||||
|
$html .= "<input id=\"cancel\" type=\"button\" onclick=\"history.go(-1);\" value=\"Cancel\" />\n";
|
||||||
|
$html .= "<input type=\"hidden\" name=\"action\" value=\"renamed\" />";
|
||||||
|
$html .= "<input type=\"hidden\" name=\"prevpage\" value=\"" . htmlspecialchars($page) . "\" />";
|
||||||
|
$html .= "</p></form>";
|
||||||
|
}
|
||||||
|
else if ( $action == "renamed" )
|
||||||
|
{
|
||||||
|
$pp = $_REQUEST['prevpage'];
|
||||||
|
$pg = $_REQUEST['page'];
|
||||||
|
|
||||||
|
$prevpage = sanitizeFilename($pp);
|
||||||
|
$prevpage = urlencode($prevpage);
|
||||||
|
|
||||||
|
$prevfilename = PAGES_PATH . "/$prevpage.txt";
|
||||||
|
|
||||||
|
if ( rename($prevfilename, $filename) )
|
||||||
|
{
|
||||||
|
// Success. Change links in all pages to point to new page
|
||||||
|
if ( $dh = opendir(PAGES_PATH) )
|
||||||
|
{
|
||||||
|
while ( ($file = readdir($dh)) !== false )
|
||||||
|
{
|
||||||
|
$content = file_get_contents($file);
|
||||||
|
$pattern = "/\[\[" . $pp . "\]\]/g";
|
||||||
|
preg_replace($pattern, "[[$pg]]", $content);
|
||||||
|
file_put_contents($file, $content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$html = "<p class=\"note\">Error renaming file</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
else if ( $action == "all_name" )
|
||||||
|
{
|
||||||
|
$dir = opendir(PAGES_PATH);
|
||||||
|
$filelist = array();
|
||||||
|
|
||||||
|
$color = "#ffffff";
|
||||||
|
|
||||||
|
while ( $file = readdir($dir) )
|
||||||
|
{
|
||||||
|
if ( $file[0] == "." )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$afile = preg_replace("/(.*?)\.txt/", "<a href=\"" . SELF . VIEW . "/\\1\">\\1</a>", $file);
|
||||||
|
$efile = preg_replace("/(.*?)\.txt/", "<a href=\"?action=edit&page=\\1\">edit</a>", urlencode($file));
|
||||||
|
|
||||||
|
array_push($filelist, "<tr style=\"background-color: $color;\"><td>$afile</td><td width=\"20\"></td><td>$efile</td></tr>");
|
||||||
|
|
||||||
|
if ( $color == "#ffffff" )
|
||||||
|
$color = "#f4f4f4";
|
||||||
|
else
|
||||||
|
$color = "#ffffff";
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dir);
|
||||||
|
|
||||||
|
natcasesort($filelist);
|
||||||
|
|
||||||
|
$html = "<table>";
|
||||||
|
|
||||||
|
|
||||||
|
for ($i = 0; $i < count($filelist); $i++)
|
||||||
|
{
|
||||||
|
$html .= $filelist[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= "</table>\n";
|
||||||
|
}
|
||||||
|
else if ( $action == "all_date" )
|
||||||
|
{
|
||||||
|
$html = "<table>\n";
|
||||||
|
$dir = opendir(PAGES_PATH);
|
||||||
|
$filelist = array();
|
||||||
|
while ( $file = readdir($dir) )
|
||||||
|
{
|
||||||
|
if ( $file[0] == "." )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$filelist[preg_replace("/(.*?)\.txt/", "<a href=\"" . SELF . VIEW . "/\\1\">\\1</a>", $file)] = filemtime(PAGES_PATH . "/$file");
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dir);
|
||||||
|
|
||||||
|
$color = "#ffffff";
|
||||||
|
arsort($filelist, SORT_NUMERIC);
|
||||||
|
|
||||||
|
foreach ($filelist as $key => $value)
|
||||||
|
{
|
||||||
|
$html .= "<tr style=\"background-color: $color;\"><td valign=\"top\">$key</td><td width=\"20\"></td><td valign=\"top\"><nobr>" . date(TITLE_DATE_NO_TIME, $value) . "</nobr></td></tr>\n";
|
||||||
|
|
||||||
|
if ( $color == "#ffffff" )
|
||||||
|
$color = "#f4f4f4";
|
||||||
|
else
|
||||||
|
$color = "#ffffff";
|
||||||
|
}
|
||||||
|
$html .= "</table>\n";
|
||||||
|
}
|
||||||
|
else if ( $action == "search" )
|
||||||
|
{
|
||||||
|
$matches = 0;
|
||||||
|
$q = $_REQUEST['q'];
|
||||||
|
$html = "<h1>Search: $q</h1>\n<ul>\n";
|
||||||
|
|
||||||
|
if ( trim($q) != "" )
|
||||||
|
{
|
||||||
|
$dir = opendir(PAGES_PATH);
|
||||||
|
|
||||||
|
while ( $file = readdir($dir) )
|
||||||
|
{
|
||||||
|
if ( $file[0] == "." )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$text = file_get_contents(PAGES_PATH . "/$file");
|
||||||
|
|
||||||
|
if ( preg_match("/{$q}/i", $text) || preg_match("/{$q}/i", $file) )
|
||||||
|
{
|
||||||
|
++$matches;
|
||||||
|
$file = preg_replace("/(.*?)\.txt/", "<a href=\"" . SELF . VIEW . "/\\1\">\\1</a>", $file);
|
||||||
|
$html .= "<li>$file</li>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= "</ul>\n";
|
||||||
|
$html .= "<p>$matches matched</p>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$html = toHTML($text);
|
||||||
|
}
|
||||||
|
|
||||||
|
$datetime = '';
|
||||||
|
|
||||||
|
if ( ($action == "all_name") || ($action == "all_date"))
|
||||||
|
$title = "All Pages";
|
||||||
|
|
||||||
|
else if ( $action == "upload" )
|
||||||
|
$title = "Upload Image";
|
||||||
|
|
||||||
|
else if ( $action == "new" )
|
||||||
|
$title = "New";
|
||||||
|
|
||||||
|
else if ( $action == "search" )
|
||||||
|
$title = "Search";
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$title = $page;
|
||||||
|
|
||||||
|
if ( TITLE_DATE )
|
||||||
|
{
|
||||||
|
$datetime = "<span class=\"titledate\">" . date(TITLE_DATE, @filemtime($filename)) . "</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable caching on the client (the iPhone is pretty agressive about this
|
||||||
|
// and it can cause problems with the editing function)
|
||||||
|
|
||||||
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
||||||
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||||
|
|
||||||
|
print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
|
||||||
|
print "<html>\n";
|
||||||
|
print "<head>\n";
|
||||||
|
print "<link rel=\"apple-touch-icon\" href=\"apple-touch-icon.png\"/>";
|
||||||
|
print "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=false\" />\n";
|
||||||
|
|
||||||
|
print "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . BASE_URI . "/" . CSS_FILE ."\" />\n";
|
||||||
|
print "<title>$title</title>\n";
|
||||||
|
print "</head>\n";
|
||||||
|
print "<body>\n";
|
||||||
|
print "<div class=\"titlebar\">$title <span style=\"font-weight: normal;\">$datetime</span></div>\n";
|
||||||
|
|
||||||
|
printToolbar();
|
||||||
|
|
||||||
|
print "<div class=\"main\">\n";
|
||||||
|
print "$html\n";
|
||||||
|
print "</div>\n";
|
||||||
|
|
||||||
|
print "</body>\n";
|
||||||
|
print "</html>\n";
|
||||||
|
|
||||||
|
?>
|
10
mdlibs/Markdown.inc.php
Normal file
10
mdlibs/Markdown.inc.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Use this file if you cannot use class autoloading. It will include all the
|
||||||
|
// files needed for the Markdown parser.
|
||||||
|
//
|
||||||
|
// Take a look at the PSR-0-compatible class autoloading implementation
|
||||||
|
// in the Readme.php file if you want a simple autoloader setup.
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||||
|
require_once dirname(__FILE__) . '/Markdown.php';
|
1889
mdlibs/Markdown.php
Normal file
1889
mdlibs/Markdown.php
Normal file
File diff suppressed because it is too large
Load diff
11
mdlibs/MarkdownExtra.inc.php
Normal file
11
mdlibs/MarkdownExtra.inc.php
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Use this file if you cannot use class autoloading. It will include all the
|
||||||
|
// files needed for the MarkdownExtra parser.
|
||||||
|
//
|
||||||
|
// Take a look at the PSR-0-compatible class autoloading implementation
|
||||||
|
// in the Readme.php file if you want a simple autoloader setup.
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||||
|
require_once dirname(__FILE__) . '/Markdown.php';
|
||||||
|
require_once dirname(__FILE__) . '/MarkdownExtra.php';
|
1870
mdlibs/MarkdownExtra.php
Normal file
1870
mdlibs/MarkdownExtra.php
Normal file
File diff suppressed because it is too large
Load diff
9
mdlibs/MarkdownInterface.inc.php
Normal file
9
mdlibs/MarkdownInterface.inc.php
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Use this file if you cannot use class autoloading. It will include all the
|
||||||
|
// files needed for the MarkdownInterface interface.
|
||||||
|
//
|
||||||
|
// Take a look at the PSR-0-compatible class autoloading implementation
|
||||||
|
// in the Readme.php file if you want a simple autoloader setup.
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
38
mdlibs/MarkdownInterface.php
Normal file
38
mdlibs/MarkdownInterface.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Markdown - A text-to-HTML conversion tool for web writers
|
||||||
|
*
|
||||||
|
* @package php-markdown
|
||||||
|
* @author Michel Fortin <michel.fortin@michelf.com>
|
||||||
|
* @copyright 2004-2021 Michel Fortin <https://michelf.com/projects/php-markdown/>
|
||||||
|
* @copyright (Original Markdown) 2004-2006 John Gruber <https://daringfireball.net/projects/markdown/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace mdlibs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Markdown Parser Interface
|
||||||
|
*/
|
||||||
|
interface MarkdownInterface {
|
||||||
|
/**
|
||||||
|
* Initialize the parser and return the result of its transform method.
|
||||||
|
* This will work fine for derived classes too.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function defaultTransform($text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main function. Performs some preprocessing on the input text
|
||||||
|
* and pass it through the document gamut.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function transform($text);
|
||||||
|
}
|
3
mktree.sh
Executable file
3
mktree.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
URL="https://codeberg.org/speedie/speedwm/raw/branch/master"
|
||||||
|
tree -I md5 -f --noreport --charset ascii | grep -vE "profiles|metadata|md5|Manifest|README|xml|repo_name|conf|directories|push|tree|LICENSE" | sed -e 's/| \+/ /g' -e 's/[|`]-\+/ */g' -e 's:\(* \)\(\(.*/\)\([^/]\+\)\):\1[\4](\2):g' | tail -n+2 | sed "s|]([.]|](${URL}|g"
|
4
pages/Home.txt
Normal file
4
pages/Home.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Welcome to the speedie.gq wiki!
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
Welcome to the very much work in progress speedie.gq wiki!
|
Loading…
Reference in a new issue