all: style.css tags
+init: files cms_images all
+
+files:
+ mkdir -m 777 $@
+
+cms_images:
+ mkdir -m 777 $@
+
tags: *.php code/*.php code/wfpl/*.php
exuberant-ctags *.php code/*.php code/wfpl/*.php
<html lang="en">
<head>
- <title><!--~$title show {~-->~this_host~ Administration<!--~}~--></title>
+ <title><!--~$title show {~-->~$host~ Administration<!--~}~--></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<!--~$body show {~-->
- <h2>~this_host~ Administration</h2>
+ <h2>~$host~ Administration</h2>
- <p><a href="admin_images">Upload/edit images</a></p>
+ <p><a href="admin_images">Manage images</a></p>
- <p><a href="admin_pages">Add/edit pages</a></p>
+ <p><a href="admin_pages">Manage pages</a></p>
+
+ <p><a href="admin_files">Manage (downloadable) files</a></p>
<p><a href="logout">Log out</a></p>
<!--~}~-->
$_REQUEST['url'] = this_url();
return 'admin_login';
}
- tem_set('this_host', this_host());
}
<form action="admin_files" method="post" enctype="multipart/form-data"><!--~id {~--><div style="display: none"><input type="hidden" name="edit_id" value="~id attr~"></div><!--~}~--><input type="hidden" name="MAX_FILE_SIZE" value="~upload_max_filesize~">
- <div class="caption">Filename</div>
+ <div class="caption">File</div>
<div class="field"><input type="file" name="filename"><input type="hidden" name="old_filename" value="~filename attr~"></div>
- <div class="caption">Description</div>
+ <div class="caption">Description (optional)</div>
+ <div class="field_notes">The files admin page sorts by this, so you can find your files.</div>
<div class="field"><input type="text" name="description" value="~description attr~"></div>
<div class="caption"> </div>
<h2>Files Listing</h2>
<!--~listings once_if {~-->
+ <p>The value in the "Path" column below can be pasted into the "URL" field of the link dialog on the page editor. Be sure to set the "protocol" pulldown there to "other". To link to a file from any other website (or e-mail, etc) create the full address by prefixing it with "http://~$host~"</p>
+
<p><a href="admin_files?new=1">[Add a new file]</a></p>
<table cellspacing="0" cellpadding="4" border="1" summary="">
- <tr><th>Filename</th><th>Description</th><th> </th></tr><!--~listings {~-->
+ <tr><th>Path</th><th>Description</th><th> </th></tr><!--~listings {~-->
<tr>
- <td class="listing"><a href="admin_files?edit_id=~id~">~filename html~<!--~filename empty {~--><em>(blank)</em><!--~}~--></a></td>
+ <td class="listing"><a href="admin_files?edit_id=~id~">/~filename html~<!--~filename empty {~--><em>(blank)</em><!--~}~--></a></td>
<td class="listing"><a href="admin_files?edit_id=~id~">~description html~<!--~description empty {~--><em>(blank)</em><!--~}~--></a></td>
<td><a href="admin_files?admin_files_delete_id=~id~" onclick="return confirm('Permanently delete?')">[delete this file]</a></td>
</tr><!--~}~-->
# Set this to the path to your uploads directory. It can be relative to the
# location of this script. IT MUST END WITH A SLASH
-$GLOBALS['upload_directory'] = 'uploads/';
+$GLOBALS['upload_directory'] = 'files/';
-$GLOBALS['filename_file_name'] = uniqid() . getmypid() . '.txt'; # comment this out to use uploader's filename
+# emergency backup in case uploaders file name is blank somehow
+$GLOBALS['filename_file_name'] = uniqid() . getmypid() . '.txt';
require_once('code/wfpl/format.php');
$data['description'] = format_oneline(_REQUEST_cut('description'));
- $filename_filename_tmp = $GLOBALS['filename_file_name'];
+ #header('Content-Type: text/plain');
+ #print_r(array($_REQUEST['filename'], $_FILES['filename']));
+ #exit();
+ $filename_filename_tmp = format_filename($_FILES['filename']['name']);
if(!$filename_filename_tmp) {
- $filename_filename_tmp = format_filename(_REQUEST_cut('filename'));
+ $filename_filename_tmp = $GLOBALS['filename_file_name'];
}
if($_FILES['filename'] && $_FILES['filename']['error'] == 0) {
$data['filename'] = save_uploaded_file('filename', $GLOBALS['upload_directory'] . $filename_filename_tmp);
}
function admin_files_main_listing() {
- $listing_rows = db_get_assocs('files', 'id,filename,description', 'order by description limit 100');
+ $listing_rows = db_get_assocs('files', 'id,filename,description', 'order by coalesce(nullif(description, ""), substring(filename, 7)) limit 100');
tem_set('listings', $listing_rows);
}
<html>
<head>
- <title><!--~$title show {~-->~this_host~ Admin Login<!--~}~--></title>
+ <title><!--~$title show {~-->~$host~ Admin Login<!--~}~--></title>
</head>
<body>
<!--~$body show {~-->
<!--~form {~-->
- <h2>~this_host~ Admin Login</h2>
+ <h2>~$host~ Admin Login</h2>
<form action="admin_login" method="post">
<div class="caption">Username (case sensitive)</div>
# Don't put (even failed) password back into the form
$data['password'] = '';
- # include domain name in title (especially for bookmarks) and header
- tem_set('this_host', this_host());
-
# display the form [again]
tem_set('form', $data);
}
<html lang="en">
<head>
<meta charset="utf-8" />
- <title><!--~$title show {~-->~this_host~ Admin: <!--~listings {~-->Pages Listing<!--~}~--><!--~form {~--><!--~id {~-->Add a new page<!--~}~--><!--~id unset {~-->Edit page "~title html~"<!--~}~--><!--~}~--><!--~}~--></title>
+ <title><!--~$title show {~-->~$host~ Admin: <!--~listings {~-->Pages Listing<!--~}~--><!--~form {~--><!--~id {~-->Add a new page<!--~}~--><!--~id unset {~-->Edit page "~title html~"<!--~}~--><!--~}~--><!--~}~--></title>
<!--~$head {~-->
<script type="text/javascript" src="code/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
return 'admin_login';
}
- tem_set('this_host', this_host());
-
$id = _REQUEST_cut('edit_id');
if($id) {
return admin_pages_main_form($id);
<?php
function cms_display($basename, &$tem) {
+ $tem->set('$host', this_host());
$nav_items = db_get_assocs('cms_pages', "coalesce(nullif(nav_title,''), title) as title,filename", 'where navbar!=0 order by navbar');
if($nav_items) {
foreach($nav_items as &$nav_item) {