Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

WebAdmin

Summary: PHP file manager, works without ftp client
Version: 1.1, 9 November 2006
Prerequisites:
Status:
Maintainer:
Category: Administration CMS

Question(s)

  • On my host, I cannot handle with FTP the files created by PHP modules, what can I do?
  • How can I delete/rename attachments?
  • Can I edit my wiki's configuration from a remote machine without downloading and re-uploading with FTP?

Answer

You can use webadmin.phpΔ.

webadmin is a complete file manager written in PHP with which you can manage your files on the server without needing a FTP client.

You can edit/rename/move/delete/upload files and directories according to the permissions settings of the server - which with a standard PmWiki installation, will mean that you can view all files, and perform operations on the files in the wiki.d and uploads directories.

Since it is a PHP script it will be able to manage files created by other PHP scripts (including PmWiki) which may not be accessible with FTP (and viceversa).


Notes

Installation:

On a wiki that is not using cleanURLs:

Download the script from above and place it in your cookbook directory. Then add include_once("$FarmD/cookbook/webadmin.php"); in your local configuration (local/config.php).

On a wiki using cleanURLs

Download the script from above and place it in your cookbook directory.
You will need to disable cleanURLs on one page of the wiki -- usually one requiring an admin-level password to read -- and place a link on that page that will trigger an ?action=webadmin, so use something like [[{$Name}?action=webadmin | Web Admin]].
Option 1: To disable cleanURLs for the chosen page, and install the WebAdmin recipe, place the following in your local configuration (local/config.php):
  // WebAdmin - http://www.pmwiki.org/wiki/Cookbook/WebAdmin
  // On the second line of code below, replace "Groupname" and "Pagename" with 
  // the group and page you've chosen to use for your Web Admin form
  $pagename = ResolvePageName($pagename);
  if ($pagename == 'Groupname.Pagename') {  
    $EnablePathInfo = 0;
    $WebAdminHomeDir="$FarmD/cookbook/";
    include_once("$FarmD/cookbook/webadmin.php");
  }
Option 2: To disable cleanURLs for the chosen page, create a local php file corresponding to that page, using the file to disable cleanURLs for the page. So if the page you've chosen for the ?action=webadmin link, described above, is -- say -- Site.WebAdmin, then create a text-file local/Site.WebAdmin.php, containing only:
  <?php
    $EnablePathInfo = 0;
(Option 2, continued) In your local configuration (local/config.php), place
  include_once("$FarmD/cookbook/webadmin.php");

Configuration:

You may give a value to the following variables before including the script to configure some aspects of the webadmin:
$WebAdminAction can be used to change the action used by the script (default is 'webadmin').
ex. $WebAdminAction = 'webadmin';
$WebAdminAuthLevel can be used to change the authorization level necessary to use the script (default is 'admin'). Please note that who uses the script can be able to add/edit/delete files and directories on the server (according to file permissions).
ex. $WebAdminAuthLevel = 'edit';
$WebAdminHomeDir can be used to configure the home directory to which the script is positioned at the beginning (default is './', which is the same directory where is pmwiki.php).
ex. $WebAdminHomeDir = './pub/';
$WebAdminLanguage can be used to configure the language in which the script displays its interface.
Available languages: 'en' (English), 'de' (German), 'fr' (French), 'it' (Italian), 'nl' (Dutch), 'se' (Swedish), 'sp' (Spanish), 'dk' (Danish), 'tr' (Turkish), 'cs' (Czech), 'ru' (Russian).
Default is 'auto': language is selected automatically by checking the accepted languages of the browser.
ex. $WebAdminLanguage = 'it';

Use:

Just add ?action=webadmin to the URL to use the file manager.

i18n:

The script retains its original internationalization system which is different from PmWiki's one. See the configuration section for more information.

Screenshot:

  • This recipe was last tested on PmWiki version: 2.1.beta17
  • This recipe requires at least PmWiki version: 2.0?

Releases

  • 0.1 - 11.12.2005
    • First adaptation and testing.
  • 1.0 - 03.01.2006
    • Public release.
  • 1.1 - 09.11.2006

Comments - in date order

2012-08-15 - It would be nice if the starting path could be passed in. That way I could provide links to start in /uploads/GroupName/.

May 21, 2007 - Using $EnablePathInfo = 1; in config.php still breaks this recipe. I am using pmwiki-2.2.0-beta47 and enabling $EnablePathInfo = 1; (clean url's) causes errors when changing directories with webadmin. Disabling $EnablePathInfo = 1; was the only way to get webadmin to change directories without problems.IanMacGregor

Nov 9, 2006 - ~Lenard Works fine now thank you Mateusz

June 19, 2006 - Comment from Michi
Is it possible switch a variable so I can configure that the script only works in the $WebAdminHomeDir directory and its subdirectories? I run a project website and would like to have a file storage system, but without the danger that users delete PmWiki files. But it's anyway a great script.

June 1, 2006 - Comment from Lenard
This receipe does not work together with PmWikiDraw; enable it: Draw is broken, disable it: works again.

I've had the same problem, but I found the reason and changed the script a tiny bit to fix it. The new version is webadmin-1.1.phpΔ
~Mateusz

April 25, 2006 - Comment from DirkBlaas
The script doesn't work when cleanurls are used, which is a pity for a lot of PmWiki-installations.

April 7, 2006 - Comment from IanMacGregor
I am using pmwiki-2.1.0 and this cookbook recipe does not work. When I use the URL of my wiki, I get the following errors:

Warning: array_key_exists() [function.array-key-exists]: The second argument should
be either an array or an object in /var/www/pmwiki/cookbook/webadmin.php on line 1306

Warning: array_key_exists() [function.array-key-exists]: The second argument should
be either an array or an object in /var/www/pmwiki/cookbook/webadmin.php on line 1312

Warning: Cannot modify header information - headers already sent by (output started at\\ /var/www/pmwiki/cookbook/webadmin.php:1306) in /var/www/pmwiki/pmwiki.php on line 857

And when I use $WebAdminHomeDir = './'; in config.php, I get a blank page.

Anyone know how to fix this?

June 20, 2008 Comment from JeffMuday
I duplicated Ian's error message above when I misconfigured $WebAdminHomeDir to a non-existent directory

I would like to modify the script to "jail" some of the users into the 'uploads' or 'pub' subdirectory rather than allowing them to climb into other parts of the PMwiki site.

April 9, 2006 - Comment from IanMacGregor
I switched from php5 to php4 and this cookbook recipe now works perfectly.

  • Does this work with PHP5 and the newest pmwiki version?

UPDATE: From IanMacGregor on August 21, 2006 I am now using pmwiki-2.1.14 with PHP5 and this cookbook recipe now works great.

  • Try going to those lines and putting (array) before the second argument complained of. That should cast the problematic variable as an array. BenWilson April 29, 2006, at 12:46 PM
  • It'd be nice if the localisation strings were moved to a page of PmWikiXx.XLPageCookbook and incorporated in the recipe -- using, possibly, MarkupToHTML(), or FmtPageName(), or however that's done in other recipes. ~MateuszCzaplinski

Some functions of webadmin 1.0 (03.01.2006) didn't work for me (i had problem with delete and copy action). I fixed the request_dump() function like this:

 function request_dump () {
    $str = "";
    foreach ($_REQUEST as $key => $value) {
        $str .= "\t<input type=\"hidden\" name=\"" . html($key) . '" value="' . html($value) . "\" />\n";
    }
    return $str;
 }
  • Thank you very much for posting this fix. I was wondering why my WebAdmin wouldn't delete files regardless of file permissions. This fix works great - August 28, 2006 IanMacGregor
  • Thanks from me also. This makes it possible to handle my files from the office, which was otherwise not possible. - June 26, 2007 Frits?
  • Thanks, this fix worked for me also. Given that the fix was provided in 2006 is there any chance we could incorporate it into the download? Mayber version 1.2? I'd be happy to do it but don't want to break anything else. -- Dave

I use CleanUrls and I was still able to get WebAdmin to work fine so far. I just disabled the clean Urls in the Page from which I call WebAdmin using a local configuration file. Let's say I have a special Admin menu page called Site.Admin with Admin level password protection. I create a local configuration file in the local directory named Site.Admin.php and inside that file I put the following directive:
$EnablePathInfo = 0;
I still have to have the following directive in my regular config.php file:
include_once('cookbook/webadmin.php');
Then in my Site.Admin menu page I have a link like the following:
[[Site/Admin?action=webadmin | Web Admin]]
This seems to work. When I'm on the WebAdmin page, the clean Urls go away and WebAdmin works fine but all other times the clean Urls are there. I am not using all the Apache rewrite directives so I can't say whether it's fully compatible with that but it works fine for me this way.
BillReveile January 30, 2007, at 11:52 PM

UPDATE - June 14, 2008: I use Apache rewrite directives and I can say that this recipe does not work with pmwiki-2.2.0-beta65. --Ian MacGregor

Feb 1, 2007 - Am I just missing something in my configuration? I can get the listing to display, but every link comes back with "The requested URL /php.cgi was not found on this server." I have noticed that all my URLs come back (..\pmwiki.php?n=Main.HomePage?) as opposed to what the script seems to be generating as a link (..\php.cgi?n=Main.HomePage?). How can I fix this? erisraven


WebAdmin initial screen
2009-05-27 IIS & PmWiki 2.2.1

has anyone got this running on 2.2.1?

I see the following problems (not using clean URLs, no configuration changes made)

  • the initial directory does no look quite right
  • clicking on the directory link seems to have an invalid URL (http://infostoretest/pmwiki.php/InfoStore/pmwiki.php?action=webadmin?dir=E%3A\home\InfoStore\pmwiki.php\InfoStore\.%2F) - gives PmWiki error invalid page name
  • clicking on the change button (URL http://infostoretest/pmwiki.php/InfoStore/pmwiki.php?action=webadmin) - also gives PmWiki error invalid page name
  • similarly for the Filename and Size links (http://infostoretest/pmwiki.php/InfoStore/pmwiki.php?action=webadmin?dir=E%3A\home\InfoStore\pmwiki.php\InfoStore\.%2F\&sort=filename&reverse=true)

Can anyone help

July 20, 2010 - webadmin-1.1.php uses several deprecated functions, specifically ereg and eregi which breaks some of the functionality. I have replaced the following code:

  • Line 282:
From: $src = ereg_replace('<font color="([^"]*)">', '<span style="color: \1">', ob_get_contents());
To: $src = preg_replace('/<font color="([^"]*)">/', '<span style="color: \1">', ob_get_contents());
  • Line 1001:
From: return ereg('\.php$|\.php3$|\.php4$|\.php5$', $filename);
To: return preg_match('/\.php$|\.php3$|\.php4$|\.php5$/', $filename);
  • Line 1016:
From: if (eregi($regex, $filename)) return $mime;
To: if (preg_match("/$regex/i", $filename)) return $mime;
  • Lines 1136-1138:
From:  while (ereg($regex, $path)) {
             $path = ereg_replace($regex, $delim, $path);
           }
To:    while (preg_match ("/$regex/", $path)) {
	     $path = preg_replace("/$regex/", $delim, $path);
           }

Should the maintainer update the code?

See Also


Contributors

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on August 22, 2012, at 02:24 PM