Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions images/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory is where any uploads will be stored.
36 changes: 21 additions & 15 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function file_put_contents($n, $d)
}
else
{
if ( $action != "save" && $action != "all_name" && $action != "all_date" && $action != "upload" && $action != "new" && $action != "logout" && $action != "uploaded" && $action != "search" && $action != "view" )
if ( $action != "save" && $action != "all_name" && $action != "all_date" && $action != "upload" && $action != "new" && $action != "logout" && $action != "uploaded" && $action != "search" && $action != "view" && $action != "rename" && $action != "renamed" )
{
$action = "edit";
}
Expand All @@ -259,10 +259,10 @@ function file_put_contents($n, $d)
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";
$html .= "<p>Title: <input id=\"title\" type=\"text\" name=\"page\" value='".$_REQUEST['title']."' /></p>\n";

if ( $action == "new" )
$text = "";
$text = $_REQUEST['newText'];

$html .= "<p><textarea id=\"text\" name=\"newText\" rows=\"" . EDIT_ROWS . "\">$text</textarea></p>\n";
$html .= "<p><input type=\"hidden\" name=\"action\" value=\"save\" />";
Expand Down Expand Up @@ -309,7 +309,10 @@ function file_put_contents($n, $d)
if ( move_uploaded_file($_FILES['userfile']['tmp_name'],
BASE_PATH . "/images/$dstName") === true )
{
$html = "<p class=\"note\">File '$dstName' uploaded</p>\n";
$html = "<p class=\"note\">File '$dstName' uploaded<br />";
$uploadedName = pathinfo($dstName);
$filename = $uploadedName['filename'];
$html .= "<a href='?action=new&newText=![$filename](".BASE_URI."/images/$dstName)&title=$filename'>Create a new page with this image in it</a></p>";
}
else
{
Expand Down Expand Up @@ -339,7 +342,7 @@ function file_put_contents($n, $d)

$html .= toHTML($newText);
}
/*

else if ( $action == "rename" )
{
$html = "<form id=\"rename\" method=\"post\" action=\"" . SELF . "\">";
Expand All @@ -362,15 +365,17 @@ function file_put_contents($n, $d)

if ( rename($prevfilename, $filename) )
{
$html = "<p class=\"note\">Renamed to <a href='" . SELF . VIEW . "/$pg'>$pg</a></p>\n";
// 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);
if ( $dh = opendir(PAGES_PATH) ) {
while ( ($file = readdir($dh)) !== false ) {
if ($file != "." && $file != "..") {
$content = file_get_contents(PAGES_PATH.'/'.$file);
if (stripos($content, "[[$pp]]") !== false) {
$content = str_ireplace("[[$pp]]", "[[$pg]]", $content);
file_put_contents(PAGES_PATH.'/'.$file, $content);
}
}
}
}
}
Expand All @@ -379,7 +384,7 @@ function file_put_contents($n, $d)
$html = "<p class=\"note\">Error renaming file</p>\n";
}
}
*/

else if ( $action == "all_name" )
{
$dir = opendir(PAGES_PATH);
Expand All @@ -394,8 +399,9 @@ function file_put_contents($n, $d)

$afile = preg_replace("/(.*?)\.txt/", "<a href=\"" . SELF . VIEW . "/\\1\">\\1</a>", $file);
$efile = preg_replace("/(.*?)\.txt/", "<a href=\"?action=edit&amp;page=\\1\">edit</a>", urlencode($file));
$rfile = preg_replace("/(.*?)\.txt/", "<a href=\"?action=rename&amp;page=\\1\">rename</a>", urlencode($file));

array_push($filelist, "<tr style=\"background-color: $color;\"><td>$afile</td><td width=\"20\"></td><td>$efile</td></tr>");
array_push($filelist, "<tr style=\"background-color: $color;\"><td>$afile</td><td width=\"20\"></td><td>$efile</td><td>$rfile</td></tr>");

if ( $color == "#ffffff" )
$color = "#f4f4f4";
Expand Down