diff --git a/images/README.txt b/images/README.txt new file mode 100644 index 0000000..9742b74 --- /dev/null +++ b/images/README.txt @@ -0,0 +1 @@ +This directory is where any uploads will be stored. \ No newline at end of file diff --git a/index.php b/index.php index 2bb2258..25fd16b 100644 --- a/index.php +++ b/index.php @@ -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"; } @@ -259,10 +259,10 @@ function file_put_contents($n, $d) if ( $action == "edit" ) $html .= "\n"; else - $html .= "

Title:

\n"; + $html .= "

Title:

\n"; if ( $action == "new" ) - $text = ""; + $text = $_REQUEST['newText']; $html .= "

\n"; $html .= "

"; @@ -309,7 +309,10 @@ function file_put_contents($n, $d) if ( move_uploaded_file($_FILES['userfile']['tmp_name'], BASE_PATH . "/images/$dstName") === true ) { - $html = "

File '$dstName' uploaded

\n"; + $html = "

File '$dstName' uploaded
"; + $uploadedName = pathinfo($dstName); + $filename = $uploadedName['filename']; + $html .= "Create a new page with this image in it

"; } else { @@ -339,7 +342,7 @@ function file_put_contents($n, $d) $html .= toHTML($newText); } -/* + else if ( $action == "rename" ) { $html = "
"; @@ -362,15 +365,17 @@ function file_put_contents($n, $d) if ( rename($prevfilename, $filename) ) { + $html = "

Renamed to $pg

\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); + } + } } } } @@ -379,7 +384,7 @@ function file_put_contents($n, $d) $html = "

Error renaming file

\n"; } } -*/ + else if ( $action == "all_name" ) { $dir = opendir(PAGES_PATH); @@ -394,8 +399,9 @@ function file_put_contents($n, $d) $afile = preg_replace("/(.*?)\.txt/", "\\1", $file); $efile = preg_replace("/(.*?)\.txt/", "edit", urlencode($file)); + $rfile = preg_replace("/(.*?)\.txt/", "rename", urlencode($file)); - array_push($filelist, "$afile$efile"); + array_push($filelist, "$afile$efile$rfile"); if ( $color == "#ffffff" ) $color = "#f4f4f4";