Wiki module, copied from contrib/wiki.

I've left out stuff that didn't seem necessary ... including a lot
of the Wiki plugins which were quote large... I'm not sure if this
is currently working ... I'm about to try it out.
This commit is contained in:
moodler 2004-06-02 12:45:55 +00:00
parent fdd1eee7e6
commit 39fcb981b8
55 changed files with 16941 additions and 0 deletions

23
mod/wiki/TODO.txt Normal file
View file

@ -0,0 +1,23 @@
ToDo
Mike:
- Group Handling (Mike)
> deal with changing group mode on active wikis
> handle group mode for teacher wikis
- Rating
- Commenting
- Grading
Michael:
- SiteMap
- Notify
Unassigned or not ready:
- Dump Pages
- http://moodle.org/mod/forum/discuss.php?d=7768#36954
- Image Thumbnails http://moodle.org/mod/forum/discuss.php?d=8351
ewiki Preparation:
- Current Version: 1.01d
- rm -r example-1.php examples/ tools/ config.php
- rm -r fragments/ patches/ php-patches/ spages/

16
mod/wiki/WARNING.txt Normal file
View file

@ -0,0 +1,16 @@
------------------------------------------------------------------------------
WIKI - MOODLE IMPLEMENTATION
------------------------------------------------------------------------------
This directory contains the work-in-progress version of the Erfurt Wiki
integration into Moodle.
THIS IS NOT PRODUCTION SOFTWARE. DO NOT INSTALL THIS ON A PRODUCTION SYSTEM!!
This version has been provided for Moodle developers and testers only. It is a
work in progress and may undergo significant changes.
If you wish to try it, it can be installed as any module.
Please fully delete any previously installed wiki module.

322
mod/wiki/admin.php Normal file
View file

@ -0,0 +1,322 @@
<?PHP // $Id$
/// Extended by Michael Schneider
/// This page prints a particular instance of wiki
require_once("../../config.php");
require_once("lib.php");
include_once($CFG->dirroot."/mod/wiki/ewikimoodlelib.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php");
require_login($course->id);
optional_variable($id); // Course Module ID, or
optional_variable($wikipage); // Pagename
optional_variable($confirm, "");
optional_variable($action,""); // Admin Action
optional_variable($userid); // User wiki.
optional_variable($groupid); // Group wiki.
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $wiki = get_record("wiki", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (! $wiki = get_record("wiki", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $wiki->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) {
error("Course Module ID was incorrect");
}
}
/// Build the ewsiki script constant
$ewbase = 'view.php?id='.$id;
if (isset($userid)) $ewbase .= '&userid='.$userid;
if (isset($groupid)) $ewbase .= '&groupid='.$groupid;
$ewscript = $ewbase.'&wikipage=';
define("EWIKI_SCRIPT", $ewscript);
if($wiki->ewikiacceptbinary) {
define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
}
/// Add the course module 'groupmode' to the wiki object, for easy access.
$wiki->groupmode = $cm->groupmode;
/// Is an Action given ?
if(!$action) {
error(get_string("noadministrationaction","wiki"));
}
/// Correct Action ?
if(!in_array($action, array("setpageflags", "removepages", "strippages", "checklinks", "revertpages"))) {
error("Unknown action '$action'","wiki");
}
/// May the User administrate it ?
if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false || wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course) === false) {
error(get_string("notadministratewiki","wiki"));
}
/// The wiki_entry->pagename is set to the specified value of the wiki,
/// or the default value in the 'lang' file if the specified value was empty.
define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
# The mighty Wiki itself
include_once($CFG->dirroot."/mod/wiki/ewiki/ewiki.php");
/// Print the page header
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
$strwikis = get_string("modulenameplural", "wiki");
$strwiki = get_string("modulename", "wiki");
/// Validate Form
if ($form = data_submitted()) {
switch($action) {
case "revertpages":
if(!$form->deleteversions || 0 > $form->deleteversions || $form->deleteversions > 1000) {
$focus="form.deleteversions";
$err->deleteversions=get_string("deleteversionserror","wiki");
}
if(!$form->changesfield || 0 > $form->changesfield || $form->changesfield > 100000) {
$focus="form.changesfield";
$err->changesfield=get_string("changesfielderror","wiki");
}
if($form->authorfieldpattern=="") {
$focus="form.authorfieldpattern";
$err->authorfieldpattern=get_string("authorfieldpatternerror","wiki");
}
break;
default: break;
}
}
print_header("$course->shortname: $wiki_entry->pagename", "$course->fullname",
"$navigation <A HREF=\"index.php?id=$course->id\">$strwikis</A> -> <A HREF=\"view.php?id=$id\">$wiki->name</a> ->".
get_string("administration","wiki"),
$focus, "", true, update_module_button($cm->id, $course->id, $strwiki),
navmenu($course, $cm));
////////////////////////////////////////////////////////////
/// Check if the Form has been submitted and display confirmation
////////////////////////////////////////////////////////////
if ($form = data_submitted()) {
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
/// Moodle Log
add_to_log($course->id, "wiki", $action, "admin.php?id=$id");
$link="admin.php?action=$action&userid=$userid&groupid=$groupid&id=$id&wikipage=$wikipage";
switch($action) {
case "removepages":
if($form->proceed) {
if(!$confirm && $form->pagestodelete) {
notice_yesno(get_string("removepagecheck", "wiki")."<br>".join(", ", $form->pagestodelete),
$link."&confirm=".urlencode(join(" ",$form->pagestodelete)), $link);
print_footer($course);
exit;
}
}
break;
case "strippages":
if($form->proceed) {
if(!$confirm && $form->pagestostrip) {
$err=array();
$strippages=wiki_admin_strip_versions($form->pagestostrip,$form->version, $err);
$confirm="";
foreach($strippages as $cnfid => $cnfver) {
$confirm.="&confirm[$cnfid]=".urlencode(join(" ",$cnfver));
}
if(count($err)==0) {
notice_yesno(get_string("strippagecheck", "wiki")."<br>".join(", ", $form->pagestostrip),
$link.$confirm, $link);
print_footer($course);
exit;
}
}
}
break;
case "checklinks":
if($form->proceed) {
if(!$confirm && $form->pagetocheck) {
$confirm="&confirm=".$form->pagetocheck;
notice_yesno(get_string("checklinkscheck", "wiki").$form->pagetocheck,
$link.$confirm, $link);
print_footer($course);
exit;
}
}
break;
case "setpageflags":
// pageflagstatus is used in setpageflags.html
$pageflagstatus=wiki_admin_setpageflags($form->flags);
break;
case "revertpages":
if(!$err) {
if(!$confirm) {
$confirm="&confirm[changesfield]=".urlencode($form->changesfield).
"&confirm[authorfieldpattern]=".urlencode($form->authorfieldpattern).
"&confirm[howtooperate]=".urlencode($form->howtooperate).
"&confirm[deleteversions]=".urlencode($form->deleteversions);
$revertedpages=wiki_admin_revert("", $form->authorfieldpattern, $form->changesfield, $form->howtooperate, $form->deleteversions);
if($revertedpages) {
notice_yesno(get_string("revertpagescheck", "wiki")."<br>".$revertedpages,
$link.$confirm, $link);
print_footer($course);
exit;
} else {
$err->remark=get_string("nochangestorevert","wiki");
}
}
}
break;
default: error("No such Wiki-Admin action: $action");
break;
}
}
/// Actions which need a confirmation. If confirmed, do the action
$redirect="view.php?userid=$userid&groupid=$groupid&id=$id&wikipage=$wikipage";
if($confirm && !$err) {
switch($action) {
case "removepages":
$ret=wiki_admin_remove(split(" ",$confirm), $course, $wiki, $userid, $groupid);
if(!$ret) {
redirect($redirect, get_string("pagesremoved","wiki"), 1);
} else {
error($ret);
}
exit;
case "strippages":
$strippages=array();
foreach($confirm as $pageid => $versions) {
$strippages[$pageid]=split(" ",$versions);
}
$ret=wiki_admin_strip($strippages);
if(!$ret) {
redirect($redirect, get_string("pagesstripped","wiki"), 1);
} else {
error($ret);
}
exit;
case "checklinks":
$ret=wiki_admin_checklinks($confirm);
redirect($redirect, get_string("linkschecked","wiki")."<br>".$ret, 5);
exit;
case "revertpages":
$revertedpages=wiki_admin_revert(1, $confirm["authorfieldpattern"], $confirm["changesfield"], $confirm["howtooperate"], $confirm["deleteversions"]);
redirect($redirect, get_string("pagesreverted","wiki"), 1);
exit;
case "setpageflags":
# No confirmation needed
break;
default: error("No such action '$action' with confirmation");
}
}
/// The top row contains links to other wikis, if applicable.
if ($wiki_list = wiki_get_other_wikis($wiki, $USER, $course, $wiki_entry->id)) {
if (isset($wiki_list['selected'])) {
$selected = $wiki_list['selected'];
unset($wiki_list['selected']);
}
echo '<tr><td colspan="2">';
echo '<form name="otherwikis" action="'.$CFG->wwwroot.'/mod/wiki/admin.php">';
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>';
echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'">&nbsp;'
.$WIKI_TYPES[$wiki->wtype].' '
.get_string('modulename', 'wiki').' for '
.wiki_get_owner($wiki_entry).':</td>';
echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'" align="right">'
.get_string('otherwikis', 'wiki').':&nbsp;&nbsp;';
$script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
/// Add Admin-Action
reset($wiki_list);
$wiki_admin_list=array();
while(list($key,$val)=each($wiki_list)) {
$wiki_admin_list[$key."&action=$action"]=$val;
}
choose_from_menu($wiki_admin_list, "wikiselect", $selected, "choose", $script);
echo '</td>';
echo '</tr></table>';
echo '</form>';
echo '</td>';
echo '</tr>';
}
if ($wiki_entry) {
/// Page Actions
echo '<table border="0" width="100%">';
echo '<tr>';
# echo '<tr><td align="center">';
# $specialpages=array("SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
# wiki_print_page_actions($cm->id, $specialpages, $ewiki_id, $ewiki_action, $wiki->ewikiacceptbinary, $canedit);
# echo '</td>';
/// Searchform
echo '<td align="center">';
wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
echo '</td>';
/// Internal Wikilinks
/// TODO: DOES NOT WORK !!!!
echo '<td align="center">';
wiki_print_wikilinks_block($cm->id, $wiki->ewikiacceptbinary);
echo '</td>';
/// Administrative Links
echo '<td align="center">';
wiki_print_administration_actions($cm->id, $userid, $groupid, $wikipage, $wiki->htmlmode!=2);
echo '</td>';
# if($wiki->htmlmode!=2) {
# echo '<td align="center">';
# helpbutton('formattingrules', get_string('formattingrules', 'wiki'), 'wiki');
# echo get_string("formattingrules","wiki");
# echo '</td>';
# }
echo '</tr></table>';
}
// The wiki Contents
print_simple_box_start( "center", "100%", "$THEME->cellcontent", "20");
// Do the Action
# "setpageflags", "removepages", "strippages", "checklinks", "revertpages"
print_heading_with_help(get_string($action,"wiki"), $action, "wiki");
include $action.".html";
print_simple_box_end();
/// Finish the page
print_footer($course);
exit;
?>

173
mod/wiki/backuplib.php Normal file
View file

@ -0,0 +1,173 @@
<?PHP //$Id$
//This php script contains all the stuff to backup/restore
//wiki mods
//This is the "graphical" structure of the wiki mod:
//
// wiki
// (CL,pk->id)
//
// wiki_entries
// (pk->id, fk->wikiid)
//
// wiki_pages
// (pk->pagename,version,wiki, fk->wiki)
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
// nt->nested field (recursive data)
// CL->course level info
// UL->user level info
// files->table may have files)
//
//-----------------------------------------------------------
//This function executes all the backup procedure about this mod
function wiki_backup_mods($bf,$preferences) {
global $CFG;
$status = true;
////Iterate over wiki table
if ($wikis = get_records ("wiki","course", $preferences->backup_course,"id")) {
foreach ($wikis as $wiki) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print assignment data
fwrite ($bf,full_tag("ID",4,false,$wiki->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"wiki"));
fwrite ($bf,full_tag("NAME",4,false,$wiki->name));
fwrite ($bf,full_tag("SUMMARY",4,false,$wiki->summary));
fwrite ($bf,full_tag("PAGENAME",4,false,$wiki->wtype));
fwrite ($bf,full_tag("WTYPE",4,false,$wiki->wtype));
fwrite ($bf,full_tag("EWIKIPRINTTITLE",4,false,$wiki->ewikiprinttitle));
fwrite ($bf,full_tag("HTMLMODE",4,false,$wiki->allowsafehtml));
fwrite ($bf,full_tag("EWIKIACCEPTBINARY",4,false,$wiki->ewikiacceptbinary));
fwrite ($bf,full_tag("INITIALCONTENT",4,false,$wiki->initialcontent));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$wiki->timemodified));
//backup entries and pages
if ($preferences->mods["forum"]->userinfo) {
$status=backup_wiki_entries($bf,$preferences,$wiki->id, $preferences->mods["wiki"]->userinfo);
}
//End mod
fwrite ($bf,end_tag("MOD",3,true));
}
}
//if we've selected to backup users info, then backup files too
if ($status) {
if ($preferences->mods["wiki"]->userinfo) {
$status = backup_wiki_files($bf,$preferences);
}
}
return $status;
}
////Return an array of info (name,value)
function wiki_check_backup_mods($course,$user_data=false,$backup_unique_code) {
//First the course data
$info[0][0] = get_string("modulenameplural","wiki");
$info[0][1] = count_records("wiki", "course", "$course");
return $info;
}
//Backup wiki_entries contents (executed from wiki_backup_mods)
function backup_wiki_entries ($bf,$preferences,$wiki, $userinfo) {
global $CFG;
$status = true;
$wiki_entries = get_records("wiki_entries","wikiid",$wiki,"id");
//If there are entries
if ($wiki_entries) {
$dumped_entries = 0;
//Iterate over each entry
foreach ($wiki_entries as $wik_ent) {
//Start entry
//Print submission contents
if ($userinfo) {
$dumped_entries++;
if ($dumped_entries == 1) {
//Write start tag
$status =fwrite ($bf,start_tag("ENTRIES",4,true));
}
$status =fwrite ($bf,start_tag("ENTRY",5,true));
fwrite ($bf,full_tag("ID",6,false,$wik_ent->id));
fwrite ($bf,full_tag("GROUPID",6,false,$wik_ent->groupid));
fwrite ($bf,full_tag("USERID",6,false,$wik_ent->userid));
fwrite ($bf,full_tag("PAGENAME",6,false,$wik_ent->pagename));
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$wik_ent->timemodified));
if ( $userinfo ) {
$status = backup_wiki_pages($bf,$preferences,$wik_ent->id);
}
$status =fwrite ($bf,end_tag("ENTRY",5,true));
}
}
if ( $dumped_entries > 0 ) {
//Write end tag
$status =fwrite ($bf,end_tag("ENTRIES",4,true));
}
}
return $status;
}
function backup_wiki_pages ($bf,$preferences,$entryid) {
global $CFG;
$status = true;
$pages = get_records("wiki_pages","wiki",$entryid);
if ($pages) {
$status =fwrite ($bf,start_tag("PAGES",6,true));
foreach ($pages as $page) {
$status =fwrite ($bf,start_tag("PAGE",7,true));
fwrite ($bf,full_tag("PAGENAME",8,false,$page->pagename));
fwrite ($bf,full_tag("VERSION",8,false,$page->version));
fwrite ($bf,full_tag("FLAGS",8,false,$page->flags));
fwrite ($bf,full_tag("CONTENT",8,false,$page->content));
fwrite ($bf,full_tag("AUTHOR",8,false,$page->author));
fwrite ($bf,full_tag("CREATED",8,false,$page->created));
fwrite ($bf,full_tag("LASTMODIFIED",8,false,$page->lastmodified));
fwrite ($bf,full_tag("REFS",8,false,$page->refs));
fwrite ($bf,full_tag("META",8,false,$page->meta));
fwrite ($bf,full_tag("HITS",8,false,$page->hits));
$status =fwrite ($bf,end_tag("PAGE",7,true));
}
$status =fwrite ($bf,end_tag("PAGES",6,true));
}
return $status;
}
//Backup wiki binary files
function backup_wiki_files($bf,$preferences) {
global $CFG;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
//Now copy the forum dir
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki")) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki",
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/wiki");
}
}
return $status;
}
?>

16
mod/wiki/checklinks.html Normal file
View file

@ -0,0 +1,16 @@
<?PHP
// Make sure all variables are defined
?>
<FORM ACTION="admin.php" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="userid" VALUE="<? print $userid; ?>">
<INPUT TYPE="HIDDEN" NAME="groupid" VALUE="<? print $groupid ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="<? print $action; ?>">
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<? print $cm->id ?>">
<INPUT TYPE="HIDDEN" NAME="wikipage" VALUE="<? print $wikipage?>">
<?
$pagelist=wiki_admin_checklinks_list();
choose_from_menu($pagelist, "pagetocheck", $wikipage, "");
?>
<input type="submit" name="proceed" value="<? print get_string("checklinks","wiki"); ?>">
</center>

44
mod/wiki/db/mysql.php Normal file
View file

@ -0,0 +1,44 @@
<?PHP
function wiki_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $CFG;
if ($oldversion < 2004040200) {
execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` DROP `allowstudentstowiki`');
}
if ($oldversion < 2004040700) {
execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` CHANGE `ewikiallowsafehtml` `htmlmode` TINYINT( 4 ) DEFAULT \'0\' NOT NULL');
}
if ($oldversion < 2004042100) {
execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` ADD `pagename` VARCHAR( 255 ) AFTER `summary`');
execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki_entries` CHANGE `name` `pagename` VARCHAR( 255 ) NOT NULL');
if ($wikis = get_records('wiki')) {
foreach ($wikis as $wiki) {
if (empty($wiki->pagename)) {
set_field('wiki', 'pagename', $wiki->name, 'id', $wiki->id);
}
}
}
}
if ($oldversion < 2004053100) {
execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` CHANGE `initialcontent` `initialcontent` VARCHAR( 255 ) DEFAULT NULL');
// Remove obsolete 'initialcontent' values.
if ($wikis = get_records('wiki')) {
foreach ($wikis as $wiki) {
if (!empty($wiki->initialcontent)) {
set_field('wiki', 'initialcontent', null, 'id', $wiki->id);
}
}
}
}
return true;
}
?>

54
mod/wiki/db/mysql.sql Normal file
View file

@ -0,0 +1,54 @@
# This file contains a complete database schema for all the
# tables used by this module, written in SQL
# It may also contain INSERT statements for particular data
# that may be used, especially new entries in the table log_display
CREATE TABLE `prefix_wiki` (
`id` int(10) unsigned NOT NULL auto_increment,
`course` int(10) unsigned NOT NULL default '0',
`name` varchar(255) NOT NULL default '',
`summary` text NOT NULL,
`pagename` varchar(255) default NULL,
`wtype` enum('teacher','group','student') NOT NULL default 'group',
`ewikiprinttitle` tinyint(4) NOT NULL default '1',
`htmlmode` tinyint(4) NOT NULL default '0',
`ewikiacceptbinary` tinyint(4) NOT NULL default '0',
`initialcontent` varchar(255) default NULL,
`timemodified` int(10) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Main wiki table';
#
# Table structure for table `mdl_wiki_entries`
#
CREATE TABLE `prefix_wiki_entries` (
`id` int(10) NOT NULL auto_increment,
`wikiid` int(10) NOT NULL default '0',
`course` int(10) NOT NULL default '0',
`groupid` int(10) NOT NULL default '0',
`userid` int(10) NOT NULL default '0',
`pagename` varchar(255) NOT NULL default '',
`timemodified` int(10) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Holds entries for each wiki start instance.';
CREATE TABLE `prefix_wiki_pages` (
`pagename` VARCHAR(160) NOT NULL,
`version` INTEGER UNSIGNED NOT NULL DEFAULT 0,
`flags` INTEGER UNSIGNED DEFAULT 0,
`content` MEDIUMTEXT,
`author` VARCHAR(100) DEFAULT 'ewiki',
`created` INTEGER UNSIGNED DEFAULT 0,
`lastmodified` INTEGER UNSIGNED DEFAULT 0,
`refs` MEDIUMTEXT,
`meta` MEDIUMTEXT,
`hits` INTEGER UNSIGNED DEFAULT 0,
`wiki` int(10) unsigned NOT NULL,
PRIMARY KEY id (pagename, version, wiki)
) TYPE=MyISAM COMMENT='Holds the Wiki-Pages';

82
mod/wiki/ewiki/CREDITS Normal file
View file

@ -0,0 +1,82 @@
Who worked on ErfurtWiki
========================
(please note that all mail addresses are 'beautified')
Mario Salzer <mario*erphesfurt·de> [http://mario.erphesfurt.de/]
- original author, current maintainer
Andy Fundinger <andy*burgiss·com> [http://www.burgiss.com/]
- compatibility fixes for PHP.A/W32, notify: address protection for info/
- markup_css_singleat, action_extracttodo
- spellcheck2, phplib_auth, title_calendar
- navbar, aview_posts
- LiveUser authentication / permission framework plugin
Carsten Senf <ewiki*csenf·de> (from Erfurt)
- db_flat_files.php bugfixes for Win32 systems
- calendar.php, db_fast_files.php` code
- page_since_updates.php
Alex Wan <alex*burgiss·com> [http://www.burgiss.com/]
- LiveUser framework auth plugin,
log viewing plugin
Jeremy Mikola <jmikola*arsjerm·net> [http://www.burgiss.com/]
- aview_piclogocntl, the Burgiss Groups` LiveUser framework auth plugin
Culley Harrelson <cully*fastmail·fm>
- fixes for html code generation bugs,
various feature requests
Hans B. Pufal <hansp*aconit·org> [http://www.aconit.org/]
- various enhancements, bugfixes
- mpi_calendar
- mpi_environment
- mpi_plugins
- mpi_page_flags
- markup_complextbl
Vladimir Támara <vtamara*users.sourceforge·net>
- Spanish translation of core messages and
the basic init-pages/
Frank 'Sigi' Luithle <sigi*fsinfo.cs.uni-sb·de>
- contributed the wiki_format.inc (reduced rendering core)
Beate Paland <bep*web·de> [http://www.paland.tv/]
- bug notices and many helpful suggestions
(constantly demanded for <pre> support)
- phpCMS integration, see http://www.paland.tv/...
Markus Ackermann <maol*symlink·ch> [http://www.symlink.ch/]
- bug reports, improvement suggestions
Dominik Eckardt <the.oberon*gmx·de>
- suggested the TAB indentation
(while now SPACEs are supported)

22
mod/wiki/ewiki/INSTALL Normal file
View file

@ -0,0 +1,22 @@
Information on how to install and use ErfurtWiki can be found in the
README, this file only contains notes for the impatient:
Quick Test Installation
=======================
- just move this newly extracted directory into your webservers docroot:
mv ewiki-R1.00f7 /var/www/wiki
- then edit the "config.php" file, you may need to set the correct
parameters to access your MySQL database server (db user name and
password, and select a database different from "test")
- just go to http://localhost/wiki/
(or whereever you did put the files)
Warning
=======
Simply installing these files unchanged onto a public webserver is a bad
idea, at least the tools/ subdir should be password-protected!

4862
mod/wiki/ewiki/README Normal file

File diff suppressed because it is too large Load diff

819
mod/wiki/ewiki/README.de Normal file
View file

@ -0,0 +1,819 @@
README.de
¯¯¯¯¯¯¯¯¯
Dies ist eine teilweise Übersetzung der README Datei, die weiterhin als
Referenz verwendet sollte, da hier nur ein paar allgemeine und Setup-
Informationen enthalten sind.
1 Was ist das?
1.1 Warum "ErfurtWiki"?
1.2 WikiAlternativen
1.3 Autor
1.4 ProjektSeiten
1.5 Support bekommen
1.6 Lizens
2 Wie jetzt?
2.1 In yoursite.php integrieren
2.2 Den WikiSeitenNamen bestimmen
2.9.1 WikiSprache einstellen (deutsch)
3 Im Detail
3.1 die ewiki_ Funktionen
3.2 $GLOBALS Verschmutzung
3.3 die EWIKI_ Konstanten
3.4 $ewiki_config[] array
4.1 Nur die WikiQuelltextTransformation einsetzen
6.1.2 Ohne MySQL DB verwenden (WICHTIG)
6.1.3 db_fast_files
7.3.3 BöseBäckSläshes \\\\" (WICHTIG)
9.5.5 Paßwörter und tools/
-------------------------------------------------------------------------
Was ist das?
¯¯¯¯¯¯¯¯¯¯¯¯
Dies ist eine "WikiWikiWeb" Bibliothek, die in der PHP Webskriptsprache
implementiert ist. Ein WikiWiki ist eine Webseite, die von wirklich jedem
verändert/ergänzt werden kann, der dort vorbeischaut (ohne vorhergehenden
Registrierungskram).
Es sollte relativ einfach in bestehende Websites integrierbar sein,
weil es eben kein komplettes Script sondern vielmehr eine Bibliothek
ist, die kein fertiges Seitenlayout erzwingt. Stattdessen können die
erzeugten WikiSeiten als Inhalt in das Layout einer bestehenden Seite
eingebunden werden.
Warum "ErfurtWiki"?
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Meine Heimatstadt (Erfurt liegt nahe bei Weimar.de) - und das ist wirklich
nix weiter als ein Name! Der interne Projektname ist übrigens "ewiki".
Warum sollte man ausgerechnet dieses Wiki verwenden wollen?
- es ist wirklich alles notwendige in einer einzigen Skriptdatei, so
daß keine 20 anderen Dateien mit herumliegen müssen, wenn man es
in die eigene Site einbindet
- vordefinierte Layouts werden nicht aufgezwungen, es gibt Beispielseiten
aber keine Skins oder Themes aus denen man wählen müßte; das Wiki paßt
sich wirklich in eine existierende Seite ein
- es ist vergleichsweise schnell, reguläre Ausdrücke werden zwar auch hier
verwendet, aber nicht so exzessiv wie in anderen Wikis
(hauptsächlich einfache und flinke String-Funktionen)
- der Funktionsumfang ist inzwischen beachtlich :)
WikiAlternativen
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Es gibt auch noch andere hübsche WikiWare, falls jemand hiermit nicht
glücklich werden tut:
* PhpWiki ist deutlich vollständiger,
siehe http://freshmeat.net/projects/phpwiki,
unterstützt versch. Datenbanktypen, Lokalisierung, integrierter
Administrationsbereich
* Miki ist eine kleine WikiImplementierung in PHP von Jukka
Zitting. http://miki.sourceforge.net/
* http://coWiki.org/ ist tatsächlich mehr ein CMS denn ein Wiki
* Und schließlich: sfWiki - das sourceforge Wiki (daher auch zu finden
bei http://sfwiki.sourceforge.net/). Teile der WikiSyntax sieht ein
wenig merkwürdig aus, ein paar andere Sachen sind ganz nett; und es
unterstützt Benutzerauthentifizierung
* für andere Wikis in anderen Programmiersprachen einfach mal die
Suchmaschienen nerven:
http://www.freshmeat.net/search/?q=wiki&section=projects
http://www.google.com/search?q=wiki
Autor
¯¯¯¯¯
Mario Salzer <milky*erphesfurt·de>
ICQ95596825 und Yahoo: icq95596825
Und alle anderen wurden in die Datei CREDITS verbannt ;->
Dies ist ein relativ neues Projekt. Um es zu verbessern, bin ich sehr
auf Rückmeldungen angewiesen. Jede Mail ist ein wertvoller Beitrag!
ProjektSeiten
¯¯¯¯¯¯¯¯¯¯¯¯¯
freshmeat
- http://freshmeat.net/ewiki
demo:
- http://erfurtwiki.sourceforge.net/
neueste Versionen (instabile EnwicklerVersionen):
- http://erfurtwiki.sourceforge.net/downloads/
Support bekommen
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Hilfe bei der Installation gibt's natürlich, und selbstverständlich sind
wir auch dankbar für jeden Hinweis über bestehende Probleme und Fehler
(bekanntermaßen ist die REAMDE noch nicht ausführlich genug und stellenweise
überhaupt keine Hilfe).
Bevor du aber einen BugReport versendest, lies dir bitte folgende Anleitung
durch (absolut notwendig um KOSTENLOSEN support zu bekommen):
http://www.lugbz.org/documents/smart-questions_de.html
Danach bitte nicht zögern, einen der Autoren zu kontakten oder einfach eine
Nachricht in BugReports oder UserSuggestion auf unserer ProjektSeite zu
hinterlassen.
Wenn du dich auf unserer http://erfurtwiki.sourceforge.net/?MailingList
anmeldest, hast du die Möglichkeit Hilfe für dein Problem von einer größeren
Gruppe von Leuten zu bekommen (an- und wieder abmelden geht schnell).
Lizens
¯¯¯¯¯¯
Dieses "Programm" wird als "Public Domain" vertrieben. Public Domain
ist wie "FreeWare", nur ein bischen mehr frei ;-> Man kann sich das
vorstellen, wie die GPL ohne an die GPL gebunden zu sein. (Tatsächlich
wollte ich einfach keine LICENSE Datei mitreinpacken, die größer ist als
das eigentliche Programm.)
Da dies ein freies (Bier) Stück Software ist, kann mich natürlich
niemand für irgendwelche Fehler oder all die WIRKLICH SCHLIMMEN
FESTPLATTEN-SCHÄDEN verantwortlich machen, die bei der Verwendung
entstehen könnten ;>
-------------------------------------------------------------------------
Wie jetzt?
¯¯¯¯¯¯¯¯¯¯
ewiki benötigt:
- Webserver (Apache, Nanoweb, ...)
- PHP 4.1 oder neuer
- nach Mglk. eine MySQL Datenbank (läuft aber auch ohne)
- deine bereits exitierenden Webseite
- die wundervollen "magic slashes" in antiken PHP version sollten wirklich
abgeschalten sein
Wenn du keine MySQL-Datenbank hast, dann verwende die Erweiterung für
die Datei-Datenbank.
In yoursite.php integrieren
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
In den nächsten Abschitten, soll mit dem Begriff "yoursite.php" der
Teil deiner bestehenden Seite verstanden werden, der das Seitenlayout
erzeugt (der also zumindest die <html><body> Tags um die Ausgaben von
ewiki.php bastelt).
Die schlichteste Lösung findet sich auch noch mal in example-2.php:
<HTML>
<BODY>
<?php
mysql_connect("localhost", "DB-USER-NAME", "PASSWORD");
mysql_query("use DATABASE-NAME-HERE");
define("EWIKI_SCRIPT", "yoursite.php?page=);
error_reporting(0);
include("ewiki.php");
echo ewiki_page();
?>
</BODY>
</HTML>
Die ersten beiden Befehle öffnen eine Verbindung zur MySQL-Datenbank,
normalerweise würde man das Ergebnis von mysql_conect() in einer Variable
wie "$db" ablegen, aber da PHP ohnehin nicht auf deren Verwendung besteht,
wenn es nur eine DB-Verbindung gibt, wird eine solche Variable in
"ewiki.php" auch gar nicht verwendet (und der Name dieser Variable wäre
damit hier egal).
Der Wert in der define() Zeile sagt ewiki wie die Hyperlinks zu den
referenzierten WikiSeiten lauten müssen, damit ewiki.php auch für die
nächste angeklickte WikiSeite aufgerufen wird.
Wenn du nur ein einziges "yoursite.php" Skript hast, wirst du den Wert
direkt in "ewiki.php" verändern wollen.
Das error_reporting(0) wird sehr empfohlen.
Das include("ewiki.php") lädt endlich die ewiki "Bibliothek" und setzt
alle bis hierher noch nicht definierten EWIKI_ Konstanten.
Der Aufruf der ewiki_page() Funktion gibt diejenige WikiSeite zurück, die
vom Browser angefragt wurde. Du mußt hier "echo" davorsetzen, denn sonst
wird der Text nicht ausgegeben (verpufft im PHP-Nirvana) - ewiki gibt die
erzeugte Seite nicht selber aus.
Den WikiSeitenNamen bestimmen
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Wenn du ewiki_page() einfach so aufrufst wie im oberen Beispiel angegeben
(empfohlen), dann wird es versuchen, den Namen der angefragten Seite selber
zu ermmitteln ($_SERVER["PATH_INFO"] oder GET-Variablen '?id=' oder '?name='
oder '?page=' oder '?file=' in $_REQUEST["name"]).
Wenn yoursite.php aber einen anderen Weg benutzt (andere Parameternamen),
um den WikiSeitenNamen zu übergeben, dann kann man ihn schlicht als ersten
Parameter angeben:
ewiki_page( $id = "WikiSeitenNanem" );
Example-4.php zeigt das beispielsweise, um die Liste der aktualisierten
Seiten einzubinden.
WikiSprache einstellen (deutsch)
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Ich hab es jetzt schon einige Leute behaupten hören, aber auch beim
IntranetExplodierer kann man die "bevorzugten Sprachen" irgendwo einstellen.
Wers nicht findet, kann ja auch gleichmal auf einen aktuellen Browser
wechseln - das lohnt sich nicht nur wegen der vielen Seiten, die es dann
plötzlich doch auf Deutsch gibt!
Wer es partou nicht hinbekommt, kann natürlich die deutsche Sprache für
ewiki erzwingen; hilfreich hierfür ist z.B. die include()-Datei
"fragments/force_lang_de.php".
Es funktioniert aber auch mit diesem Befehl, der irgendwo in ewiki.php,
config.php oder yoursite.php eingefügt werden kann (nicht empfohlen):
$_SERVER["HTTP_ACCEPT_LANGUAGE"] = "de; q=1.0, en; q=0.2, eo, nl";
-------------------------------------------------------------------------
Im Detail
¯¯¯¯¯¯¯¯¯
Die MySQL DB Tabellenstruktur ist zu einem gewissen Grad kompatibel mit der
des allseits bekannten »PHPWiki« (normalerweise reicht es EWIKI_DB_TABLE_NAME
auf "wiki" zu ändern, um PhpWikis DB weiterzuverwenden).
Dies ist der MySQL Befehl, der die DB-Tabelle erstellt (beim ersten Start,
automatisch):
CREATE TABLE ewiki (
pagename VARCHAR(160) NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
flags INTEGER UNSIGNED DEFAULT 0,
content MEDIUMTEXT,
author VARCHAR(100) DEFAULT 'ewiki',
created INTEGER UNSIGNED DEFAULT 0,
lastmodified INTEGER UNSIGNED DEFAULT 0,
refs TEXT,
meta TEXT,
hits INTEGER UNSIGNED DEFAULT 0,
PRIMARY KEY id (pagename, version)
)
Den Spaltennamen {pagename} mochte ich eigentlich nicht, aber weil das der
offensichtlich einzige Unterschied zur PhpWiki-Tabelle war, kam mir die Idee
mit der Kombatibilität un so hab ich das adaptiert.
Dummerweise muß nun die ewiki_database() Funktion "pagename" ständig von
und nach "id" übersetzen.
Die Spalte {version} wird zur Speicherung der verschiedenen abgelegten
Seitenänderungen verwendet. In anderen Wikis gibt es zu diesem Zweck eine
Bonus-tabelle wie "backup" oder "history", aber ich hab den Sinn von sowas
bisher nicht verstanden; und daher gibt es in ewiki nur diese eine Tabelle
(und das scheint absolut zu reichen)!
Die erste {version} einer Seite erhält die Nummer 1. Eine bestehende
Seiten {version} wird niemals überschrieben werden => sehr sicherer MySQL-
Einsatz.
Mehr über die {flags} in dem entsprechenden Abschnitt in der README. Das
Feld {content} enthält natürlich den WikiSeitenQuelltext. {created} und
{lastmodified} enthalten die entsprechenden Zeitangaben im UNIX format.
{refs} enthälte eine "\n" - getrennte Liste von referenzierten WikiSeiten.
Der Code um diese List zu erzeugen ist etwas unsauber, so daß oftmals
GeisterSeiten aufgeführt sind. Wieauchimmer, daß beeinträchtigt ewiki
nicht wirklich, und eine Korrektur wäre Zeit- und Geschwindigkeits-
verschwendung.
{meta} kann Bonusinfos enth, so daß die Tabellenstruktur nicht bei jeder
Erweiterung geändert werden muß. Aktuell nur für Binärdaten (Bilder)
verwendet.
{hits} zählt die Seitenaufrufe, und ist nicht in {meta} integriert, weil
separat schneller und einfacher zu verwenden.
Die ewiki DB Tabelle kann nicht nur Texteseiten enthalten, sondern auch
binären Inhalt (vornehmlich Bilder), siehe {flags}.
Das Ein-Tabellen-Konzept hat es übrigens auch recht einfach gemacht, das
Datei-basierte DB-Backend zu entwickeln. Eine Beispieldatei:
id: WikiPageName
version: 1
flags: 1
author: 127.0.0.1:3054
created: 1046532697
lastmodified: 1046532697
refs: \nErfurtWiki\nNewestPages\n
!! WikiSourceContent
<more-text>...
ewiki_ Funktionen
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Einige der Basis-Funktionen aus ewiki.php können getrennt von den anderen
verwendet werden, andere sind ausgelegt um durch bessere Implementierungen
ersetzt zu werden.
ewiki_page($id)
---------------
Hauptfunktion, die die angefragte WikiSeite (oder die mit $id
angegebene) aus der DB holt, und mit ewiki_format() die fertige
HTML-Seite erzeugt.
Wenn die angefragte Seite nicht existert, wird eine edit-Box
zurückgegeben.
ewiki_page_...()
----------------
Die meisten Fkt. mit diesem Prefix wurden aus der Hauptfkt.
herausgetrennt, um ewiki übersichtlicher und leichter erweiterbar
zu machen.
Die meisten enthalten Code um spezielle/interne Seiten zu erzeugen
(Suche, Neuest, Info, und das Edit <FORMular>, ...)
ewiki_script()
--------------
Erzeugt URL aus angegebener Seiten $id und $action, verwendet dazu
die EWIKI_SCRIPT-Konstante. Dieser wrapper ermöglicht es auch die
eigentlich reservierten Schrägstriche in Seitennamen zu verwenden.
ewiki_control_links($id, $data)
-------------------------------
Gibt die Zeile mit "DieseSeiteÄndern, SeitenInfo, ... links" aus.
ewiki_format($wiki_source, $scan_links=1, $html_allowed=0)
----------------------------------------------------------
Erzeugt die formatierten (HTML) Ausgabe für den übergebenen
WikiQuelltext.
Der zweite Parameter gibt an, ob nach denen im Quelltext referenzierten
WikiLinks in der DB nachgesehen werden soll. Wenn dieser Parameter 0
ist, dann wird eine bereits vorh. $ewiki_links Array stattdessen
verwendet, um zu prüfen ob eine Seite in der DB vorh. ist.
ewiki_link_regex_callback()
---------------------------
Aufgerufen aus ewiki_format(). Um ewiki_format() {die eigentliche
WikiEngine} weiter von der Datenbank zu trennen, verwendet diese
Fkt. das globale array in $ewiki_links, in dem normalerweise vorher
schon gefundene WikiSeiten eingetragen wurden (siehe zweiter Param.
von ewiki_format) um entweder einen normalen Verweis oder einen
Fragezeichen-Link auszugeben (wenn die angegebene Seite noch nicht
exisitiert).
ewiki_binary()
--------------
Wird automatisch aufgerufen, wenn das Skript mit dem ?binary= Anhang
aufgerufen wird, um referenzierte / hochgeladene Bilder auszugeben.
ewiki_author()
--------------
erzeugt einen String, der mit REMOTE_ADDR und $ewiki_author
angereichert wurde.
ewiki_database($FUNCTION, $args=array() )
------------------------------------------
Diese Funktion ist die "Datenbankabstraktion" in ewiki. Sie enthält
''only'' sechs SQL Kommandos, die ersetzt werden müßtem, wenn du eine
andere DB verwenden mußt.
Die einzelnen "atomaren" Funktionen sind beschrieben in der
orignialen README-Datei.
$GLOBALS Verschmutzung
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Zumindest die ewiki_page() Funktion erzeugt einige Variablen im globalen
Namensraum. Natürlich haben auch diese Namen, die sich mit irgendetwas
aus yoursite.php überschneiden sollten:
$ewiki_id - Enthält die DB-$id der aktuellen Seite, ist nicht
immer identisch mit $ewiki_title.
$ewiki_action - Der $action-Parameter, mit dem die Seite angefordert
wurde.
$ewiki_title - Wird nach dem ersten Aufruf von ewiki_page() gestzt,
am nützlichsten um in dem <TITLE> Tag ausgegeben
zu werden - dafür muß aber ewiki_page() schon im
Kopfbereich aufgerufen werden, die Ausgabe gepuffert,
damit der Seitentitel noch innerhalb von <HEAD>
ausgegeben werden kann.
$ewiki_script - Eine Kopie von EWIKI_SCRIPT.
$ewiki_links - Ist ein Arraym daß in ewiki_format() prodiziert wird, und
alle gesuchten WikiSeitenNamen mit einem Wert von 0 oder 1
assoziiert, je nach dem, ob die Seite existiert oder nicht.
Wird diese variable jedoch auf ==true gesetzt (also kein
Array), wird angenommen, daß alle WikiSeiten existieren.
$ewiki_author - Der Inhalt dieser Variable wird in der {author}-Spalte
von gespeicherten WikiSeiten abgelegt (zusammen mit
IP:PORT).
Wenn yoursite.php Benutzer kennt und authentifizieren
kann, sollte der Nutzername hier abgelegt werden.
Diese Feld sollte aber NICHT ZUGEMÜLLT werden mit
irgendwelchen Bonusinfos.
$ewiki_auth_user - Enthält Namen eines wirklich authentifizierten
Benutzers im _PROTECTED_MODE. Nicht notwendig, wird aber
u.a. gerne von ewiki_auth() und ewiki_auth_user() zur
Vereinfachung verwendet.
$ewiki_ring - Berechtigungslevel im _PROTECTED_MODE
3 = nur lesen
2 = normaler Benutzer (lesen, editieren, ...)
1 = Moderator (auch Seiten löschen?)
0 = Administrator (darf alles)
$ewiki_plugins - Dieses array verbindet Aufgabengruppen (z.B. "database"
oder "image_resize") mit Funktionsnamen.
Dies stellt einen wirklich einfachen und dennoch mächtigen
Weg dar, um ewiki zu erweitern.
Es gibt ein eigenes Kapitel darüber in der orig. README.
$ewiki_config - Ersetzt teilweise die EWIKI_ Konstanten.
Folgende gibt's nich mehr (teilweise in $ewiki_config):
$ewiki_data, $ewiki_interwiki, $ewiki_internal_pages,
EWIKI_ Konstanten
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
- - WARNUNG - WARNUNG - WARNUNG - WARNUNG - WARNUNG - WARNUNG - WARNUNG - -
WARNUNG: Dieser Abschnitt ist grundsätzlich besonders inaktuell! Von daher
sollte ein Studium des gleichnamigen Abschnitts in der orig. README-Datei
wirklich vorgezogen werden!! Viele der neu hinzugekommenen Konstanten werden
hier schlichtweg nicht erwähnt, oder inzwischen sogar __falsch__ beschrieben.
- - WARNUNG - WARNUNG - WARNUNG - WARNUNG - WARNUNG - WARNUNG - WARNUNG - -
Dieser Abschnitt erklärt einige der Konstanten und wie man sie verwenden
kann, um ewiki nach der eigenen Pfeife tanzen zu lassen.
Normalerweise solltest diese innherhalb von "ewiki.php" angepaßt werden, einige
sind jedoch mehr wie Statusvariablen ausgelegt und sollten von "yoursite.php"
in Abhängigkeit von dort vorhanden Infos gesetzt werden (wenn dort Benutzer
eingeloggt sind z.B.).
Dann ist es gut einige der Konstanten vorzudefinieren (einmal def. Konst.
können nicht wieder geändert werden).
EWIKI_SCRIPT
Wichtigste Einstellung. Wird von ewiki.php verwendet, um Links zu
anderen WikiSeiten zu erzeugen.
Es benötigt den Namen von yourscript.php, daß selbst wiederrum
ewiki.php geeignet einbindet.
Der Name der angefragten WikiSeite wird immer schlicht an den hier
definierten TextString angehängt, daher sollter dieser immer in
"/" oder "?" oder "?id=" oder "?name=" oder "?page=" enden, damit
eine gültige URL dabei herauskommt und der SeitenName von ewiki_page()
gefunden wird.
Wenn auf deinem Server mod_rewrite vorhanden ist und funktioniert,
könntest du diese Konst. auch leer lassen, so alle Anfragen zu
http://wiki.example.com/ an das richtige Skript übergeben werden.
Ansonsten ist es gut, wenn eine URL absolut zum Server-Hauptpfad
angegeben ist, also z.B. "/~user/wiki/index.php/", damit Browser
keine ungültigen URLs erzeugen, sobald eine $action vor den
Seitennamen gesetzt wird (z.B. "edit/DieseSeite").
Die Konstante wird von ewiki_script() eingesetzt um URLs zu den
angegebenen Seiten zu erstellen (wobei einige Fehler abgefangen
werden).
EWIKI_SCRIPT_URL
Sollte eine absolute URL enthalten, die ebenfalls zum ewiki-wrapper
zeigt, z.B. "http://www.example.com/wiki/?id="
EWIKI_DB_TABLE_NAME
Setzt den Namen der MySQL DB Tabelle fest, die erzeugt und verwendet
werden soll, um alle WikiSeiten abzulegen.
EWIKI_PAGE_INDEX
Definiert den Namen der WikiSeite, die als Startseite angezeigt werden
soll.
EWIKI_PAGE_NEWEST
Name (intern erzeugt) der Seite, die List der zuletzt hinzugefügten
Seiten enthält.
EWIKI_PAGE_SEARCH
Enthält den WikiSeitenNamen für dei SuchFunktion.
EWIKI_CONTROL_LINE
Wenn auf 0 gestzt, wird die Zeile unter einer WikiSeite mit
"DieseSeiteÄndern, SeitenInfo, ..." nicht angezeigt.
In diesem Fall sollte der Edit-Link in yoursite.php erzeugt werden.
Besser ist es normalerweise das Aussehen der Ausgabe in
ewiki_control_links() selbst zu ändern.
EWIKI_AUTO_EDIT
Bei 1 (voreinstellung) wird automatisch eine Edit-Box für
nicht-exisiterende Seiten angezeigt, ansonsten wird eine ZwischenSeite
("Bitte ändere mich!") angezeigt (wie in PhpWiki).
EWIKI_LIST_LIMIT
Maximale Anzahl von Seiten, die in den generierten Listen angezeigt
werden sollen (Suche, ...)
EWIKI_PRINT_TITLE
Wenn 0 werden keine SeitenTitel (WikiSeiten und InterneSeiten)
angeziegt.
EWIKI_ALLOW_HTML
Normalerweise sollte im Wiki keine HTML erlaubt sein - böses JavaScript
und <brokenHTML/>, andere Leute nerven.
Siehe orig. README für mehr Informationen.
EWIKI_RESCUE_HTML
Überholt, siehe plugins/markup_rescuehtml.php
EWIKI_DB_F_TEXT
Dieses Flag wird für normale WikiSeiten in der DB gesetzt.
EWIKI_DB_F_BINARY
Für binären Inhalt in der DB.
EWIKI_DB_F_DISABLED
DB-Eintrage werden hiermit ausgeknippst.
EWIKI_DB_F_HTML
Erlaubt die Verwendung von HTML im WikiQuelltext, unabhängig von
EWIKI_ALLOW_HTML.
EWIKI_DB_F_READONLY
WikiSeite kann nicht verändert werden, so dieses Flag gesetzt ist.
EWIKI_DB_F_WRITEABLE
Umkehrung von READONLY, nur nützlich wenn zuvor alle Seiten mit
EWIKI_EDIT_AUTHENTICATE schriebgeschützt wurden.
EWIKI_ALLOW_OVERWRITE
Für eingeloggte nutzer kann yoursite.php diese Konst. auf 1 setzen, um
auch das Ändern von schreibgeschützten Seiten zu erlauben.
EWIKI_EDIT_AUTHENTICATE
Hiermit kann man ewiki dahingehend kaputt machen, daß alle Seiten
schreibgeschützt werden, und nur veränderbar sind, so yoursite.php
$ewiki_author setzt.
EWIKI_SCRIPT_BINARY
Um binäre Daten ausgeben zu können, muß hier ein wrapper-script
angegeben werden, daß ein Datenbank-Verbindung öffnet und keine
Textausgaben erzeugt, bevor nicht ewiki.php eingebunden wurde,
da sonst nur Datenmüll ausgegeben würde.
Um alle binary-Funktionalität (Bilder hochladen / cachen) loszuwerden,
einfach diese Konstante auf "" setzen, und die folgenden zwei auf 0:
EWIKI_CACHE_IMAGES
Bilder zwischenspeichern.
EWIKI_IMAGE_MAXSIZE
Maximale Größe von Bildern die in der DB abgelegt werden sollen.
EWIKI_IMAGE_RESIZE
Bilder herunterskalieren, wenn zu groß.
EWIKI_IDF_INTERNAL
Wird verwendet um hochgeladene Bilder zu identifizieren. Bitte
im laufenden Betrieb nicht ändern.
EWIKI_ADDPARAMDELIM
Automatisch definiert, enthält entweder "?" oder "&", abhängig von
EWIKI_SCRIPT.
EWIKI_T_*
überholt, siehe ewiki_t() und $ewiki_t[] in der englischen README
EWIKI_CHARS_U
EWIKI_CHARS_L
Erlaubte Zeichen in WikiSeitenNamen (große und kleine Letter). Hiermit
kann man das wiki lokalisieren; deutsche Umlaute sind schon enthalten.
UNIX_MILLENNIUM
Sehr wichtiges Ereignis ;)
Im tools/ Ordner ist ein kleines Script, mit dem man die erwähnten
SeitenFlags ändern kann.
$ewiki_config[] array
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Einige der EWIKI_ Konstanten wurden durch Einträge im $ewiki_config[] Array
ersetzt oder ergänzt (die Konstanten können weiterhin zur Voreinstellung
verwendet werden). Der Vorteil dieses Arrays ist, daß die Einstellungen auch
zur Laufzeit geändert werden können.
Für eine komplette und (einigermaßen) aktuelle Übersicht bemühe bitte die
englischsprachige README.
-------------------------------------------------------------------------
Nur WikiQuelltextTransformation einsetzen
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Die ewiki_format Funktion war entworfen, um sie auch unabhängig von dem
restlichen WikiSkript einsetzen zu können.
Benötigt normalerweise nur den "wiki_source" Parmeter und erzeugt die
HTML-Seite daraus.
ewiki_format($wiki_source, 0);
Alles was man noch anpassen muß ist die $ewiki_links Variable. Setze
$ewiki_links=true ("true" und nicht "1") so daß ewiki_format() später
annimmt alle WikiSeiten würden existieren.
Wers eilig hat, kann auch die extrahierte Variante fragments/wiki_format.inc
verwenden, die Frank Luithle beigesteuert hat.
-------------------------------------------------------------------------
Ohne MySQL DB verwenden
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sollte dein Provider keine MySQL Datenbank für dich bereithalten, kannst
du das plugin "db_flat_files.php" verwenden (einfach include("plugins/...");
aufrufen um es zu laden).
Alle WikiSeiten werden dann in Textdateien in einem nur dafür
bereitgestelltem Ordner gespeichert. Stelle hierzu noch die Konstante
EWIKI_DBFILES_DIRECTORY in der Datei "ewiki.php" passend ein ("/tmp" würde
jedesmal gelöscht, wenn der Server neu startet).
Das Verzeichnus muß relativ zum ewiki.php script angegeben werden, oder
absolut zum Serverhauptverzeichnis, nicht aber relativ zum DocumentRoot
deines Webspeicherplatzes! In diesem Beispiel wäre "./pages" richtig:
Erstelle ein neues Verzeichnis (via FTP-Programm) und gib dem Webserver
Schreibzugriff dafür mit dem Befehl " chmod 777 ./pages ".
ftp> cd .../ewiki
ftp> mkdir pages
ftp> chmod 777 pages
ftp> ls
-rw----r-- 1 deinname deinname 57024 01. Jan 00:00 ewiki.php
-rw----r-- 1 deinname deinname 512 01. Jan 00:00 index.php
drw----r-x 2 deinname deinname 4096 01. Jan 00:00 init-pages
drwxrwxrwx 2 deinname deinname 4096 25. Feb 23:59 pages
drw----r-x 5 deinname deinname 4096 01. Jan 00:00 plugins
-rw----r-- 1 deinname deinname 15826 01. Jan 00:00 README.de
ftp> quit
Mit einem graphischem FTP-Programm gibt es auch immer die Mglk. die
"Dateizugriffsrechte" einzustellen.
db_fast_files
¯¯¯¯¯¯¯¯¯¯¯¯¯
Diese neuere Version von db_flat_files, speichert die WikiSeiten
komprimiert in einem Binär-Format (kann man nicht mehr mit Editor
ansehen und bearbeiten). Zusätzlich wurde der HitZähler aktiviert.
db_fast_files wurde in db_flat_files integriert, so daß das neue
Format jetzt nur noch über eine Konstante aktiviert werden muß
(beide Dateiformate können gleichzeitig in der DB vorhanden sein).
Für die schnellere Variante aktiviere in "plugins/db_flat_files.php"
die entsprechende Konstante:
define("EWIKI_DB_FAST_FILES", 1);
(Diese Einstellung könntest du aber auch schon in der "config.php"
eintragen.)
Zusätzliche Konstante: EWIKI_DBFILES_GZLEVEL sagt wieviel Zeit
beim Komprimieren verschwendet werden soll:
0 - keine Komprimierung
1 - ein ganz klein wenig Kompr.
2 - Voreinstellung, schnell
5 - normaler Wert in zlib, gute Komprimierung
9 - langsam für allerbeste Kompression
Dieses plugin wurde von Carsten Senf beigesteuert.
--------------------------------------------------------------------------
BöseBäckSläshes
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Wenn auf deinen Seiten pötzlich viele "\" RückwärtsSchrägStriche
auftauchen liegt das an einer Fehlkonfiguration von PHP. In älteren
Versionen war leider immer die Option "magic_slashes_gpc" aktiviert
(siehe auch php.ini).
Bitte am besten deinen WebserverProvider das zu ändern. Wenn du aber bei
einem der BilligHoster (umsonst wie sourceforge.net oder tripod.com) bist,
gilt wie immer: einem geschenkten Gaul...
Dann verwende bitte "fragements/strip_wonderful_slashes.php", um das
Problem zumindest zu umschiffen, oder ändere deine .htaccess Datei (Apache)
wie darin beschrieben.
--------------------------------------------------------------------------
Paßwörter und tools/
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Die tools/ sind gefährlich und daher per Voreinstellung nicht ohne weiteres
Nutzbar. In der Datei "tools/t_config.php" wird das Script
"fragmenst/funcs/auth.php" geladen, daß für den Browser-Login-Dialog
verantwortlich ist. Wenn du also die tools/ verwenden willst, mußt du dort
zuerst einen Benutzer mit Paßwort eintragen, sonst geht nix.
Um hingegen dein Wiki zu schützen, so daß nur einige wenige Personen die
Seiten editieren können, ließ dir bitte die Datei "plugins/auth/README.auth"
durch (leider nur in Englisch). Sie beschreibt den _PROTECTED_MODE und
stellt die entsprechenden Plugins vor.

2
mod/wiki/ewiki/UPGRADE Normal file
View file

@ -0,0 +1,2 @@
If you updated from R1.01c or earlier, then use the "tools/upgrade-101d"
to convert the plugin file names in your 'config.php' file.

3472
mod/wiki/ewiki/ewiki.php Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,114 @@
ewiki/fragments/
================
This directory contains various (code) snippets, which may or may not
be useful for you. You are on your own, when it comes to make them
work.
mkhuge
¯¯¯¯¯¯
Is a shell script to merge the core "ewiki.php" with some of the common
extension plugins into a "huge-ewiki.php" script - for lazy people ;->
core.css
¯¯¯¯¯¯¯¯
Is an example (text/css) stylesheet, which shows how to tweak
the look of rendered pages using CSS.
You could copy it into yoursites.css or do something like this in
yoursite.php:
<HTML>
<HEAD>
<STYLE TYPE="text/css"><!--
<?php
include("fragments/core.css");
?>
//--></STYLE>
calendar.css
¯¯¯¯¯¯¯¯¯¯¯¯
These stylesheet definitions show all possible CSS classes that
are used within the calendar.php plugin. Use like core.css
binary.php
¯¯¯¯¯¯¯¯¯¯
If yoursite.php is not designed carefully enough or EWIKI_SCRIPT_BINARY
cannot be set correctly, you may want to use this wrapper script to
allow for uploading and retrieval of binary content (images) via ewiki.
Copy it to where the main ewiki.php script is, and set the
EWIKI_SCRIPT_BINARY constant to the correct absolute position (possibly
including http://server.name/) of "binary.php".
(this constant must be set on top of ewiki.php)
You must set the database access params in here, too.
It may also be useful if you'd like to divide the database into its
two parts again - text content and binary content. You could even
let it save binary content in a flat file database, while WikiPages
remain in a RDBMS.
homepage.src
¯¯¯¯¯¯¯¯¯¯¯¯
Is an __EXAMPLE__ on how to build a crippled Wiki (using authentication)
for a private homepage.
There is a lot of infos inside the script. And please remember all
files labeled with "example" are just examples!!!!!!! (read: I'm rarely
interested in bug reports)
funcs.inc
¯¯¯¯¯¯¯¯¯
Possibly useful pseudo-external helper functions are collected in here.
function save_newest_pages()
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reads the recently updated pages list from the database (like
"UpdatedPages") and tries to save it in another database table
(this example does so in my privately used webcms for speed purposes).
htaccess
¯¯¯¯¯¯¯¯
Shows how to use mod_rewrite with ewiki.
* old style: http://www.example.com/wiki.php?page=WikiPage
* PATH_INFO: http://www.example.com/WikiPage
Remember to enable EWIKI_USE_PATH_INFO inside ewiki.php - this was
disabled once, because of the many broken Apache implementations (they
seem to support that broken CGI/1.1 specification, which was for good
reasons and luckily never blessed to become an official RFC).
strip_wonderful_slashes.php
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Fixes the very bad "magic_quotes_gpc" setting from php.ini for PHP
versions prior to 4.3
Does not hurt a well configured PHP interpreter setup.
wiki_format.inc
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Stripped version of the wiki rendering core for easier inclusion into
your own projects.

View file

@ -0,0 +1,42 @@
<?php
# http user space authentication layer
# ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
# can be used with the tools/, if you don't want to
# set up the .htaccess and .htpasswd files
#-- (pw array - I have such one in an external config file)
$passwords = array(
// "user" => "password",
// "u2" => "password",
);
#-- fetch user:password
if ($uu = trim($_SERVER["HTTP_AUTHORIZATION"])) {
strtok($uu, " ");
$uu = strtok(" ");
$uu = base64_decode($uu);
list($_a_u, $_a_p) = explode(":", $uu, 2);
}
elseif (strlen($_a_u = trim($_SERVER["PHP_AUTH_USER"]))) {
$_a_p = trim($_SERVER["PHP_AUTH_PW"]);
}
#-- check password
$_success = false;
if (strlen($_a_u) && strlen($_a_p) && ($_a_p == @$passwords[$_a_u])) {
$_success = $_a_u;
}
#-- request HTTP Basic authentication otherwise
if (!$_success) {
header('HTTP/1.1 401 Authentication Required');
header('Status: 401 Authentication Required');
header('WWW-Authenticate: Basic realm="restricted access"');
die();
}
?>

View file

@ -0,0 +1,22 @@
<?php
# if you cannot manage to include() the core "ewiki.php" library
# before any plain <HTML> output is made inside "yoursite.php", you
# could use such a lib wrapper beside yoursites/index.php
# it is also useful, if you want to keep binary data in a separate
# database, say a db_flat_files one - because you can then set this up
# herein without any affect to yoursites/ewiki.php
# remember to define() inside ewiki.php or yoursite.php:
define("EWIKI_SCRIPT_BINARY", "binary.php?binary=");
#-- that's all:
mysql_connect("localhost", "DBUSER", "DBPASSWORD");
mysql_query("use DATABASENAME");
include("ewiki.php");
?>

View file

@ -0,0 +1,39 @@
/*
Include these style definitions into your sites` css, if you'd like
to use the calendar plugin.
*/
table.caltable{
background-color: #CDBDAD;
}
td.calhead {
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:center;
}
th.caldays{
color:#BA997A;
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:center;
}
td.calday{
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:right;
}
td.caltoday{
background-color:#D7CFC7;
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
text-align:right;
}
a.calpg{
text-decoration: none;
font-weight:600;
}
a.calhide{
text-decoration: none;
}

View file

@ -0,0 +1,63 @@
/*
These example style definitions only show how to tweak look
of generated WikiPages.
*/
body, td {
line-height:140%;
}
a {
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
p {
line-height:110%;
}
em {
text-decoration:none;
font-style:normal;
background-color:#cccc22;
}
strong {
font-weight:700;
}
.box {
background-color:#222266;
border:1px #111133 solid;
}
.box hr {
display:none;
}
hr {
visibility:hidden;
}
form[name=ewiki] {
border:2px #ffffff dashed;
padding:5px;
background-color:#444444;
}
textarea[name=content] {
border:2px #000000 dotted;
background-color:#B4D3D7;
}
input[name=save], input[name=preview] {
border:1px #000000 solid;
background-color:#B4D3D7;
-moz-border-redius:10px;
}

View file

@ -0,0 +1,33 @@
#
# this file contains various useful helper functions, to interfer
# with the ewiki database from within another site engine
#
# may be there is something useful in here for you, too
#
#-- save newest pages
function save_newest_pages()
{
$sorted = array();
foreach (ewiki_database("GETALL", array("lastmodified", "flags", "version")) as $row) {
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
$sorted[$row["id"]] = $row["lastmodified"];
}
}
arsort($sorted);
$n = 0;
$o = "";
foreach ($sorted as $id=>$uu) {
$o .= '·<a href="/wiki/?id=' . urlencode($id) . '">' .
preg_replace('/(\w{15}[a-zäöüß]*)(\w{3,5})/', '$1&shy;$2', $id) . "</a><br>\n";
if ($n++ >= 15) break;
}
$o = addslashes($o);
mysql_query("UPDATE text_table SET html='$o' WHERE filename='wiki-updated' ")
or
return($o);
}

View file

@ -0,0 +1,172 @@
<?php
#-- This is an example standalone lite-CMS Homepage based on ewiki.php
# - it requires PHP4.1+
# - you should install it as index.php into your dedicated webspace
# - copy the ewiki.php there, too
# - DON'T upload the tools/ directory, as this requires a lot more
# setup to be used securely
# - HTML Editors usually allow you to tweak the layout without
# garbaging the PHP code inside
# - authentication is done using JavaScript+Cookies
# - requires a MySQL database, just visit http://freesql.org/ and
# get happy (if your provider doesn't provide one)
# - there will be no pages initially, you must first create some
# - most config options are in the upper area of this file:
$HOMEPAGE_TITLE = 'MyHomepage';
$LOGIN_PASSWORD = 'ewiki';
$AUTHOR_NAME = 'your_nickname_here';
$MYSQL_HOST = 'localhost';
$MYSQL_USER = 'root';
$MYSQL_PASSWORD = '';
$MYSQL_DATABASE = 'test';
#-- open database
if (!@mysql_ping()) {
mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
mysql_query("use $MYSQL_DATABASE");
}
#-- no errors shown from here
error_reporting(0);
#-- check for password
if ($LOGIN_PASSWORD == "password") die("poor");
if ($_COOKIE["password"]) {
if ($LOGIN_PASSWORD == $_COOKIE["password"]) {
$ewiki_author = $AUTHOR_NAME;
}
else {
$page_content == "<h3>password wrong</h3>";
}
}
#-- load ewiki
define("EWIKI_EDIT_AUTHENTICATE", 1);
define("EWIKI_SCRIPT", substr(__FILE__, strrpos(__FILE__, "/") + 1) . "?page=");
define("EWIKI_SCRIPT_BINARY", substr(__FILE__, strrpos(__FILE__, "/") + 1) . "?binary=");
define("EWIKI_PAGE_INDEX", $HOMEPAGE_TITLE);
define("EWIKI_CONTROL_LINE", 0);
define("EWIKI_T_CANNOTCHANGEPAGE", "You must first login to change a page.");
include("ewiki.php");
#-- get current page
if (empty($page_content)) {
$page_content = ewiki_page();
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo($ewiki_title); ?></title>
<meta name="GENERATOR" content="ewiki" />
<meta name="ROBOTS" content="INDEX,FOLLOW" />
<style type="text/css">
<!--
body {
background-color:#6666ee;
color:#000011;
}
.menu {
background-color:#111166;
color:#ffffff;
border: 2px solid #000055;
padding: 8px;
text-align:center;
width:120px;
}
a,a:link { color: #ffff33; text-decoration: none; }
a:active { color: #FF6666; }
a:visited { color: #660000; }
a:hover { font-weight:900; background-color:#ffff00; color:#000000; }
.menu a { color:#ffffff; }
.menu a:hover { color:#000000; }
//-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function login()
{
var password = window.prompt("Please enter the administrator password:");
window.document.cookie = "password=" + password;
window.document.location.reload();
}
function logout()
{
window.document.cookie = "password=";
}
//-->
</script>
</HEAD>
<BODY>
<CENTER>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="10" WIDTH="90%">
<TR>
<TD WIDTH="120" VALIGN="TOP">
<DIV CLASS="menu">
<h3>Welcome to my Homepage!</h3>
<A HREF=".">Startpage</A> <BR>
<A HREF="?page=EMailMe">EMailMe</A> <BR>
<A HREF="?page=MyLinks">MyLinks</A> <BR>
<BR>
<?php
if ($ewiki_author) {
echo "<A HREF=\"javascript:logout()\">Logout</A><BR>";
echo "<A HREF=\"?page=edit/$ewiki_title\">EditThisPage</A><BR>";
echo "<A HREF=\"?page=info/$ewiki_title\">PageInfo</A><BR>";
}
else {
echo "<A HREF=\"?page=links/$ewiki_title\">Links to here</A><BR><BR>";
echo "<SMALL><A HREF=\"javascript:login()\">EditorLogin</A><BR></SMALL>";
}
?>
</DIV>
</TD>
<TD VALIGN="TOP" WIDTH="90%">
<DIV CLASS="content">
<?php
echo($page_content);
?>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>

View file

@ -0,0 +1,25 @@
# This is file is to be used with the Apache or Nanoweb webserver.
#
# Rename it to .htaccess (or .nwaccess for Nanoweb) in a dedicated
# directory for your Wiki.
#
# It uses the mod_rewrite to look a bit more professionall than
# the usual GET-vars at the end of our URLs. This is highly
# recommended as things like "script.php?edit=1&id=page" usually
# scare search engines and may prevent your Wiki from getting
# indexed.
#
# Please edit ewiki.php and enable EWIKI_USE_PATH_INFO for Apache
# webservers - the PATH_INFO implementation is very broken for many
# versions (mostly commercial Unicies and for PHP-CGI variants),
# because to the Apache Group once choosed to follo that never
# finished and heavily broken (proposed) CGI/1.1 specification.
#-- enable mod_rewrite (Apache + Nanoweb)
RewriteEngine On
#-- pass WikiWord-URLs to the wiki wrapper script:
RewriteRule ^((\w+/)?[A-Z]+[a-z]+\w*[A-Z]+\w+)$ yoursite.php/$1 [L]
#-- or this one, if there is really nothing else in the same directory:
#RewriteRule ^(.*)$ yoursite.php?id=$1 [L]

View file

@ -0,0 +1,61 @@
#!/bin/sh
#
# a shell script, which combines the ewiki.php library and some
# default plugins into a huger include library
#
HUGE_FILE="huge-ewiki.php"
CORE_FILE="ewiki.php"
#-- current dir
if [ -e "ewiki.php" ] ; then
DWP=.
else
DWP=..
fi
#-- help
if [ "$1" == "-h" -o "$1" == "--help" ] ; then
echo "syntax: mkhuge"
echo "combines many of the plugins and the core ewiki.php file into a bigger lib."
exit
fi
#-- choose size
N=$1
if [ -z "$N" ] ; then
N=0
fi
if [ "$1" -ge "3" ] ; then
PLUGINS="markup_phpwiki.php markup_bbcode.php spellcheck.php $PLUGINS"
fi
if [ "$1" -ge "2" ] ; then
PLUGINS="more_interwiki.php page_imagegallery.php $PLUGINS"
fi
if [ "$1" -ge "1" ] ; then
PLUGINS="diff.php page_randompage.php markup_footnotes.php page_wordindex.php $PLUGINS"
fi
PLUGINS="strip_wonderful_slashes.php calendar.php email_protect.php like_pages.php page_pageindex.php page_powersearch.php $PLUGINS"
#-- proceed
echo -n "writing: $CORE_FILE"
cat $DWP/$CORE_FILE > $DWP/$HUGE_FILE
for ADD in $PLUGINS
do
echo -n "+$ADD"
for SUB in plugins fragments ; do
if [ -e "$DWP/$SUB/$ADD" ] ; then
ADD=$DWP/$SUB/$ADD
fi
done
cat $ADD >> $DWP/$HUGE_FILE
done
echo " > $DWP/$HUGE_FILE"
echo "done."

View file

@ -0,0 +1,58 @@
<?php
/*
This is a PHPNuke5.2 module (don't know if it works with v6) to be
copied into the modules directory like the filename implies
( phpnuke/modules/Wiki/ ).
You should copy the "ewiki.php" into the same directory!
If you want it to initialize the db correctly you must copy the
init-pages/ to there as well.
*/
#-- stupid legacy code
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
#-- blocks to the left and to the right?
$index = 0;
#-- HTML,HEAD,TABLESTART
include("header.php"); #-- or better "mainfile.php" ???
#-- Output -----------------------------------------------------------
OpenTable(); # do we want to know, what this is for?
chdir("modules/Wiki/");
error_reporting(0);
define("EWIKI_SCRIPT", "modules.php?op=modload&name=Wiki&file=index&wikipage=");
include("ewiki.php");
($wikipage = $_REQUEST["wikipage"]) or
($wikipage = $_REQUEST["page"]) or
($wikipage = EWIKI_PAGE_INDEX);
echo ewiki_page($wikipage);
chdir("../..");
CloseTable(); # strange function names ;)
# /BODY
include("footer.php");
?>

View file

@ -0,0 +1,49 @@
<?php
/*
this strips all "\" from $_REQUEST and
disables the runtime garbaging as well
just include() it before ewiki.php
and everythink should work fine
for Apache+mod_php you should however rather use the
[.htaccess] PHP reconfiguration trick:
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
*/
#-- this is very evil too
set_magic_quotes_runtime(0);
#-- strip \'s only if the variables garbaging is really enabled
if (get_magic_quotes_gpc()) {
$superglobals = array(
"_REQUEST",
"_GET",
"_POST",
"_COOKIE",
"_ENV",
"_SERVER"
);
foreach ($superglobals as $AREA) {
foreach ($GLOBALS[$AREA] as $name => $value) {
if (!is_array($value)) {
$GLOBALS[$AREA][$name] = stripslashes($value);
}
}
}
}
?>

View file

@ -0,0 +1,291 @@
<?php
/*
* Wiki-Engine from "ErfurtWiki", Mario Salzer <milky@erphesfurt.de>
* Adapted by Frank Luithle <sigi@fsinfo.cs.uni-sb.de>
*
* WikiLinks and binary already stripped off -> just the rendering core
*/
// URL prefixes
$ewiki_idf_url = array( "http://",
"mailto:",
"ftp://",
"irc://",
"telnet://",
"news://",
"internal://",
"chrome://",
"file://" );
// allowed wikinames
//define( "EWIKI_CHARS_L", "a-zäöüß_µ¤$" );
//define( "EWIKI_CHARS_U", "A-ZÄÖÜ" );
function wiki_format( $wiki_source,
$strip_slashes = true,
$safe_html_allowed = true,
$table_html_allowed = false ) {
if ( $strip_slashes ) {
$wiki_source = stripslashes( $wiki_source );
}
// formatted output
$o = "<p>\n";
// state vars
$li_o = "";
$tbl_o = 0;
$post = "";
$wm_whole_line = array( "!!!" => "h2",
"!!" => "h3",
"!" => "h4",
" " => "tt",
";:" => 'div style="left-margin:10pt;"' );
$table_defaults = 'cellpadding="2" border="1" cellspacing="0"';
// these tags will be preserved if the $safe_html_allowed argument
// is set to 'true'
$rescue_html = array( "tt", "b", "i", "strong", "em", "s", "kbd", "var",
"xmp", "sup", "sub", "pre", "q", "h2", "h3", "h4",
"h5", "h6", "cite", "code", "u" );
$syn_htmlentities = array( "&" => "&amp;",
">" => "&gt;",
"<" => "&lt;",
"%%%" => "<br>" );
$wm_list = array( "-" => array('ul type="square"', "", "li"),
"*" => array('ul type="circle"', "", "li"),
"#" => array("ol", "", "li"),
":" => array("dl", "dt", "dd") );
$wm_text_style = array( "'''" => array("''__", "__''"),
"___" => array("''__", "__''"),
"''" => array("<em>", "</em>"),
"__" => array("<strong>", "</strong>"),
// "^^" => array("<sup>", "</sup>"),
// "***" => array("<b><i>", "</i></b>"),
// "###" => array("<big><b>", "</b></big>"),
"**" => array("<b>", "</b>"),
"##" => array("<big>", "</big>"),
"µµ" => array("<small>", "</small>") );
$link_regex = "#(!?\[[^[\]\n]+\])|((?:!?[a-z]{2,6}://|mailto:)[^\s\[\]\'\"\)\,<]+)#";
#$link_regex = "#(!?\[[^[\]\n]+\])|((?:!?[".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L.
# ":]+){2}[\w\d]*)|((?:!?[a-z]{2,6}://|mailto:)[^\s\[\]\'\"\)\,<]+)#";
// eliminate html
foreach ( $syn_htmlentities as $find => $replace ) {
$wiki_source = str_replace( $find, $replace, $wiki_source );
}
array_pop( $syn_htmlentities );
// unescape allowed html
if ( $safe_html_allowed ) {
foreach ( $rescue_html as $tag ) {
foreach( array( $tag, "/$tag", ( $tag = strtoupper($tag) ), "/$tag" )
as $tag ) {
$wiki_source = str_replace( '&lt;' . $tag . '&gt;',
"<" . $tag . ">",
$wiki_source );
}
}
}
$wiki_source = trim( $wiki_source ) . "\n";
foreach ( explode( "\n", $wiki_source ) as $line ) {
$line = rtrim( $line );
$post = "";
// paragraphs
if ( empty($line) ) {
$post .= "</p>\n\n<p>";
} elseif ( strpos( $line, "----" ) === 0 ) {
$o .= "<hr>\n";
continue;
} elseif ( strpos( $line, "&lt;!--" ) === 0 ) {
$o .= "<!-- " . htmlentities( str_replace( "--", "__", substr($line, 7) ) ) . " -->\n";
continue;
}
// unescape html markup || tables wiki markup
if ( strlen( $line ) && ( $line[0] == "|" ) ) {
if ( strlen( $line ) >
strlen( trim( $line, "|" ) ) + 1 ) {
$line = substr( $line, 1, strlen( $line ) - 2 );
if ( !$tbl_o ) {
$o .= "<table " . $table_defaults . ">\n";
}
$line = "<tr>\n<td>" . str_replace("|", "</td>\n<td>", $line) . "</td>\n</tr>";
$tbl_o = 1;
} elseif ( $table_html_allowed ) {
$line = ltrim( substr( $line, 1 ) );
foreach ( array_flip( $syn_htmlentities ) as $find => $replace ) {
$line = str_replace( $find, $replace, $line );
}
}
} elseif ($tbl_o) {
$o .= "</table>\n";
$tbl_o = 0;
}
// whole-line wikimarkup
foreach ( $wm_whole_line as $find => $replace ) {
if ( substr( $line, 0, strlen($find) ) == $find ) {
$line = ltrim( substr( $line, strlen($find) ) );
$o .= "<$replace>";
$post = "</" . strtok( $replace, " " ) . ">" . $post;
}
}
// wiki list markup
if ( strlen( $li_o ) ||
strlen( $line ) && isset( $wm_list[@$line[0]] ) ) {
$n = 0;
$li = "";
// count differences to previous list wikimarkup
while ( strlen( $line ) && ( $li0 = $line[0] ) && isset( $wm_list[$li0] ) ) {
$li .= $li0;
$n++;
$line = substr($line, 1);
}
$line = ltrim($line);
// fetch list definition
if ( strlen( $li ) && ( $last_list_i = $li[strlen($li)-1] ) )
list( $list_tag, $list_dt0, $list_entry_tag ) = $wm_list[$last_list_i];
// output <ul> until new list wikimarkup rule matched
while ( strlen($li_o) < strlen($li) ) {
$add = $li[ strlen($li_o) ];
$o .= "<" . $wm_list[ $add ][ 0 ] . ">\n";
$li_o .= $add;
}
// close </ul> lists until "$li_o" == "$li" (list wikimarkup state var)
while ( strlen($li_o) > strlen($li) ) {
$del = $li_o[ strlen($li_o) - 1 ];
$o .= "</" . strtok( $wm_list[$del][0], " " ) . ">\n";
$li_o = substr( $li_o, 0, strlen($li_o) - 1 );
}
// more work for <dl> lists
if ( !empty($list_dt0) ) {
list( $line_dt, $line ) = explode( $last_list_i, $line, 2 );
$o .= "<$list_dt0>$line_dt</$list_dt0>";
$list_dt0 = $last_list_i = false;
}
// finally enclose current line in <li>...</li>
if ( !empty($line) ) {
$o .= "<$list_entry_tag>";
$post = "</$list_entry_tag>" . $post;
}
$li_o = $li;
}
// link-regex here??
// (was formerly, may be faster if applied to the whole formatted
// page, but this could also introduce some rendering bugs)
// text style triggers
foreach ( $wm_text_style as $find => $replace ) {
$n = strlen( $find );
$loop = 20;
while( ( $loop-- ) &&
( ($l = strpos($line, $find)) !== false ) &&
( $r = strpos($line, $find, $l + $n) ) ) {
$line = substr( $line, 0, $l ) . $replace[0] .
substr( $line, $l + strlen($find), $r - $l - $n ) .
$replace[1] . substr( $line, $r + $n );
}
}
// add formatted line to page-output
$o .= $line . $post . "\n";
}
// close last line
$o .= "</p>\n";
// finally the link-detection-regex
// (impossible to do with simple string arithmetics)
$o = preg_replace_callback( $link_regex, "wiki_link_regex_callback", $o );
return( $o );
}
function wiki_link_regex_callback( $uu ) {
global $ewiki_idf_url;
$str = $uu[0];
// link bracket '[' escaped with '!'
if ( $str[0] == "!" ) {
return(substr($str, 1));
} elseif ( $str[0] == "[" ) {
$str = substr( $str, 1, strlen($str) - 2 );
}
// explicit title given via [ foo | bar ]
$href = $title = strtok( $str, "|" );
if ( $uu = strtok("|") ) {
$href = $uu;
}
// title and href swapped: swap back
if ( strpos( "://", $title ) ||
strpos( $title, ":" ) && !strpos( $href, ":" ) ) {
$uu = $title;
$title = $href;
$href = $uu;
}
$title = trim($title);
$href = trim($href);
/* create _no_ WikiLinks */
if ( false ):
// interwiki links
if ( strpos($href, ":") &&
!strpos($href, "//") &&
($p1 = @$ewiki_interwiki[strtok($href, ":")]) ) {
while ($p1_alias = @$ewiki_interwiki[$p1]) {
$p1 = $p1_alias;
}
$href = $p1 . strtok("\000");
} elseif (($ewiki_links === true) ||
@$ewiki_links[$href] ||
@$ewiki_internal_pages[$href]) {
// ordinary internal WikiLinks
$str = '<a href="' . EWIKI_SCRIPT .
urlencode($href) . '">' . $title . '</a>';
} else {
$str = '<b>' . $title . '</b><a href="' .
EWIKI_SCRIPT . urlencode($href) /*.EWIKI_ADDPARAMDELIM.'edit'*/ .
' ">?</a>';
}
endif;
// convert normal URLs
foreach ( $ewiki_idf_url as $find ) {
if ( strpos( $href, $find ) === 0 ) {
$str = '<a href="' . $href . '">' . $title . '</a>';
break;
}
}
return($str);
}
?>

View file

@ -0,0 +1,305 @@
<?php
# This plugin protects email addresses from getting seen by spambots,
# by the cost of additonal effort for real persons, who really want
# to mail someone.
#
# It is __really safe__ because it protects addresses with an request
# <FORM> before the real email address gets shown on a page (it seems
# impossible to me, that there are already all that intelligent spambots
# available, which can automatically fill out a <form> to access the
# following page).
# The 'cipher' method is really unimportant, when it comes to tricking
# automated harvesters.
#
# Additionally it generates faked/trap email addresses to annoy the
# marketing mafia.
#-- change these from time to time:
define("EWIKI_PAGE_EMAIL", "ProtectedEmail");
define("EWIKI_UP_ENCEMAIL", "encoded_email");
define("EWIKI_UP_NOSPAMBOT", "i_am_no_spambot");
define("EWIKI_UP_REQUESTLV", "rl");
define("EWIKI_FAKE_EMAIL_LOOP", 5);
$ewiki_config["feedbots_tarpits"] = "@spamassassin.taint.org,@123webhosting.org,@e.mailsiphon.com,@heypete.com,@ncifcrf.gov";
$ewiki_config["feedbots_badguys"] = "@riaa.com,@whitehouse.gov,@aol.com,@microsoft.com";
#-- text, translations
$ewiki_t["en"]["PROTE0"] = "Protected Email Address";
$ewiki_t["en"]["PROTE1"] = "The email address you've clicked on is protected by this form, so it won't get found by <a href=\"http://google.com/search?q=spambots\">spambots</a> (automated search engines, which crawl the net for addresses just for the entertainment of the marketing mafia).";
$ewiki_t["en"]["PROTE2"] = "The page you're going to edit contains at least one email address. To protect it we must ensure that no spambot reaches the edit box (with the email address in cleartext).";
$ewiki_t["en"]["PROTE4"] = "I'm no spambot, really!";
$ewiki_t["en"]["PROTE5"] = "<b>generate more faked email addresses</b>";
$ewiki_t["en"]["PROTE6"] = "the email address you've clicked on is:";
$ewiki_t["en"]["PROTE7"] = "<b>spammers, please eat these:</b>";
$ewiki_t["de"]["PROTE0"] = "Geschützte EMail-Adresse";
$ewiki_t["de"]["PROTE1"] = "Die EMail-Adresse, die du angeklickt hast, wird durch dieses Formular vor <a href=\"http://google.com/search?q=spambots\">spambots</a> (automatisierte Suchwerkzeuge, die das Netz zur Freude der MarketingMafia nach Adressen abgrasen) beschützt.";
$ewiki_t["de"]["PROTE2"] = "Die Seite, die du ändern willst, enthält momentan wenigstens eine EMail-Adresse. Um diese zu schützen müssen wir sicherstellen, daß kein Spambot an die Edit-Box kommt (weil dort die Adresse ja im Klartext steht).";
$ewiki_t["de"]["PROTE4"] = "Ich bin wirklich kein Spambot!";
$ewiki_t["de"]["PROTE5"] = "<b>noch mehr fingierte Adressen anzeigen</b>";
$ewiki_t["de"]["PROTE6"] = "die EMail-Adresse die du angeklickt hast lautet:";
$ewiki_t["de"]["PROTE7"] = "<b>Liebe Spammer, bitte freßt das:</b>";
#-- plugin glue
$ewiki_plugins["link_url"][] = "ewiki_email_protect_link";
$ewiki_plugins["page"][EWIKI_PAGE_EMAIL] = "ewiki_email_protect_form";
$ewiki_plugins["edit_hook"][] = "ewiki_email_protect_edit_hook";
$ewiki_plugins["page_final"][] = "ewiki_email_protect_enctext";
function ewiki_email_protect_enctext(&$html, $id, $data, $action) {
$a_secure = array("info", "diff");
if (in_array($action, $a_secure)) {
$html = preg_replace('/([-_+\w\d.]+@[-\w\d.]+\.[\w]{2,5})\b/me',
'"<a href=\"".ewiki_email_protect_encode("\1",2).
"\">".ewiki_email_protect_encode("\1",0)."</a>"',
$html);
}
}
/* ewiki_format() callback function to replace mailto: links with
* encoded redirection URLs
*/
function ewiki_email_protect_link(&$href, &$title) {
if (substr($href, 0, 7) == "mailto:") {
$href = substr($href, 7);
$href = ewiki_email_protect_encode($href, 2);
$title = ewiki_email_protect_encode($title, 0);
}
}
/* the edit box for every page must be protected as well - else all
* mail addresses would still show up in the wikimarkup (cleartext)
*/
function ewiki_email_protect_edit_hook($id, &$data, &$hidden_postdata) {
$hidden_postdata[EWIKI_UP_NOSPAMBOT] = 1;
if (empty($_REQUEST[EWIKI_UP_NOSPAMBOT])
&& strpos($data["content"], "@")
&& preg_match('/\w\w@([-\w]+\.)+\w\w/', $data["content"]) )
{
$url = ewiki_script("edit", $id);
$o = ewiki_email_protect_form($id, $data, "edit", "PROTE2", $url);
return($o);
}
if (!empty($_POST[EWIKI_UP_NOSPAMBOT]) && empty($_COOKIE[EWIKI_UP_NOSPAMBOT]) && EWIKI_HTTP_HEADERS) {
setcookie(EWIKI_UP_NOSPAMBOT, "grant_access", time()+7*24*3600, "/");
}
}
/* this places a <FORM METHOD="POST"> in between the WikiPage with the
* encoded mail address URL and the page with the clearly readable
* mailto: string
*/
function ewiki_email_protect_form($id, $data=0, $action=0, $text="PROTE1", $url="") {
if ($url || ($email = @$_REQUEST[EWIKI_UP_ENCEMAIL])) {
$html = "<h3>" . ewiki_t("PROTE0") . "</h3>\n";
if (empty($_REQUEST[EWIKI_UP_NOSPAMBOT])) { #// from GET,POST,COOKIE
(empty($url)) and ($url = ewiki_script("", EWIKI_PAGE_EMAIL));
$html .= ewiki_t($text) . "<br><br><br>\n";
$html .= '<form action="' . $url .
'" method="POST" enctype="multipart/form-data" encoding="iso-8859-1">';
$html .= '<input type="hidden" name="'.EWIKI_UP_ENCEMAIL.'" value="' . $email . '">';
foreach (array_merge($_GET, $_POST) as $var=>$value) {
if (($var != "id") && ($var != EWIKI_UP_ENCEMAIL) && ($var != EWIKI_UP_NOSPAMBOT)) {
$html .= '<input type="hidden" name="' . htmlentities($var) . '" value="' . htmlentities($value) . '">';
}
}
$html .= '<input type="checkbox" name="'.EWIKI_UP_NOSPAMBOT.'" value="true"> ' . ewiki_t("PROTE4") . '<br><br>';
$html .= '<input type="submit" name="go"></form><br><br>';
if (EWIKI_FAKE_EMAIL_LOOP) {
$html .= "\n" . ewiki_t("PROTE7") . "<br>\n";
$html .= ewiki_email_protect_feedbots();
}
}
else {
$email = ewiki_email_protect_encode($email, -1);
$html .= ewiki_t("PROTE6") . "<br>";
$html .= '<a href="mailto:' . $email . '">' . $email . '</a>';
if (EWIKI_HTTP_HEADERS && empty($_COOKIE[EWIKI_UP_NOSPAMBOT])) {
setcookie(EWIKI_UP_NOSPAMBOT, "grant_access", time()+7*24*3600, "/");
}
}
}
return($html);
}
/* security really does not depend on how good "encoding" is, because
* bots cannot automatically guess that one is actually used
*/
function ewiki_email_protect_encode($string, $func) {
switch ($func) {
case 0: // garbage shown email address
if (strpos($string, "mailto:") === 0) {
$string = substr($string, 7);
}
while (($rd = strrpos($string, ".")) > strpos($string, "@")) {
$string = substr($string, 0, $rd);
}
$string = strtr($string, "@.-_", "»·±¯");
break;
case 1: // encode
$string = str_rot17($string);
$string = base64_encode($string);
break;
case -1: // decode
$string = base64_decode($string);
$string = str_rot17($string);
break;
case 2: // url
$string = ewiki_script("", EWIKI_PAGE_EMAIL,
array(EWIKI_UP_ENCEMAIL => ewiki_email_protect_encode($string, 1))
);
break;
}
return($string);
}
/* this is a non-portable string encoding fucntion which ensures, that
* encoded strings can only be decoded when requested by the same client
* or user in the same dialup session (IP address must match)
* feel free to exchange the random garbage string with anything else
*/
function str_rot17($string) {
if (!defined("STR_ROT17")) {
$i = @$_SERVER["SERVER_SOFTWARE"] .
@$_SERVER["HTTP_USER_AGENT"] .
@$_SERVER["REMOTE_ADDR"];
$i .= 'MxQXF^e-0OKC1\\s{\"?i!8PRoNnljHf65`Eb&A(\':g[D}_|S#~3hG>*9yvdI%<=.urcp/@$ZkqL,TWBw]a;72UzYJ)4mt+ V';
$f = "";
while (strlen($i)) {
if (strpos($f, $i[0]) === false) {
$f .= $i[0];
}
$i = substr($i, 1);
}
define("STR_ROT17", $f);
}
return(strtr($string, STR_ROT17, strrev(STR_ROT17)));
}
/* this function emits some html with random (fake) email addresses
* and spambot traps
*/
function ewiki_email_protect_feedbots() {
global $ewiki_config;
$html = "";
srand(time()/17-1000*microtime());
#-- spamtraps, and companys/orgs fighting for spammers rights
$domains = explode(",",
$ewiki_config["feedbots_tarpits"]. "," .$ewiki_config["feedbots_badguys"]
);
$traps = explode(" ", "blockme@relays.osirusoft.com simon.templar@rfc1149.net james.bond@ada-france.org anton.dvorak@ada.eu.org amandahannah44@hotmail.com usenet@fsck.me.uk meatcan2@beatrice.rutgers.edu heystupid@artsackett.com listme@dsbl.org bill@caradoc.org spamtrap@spambouncer.org spamtrap@woozle.org gfy@spamblocked.com listme@blacklist.woody.ch tarpit@lathi.net");
$word_parts = explode(" ", "er an Ma ar on in el en le ll Ca ne ri De Mar Ha Br La Co St Ro ie Sh Mc re or Be li ra Al la al Da Ja il es te Le ha na Ka Ch is Ba nn ey nd He tt ch Ho Ke Ga Pa Wi Do st ma Mi Sa Me he to Car ro et ol ck ic Lo Mo ni ell Gr Bu Bo Ra ia de Jo El am An Re rt at Pe Li Je She Sch ea Sc it se Cha Har Sha Tr as ng rd rr Wa so Ki Ar Bra th Ta ta Wil be Cl ur ee ge ac ay au Fr ns son Ge us nt lo ti ss Cr os Hu We Cor Di ton Ri ke Ste Du No me Go Va Si man Bri ce Lu rn ad da ill Gi Th and rl ry Ros Sta sh To Se ett ley ou Ne ld Bar Ber lin ai Mac Dar Na ve no ul Fa ann Bur ow Ko rs ing Fe Ru Te Ni hi ki yn ly lle Ju Del Su mi Bl di lli Gu ine do Ve Gar ei Hi vi Gra Sto Ti Hol Vi ed ir oo em Bre Man ter Bi Van Bro Col id Fo Po Kr ard ber sa Con ick Cla Mu Bla Pr Ad So om io ho ris un her Wo Chr Her Kat Mil Tre Fra ig Mel od nc yl Ale Jer Mcc Lan lan si Dan Kar Mat Gre ue rg Fi Sp ari Str Mer San Cu rm Mon Win Bel Nor ut ah Pi gh av ci Don ot dr lt ger co Ben Lor Fl Jac Wal Ger tte mo Er ga ert tr ian Cro ff Ver Lin Gil Ken Che Jan nne arr va ers all Cal Cas Hil Han Dor Gl ag we Ed Em ran han Cle im arl wa ug ls ca Ric Par Kel Hen Nic len sk uc ina ste ab err Or Am Mor Fer Rob Luc ob Lar Bea ner pe lm ba ren lla der ec ric Ash Ant Fre rri Den Ham Mic Dem Is As Au che Leo nna rin enn Mal Jam Mad Mcg Wh Ab War Ol ler Whi Es All For ud ord Dea eb nk Woo tin ore art Dr tz Ly Pat Per Kri Min Bet rie Flo rne Joh nni Ce Ty Za ins eli ye rc eo ene ist ev Der Des Val And Can Shi ak Gal Cat Eli May Ea rk nge Fu Qu nie oc um ath oll bi ew Far ich Cra The Ran ani Dav Tra Sal Gri Mos Ang Ter mb Jay les Kir Tu hr oe Tri lia Fin mm aw dy cke itt ale wi eg est ier ze ru sc My lb har ka mer sti br ya Gen Hay a b c d e f g h i j k l m n o p q r s t u v w x y z");
$word_delims = explode(" ", "0 1 2 3 3 3 4 5 5 6 7 8 9 - - - - - - - _ _ _ _ _ _ _ . . . . . . .");
$n_dom = count($domains)-1;
$n_trp = count($traps)-1;
$n_wpt = count($word_parts)-1;
$n_wdl = count($word_delims)-1;
for ($n = 1; $n < EWIKI_FAKE_EMAIL_LOOP; $n++) {
// email name part
$m = "";
while (strlen($m) < rand(3,17)) {
$a = $word_parts[nat_rand($n_wpt)];
if (!empty($m)) {
$a = strtolower($a);
if (rand(1,9)==5) {
$m .= $word_delims[rand(0,$n_wdl)];
}
}
$m .= $a;
}
// add domain
switch ($dom = $domains[rand(0, $n_dom)]) {
case "123webhosting.org":
$m = strtr(".", "-", $_SERVER["REMOTE_ADDR"])."-".$_SERVER["SERVER_NAME"]."-".time();
break;
default:
}
$m .= $dom;
$html .= '<a href="mailto:'.$m.'">'.$m.'</a>'.",\n";
}
$html .= '<a href="mailto:'.$traps[rand(0, $n_trp)].'">'.$traps[rand(0, $n_trp)].'</a>';
if (($rl = 1 + @$_REQUEST[EWIKI_UP_REQUESTLV]) < EWIKI_FAKE_EMAIL_LOOP) {
$html .= ",\n" . '<br><a href="' .
ewiki_script("", EWIKI_PAGE_EMAIL,
array(
EWIKI_UP_ENCEMAIL=>ewiki_email_protect_encode($m, 1),
EWIKI_UP_REQUESTLV=>"$rl"
)
) . '">' . ewiki_t("PROTE5") . '</a><br>' . "\n";
($rl > 1) && sleep(3);
}
sleep(1);
return($html);
}
function nat_rand($max, $dr=0.5) {
$x = $max+1;
while ($x > $max) {
$x = rand(0, $max * 1000)/100;
$x = $x * $dr + $x * $x / 2 * (1-$dr) / $max;
}
return((int)$x);
}
?>

View file

@ -0,0 +1,122 @@
<?php
/*
This plugin is used as SetupWizard and initializes the database with
the distributed default pages from the ./init-pages directory. It
gives some configuration advice, when it thinks this is necessary.
You need this plugin to run only once (when you first run the Wiki),
afterwards you can and should comment out the include() directive which
enabled it.
*/
$ewiki_plugins["handler"][-125] = "ewiki_initialization_wizard";
$ewiki_plugins["page_init"][] = "ewiki_initialization_wizard2";
function ewiki_initialization_wizard2($id, &$data, $action) {
global $ewiki_plugins;
#-- disable the default handler
unset($ewiki_plugins["handler"][-105]);
}
function ewiki_initialization_wizard($id, &$data, &$action) {
global $ewiki_plugins;
#-- proceed only if frontpage missing or explicetely requested
if ((strtolower($id)=="wikisetupwizard") || ($id==EWIKI_PAGE_INDEX) && ($action=="edit") && empty($data["version"]) && !($_REQUEST["abort"])) {
if ($_REQUEST["abort"]) {
}
#-- first print some what-would-we-do-stats
elseif (empty($_REQUEST["init"])) {
$o = "<h2>WikiSetupWizard</h2>\n";
$o .= "You don't have any pages in your Wiki yet, so we should try to read-in the default ones from <tt>init-pages/</tt> now.<br><br>";
$o .= '<a href="'.ewiki_script("",$id,array("init"=>"now")).'">[InitializeWikiDatabase]</a>';
$o .= " &nbsp; ";
$o .= '<a href="'.ewiki_script("",$id,array("abort"=>"this")).'">[NoThanks]</a>';
$o .= "<br><br>";
#-- analyze and print settings and misconfigurations
$pf_db = $ewiki_plugins["database"][0];
$db = substr($pf_db, strrpos($pf_db, "_") + 1);
$o .= '<table border="0" width="90%" class="diagnosis">';
$o .= '<tr><td>DatabaseBackend</td><td>';
$o .= "<b>" . $db . "</b><br>";
if ($db == "files") {
$o .= "<small>_DBFILES_DIR='</small><tt>" . EWIKI_DBFILES_DIRECTORY . "'</tt>";
if (strpos(EWIKI_DBFILES_DIRECTORY, "tmp")) {
$o .= "<br><b>Warning</b>: Storing your pages into a temporary directory is not what you want (there they would get deleted randomly), except for testing purposes of course. See the README.";
}
}
else {
$o .= "(looks ok)";
}
$o .= "</td></tr>";
$o .= '<tr><td>WikiSoftware</td><td>ewiki '.EWIKI_VERSION."</td></tr>";
$o .= "</table>";
#-- more diagnosis
if (ini_get("magic_quotes")) {
$o.= "<b>Warning</b>: Your PHP interpreter has enabled the ugly and outdated '<i>magic_quotes</i>'. This will lead to problems, so please ask your provider to correct it; or fix it yourself with .htaccess settings as documented in the README. Otherwise don't forget to include() the <tt>fragments/strip_wonderful_slashes.php</tt> (it's ok to proceed for the moment).<br><br>";
}
if (ini_get("register_globals")) {
$o.= "<b>Security warning</b>: The horrible '<i>register_globals</i>' setting is enabled. Without always using <tt>fragments/strike_register_globals.php</tt> or letting your provider fix that, you could get into trouble some day.<br><br>";
}
return('<div class="wiki view WikiSetupWizard">' . $o . '</div>');
}
#-- actually initialize the database
else {
ewiki_database("INIT", array());
if ($dh = @opendir($path=EWIKI_INIT_PAGES)) {
while ($filename = readdir($dh)) {
if (preg_match('/^(['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+\w*)+/', $filename)) {
$found = ewiki_database("FIND", array($filename));
if (! $found[$filename]) {
$content = implode("", file("$path/$filename"));
ewiki_scan_wikiwords($content, $ewiki_links, "_STRIP_EMAIL=1");
$refs = "\n\n" . implode("\n", array_keys($ewiki_links)) . "\n\n";
$save = array(
"id" => "$filename",
"version" => "1",
"flags" => "1",
"content" => $content,
"author" => ewiki_author("ewiki_initialize"),
"refs" => $refs,
"lastmodified" => filemtime("$path/$filename"),
"created" => filectime("$path/$filename") // (not exact)
);
ewiki_database("WRITE", $save);
}
}
}
closedir($dh);
}
else {
return("<b>ewiki error</b>: could not read from directory ". realpath($path) ."<br>\n");
}
#-- try to view/ that newly inserted page
if ($data = ewiki_database("GET", array("id"=>$id))) {
$action = "view";
}
#-- let ewiki_page() proceed as usual
return("");
}
}
}
?>

View file

@ -0,0 +1,102 @@
<?php
/*
This plugin adds a page redirection feature. ewiki instantly switches
to another page, when one of the following markup snippets is found:
[jump:AnotherPage]
[goto:SwitchToHere]
or
[jump:WardsWiki:WelcomeVisitors]
[jump:Google:ErfurtWiki:MarioSalzer]
[jump:http://www.heise.de/]
One can also use [redirect:] or [location:]. Page switching only occours
with the "view" action. Sending a HTTP redirect is the default, but in
place redirects are also possible.
There exists a loop protection, which limits redirects to 5 (for browsers
that cannot detect this themselfes).
*/
#-- config
define("EWIKI_JUMP_HTTP", 1); #-- issue a HTTP redirect, or jump in place
define("EWIKI_UP_REDIRECT_COUNT", "redir");
#-- text
$ewiki_t["en"]["REDIRECTION_LOOP"] = "<h2>Redirection loop detected<h2>\nOperation stopped, because we're traped in an infinite redirection loop with page \$id.";
#-- plugin glue
$ewiki_plugins["handler"][] = "ewiki_handler_jump";
$ewiki_config["interwiki"]["jump"] = "";
$ewiki_config["interwiki"]["goto"] = "";
function ewiki_handler_jump(&$id, &$data, &$action) {
global $ewiki_config;
static $redirect_count = 5;
$jump_markup = array("jump", "goto", "redirect", "location");
#-- we only care about "view" action
if ($action != "view") {
return;
}
#-- escape from loop
if (isset($_REQUEST["EWIKI_UP_REDIRECT_COUNT"])) {
$redirect_count = $_REQUEST["EWIKI_UP_REDIRECT_COUNT"];
}
if ($redirect_count-- <= 0) {
return(ewiki_t("REDIRECTION_LOOP", array("id"=>$id)));
}
#-- search for [jump:...]
if ($links = explode("\n", trim($data["refs"])))
foreach ($links as $link) {
if (strlen($link) && strpos($link, ":")
&& in_array(strtolower(strtok($link, ":")), $jump_markup)
&& ($dest = trim(strtok("\n"))) )
{
$url = "";
if (strpos($dest, "://")) {
$url = $dest;
}
else {
$url = ewiki_interwiki($dest);
}
#-- Location:
if (EWIKI_JUMP_HTTP && EWIKI_HTTP_HEADERS && !headers_sent()) {
if (empty($url)) {
$url = ewiki_script("", $dest,
array(EWIKI_UP_REDIRECT_COUNT=>$redirect_count),
0, 0, ewiki_script_url()
);
}
header("Location: $url");
die();
}
#-- show page as usual, what will reveal dest URL
elseif ($url) {
return("");
# the rendering kernel will just show up the [jump:]!
# (without the jump: of course)
}
#-- it's simply about another WikiPage
else {
#-- we'll just restart ewiki
$data = array();
$id = $dest;
return(ewiki_page("view/".$id));
}
}
}#-search
}
?>

View file

@ -0,0 +1,379 @@
<?php
require_once("../../config.php");
require_once("$CFG->dirroot/files/mimetypes.php");
# this is the upload/download plugin, which allows to put arbitrary binary
# files into the ewiki database using the provided specialized form, or the
# standard image upload form below every edit page (if EWIKI_ALLOW_BINARY)
#-- settings
define("EWIKI_UPLOAD_MAXSIZE", 2*1024*1024);
define("EWIKI_PAGE_UPLOAD", "FileUpload");
define("EWIKI_PAGE_DOWNLOAD", "FileDownload");
define("EWIKI_ACTION_ATTACHMENTS", "attachments"); #-- define to 0 to disable
#-- register plugin (main part)
$ewiki_plugins["page"][EWIKI_PAGE_UPLOAD] = "ewiki_page_fileupload";
$ewiki_plugins["page"][EWIKI_PAGE_DOWNLOAD] = "ewiki_page_filedownload";
$ewiki_plugins["action"]["binary"] = "ewiki_binary";
#-- allow per-page downloads
if (defined("EWIKI_ACTION_ATTACHMENTS") && EWIKI_ACTION_ATTACHMENTS) {
$ewiki_plugins["action"][EWIKI_ACTION_ATTACHMENTS] = "ewiki_action_attachments";
$ewiki_config["action_links"]["view"][EWIKI_ACTION_ATTACHMENTS] = "Attachments";
}
#-- icons (best given absolute to www root)
/*$ewiki_binary_icons = array(
".bin" => "/icons/exec.gif",
"application/" => "/icons/exec.gif",
"application/octet-stream" => "/icons/exec.gif",
".ogg" => "/icons/son.gif",
".jpeg" => "/icons/pic.gif",
"text/" => "/icons/txt.gif",
".pdf" => "/icons/txt.gif",
);*/
#-- the upload function __can__ use different sections
$ewiki_upload_sections = array(
"" => "main",
# "section2" => "section2",
);
#-- text, translations
$ewiki_t["en"]["UPLOAD0"] = "Use this form to upload an arbitrary binary file into the wiki:<br>";
$ewiki_t["en"]["UPL_NEWNAM"] = "Save with different filename";
$ewiki_t["en"]["UPL_INSECT"] = "Upload into section";
$ewiki_t["en"]["UPL_TOOLARGE"] = "Your upload has been rejected, because that file was too large!";
$ewiki_t["en"]["UPL_REJSECT"] = 'The given download section "$sect" has been rejected. Please only use the default ones, or tell the WikiAdmin to reenable per-page uploads; else others can\'t find your uploaded files easily.<br><br>';
$ewiki_t["en"]["UPL_OK"] = "Your file was uploaded correctly, please see <a href=\"\$script".EWIKI_PAGE_DOWNLOAD."\">".EWIKI_PAGE_DOWNLOAD."</a>.<br><br>";
$ewiki_t["en"]["UPL_ERROR"] = "We're sorry, but something went wrong during the file upload.<br><br>";
$ewiki_t["en"]["DWNL_SEEUPL"] = 'See also <a href="$script'.EWIKI_PAGE_UPLOAD.'">FileUpload</a>, this page is only about downloading.<br><br>';
$ewiki_t["en"]["DWNL_NOFILES"] = "No files uploaded yet.<br>\n";
$ewiki_t["en"]["file"] = "File";
$ewiki_t["en"]["of"] = "of";
$ewiki_t["en"]["comment"] = "Comment";
$ewiki_t["en"]["dwnl_section"] = "download section";
$ewiki_t["en"]["DWNL_ENTRY_FORMAT"] =
'<div class="download"><a href="$url">$icon$title</a><small>$size<br>'.
'uploaded on <b>$time</b>, downloaded <tt>$hits</tt> times<br>'.
'(<a href="$url">$id</a>)<br>'.
'$section'.'file is of type <tt>$type</tt>'.
'$comment'."</small></div><br>\n";
$ewiki_t["de"]["UPLOAD0"] = "Mit diesem Formular kannst du beliebige Dateien in das Wiki abspeichern:<br>";
$ewiki_t["de"]["UPL_NEWNAM"] = "Mit unterschiedlichem Dateinamen speichern";
$ewiki_t["de"]["UPL_INSECT"] = "Hochladen in Bereich:";
$ewiki_t["de"]["UPL_TOOLARGE"] = "Deine Datei wurde nicht aufgenommen, weil sie zu groß war!";
$ewiki_t["de"]["UPL_REJSECT"] = 'Der angegebene Download-Bereich "$sect" wird nicht verwendet. Bitte verwende einen von den voreingestellten Bereichen, damit Andere die Datei später auch finden können, oder frag den Administrator das Hochladen für beliebige Seiten zu aktivieren.<br><br>';
$ewiki_t["de"]["UPL_OK"] = "Deine Datei wurde korrekt hochgeladen, sehe einfach auf der <a href=\"\$script".EWIKI_PAGE_DOWNLOAD."\">".EWIKI_PAGE_DOWNLOAD."</a> nach.<br><br>";
$ewiki_t["de"]["UPL_ERROR"] = "'Tschuldige, aber irgend etwas ist während des Hochladens gründlich schief gelaufen.<br><br>";
$ewiki_t["de"]["DWNL_SEEUPL"] = 'Siehe auch <a href="$script'.EWIKI_PAGE_UPLOAD.'">DateiHochladen</a>, auf dieser Seite stehen nur die Downloads.<br><br>';
$ewiki_t["de"]["DWNL_NOFILES"] = "Noch keine Dateien hochgeladen.<br>\n";
$ewiki_t["de"]["file"] = "Datei";
$ewiki_t["de"]["of"] = "von";
$ewiki_t["de"]["comment"] = "Kommentar";
$ewiki_t["de"]["dwnl_section"] = "Download Bereich";
$ewiki_t["de"]["DWNL_ENTRY_FORMAT"] =
'<div class="download"><a href="$url">$icon$title</a><small>$size<br>'.
'am <b>$time</b> hochgeladen, <tt>$hits</tt> mal abgerufen<br>'.
'(<a href="$url">$id</a>)<br>'.
'$section'.'Datei ist vom Typ <tt>$type</tt>'.
'$comment'."</small></div><br>\n";
function ewiki_page_fileupload($id, $data, $action, $def_sec="") {
global $ewiki_upload_sections, $ewiki_plugins;
$o = ewiki_make_title($id, $id, 2);
$upload_file = $_FILES[EWIKI_UP_UPLOAD];
if (empty($upload_file)) {
$o .= ewiki_t("UPLOAD0");
$o .= '<div class="upload">'.
'<form action="' .
ewiki_script( ($action!="view" ? $action : ""), $id).
'" method="POST" enctype="multipart/form-data">' .
'<b>'.ewiki_t("file").'</b><br><input type="file" name="'.EWIKI_UP_UPLOAD.'"><br><br>' .
'<input type="submit" value="' . EWIKI_PAGE_UPLOAD . '"><br><br>';
$o .= '<b>' . ewiki_t("comment") . '</b><br><textarea name="comment" cols="35" rows="3"></textarea><br><br>';
if (empty($ewiki_upload_sections[$def_sec])) {
$ewiki_upload_sections[$def_sec] = $def_sec;
}
if (count($ewiki_upload_sections) > 1) {
if (empty($def_sec)) {
$def_sec = $_REQUEST["section"];
}
$o .= '<b>'.ewiki_t("UPL_INSECT").'</b><br><select name="section">';
foreach ($ewiki_upload_sections as $id => $title) {
$o .= '<option value="'.$id.'"' .($id==$def_sec?' selected':''). '>'.$title.'</option>';
}
$o .= '</select><br><br>';
}
$o .= '<b>'.ewiki_t("UPL_NEWNAM").'</b><br><input type="text" name="new_filename" size="20"><br><br>';
$o .= '</form></div>';
}
elseif ($upload_file["size"] > EWIKI_UPLOAD_MAXSIZE) {
$o .= ewiki_t("UPL_TOOLARGE");
}
else {
$meta = array(
"X-Content-Type" => $upload_file["type"],
#"X-Content-Length" => $upload_file["size"],
);
if (($s = $upload_file["name"]) && (strlen($s) >= 3)
|| ($s = substr(md5(time()+microtime()),0,8) . ".dat"))
{
if (strlen($uu = trim($_REQUEST["new_filename"])) >= 3) {
if ($uu != $s) {
$meta["Original-Filename"] = $s;
}
$s = $uu;
}
$meta["Content-Location"] = $s;
($p = 0) or
($p = strrpos($s, "/")) and ($p++) or
($p = strrpos($s, '\\')) and ($p++);
$meta["Content-Disposition"] = 'attachment; filename="'.urlencode(substr($s, $p)).'"';
}
if (strlen($sect = $_REQUEST["section"])) {
if ($ewiki_upload_sections[$sect]
|| ($action==EWIKI_ACTION_ATTACHMENTS) && ($data["content"])
&& strlen($ewiki_plugins["action"][EWIKI_ACTION_ATTACHMENTS])) {
$meta["section"] = $sect;
}
else {
$o .= ewiki_t("UPL_REJSECT", array('sect' => $sect));
return($o);
}
}
if (strlen($s = trim($_REQUEST["comment"]))) {
$meta["comment"] = $s;
}
$result = ewiki_binary_save_image($upload_file["tmp_name"], "", "RETURN", $meta, "ACCEPT_ALL", $care_for_images=0);
if ($result) {
$o .= ewiki_t("UPL_OK", array('$script'=>ewiki_script()));
}
else {
$o .= ewiki_t("UPL_ERROR");
}
}
return($o);
}
function ewiki_page_filedownload($id, $data, $action, $def_sec="") {
global $ewiki_binary_icons, $ewiki_upload_sections;
$o = ewiki_make_title($id, $id, 2);
#<off># $o .= ewiki_t("DWNL_SEEUPL", '$scr'=>ewiki_script("", ""));
#-- params (section, orderby)
($orderby = $_REQUEST["orderby"]) or ($orderby = "created");
if ($def_sec) {
$section = $def_sec;
}
else {
($section = $_REQUEST["section"]) or ($section = "");
if (count($ewiki_upload_sections) > 1) {
$oa = array();
$ewiki_upload_sections["*"] = "*";
if (empty($ewiki_plugins["action"][EWIKI_ACTION_ATTACHMENTS])) {
$ewiki_upload_sections["**"] = "**";
}
foreach ($ewiki_upload_sections as $sec=>$title) {
$oa[] = '<a href="' . ewiki_script("", $id, array(
"orderby"=>$orderby, "section" => $sec)) .
'">' . $title . "</a>";
}
$o .= '<div align="center" class="darker">'.implode(" &middot; ", $oa).'</div><br>';
}
}
#-- collect entries
$files = array();
$sorted = array();
$result = ewiki_database("GETALL", array("flags", "meta", "created", "hits"));
while ($row = $result->get()) {
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_BINARY) {
$m = &$row["meta"];
if(!$section) {
$section="**";
}
if ($m["section"] != $section) {
if ($section == "**") {
}
elseif (($section == "*") && !empty($ewiki_upload_sections[$m["section"]])) {
}
else {
continue;
}
}
else {
}
$files[$row["id"]] = $row;
$sorted[$row["id"]] = $row[$orderby];
}
}
#-- sort
arsort($sorted);
#-- slice
($pnum = $_REQUEST[EWIKI_UP_PAGENUM]) or ($pnum = 0);
if (count($sorted) > EWIKI_LIST_LIMIT) {
$o_nl .= '<div class="lighter">&gt;&gt; ';
for ($n=0; $n < (int)(count($sorted) / EWIKI_LIST_LIMIT); $n++) {
$o_nl .= '<a href="' . ewiki_script("", $id, array(
"orderby"=>$orderby, "section"=>$section, EWIKI_UP_PAGENUM=>$n)) .
'">[' . $n . "]</a> ";
}
$o_nl .= '</div><br>';
$o .= $o_nl;
}
$sorted = array_slice($sorted, $pnum * EWIKI_LIST_LIMIT, EWIKI_LIST_LIMIT);
#-- output
if (empty($sorted)) {
$o .= ewiki_t("DWNL_NOFILES");
}
else {
foreach ($sorted as $id=>$uu) {
$row = $files[$id];
$o .= ewiki_entry_downloads($row, $section[0]=="*");
}
}
$o .= $o_nl;
return($o);
}
function ewiki_entry_downloads($row, $show_section=0) {
global $ewiki_binary_icons, $ewiki_upload_sections;
$meta = &$row["meta"];
$id = $row["id"];
$p_title = basename($meta["Content-Location"]);
$p_time = strftime("%c", $row["created"]);
$p_hits = ($row["hits"] ? $row["hits"] : "0");
$p_size = $meta["size"];
$p_size = isset($p_size) ? (", " . ($p_size>=4096 ? round($p_size/1024)."K" : $p_size." bytes")) : "";
$p_ct1 = $meta["Content-Type"];
$p_ct2 = $meta["X-Content-Type"];
if ($p_ct1==$p_ct2) { unset($p_ct2); }
if ($p_ct1 && !$p_ct2) { $p_ct = "<tt>$p_ct1</tt>"; }
elseif (!$p_ct1 && $p_ct2) { $p_ct = "<tt>$p_ct2</tt>"; }
elseif ($p_ct1 && $p_ct2) { $p_ct = "<tt>$p_ct1</tt>, <tt>$p_ct2</tt>"; }
else { $p_ct = "<tt>application/octet-stream</tt>"; }
$p_section = $ewiki_upload_sections[$meta["section"]];
$p_section = $p_section ? $p_section : $meta["section"];
$p_comment = strlen($meta["comment"]) ? '<table border="1" cellpadding="2" cellspacing="0"><tr><td class="lighter">'.
str_replace('</p>', '', str_replace('<p>', '',
ewiki_format($meta["comment"]))) . '</td></tr></table>' : "<br>";
$p_icon = "";
/*foreach ($ewiki_binary_icons as $str => $i) {
if (empty($str) || strstr($row["Content-Location"], $str) || strstr($p_ct, $str) || strstr($p_ct2, $str)) {
$p_icon = $i;
$p_icon_t = $str;
}
}*/
/// Moodle Icon Handling
global $CFG;
$icon = mimeinfo("icon", $id);
$p_icon="$CFG->pixpath/f/$icon";
$p_icon_t="";
$info->id = $id;
$info->size = $p_size;
$info->icon = ($p_icon ? '<img src="'.$p_icon.'" alt="['.$p_icon_t.']" align="left" width="14" height="14" border="0"> ' : '');
$info->time = $p_time;
$info->hits = $p_hits;
$info->section = ($show_section ? ewiki_t('dwnl_section') . ": $p_section<br>" : '');
$info->type = $p_ct;
$info->url = ewiki_script_binary("", $row["id"]);
$info->title = $p_title;
$info->comment = $p_comment;
$o .= '<a href="'.$info->url.'">'.$info->icon.$info->title.'</a>'.$info->size.'<br>'.
get_string("uploadedon","wiki").": ".$info->time.", ".get_string("downloadtimes","wiki",$info->hits)."<br>".
'(<a href="'.$info->url.'">'.$info->id."</a>)<br>".
$info->section." ".get_string("fileisoftype","wiki").": ".$info->type.
"$info->comment<br><br>";
ewiki_t("DWNL_ENTRY_FORMAT", $info);
return($o);
}
#------------------------------------------------------- per-page uploads ---
function ewiki_action_attachments($id, $data, $action=EWIKI_ACTION_ATTACHMENTS) {
if (!empty($_FILES[EWIKI_UP_UPLOAD])) {
$o .= ewiki_page_fileupload($id, $data, EWIKI_ACTION_ATTACHMENTS, $id);
}
$o .= ewiki_page_filedownload(ucwords(EWIKI_ACTION_ATTACHMENTS) . " " . ewiki_t("of") . " $id", $data, "view", $id);
unset($_FILES[EWIKI_UP_UPLOAD]);
$o .= ewiki_page_fileupload($id, $data, EWIKI_ACTION_ATTACHMENTS, $id);
return($o);
}
?>

View file

@ -0,0 +1,172 @@
<?php
/*
This filter plugin implements minimal html tag balancing, and can also
convert ewiki_page() output into (hopefully) valid xhtml. It just works
around some markup problems found in ewiki and that may arise from Wiki
markup abuse; it however provides no fix for <ul> inside <ul> or even
<h2> inside <p> problems (this should rather be fixed in the ewiki_format
function). So following code is not meant to fix any possible html file,
and it certainly won't make valid html files out of random binary data.
So for full html spec conformance you should rather utilize w3c tidy (by
using your Webservers "Filter" directive).
*/
define("EWIKI_XHTML", 0);
$ewiki_plugins["page_final"][] = "ewiki_html_tag_balancer";
function ewiki_html_tag_balancer(&$html) {
#-- vars
$html_standalone = array(
"img", "br", "hr",
"input", "meta", "link",
);
$html_tags = array(
"a", "abbr", "acronym", "address", "applet", "area", "b", "base",
"basefont", "bdo", "big", "blockquote", "body", "br", "button",
"caption", "center", "cite", "code", "col", "colgroup", "dd", "del",
"dfn", "dir", "div", "dl", "dt", "em", "fieldset", "font", "form",
"h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "html", "i",
"iframe", "img", "input", "ins", "kbd", "label", "legend", "li",
"link", "map", "menu", "meta", "noframes", "noscript", "object", "ol",
"optgroup", "option", "p", "param", "pre", "q", "s", "samp", "script",
"select", "small", "span", "strike", "strong", "style", "sub", "sup",
"table", "tbody", "td", "textarea", "tfoot", "th", "thead", "title",
"tr", "tt", "u", "ul", "var",
#-- H2.0 "nextid", "listing", "xmp", "plaintext",
#-- H3.2 "frame", "frameset",
#-- X1.1 "rb", "rbc", "rp", "rt", "rtc", "ruby",
);
$close_opened_when = array(
"p", "div", "ul", "td", "table", "tr",
);
if (!EWIKI_XHTML) {
$html_tags = array_merge( (array) $html_tags, array(
"bgsound", "embed", "layer", "multicol", "nobr", "noembed",
));
}
#-- walk through all tags
$tree = array();
$len = strlen($html);
$done = "";
$pos = 0;
$loop = 1000;
while (($pos < $len) && $loop--) {
#-- search next tag
$l = strpos($html, "<", $pos);
$r = strpos($html, ">", $l);
if (($l===false) or ($r===false)) {
# finish
$done .= substr($html, $pos);
break;
}
#-- copy plain text part
if ($l >= $pos) {
$done .= substr($html, $pos, $l-$pos);
$pos = $l;
}
#-- analyze current html tag
if ($r >= $pos) {
$pos = $r + 1;
$tag = substr($html, $l + 1, $r - $l - 1);
#-- split into name and attributes
$tname = strtolower(strtok($tag, " \t\n>")); // LOWERCASING not needed here really
($tattr = strtok(">")) && ($tattr = " $tattr");
// attribute checking could go here
// (here we just assume good output from ewiki core)
// ...
#-- html comment
if (substr($tname, 0, 3) == "!--") {
$r = strpos($html, "-->", $l+4);
$pos = $r + 3;
$done .= substr($html, $l, $r-$l+3);
continue;
}
#-- opening tag?
elseif ($tname[0] != "/") {
#-- standalone tag
if (in_array($tname, $html_standalone)) {
$tattr = rtrim(rtrim($tattr, "/"));
if (EWIKI_XHTML) {
$tattr .= " /";
}
}
#-- normal tag
else {
if (in_array($tname, $html_tags)) {
#-- ok
}
else {
#$tattr .= " class=\"$tname\"";
#$tname = "div";
}
array_push($tree, $tname);
}
$tag = "$tname$tattr";
}
#-- closing tag
else {
$tname = substr($tname, 1);
if (!in_array($tname, $html_tags)) {
$tname= "div";
}
#-- check if this is allowed
if (!$tree) {
continue; // ignore closing tag
}
$last = array_pop($tree);
if ($last != $tname) {
#-- close until last opened block element
if (in_array($tname, $close_opened_when)) {
do {
$done .= "</$last>";
}
while (($last = array_pop($tree)) && ($last!=$tname));
}
#-- close last, close current, reopen last
else {
array_push($tree, $last);
$done .= "</$last></$tname><$last>";
continue;
}
}
else {
#-- all ok
}
#-- readd closing-slash to tag name
$tag = "/$tname";
}
$done .= "<$tag>";
}
}
#-- close still open tags
while ($tree && ($last = array_pop($tree))) {
$done .= "</$last>";
}
#-- copy back changes
$html = $done;
}
?>

View file

@ -0,0 +1,154 @@
<?php
/*
This plugin intercepts some of the binary handling functions to
store uploaded files (as is) into a dedicated directory.
Because the ewiki database abstraction layer was not designed to
hold large files (because it reads records in one chunk), you may need
to use this, else large files may break.
WARNING: this is actually a hack and not a database layer extension,
so it will only work with the ewiki.php script itself. The database
administration tools are not aware of this agreement and therefor
cannot (for example) backup the externally stored data files!
If you later choose to disable this extension, the uploaded (and thus
externally stored) files then cannot be accessed any longer, of course.
- You must load this plugin __before__ the main script, because the
binary stuff in ewiki.php always engages automatically.
- The store directory can be the same as for dbff (filenames differ).
- All the administration tools/ are not aware of this hack, so __you__
must take care, when it comes to creating backups.
*/
#-- config
define("EWIKI_DB_STORE_DIRECTORY", "/tmp"); // where to save binary files
define("EWIKI_DB_STORE_MINSIZE", 0); // send smaller files into db
define("EWIKI_DB_STORE_MAXSIZE", 32 <<20); // 32MB max per file (but
// there is actually no way to upload such large files via HTTP)
# define("EWIKI_DB_STORE_URL", "http://example.com/wiki/files/store/");
// allows clients to directly access stored plain data files,
// without redirection through ewiki.php, RTFM
#-- glue
$ewiki_plugins["binary_store"][] = "moodle_binary_store_file";
$ewiki_plugins["binary_get"][] = "moodle_binary_store_get_file";
function moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid) {
global $CFG;
$entry=wiki_get_entry($wiki, $course, $userid, $groupid);
if(!$entry) {
error("Cannot get entry.");
}
$dir=make_upload_directory("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/".$meta["section"]);
if(substr($id, 0, strlen(EWIKI_IDF_INTERNAL))!=EWIKI_IDF_INTERNAL) {
error("Binary entry does not start with ".EWIKI_IDF_INTERNAL.":::".substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
}
$id = substr($id,11);
$id = clean_filename($id);
return "$dir/$id";
}
#-- upload
function moodle_binary_store_file(&$filename, &$id, &$meta, $ext=".bin") {
# READ-Only
global $_FILES, $CFG, $course, $wiki, $groupid, $userid, $ewiki_title, $cm;
if(!$wiki->ewikiacceptbinary) {
error("This wiki does not accept binaries");
return 0;
}
$maxbytes = get_max_upload_file_size();
$entry=wiki_get_entry($wiki, $course, $userid, $groupid);
if(!$entry->id) {
error("Cannot get entry.");
}
$newfile = $_FILES["upload"];
if(!$id) {
$newfilename = clean_filename($newfile['name']);
$id = EWIKI_IDF_INTERNAL.$newfilename;
}
$dir=make_upload_directory("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/$ewiki_title");
if ($maxbytes and $newfile['size'] > $maxbytes) {
return 0;
}
if (! $newfilename) {
notify("This file had a weird filename and couldn't be uploaded");
} else {
if (move_uploaded_file($filename, "$dir/$newfilename")) {
chmod("$dir/$newfilename", $CFG->directorypermissions);
$meta["binary_store"]=$ewiki_title;
$filename="";
return true;
} else {
notify("An error happened while saving the file on the server");
return false;
}
}
return false;
/* if (($meta["size"] >= EWIKI_DB_STORE_MINSIZE) && ($meta["size"] <= EWIKI_DB_STORE_MAXSIZE)) {
#-- generate internal://md5sum
if (empty($id)) {
$md5sum = md5_file($filename);
$id = EWIKI_IDF_INTERNAL . $md5sum . ".$ext";
ewiki_log("generated md5sum '$md5sum' from file content");
}
#-- move file to dest. location
$dbfname = EWIKI_DB_STORE_DIRECTORY."/".rawurlencode($id);
if (@rename($filename, $dbfname) || copy($filename, $dbfname) && unlink($filename)) {
$filename = "";
$meta["binary_store"] = 1;
return(true);
}
else {
ewiki_log("file store error with '$dbfname'", 0);
}
}
return(false);*/
}
#-- download
function moodle_binary_store_get_file($id, &$meta) {
# READ-Only
global $CFG, $cm, $course, $wiki, $groupid, $userid;
#-- check for file
if(!$wiki->ewikiacceptbinary) {
error("This wiki does not accept binaries");
return 0;
}
$filepath=moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid);
if (file_exists($filepath)) {
readfile($filepath);
return(true);
} else {
return(false);
}
//$dbfname = EWIKI_DB_STORE_DIRECTORY."/".rawurlencode($id);
//if (file_exists($dbfname)) {
// readfile($dbfname);
// return(true);
//}
//else {
// return(false);
//}
}
?>

View file

@ -0,0 +1,79 @@
<?php
/*
CSS-highlights the terms used as search patterns. This is done
by evaluating the REFERRER and using the QUERY_STRINGs "q="
parameter (which is used by Google and ewikis` PowerSearch).
Highlighting color should be controlled from CSS:
em.highlight {
color: red;
}
em.marker {
background: yellow;
}
Using this plugin costs you nearly nothing (not slower), because
there most often isn't a "?q=" from a search engine in the referer
url.
*/
$ewiki_plugins["page_final"][] = "ewiki_moodle_highlight";
function ewiki_moodle_highlight(&$o, &$id, &$data, &$action) {
if (strpos($_SERVER["HTTP_REFERER"], "q=")) {
#-- PHP versions
$stripos = function_exists("stripos") ? "stripos" : "strpos";
#-- get ?q=...
$uu = $_SERVER["HTTP_REFERER"];
$uu = substr($uu, strpos($uu, "?"));
parse_str($uu, $q);
if ($q = $q["q"]) {
#-- get words out of it
$q = preg_replace('/[^-_\d'.EWIKI_CHARS_L.EWIKI_CHARS_U.']+/', " ", $q);
$q = array_unique(explode(" ", $q));
#-- walk through words
foreach ($q as $word) {
if (empty($word)) {
continue;
}
#-- search for word
while ($l = $stripos(strtolower($o), strtolower($word), $l)) {
#-- check for html-tags
$t0 = strpos($o, "<", $l);
$t1 = strpos($o, ">", $l);
if ((!$t0) || ($t0 < $t1)) {
$repl = '<em class="highlight marker">' . $word . '</em>';
$o = substr($o, 0, $l)
. $repl
. substr($o, 1 + $l + strlen($word)-1);
$l += strlen($repl);
}
$l++; // advance strpos
}
} // foreach(word)
}
} // if(q)
} // func
?>

View file

@ -0,0 +1,46 @@
<?php
/*
Can be used to allow preserving of certain "safe" HTML <tags>
(as seen in [sfWiki | http://sfwiki.sf.net/].
"Safe" tags include Q, S, PRE, TT, H1-H6, KBD, VAR, XMP, B, I
but just see (or change) ewiki_format() for more. They are not
accepted if written with mixed lowercase and uppercase letters,
and they cannot contain any tag attributes.
RESCUE_HTML was formerly part of the main rendering function, but
has now been extracted into this plugin, so one only needs to
include it to get simple html tags working.
*/
$ewiki_plugins["format_source"][] = "ewiki_moodle_rescue_html";
function ewiki_moodle_rescue_html(&$wiki_source) {
$safe_html = EWIKI_RESCUE_HTML;
$safe_html += 1;
$rescue_html = array(
"br", "tt", "b", "i", "strong", "em", "s", "kbd", "var", "xmp", "sup", "sub",
"pre", "q", "h1", "h2", "h3", "h4", "h5", "h6", "cite", "code", "u",
);
#-- unescape allowed html
if ($safe_html) {
/*
foreach ($rescue_html as $tag) {
foreach(array($tag, "/$tag", ($tag=strtoupper($tag)), "/$tag") as $tag) {
$wiki_source = str_replace('&lt;'.$tag.'&gt;', "<".$tag.">", $wiki_source);
} }
*/
$regexp='#&lt;(/?('.implode("|",$rescue_html).'))( /)?&gt;#i';
$wiki_source = preg_replace($regexp, '<$1>', $wiki_source);
}
}
?>

View file

@ -0,0 +1,239 @@
<?php
/*
This plugin will create a sitemap rooted at the given location
Written By: Jeffrey Engleman
*/
define("EWIKI_PAGE_SITEMAP", "SiteMap");
define("EWIKI_SITEMAP_DEPTH", 10);
$ewiki_t["en"]["INVALIDROOT"] = "You are not authorized to access the current root page so no sitemap can be created.";
$ewiki_t["en"]["SITEMAPFOR"] = "Site map for ";
$ewiki_t["en"]["VIEWSMFOR"] = "View site map for ";
$ewiki_plugins["page"][EWIKI_PAGE_SITEMAP]="ewiki_page_sitemap";
$ewiki_plugins["action"]['sitemap']="ewiki_page_sitemap";
if(!isset($ewiki_config["SiteMap"]["RootList"])){
$ewiki_config["SiteMap"]["RootList"]=array(EWIKI_PAGE_INDEX);
}
/*
populates an array with all sites the current user is allowed to access
calls the sitemap creation function.
returns the sitemap to be displayed.
*/
function ewiki_page_sitemap($id=0, $data=0, $action=0){
global $ewiki_config;
//**code hijacked from page_pageindex.php**
//creates a list of all of the valid wiki pages in the site
$str_null=NULL;
$a_validpages=ewiki_valid_pages(0,1);
//**end of hijacked code**
//$time_end=getmicrotime();
//creates the title bar on top of page
if($id == EWIKI_PAGE_SITEMAP){
$o = ewiki_make_title($id, $id, 2);
foreach($ewiki_config["SiteMap"]["RootList"] as $root){
if(isset($a_validpages[$root])){
$valid_root=TRUE;
$str_rootid=$root;
break;
}
}
}else{
$o = ewiki_make_title($id, ewiki_t("SITEMAPFOR")." ".$id, 2);
if(isset($a_validpages[$id])){
$valid_root=TRUE;
$str_rootid=$id;
}
}
$o .= "<p>".ewiki_t("VIEWSMFOR")." ";
foreach($ewiki_config["SiteMap"]["RootList"] as $root){
if(isset($a_validpages[$root])){
$o.='<a href="'.ewiki_script('sitemap/',$root).'">'.$root.'</a> ';
}
}
$o.="</p>";
//checks to see if the user is allowed to view the root page
if(!isset($a_validpages[$str_rootid])){
$o .= ewiki_t("INVALIDROOT");
return $o;
}
//$timesitemap=getmicrotime();
$a_sitemap=ewiki_sitemap_create($str_rootid, $a_validpages, EWIKI_SITEMAP_DEPTH);
$timer=array();
$level=-1;
$fordump=0;
$str_formatted="<ul>\n<li><a href=\"".EWIKI_SCRIPT.$str_rootid."\">".$str_rootid."</a></li>";
$fin_level=format_sitemap($a_sitemap, $str_rootid, $str_formatted, $level, $timer, $fordump);
$str_formatted.="</ul>".str_pad("", $fin_level*6, "</ul>\n");
$o.=$str_formatted;
//$timesitemap_end=getmicrotime();
//$o.="GetAll: ".($time_end-$time)."\n";
//$o.="SiteMap: ".($timesitemap_end-$timesitemap)."\n";
//$o.="Total: ".($timesitemap_end-$time);
return($o);
}
function ewiki_valid_pages($bool_allowimages=0, $virtual_pages=0){
//$time=getmicrotime();
global $ewiki_plugins;
$result = ewiki_database("GETALL", array("flags", "refs", "meta"));
while ($row = $result->get()) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $str_null, "view")) {
continue;
}
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT || ($bool_allowimages ? $row["meta"]["class"]=="image" : 0)) {
$temp_refs=explode("\n",$row["refs"]);
foreach($temp_refs as $key => $value) {
if(empty($value)) {
unset($temp_refs[$key]);
}
}
if($row["meta"]["class"]=="image"){
$a_validpages[$row["id"]]=$temp_array=array("refs" => $temp_refs, "type" => "image", "touched" => FALSE);
} else {
$a_validpages[$row["id"]]=$temp_array=array("refs" => $temp_refs, "type" => "page", "touched" => FALSE);
}
unset($temp_refs);
}
}
if($virtual_pages){
#-- include virtual pages to the sitemap.
$virtual = array_keys($ewiki_plugins["page"]);
foreach($virtual as $vp){
if(!EWIKI_PROTECTED_MODE || !EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($vp, $str_null, "view")){
$a_validpages[$vp]=array("refs" => array(), "type" => "page", "touched" => FALSE);
}
}
}
return $a_validpages;
}
/*
Adds each of the pages in the sitemap to an HTML list. Each site is a clickable link.
*/
function format_sitemap($a_sitemap, $str_rootpage, &$str_formatted, &$prevlevel, &$timer, &$fordump){
//get all children of the root format them and store in $str_formatted array
$a_sitemap[$str_rootpage]["child"]= is_array($a_sitemap[$str_rootpage]["child"])?$a_sitemap[$str_rootpage]["child"]:array();
if($a_sitemap[$str_rootpage]["child"]){
while($str_child = current($a_sitemap[$str_rootpage]["child"])){
$str_mark="";
if($a_sitemap[$str_rootpage]["level"]>$prevlevel){
$str_mark="<ul>\n";
}
elseif ($a_sitemap[$str_rootpage]["level"]<$prevlevel){
//markup length is 6 characters
$str_mark=str_pad("", ($prevlevel-$a_sitemap[$str_rootpage]["level"])*6, "</ul>\n");
}
$prevlevel=$a_sitemap[$str_rootpage]["level"];
if($fordump){
$str_formatted.=($str_mark."<li><a href=\"".preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", urlencode($str_child)).".html\">".$str_child."</a></li>\n");
} else {
$str_formatted.=($str_mark."<li><a href=\"".EWIKI_SCRIPT.$str_child."\">".$str_child."</a></li>\n");
}
array_shift($a_sitemap[$str_rootpage]["child"]);
format_sitemap($a_sitemap, $str_child, $str_formatted, $prevlevel, $timer, $fordump);
}
return ($prevlevel+1);
}
}
/*
gets all children of the given root and stores them in the $a_children array
*/
function ewiki_page_listallchildren($str_root, &$a_children, &$a_sitemap, &$a_validpages, $i_level, $i_maxdepth, $i_flatmap){
if(($i_level<$i_maxdepth) && is_array($a_validpages[$str_root]["refs"])){ //controls depth the sitemap will recurse into
foreach($a_validpages[$str_root]["refs"] as $str_refs){
if($str_refs){ //make sure $str_refs contains a value before doing anything
if(isset($a_validpages[$str_refs])){ //test page validity
if(!$a_validpages[$str_refs]["touched"]){ //check to see if page already exists
if($i_flatmap){
$a_sitemap[]=$str_refs;
}
$a_validpages[$str_refs]["touched"]=TRUE; //mark page as displayed
$a_children[$str_refs]="";
$a_currchildren[]=$str_refs;
}
}
}
}
if(!$i_flatmap){
if($a_currchildren){
$a_sitemap[$str_root]=array("level" => $i_level, "child" => $a_currchildren);
} else {
$a_sitemap[$str_root]=array("level" => $i_level);
}
}
}
}
/*
Creates the sitemap. And sends the data to the format_sitemap function.
Returns the HTML formatted sitemap.
*/
function ewiki_sitemap_create($str_rootid, $a_validpages, $i_maxdepth, $i_flatmap=0){
//map starts out with a depth of 0
$i_depth=0;
$forcelevel=FALSE;
//create entry for root in the sitemap array
if(!$i_flatmap){
$a_sitemap[$str_rootid]=array("parent" => "", "level" => $i_depth, "child" => $str_rootid);
} else {
$a_sitemap[]=$str_rootid;
}
//mark the root page as touched
$a_validpages[$str_rootid]["touched"]=TRUE;
//list all of the children of the root
ewiki_page_listallchildren($str_rootid, $a_children, $a_sitemap, $a_validpages, $i_depth, $i_maxdepth, $i_flatmap);
$i_depth++;
if($a_children){
end($a_children);
$str_nextlevel=key($a_children);
reset($a_children);
while($str_child = key($a_children)){
//list all children of the current child
ewiki_page_listallchildren($str_child, $a_children, $a_sitemap, $a_validpages, $i_depth, $i_maxdepth, $i_flatmap);
//if the child is the next level marker...
if($str_child==$str_nextlevel){
//increment the level counter
$i_depth++;
//determine which child marks the end of this level
end($a_children);
$str_nextlevel=key($a_children);
//reset the array counter to the beginning of the array
reset($a_children);
//we are done with this child...get rid of it
}
array_shift($a_children);
}
}
return $a_sitemap;
}
?>

View file

@ -0,0 +1,53 @@
<?php
# lists pages, which were referenced
# but not yet written
$ewiki_plugins["page"]["WantedPages"] = "ewiki_page_wantedpages";
#<off># $ewiki_plugins["page"]["DanglingSymlinks"] = "ewiki_page_wantedpages";
function ewiki_page_wantedpages($id, $data, $action) {
$wanted=array();
#-- collect referenced pages
$result = ewiki_database("GETALL", array("refs"));
while ($row = $result->get()) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
continue;
}
$refs .= $row["refs"];
}
#-- build array
$refs = array_unique(explode("\n", $refs));
#-- strip existing pages from array
$refs = ewiki_database("FIND", $refs);
foreach ($refs as $id=>$exists) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
continue;
}
if (!$exists && !strstr($id, "://") && strlen(trim($id))) {
$wanted[] = $id;
}
}
#-- print out
$o .= "<ul>";
foreach ($wanted as $page) {
$link = ewiki_link_regex_callback(array($page, $page));
if (strstr($link, "?</a>")) {
$o .= "<li>" . $link . "</li>";
}
}
$o .= "<ul>";
return($o);
}
?>

View file

@ -0,0 +1,230 @@
<?php
#
# The otherwise invisible markup [notify:you@there.net] will trigger a
# mail, whenever a page is changed. The TLD decides in which language
# the message will be delivered. One can also append the lang code after
# a comma or semicolon behind the mail address to set it explicitely:
# [notify:me@here.org,de] or [notify:you@there.net;eo]
#
# Nevertheless English will be used as the default automagically, if
# nothing else was specified, no need to worry about this.
#
# additional features:
# * diff inclusion
# * [notify:icq:123456789] - suddenly ICQ.com took the pager service down
#
# To include a diff, just set the following constant. Also use it to
# define the minimum number of changed bytes that are necessary to
# result in a notification mail. Only use it with Linux/UNIX.
define("EWIKI_NOTIFY_WITH_DIFF", 0); #-- set it to 100 or so
define("EWIKI_NOTIFY_SENDER",'ewiki');
#-- glue
$ewiki_plugins["edit_hook"][] = "ewiki_notify_edit_hook";
$ewiki_plugins["format_source"][] = "ewiki_format_remove_notify";
$ewiki_config["interwiki"]["notify"] = "mailto:";
#-- email message text ---------------------------------------------------
$ewiki_t["en"]["NOTIFY_SUBJECT"] = '"$id" was changed [notify:...]';
$ewiki_t["en"]["NOTIFY_BODY"] = <<<_END_OF_STRING
Hi,
A WikiPage has changed and you requested to be notified when this
happens. The changed page was '\$id' and can be found
at the following URL:
\$link
To stop messages like this please strip the [notify:...] with your address
from the page edit box at \$edit_link
(\$wiki_title on http://\$server/)
\$server_admin
_END_OF_STRING;
#-- translation.de
$ewiki_t["de"]["NOTIFY_SUBJECT"] = '"$id" wurde geändert [notify:...]';
$ewiki_t["de"]["NOTIFY_BODY"] = <<<_END_OF_STRING
Hi,
Eine WikiSeite hat sich geändert, und du wolltest ja unbedingt wissen,
wenn das passiert. Die geänderte Seite war '\$id' und
ist leicht zu finden unter folgender URL:
\$link
Wenn du diese Benachrichtigungen nicht mehr bekommen willst, solltest du
deine [notify:...]-Adresse aus der entsprechenden Edit-Box herauslöschen:
\$edit_link
(\$wiki_title auf http://\$server/)
\$server_admin
_END_OF_STRING;
#----------------------------------------------------------------------------
#-- implementatition
function ewiki_notify_edit_hook($id, $data, &$hidden_postdata) {
global $ewiki_t, $ewiki_plugins;
$ret_err = 0;
if (!isset($_REQUEST["save"])) {
return(false);
}
$mailto = ewiki_notify_links($data["content"], 0);
if (!count($mailto)) {
return(false);
}
#-- generate diff
$diff = "";
if (EWIKI_NOTIFY_WITH_DIFF && (DIRECTORY_SEPARATOR=="/")) {
#-- save page versions temporarily as files
$fn1 = EWIKI_TMP."/ewiki.tmp.notify.diff.".md5($data["content"]);
$fn2 = EWIKI_TMP."/ewiki.tmp.notify.diff.".md5($_REQUEST["content"]);
$f = fopen($fn1, "w");
fwrite($f, $data["content"]);
fclose($f);
$f = fopen($fn2, "w");
fwrite($f, $_REQUEST["content"]);
fclose($f);
#-- set mtime of the old one (GNU diff will report it)
touch($fn1, $data["lastmodified"]);
#-- get diff output, rm temp files
$diff_exe = "diff";
if ($f = popen("$diff_exe --normal --ignore-case --ignore-space-change $fn1 $fn2 2>&1 ", "r")) {
$diff .= fread($f, 16<<10);
pclose($f);
$diff_failed = !strlen($diff)
|| (strpos($diff, "Files ") === 0);
#-- do not [notify:] if changes were minimal
if ((!$diff_failed) && (strlen($diff) < EWIKI_NOTIFY_WITH_DIFF)) {
#echo("WikiNotice: no notify, because too few changes (" .strlen($diff)." byte)\n");
$ret_err = 1;
}
$diff = "\n\n-----------------------------------------------------------------------------\n\n"
. $diff;
}
else {
$diff = "";
#echo("WikiWarning: diff failed in notify module\n");
}
unlink($fn1);
unlink($fn2);
if ($ret_err) {
return(false);
}
}
#-- separate addresses into (TLD) groups
$mailto_lang = array(
);
foreach ($mailto as $m) {
$lang = "";
#-- remove lang selection trailer
$m = strtok($m, ",");
if ($uu = strtok(",")) {
$lang = $uu;
}
$m = strtok($m, ";");
if ($uu = strtok(";")) {
$lang = $uu;
}
#-- else use TLD as language code
if (empty($lang)) {
$r = strrpos($m, ".");
$lang = substr($m, $r+1);
}
$lang = trim($lang);
#-- address mangling
$m = trim($m);
if (substr($m, 0, 4) == "icq:") {
$m = substr($m, 4) . "@pager.icq.com";
}
$mailto_lang[$lang][] = $m;
}
#-- go thru email address groups
foreach ($mailto_lang as $lang=>$a_mailto) {
$pref_langs = array_merge(array(
"$lang", "en"
), $ewiki_t["languages"]);
($server = $_SERVER["HTTP_HOST"]) or
($server = $_SERVER["SERVER_NAME"]);
$s_4 = "http".($_SERVER['HTTPS'] == "on" ? 's':'')."://" . $server . $_SERVER["REQUEST_URI"];
$link = str_replace("edit/$id", "$id", $s_4);
$m_text = ewiki_t("NOTIFY_BODY", array(
"id" => $id,
"link" => $link,
"edit_link" => $s_4,
"server_admin" => $_SERVER["SERVER_ADMIN"],
"server" => $server,
"wiki_title" => EWIKI_PAGE_INDEX,
), $pref_langs);
$m_text .= $diff;
$m_from = EWIKI_NOTIFY_SENDER."@$server";
$m_subject = ewiki_t("NOTIFY_SUBJECT", array(
"id" => $id,
), $pref_langs);
$m_to = implode(", ", $a_mailto);
mail($m_to, $m_subject, $m_text, "From: \"$s_2\" <$m_from>\nX-Mailer: ErfurtWiki/".EWIKI_VERSION);
}
}
function ewiki_notify_links(&$source, $strip=1) {
$links = array();
$l = 0;
if (strlen($source) > 10)
while (($l = @strpos($source, "[notify:", $l)) !== false) {
$r = strpos($source, "]", $l);
$str = substr($source, $l, $r + 1 - $l);
if (!strpos("\n", $str)) {
$links[] = trim(substr($str, 8, -1));
if ($strip) {
$source = substr($source, 0, $l) . substr($source, $r + 1);
}
}
$l++;
}
return($links);
}
function ewiki_format_remove_notify(&$source) {
ewiki_notify_links($source, 1);
}
?>

View file

@ -0,0 +1,86 @@
<?php
/*
This plugin catches concurrent edits of a page, and lets the 'patch'
and 'diff' utilities try to merge the different versions. This will
often prevent the "This page version was already saved by someone else"
failure message.
Please use the GNU diff and patch only. Sometimes the unified output
format may be superiour; but this depends on the subjects in your Wiki.
*/
define("EWIKI_BIN_DIFF", "/usr/bin/diff");
define("EWIKI_BIN_PATCH", "/usr/bin/patch");
if (function_exists("is_executable") && is_executable(EWIKI_BIN_PATCH) && is_executable(EWIKI_BIN_DIFF)) {
$ewiki_plugins["edit_patch"][] = "ewiki_edit_patch";
}
function ewiki_edit_patch($id, &$data) {
$r = false;
$base = ewiki_database(
"GET",
array("id"=>$id, "version"=>$_REQUEST["version"])
);
if (!$base) {
return(false);
}
$fn_base = EWIKI_TMP."/ewiki.base.".md5($base["content"]);
$fn_requ = EWIKI_TMP."/ewiki..requ.".md5($_REQUEST["content"]);
$fn_patch = EWIKI_TMP."/ewiki.patch.".md5($base["content"])."-".md5($_REQUEST["content"]);
$fn_curr = EWIKI_TMP."/ewiki.curr.".md5($data["content"]);
if ($f = fopen($fn_base, "w")) {
fwrite($f, $base["content"]);
fclose($f);
}
else {
return(false);
}
if ($f = fopen($fn_requ, "w")) {
fwrite($f, $_REQUEST["content"]);
fclose($f);
}
else {
unlink($fn_base);
return(false);
}
if ($f = fopen($fn_curr, "w")) {
fwrite($f, $data["content"]);
fclose($f);
}
else {
unlink($fn_base);
unlink($fn_requ);
return(false);
}
exec("diff -c $fn_base $fn_requ > $fn_patch", $output, $retval);
if ($retval) {
exec("patch $fn_curr $fn_patch", $output, $retval);
if (!$retval) {
$_REQUEST["version"] = $curr["version"];
$_REQUEST["content"] = implode("", file($fn_curr));
$r = true;
}
}
unlink($fn_base);
unlink($fn_requ);
unlink($fn_patch);
unlink($fn_curr);
return($r);
}
?>

View file

@ -0,0 +1,127 @@
<?php
/*
dynamic plugin loading
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Will load plugins on demand, so they must not be included() one by one
together with the core script. This is what commonly the "plugin idea"
suggests, and only has minimal disadvantages.
- This loader currently only handles "page" and "action" plugins,
many other extensions must be activated as before (the other ones
are real functionality enhancements and behaviour tweaks, so this
approach really made no sense for them).
- There is no security risk with this plugin loader extension, because
it allows you to set which of the available plugins CAN be loaded
on demand (all others must/can be included() as usual elsewhere).
- This however requires administration of this plugins` configuration
array, but that is not much more effort than maintaining a bunch of
include() statements.
- Is a small degree faster then including multiple plugin script files
one by one. Alternatively you could also merge (cat, mkhuge) all
wanted plugins into one script file so you get a speed improvement
against multiple include() calls.
- Use tools/mkpluginmap to create the initial plugin list.
*/
$ewiki_plugins["dl"]["action"] = array(
"view" => array("", "", 0),
"links" => array("", "", 0),
"info" => array("", "", 0),
# "edit" => array("spellcheck.php", "", 0),
# "calendar" => array("calendar.php", "ewiki_page_calendar", 0),
# "addpost" => array("contrib/aview_posts.php", "ewiki_add_post", 0),
# "imageappend" => array("contrib/aview_imgappend.php", "ewiki_action_image_append", 0),
# "extodo" => array("contrib/action_extracttodo.php", "ewiki_extract_todo", 0),
# "addthread" => array("contrib/aview_threads.php", "ewiki_add_thread", 0),
# "control" => array("admin/control.php", "ewiki_action_control_page", 0),
# "pdf" => array("pdf.php", "ewiki_send_page_as_pdf", 0),
"diff" => array("diff.php", "ewiki_page_stupid_diff", 0),
# "diff" => array("diff_gnu.php", "ewiki_page_gnu_diff", 0),
# "binary" => array("downloads.php", "ewiki_binary", 0),
# "attachments" => array("downloads.php", "ewiki_action_attachments", 0),
"like" => array("like_pages.php", "ewiki_page_like", 0),
# "verdiff" => array("action_verdiff.php", "ewiki_action_verdiff", 0),
);
$ewiki_plugins["dl"]["page"] = array(
# "PageCalendar" => array("calendar.php", "ewiki_page_calendar", 0),
# "PageYearCalendar" => array("calendar.php", "ewiki_page_year_calendar", 0),
# "WikiNews" => array("contrib/page_wikinews.php", "ewiki_page_wikinews", 0),
# "WikiDump" => array("contrib/page_wikidump.php", "ewiki_page_wiki_dump_tarball", 0),
# "README" => array("contrib/page_README.php", "ewiki_page_README", 0),
# "README.de" => array("contrib/page_README.php", "ewiki_page_README", 0),
# "plugins/auth/README.auth" => array("contrib/page_README.php", "ewiki_page_README", 0),
# "Fortune" => array("contrib/page_fortune.php", "ewiki_page_fortune", 0),
# "ScanDisk" => array("contrib/page_scandisk.php", "ewiki_page_scandisk", 0),
"InterWikiMap" => array("contrib/page_interwikimap.php", "ewiki_page_interwikimap", 0),
# "WikiUserLogin" => array("contrib/page_wikiuserlogin.php", "ewiki_page_wikiuserlogin", 0),
# "PhpInfo" => array("contrib/page_phpinfo.php", "ewiki_page_phpinfo", 0),
# "ImageGallery" => array("contrib/page_imagegallery.php", "ewiki_page_image_gallery", 0),
# "SinceUpdatedPages" => array("contrib/page_since_updates.php", "ewiki_page_since_updates", 0),
# "TextUpload" => array("contrib/page_textupload.php", "ewiki_page_textupload", 0),
"HitCounter" => array("contrib/page_hitcounter.php", "ewiki_page_hitcounter", 0),
# "SearchCache" => array("admin/page_searchcache.php", "ewiki_cache_generated_pages", 0),
# "SearchAndReplace" => array("admin/page_searchandreplace.php", "ewiki_page_searchandreplace", 0),
# "FileUpload" => array("downloads.php", "ewiki_page_fileupload", 0),
# "FileDownload" => array("downloads.php", "ewiki_page_filedownload", 0),
"PowerSearch" => array("page_powersearch.php", "ewiki_page_powersearch", 0),
# "AboutPlugins" => array("page_aboutplugins.php", "ewiki_page_aboutplugins", 0),
"OrphanedPages" => array("page_orphanedpages.php", "ewiki_page_orphanedpages", 0),
"PageIndex" => array("page_pageindex.php", "ewiki_page_index", 0),
"RandomPage" => array("page_randompage.php", "ewiki_page_random", 0),
"WantedPages" => array("page_wantedpages.php", "ewiki_page_wantedpages", 0),
"WordIndex" => array("page_wordindex.php", "ewiki_page_wordindex", 0),
);
#-- plugin glue
$ewiki_plugins["view_init"][] = "ewiki_dynamic_plugin_loader";
function ewiki_dynamic_plugin_loader(&$id, &$data, &$action) {
global $ewiki_plugins, $ewiki_id, $ewiki_title, $ewiki_t,
$ewiki_ring, $ewiki_author, $ewiki_config, $ewiki_auth_user,
$ewiki_action;
#-- check for entry
if (empty($ewiki_plugins["page"][$id])) {
$load = $ewiki_plugins["dl"]["page"][$id];
}
elseif (empty($ewiki_plugins["action"][$action])) {
$load = $ewiki_plugins["dl"]["action"][$action];
}
#-- load plugin
if ($load) {
if (!is_array($load)) {
$load = array($load, "");
}
if (!($pf=$load[1]) || !function_exists($pf)) {
include(dirname(__FILE__)."/".$load[0]);
}
}
#-- fake static pages
foreach ($ewiki_plugins["dl"]["page"] as $name) {
if (empty($ewiki_plugins["page"][$name])) {
$ewiki_plugins["page"][$name] = "ewiki_dynamic_plugin_loader";
}
}
#-- show action links
foreach ($ewiki_plugins["dl"]["action"] as $action=>$uu) {
foreach ($ewiki_config["dl"]["action_links"] as $where) {
if ($title = $ewiki_config["dl"]["action_links"][$where][$action]) {
$ewiki_config["action_links"][$where][$action] = $title;
}
}
}
return(NULL);
}
?>

View file

@ -0,0 +1,182 @@
<?php
/*
The StaticPages plugin allows you to put some .html or .php files
into dedicated directories, which then will get available with their
basename as ewiki pages. The files can be in wiki format (.txt or no
extension), they can also be in .html format and they may even contain
php code (.php).
Of course it is not possible to provide anything else, than viewing
those pages (editing is not possible), but it is of course up to you
to add php code to achieve some interactivity.
The idea for this plugin was 'borought' from http://geeklog.org/.
In your static page .php files you cannot do everything you could
normally do, there are some restrictions because of the way these static
pages are processed. You need to use $GLOBALS to access variables other
than the $ewiki_ ones. To return headers() you must append them to the
$headers[] or $ewiki_headers[] array.
If you define("EWIKI_SPAGES_DIR") then this directory will be read
initially, but you could also just edit the following list/array of
directories, or call ewiki_init_spages() yourself.
*/
#-- specify which dirs to search for page files
ewiki_init_spages(
array(
"spages",
# "/usr/local/share/wikipages",
# "C:/Documents/StaticPages/",
)
);
if (defined("EWIKI_SPAGES_DIR")) {
ewiki_init_spages(EWIKI_SPAGES_DIR);
}
#-- plugin glue
# - will be added automatically by _init_spages()
#-- return page
function ewiki_spage($id, $data, $action) {
global $ewiki_spages, $ewiki_plugins;
$r = "";
#-- filename from $id
$fn = $ewiki_spages[strtolower($id)];
#-- php file
if (strpos($fn, ".php") || strpos($fn, ".htm")) {
#-- start new ob level
ob_start();
ob_implicit_flush(0);
#-- prepare environment
global $ewiki_id, $ewiki_title, $ewiki_author, $ewiki_ring,
$ewiki_t, $ewiki_config, $ewiki_action, $_EWIKI,
$ewiki_auth_user, $ewiki_headers, $headers;
$ewiki_headers = array();
$headers = &$ewiki_headers;
#-- execute script
include($fn);
#-- close ob
$r = ob_get_contents();
ob_end_clean();
#-- add headers
if ($ewiki_headers) {
headers(implode("\n", $ewiki_headers));
}
}
#-- wiki file
else {
$f = fopen($fn, "rb");
$r = fread($f, 256<<10);
fclose($f);
$r = $ewiki_plugins["render"][0]($r);
}
#-- strip <html> and <head> parts (if any)
if (($l = strpos(strtolower($r), "<body")) &&
($w = strpos(strtolower($r), "</body")) )
{
$l = strpos($r, ">", $l+1) + 1;
$w = $w - $l;
$r = substr($r, $l, $w);
}
#-- return body (means successful handled)
return($r);
}
#-- return page
#<old># $ewiki_plugins["handler"][] = "ewiki_handler_spages";
function ewiki_handler_spages($id, $data, $action) {
global $ewiki_spages;
#-- compare requested page $id with spages` $id values
$i0 = strtolower($id);
foreach ($ewiki_spages as $i1 => $fn) {
if (strtolower($i1)==$i0) {
return(ewiki_spage($id));
}
}
}
#-- init
function ewiki_init_spages($dirs, $idprep="") {
global $ewiki_spages, $ewiki_plugins;
if (!is_array($dirs)) {
$dirs = array($dirs);
}
#-- go through list of directories
foreach ($dirs as $dir) {
if (empty($dir)) {
continue;
}
#-- read in one directory
$dh = opendir($dir);
while ($fn = readdir($dh)) {
#-- skip over . and ..
if ($fn[0] == ".") { continue; }
#-- be recursive
if ($fn && is_dir("$dir/$fn")) {
if ($fn != trim($fn, ".")) {
$fnadd = trim($fn, ".") . ".";
}
else {
$fnadd = "$fn/";
}
ewiki_init_spages(array("$dir/$fn"), "$idprep$fnadd");
continue;
}
#-- strip filename extensions
$id = str_replace(
array(".html", ".htm", ".php", ".txt", ".wiki", ".src"),
"",
basename($fn)
);
#-- register spage file and as page plugin (one for every spage)
$ewiki_spages[strtolower("$idprep$id")] = "$dir/$fn";
$ewiki_plugins["page"]["$idprep$id"] = "ewiki_spage";
}
closedir($dh);
}
}
?>

293
mod/wiki/ewikimoodlelib.php Normal file
View file

@ -0,0 +1,293 @@
<?php
/* MySQL database backend
(Glue between Moodle and ewiki Database)
Adapted by Michael Schneider
*/
/// Glue
$ewiki_plugins["database"][0] = "ewiki_database_moodle";
/// #-- predefine some of the configuration constants
define("EWIKI_NAME", $wiki_entry->pagename);
define("EWIKI_CONTROL_LINE", 0);
define("EWIKI_LIST_LIMIT", 25);
define("EWIKI_DEFAULT_LANG", current_language());
define("EWIKI_HTML_CHARS", 1);
define("EWIKI_DB_TABLE_NAME", "wiki_pages");
function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
global $wiki, $wiki_entry, $CFG;
#-- result array
$r = array();
switch($action) {
/* Returns database entry as array for the page whose name was given
with the "id" key in the $args array, usually fetches the latest
version of a page, unless a specific "version" was requested in
the $args array.
*/
# Ugly, but we need to choose which wiki we are about to change/read
case "GET":
$id = "'" . mysql_escape_string($args["id"]) . "'";
($version = 0 + @$args["version"]) and ($version = "AND (version=$version)") or ($version="");
# $result = mysql_query("SELECT * FROM " . EWIKI_DB_TABLE_NAME
# . " WHERE (pagename=$id) $version ORDER BY version DESC LIMIT 1"
#);
#if ($result && ($r = mysql_fetch_array($result, MYSQL_ASSOC))) {
# $r["id"] = $r["pagename"];
# unset($r["pagename"]);
#}
#if (strlen($r["meta"])) {
# $r["meta"] = @unserialize($r["meta"]);
#}
$select="(pagename=$id) AND wiki=".$wiki_entry->id." $version ";
$sort="version DESC";
$result_obj=get_records_select(EWIKI_DB_TABLE_NAME, $select,$sort,"*",0,1);
if($result_obj) {
$r=get_object_vars($result_obj[$args["id"]]);
$r["id"] = $r["pagename"];
unset($r["pagename"]);
$r["meta"] = @unserialize($r["meta"]);
}
break;
/* Increases the hit counter for the page name given in $args array
with "id" index key.
*/
case "HIT":
#mysql_query("UPDATE " . EWIKI_DB_TABLE_NAME . " SET hits=(hits+1) WHERE pagename='" . mysql_escape_string($args["id"]) . "'");
# set_field does not work because of the "hits+1" construct
#print "DO ".mysql_escape_string($args["id"]); exit;
execute_sql("UPDATE " .$CFG->prefix.EWIKI_DB_TABLE_NAME . " SET hits=(hits+1) WHERE pagename='" . mysql_escape_string($args["id"]) . "' and wiki=".$wiki_entry->id, 0);
break;
/* Stores the $data array into the database, while not overwriting
existing entries (using WRITE); returns 0 on failure and 1 if
saved correctly.
*/
case "OVERWRITE":
$COMMAND = "REPLACE";
break;
case "WRITE":
$COMMAND="WRITE";
$args["pagename"] = $args["id"];
unset($args["id"]);
if (is_array($args["meta"])) {
$args["meta"] = serialize($args["meta"]);
}
#$sql1 = $sql2 = "";
#foreach ($args as $index => $value) {
# if (is_int($index)) {
# continue;
# }
# $a = ($sql1 ? ', ' : '');
# $sql1 .= $a . $index;
# $sql2 .= $a . "'" . mysql_escape_string($value) . "'";
#}
#strlen(@$COMMAND) || ($COMMAND = "INSERT");
foreach ($args as $index => $value) {
if (is_int($index)) {
continue;
}
$args[$index] =mysql_escape_string($value);
}
$args["wiki"]=$wiki_entry->id;
# Check if Record exists
if($COMMAND=="REPLACE") {
if(count_records(EWIKI_DB_TABLE_NAME,"wiki", $wiki_entry->id,"pagename",$args["pagename"],"version",$args["version"])) {
delete_record(EWIKI_DB_TABLE_NAME,"wiki", $wiki_entry->id,"pagename",$args["pagename"],"version",$args["version"]);
}
}
# Write
$result=insert_record(EWIKI_DB_TABLE_NAME,$args,false,"pagename");
#$result = mysql_query("$COMMAND INTO " . EWIKI_DB_TABLE_NAME .
# " (" . $sql1 . ") VALUES (" . $sql2 . ")"
#);
#return($result && mysql_affected_rows() ?1:0);
return $result;
break;
/* Checks for existence of the WikiPages whose names are given in
the $args array. Returns an array with the specified WikiPageNames
associated with values of "0" or "1" (stating if the page exists
in the database). For images/binary db entries returns the "meta"
field instead of an "1".
*/
case "FIND":
$select = "";
foreach (array_values($args) as $id) {
if (strlen($id)) {
$r[$id] = 0;
$select .= ($select ? " OR " : "") .
"(pagename='" . mysql_escape_string($id) . "')";
}
}
if($select) {
$select = "(".$select.") AND wiki=".$wiki_entry->id;
$result = get_records_select(EWIKI_DB_TABLE_NAME,$select);
#$sql = "SELECT pagename AS id, meta FROM " .
# EWIKI_DB_TABLE_NAME . " WHERE $sql "
#);
#while ($result && ($row = mysql_fetch_row($result))) {
# $r[$row[0]] = strpos($row[1], 's:5:"image"') ? $row[1] : 1;
while(list($key, $val) = @each($result)) {
$r[$val->pagename]=strpos($val->meta, 's:5:"image"') ? $val->meta : 1;
}
}
break;
/* Counts the number of Versions
*/
case "COUNTVERSIONS":
$sql= "SELECT pagename AS id, count(*) as versioncount".
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
" WHERE wiki = ".$wiki_entry->id.
" GROUP BY id";
#print "$sql";
$result=get_records_sql($sql);
while(list($key, $val) = each($result)) {
$r[$key]=$val->versioncount;
}
break;
/* Returns an array of __all__ pages, where each entry is made up
of the fields from the database requested with the $args array,
e.g. array("flags","meta","lastmodified");
*/
case "GETALL":
#$result = mysql_query("SELECT pagename AS id, ".
# implode(", ", $args) .
# " FROM ". EWIKI_DB_TABLE_NAME .
# " GROUP BY id, version DESC"
#);
$sql= "SELECT pagename AS id, ".
implode(", ", $args) .
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
" WHERE wiki = ".$wiki_entry->id.
" GROUP BY id, version";
#print "$sql";
$result=get_records_sql($sql);
$r = new ewiki_dbquery_result($args);
$drop = "";
#while ($result && ($row = mysql_fetch_array($result, MYSQL_ASSOC))) {
# $i = EWIKI_CASE_INSENSITIVE ? strtolower($row["id"]) : $row["id"];
# if ($i != $drop) {
# $drop = $i;
# $r->add($row);
# }
#}
#print "<pre>"; print_r($result); print "</pre>";
while(list($key, $val) = each($result)) {
$row=get_object_vars($val);
$i = EWIKI_CASE_INSENSITIVE ? strtolower($row["id"]) : $row["id"];
if ($i != $drop) {
$drop = $i;
$r->add($row);
}
}
break;
/* Returns array of database entries (also arrays), where the one
specified column matches the specified content string, for example
$args = array("content" => "text...piece")
is not guaranteed to only search/return the latest version of a page
*/
case "SEARCH":
$field = implode("", array_keys($args));
$content = strtolower(implode("", $args));
if ($field == "id") { $field = "pagename"; }
#$result = mysql_query("SELECT pagename AS id, version, flags" .
# (EWIKI_DBQUERY_BUFFER && ($field!="pagename") ? ", $field" : "") .
# " FROM " . EWIKI_DB_TABLE_NAME .
# " WHERE LOCATE('" . mysql_escape_string($content) . "', LCASE($field)) " .
# " GROUP BY id, version DESC"
#);
$sql= "SELECT pagename AS id, version, flags" .
(EWIKI_DBQUERY_BUFFER && ($field!="pagename") ? ", $field" : "") .
" FROM " . $CFG->prefix.EWIKI_DB_TABLE_NAME .
" WHERE LOCATE('" . mysql_escape_string($content) . "', LCASE($field)) and wiki=".$wiki_entry->id .
" GROUP BY id, version DESC";
$result=get_records_sql($sql);
$r = new ewiki_dbquery_result(array("id","version",$field));
$drop = "";
#while ($result && ($row = mysql_fetch_array($result, MYSQL_ASSOC))) {
# $i = EWIKI_CASE_INSENSITIVE ? strtolower($row["id"]) : $row["id"];
# if ($i != $drop) {
# $drop = $i;
# $r->add($row);
# }
#}
while(list($key, $val) = @each($result)) {
$row=get_object_vars($val);
$i = EWIKI_CASE_INSENSITIVE ? strtolower($row["id"]) : $row["id"];
if ($i != $drop) {
$drop = $i;
$r->add($row);
}
}
break;
case "DELETE":
$id = mysql_escape_string($args["id"]);
$version = $args["version"];
#mysql_query("DELETE FROM " . EWIKI_DB_TABLE_NAME ."
# WHERE pagename='$id' AND version=$version");
# print "DELETING wiki:".$wiki_entry->id."Pagename: $id Version: $version <br>\n";
delete_records(EWIKI_DB_TABLE_NAME,"wiki", $wiki_entry->id,"pagename",$id,"version",$version);
break;
case "INIT":
#mysql_query("CREATE TABLE " . EWIKI_DB_TABLE_NAME ."
# (pagename VARCHAR(160) NOT NULL,
# version INTEGER UNSIGNED NOT NULL DEFAULT 0,
# flags INTEGER UNSIGNED DEFAULT 0,
# content MEDIUMTEXT,
# author VARCHAR(100) DEFAULT 'ewiki',
# created INTEGER UNSIGNED DEFAULT ".time().",
# lastmodified INTEGER UNSIGNED DEFAULT 0,
# refs MEDIUMTEXT,
# meta MEDIUMTEXT,
# hits INTEGER UNSIGNED DEFAULT 0,
# PRIMARY KEY id (pagename, version) )
# ");
#echo mysql_error();
break;
default:
}
return($r);
}

132
mod/wiki/filter.php Executable file
View file

@ -0,0 +1,132 @@
<?PHP // $Id$
//This function provides automatic linking to
//wiki pages when its page title is found inside every Moodle text
//It's based in the glosssary filter by Williams Castillo
//Modifications by mchurch. Enjoy! :-)
require_once($CFG->dirroot.'/mod/wiki/lib.php');
$textfilter_function='wiki_page_filter';
if (function_exists($textfilter_function)) {
return;
}
function wiki_page_filter($courseid, $text) {
global $CFG;
if (empty($courseid)) {
if ($site = get_site()) {
$courseid = $site->id;
}
}
if (!($course = get_record('course', 'id', $courseid))) {
return $text;
}
// Get all wikis for this course.
$wikis = get_records('wiki', 'course', $courseid);
if (empty($wikis)) {
return $text;
}
// Walk through each wiki, and get entries.
foreach ($wikis as $wiki) {
if ($wiki_entries = wiki_get_entries($wiki)) {
// Walk through each entry and get the pages.
foreach ($wiki_entries as $wiki_entry) {
if ($wiki_pages = get_records('wiki_pages', 'wiki', $wiki_entry->id)) {
// Walk through each page and filter.
foreach ($wiki_pages as $wiki_page) {
$startlink = '<a class="autolink" title="Wiki" href="'
.$CFG->wwwroot.'/mod/wiki/view.php?wid='.$wiki->id
.'&userid='.$wiki_entry->userid
.'&groupid='.$wiki_entry->groupid
.'&wikipage='.$wiki_page->pagename.'">';
$text = wiki_link_names($text, $wiki_page->pagename, $startlink, '</a>');
}
}
}
}
}
return $text;
}
function wiki_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>") {
$list_of_words_cp = strip_tags($name);
$list_of_words_cp = trim($list_of_words_cp,'|');
$list_of_words_cp = trim($list_of_words_cp);
$list_of_words_cp = preg_quote($list_of_words_cp,'/');
$invalidprefixs = "([a-zA-Z0-9])";
$invalidsufixs = "([a-zA-Z0-9])";
//Avoid seaching in the string if it's inside invalidprefixs and invalidsufixs
$words = array();
$regexp = '/'.$invalidprefixs.'('.$list_of_words_cp.')|('.$list_of_words_cp.')'.$invalidsufixs.'/is';
preg_match_all($regexp,$text,$list_of_words);
foreach (array_unique($list_of_words[0]) as $key=>$value) {
$words['<*'.$key.'*>'] = $value;
}
if (!empty($words)) {
$text = str_replace($words,array_keys($words),$text);
}
//Now avoid searching inside the <nolink>tag
$excludes = array();
preg_match_all('/<nolink>(.+?)<\/nolink>/is',$text,$list_of_excludes);
foreach (array_unique($list_of_excludes[0]) as $key=>$value) {
$excludes['<+'.$key.'+>'] = $value;
}
if (!empty($excludes)) {
$text = str_replace($excludes,array_keys($excludes),$text);
}
//Now avoid searching inside links
$links = array();
preg_match_all('/<A[\s](.+?)>(.+?)<\/A>/is',$text,$list_of_links);
foreach (array_unique($list_of_links[0]) as $key=>$value) {
$links['<@'.$key.'@>'] = $value;
}
if (!empty($links)) {
$text = str_replace($links,array_keys($links),$text);
}
//Now avoid searching inside every tag
$final = array();
preg_match_all('/<(.+?)>/is',$text,$list_of_tags);
foreach (array_unique($list_of_tags[0]) as $key=>$value) {
$final['<|'.$key.'|>'] = $value;
}
if (!empty($final)) {
$text = str_replace($final,array_keys($final),$text);
}
$text = preg_replace('/('.$list_of_words_cp.')/is', $href_tag_begin.'$1'.$href_tag_end,$text);
//Now rebuild excluded areas
if (!empty($final)) {
$text = str_replace(array_keys($final),$final,$text);
}
if (!empty($links)) {
$text = str_replace(array_keys($links),$links,$text);
}
if (!empty($excludes)) {
$text = str_replace(array_keys($excludes),$excludes,$text);
}
if (!empty($words)) {
$text = str_replace(array_keys($words),$words,$text);
}
return $text;
}
?>

BIN
mod/wiki/icon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

108
mod/wiki/index.php Normal file
View file

@ -0,0 +1,108 @@
<?PHP // $Id$
/// This page lists all the instances of wiki in a particular course
/// Replace wiki with the name of your module
require_once("../../config.php");
require_once("lib.php");
require_variable($id); // course
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
}
require_login($course->id);
add_to_log($course->id, "wiki", "view all", "index.php?id=$course->id", "");
/// Get all required strings
$strwikis = get_string("modulenameplural", "wiki");
$strwiki = get_string("modulename", "wiki");
/// Print the header
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
print_header("$course->shortname: $strwikis", "$course->fullname", "$navigation $strwikis", "", "", true, "", navmenu($course));
/// Get all the appropriate data
if (! $wikis = get_all_instances_in_course("wiki", $course)) {
notice("There are no wikis", "../../course/view.php?id=$course->id");
die;
}
/// Print the list of instances (your module will probably extend this)
$timenow = time();
$strname = get_string('wikiname', 'wiki');
$strsummary = get_string('summary');
$strtype = get_string('wikitype', 'wiki');
$strlastmodified = get_string('lastmodified');
$strweek = get_string('week');
$strtopic = get_string('topic');
if ($course->format == "weeks") {
$table->head = array ($strweek, $strname, $strsummary, $strtype, $strlastmodified);
$table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
} else if ($course->format == "topics") {
$table->head = array ($strtopic, $strname, $strsummary, $strtype, $strlastmodified);
$table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
} else {
$table->head = array ($strname, $strsummary, $strtype, $strlastmodified);
$table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT');
}
foreach ($wikis as $wiki) {
if (!$wiki->visible) {
//Show dimmed if the mod is hidden
$link = '<A class="dimmed" HREF="view.php?id='.$wiki->coursemodule.'">'.$wiki->name.'</A>';
} else {
//Show normal if the mod is visible
$link = '<A HREF="view.php?id='.$wiki->coursemodule.'">'.$wiki->name.'</A>';
}
$timmod = '<span class="smallinfo">'.userdate($wiki->timemodified).'</span>';
$summary = '<span class="smallinfo">'.$wiki->summary.'</span>';
$site = get_site();
switch ($wiki->wtype) {
case 'teacher':
$wtype = $site->teacher;
break;
case 'student':
$wtype = $site->student;
break;
case 'group':
default:
$wtype = get_string('group');
break;
}
$wtype = '<span class="smallinfo">'.$wtype.'</span>';
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($wiki->section, $link, $summary, $wtype, $timmod);
} else {
$table->data[] = array ($link, $summary, $wtype, $timmod);
}
}
echo "<BR>";
print_table($table);
/// Finish the page
print_footer($course);
?>

1383
mod/wiki/lib.php Normal file

File diff suppressed because it is too large Load diff

159
mod/wiki/mod.html Normal file
View file

@ -0,0 +1,159 @@
<!-- This page defines the form to create or edit an instance of this module -->
<!-- It is used from /course/mod.php. The whole instance is available as $form. -->
<?php
require("$CFG->dirroot/mod/wiki/lib.php");
if (!isset($form->name)) {
$form->name = '';
}
if (!isset($form->summary)) {
$form->summary = '';
}
if (!isset($form->pagename)) {
$form->pagename = '';
}
if (!isset($form->pagename)) {
$form->pagename = '';
}
if (!isset($form->wtype)) {
$form->wtype = 'group';
}
if (!isset($form->ewikiprinttitle)) {
$form->ewikiprinttitle = 1;
}
if (!isset($form->htmlmode)) {
$form->htmlmode = 2 ;
}
if (!isset($form->ewikiacceptbinary)) {
$form->ewikiacceptbinary = 0;
}
if (!isset($form->initialcontent)) {
$form->initialcontent = '';
}
/// If updating an existing wiki, find out if it has entries.
if ($form->id) {
$wikihasentries = wiki_has_entries($form);
}
?>
<FORM name="form" method="post" action="<?php echo $ME ?>">
<CENTER>
<TABLE cellpadding=5>
<TR valign=top>
<TD align=right><P><B><?php print_string('name') ?>:</B></P></TD>
<TD>
<INPUT type="text" name="name" size=30 value="<?php p($form->name) ?>">
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string('summary') ?>:</B></P></TD>
<TD>
<?php print_textarea(false, 5, 60, 680, 400, "summary", $form->summary); ?>
</TD>
</TR>
<tr valign=top>
<TD align=right><P>
<?php helpbutton('wikitype', get_string('wikitype', 'wiki'), 'wiki'); ?>
<B><?php print_string('wikitype', "wiki") ?>:</B></P></TD>
<TD>
<?php
if ($wikihasentries) {
echo $WIKI_TYPES[$form->wtype];
}
else {
choose_from_menu($WIKI_TYPES, 'wtype', $form->wtype, "");
}
?>
</TD>
</tr>
<TR valign=top>
<TD align=right><P><B><?php print_string('ewikiprinttitle', 'wiki') ?>:</B></P></TD>
<TD>
<select size="1" name="ewikiprinttitle">
<option value="1" <?php if ( $form->ewikiprinttitle) { echo 'selected'; }?>><?php print_string('yes') ?></option>
<option value="0" <?php if ( !$form->ewikiprinttitle) { echo 'selected'; }?>><?php print_string('no') ?></option>
</select>
</TD>
</TR>
<TR valign=top>
<TD align=right><P>
<?php helpbutton('htmlmode', get_string('htmlmode', 'wiki'), 'wiki'); ?>
<B><?php print_string('htmlmode', 'wiki') ?>:</B></P></TD>
<TD>
<?php
$htmlmodes=array( "0" => get_string("nohtml","wiki") , "1" => get_string("safehtml","wiki"), "2" => get_string("htmlonly","wiki"));
choose_from_menu($htmlmodes, "htmlmode", $form->htmlmode, "");
?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P>
<?php helpbutton('ewikiacceptbinary', get_string('ewikiacceptbinary', 'wiki'), 'wiki') ?>
<B><?php print_string('ewikiacceptbinary', 'wiki') ?>:</B></P></TD>
<TD>
<select size="1" name="ewikiacceptbinary">
<option value="1" <?php if ( $form->ewikiacceptbinary) { echo 'selected'; }?>><?php print_string('yes') ?></option>
<option value="0" <?php if ( !$form->ewikiacceptbinary) { echo 'selected'; }?>><?php print_string('no') ?></option>
</select>
</TD>
</TR>
<tr valign="top">
<td align="right"><b> Optional: </b></td>
<td></td>
</tr>
<TR valign=top>
<TD align=right><P>
<?php helpbutton('wikiname', get_string('wikiname', 'wiki'), 'wiki'); ?>
<B><?php print_string('wikiname', 'wiki') ?>:</B></P></TD>
<TD>
<?php
if ($wikihasentries) {
echo $form->pagename;
}
else {
?>
<INPUT type="text" name="pagename" size=30 value="<?php p($form->pagename) ?>"><b> - or - </b>
<?php
}
?>
</TD>
</TR>
<tr valign="top">
<td align="right" nowrap>
<?php helpbutton('initialcontent', get_string('initialcontent', 'wiki'), 'wiki'); ?>
<B><?php echo get_string("initialcontent", "wiki") ?>:</B></P>
</td>
<td>
<?php
if ($wikihasentries) {
echo $form->initialcontent;
}
else {
$strchooseafile = get_string("chooseafile", "wiki");
echo "<input name=\"initialcontent\" size=\"50\" value=\"$form->initialcontent\">&nbsp;";
button_to_popup_window ("/mod/wiki/wikifiles.php?id=$course->id",
"wikifiles", $strchooseafile, 500, 750, $strchooseafile);
}
?>
</td>
</tr>
</TABLE>
<!-- These hidden variables are always the same -->
<INPUT type="hidden" name=course value="<?php p($form->course) ?>">
<INPUT type="hidden" name=coursemodule value="<?php p($form->coursemodule) ?>">
<INPUT type="hidden" name=section value="<?php p($form->section) ?>">
<INPUT type="hidden" name=module value="<?php p($form->module) ?>">
<INPUT type="hidden" name=modulename value="<?php p($form->modulename) ?>">
<INPUT type="hidden" name=instance value="<?php p($form->instance) ?>">
<INPUT type="hidden" name=id value="<?php p($form->instance) ?>">
<INPUT type="hidden" name=mode value="<?php p($form->mode) ?>">
<INPUT type="submit" value="<?php print_string('savechanges') ?>">
</CENTER>
</FORM>

32
mod/wiki/removepages.html Normal file
View file

@ -0,0 +1,32 @@
<?PHP
// Make sure all variables are defined
print get_string("removenotice","wiki")."<br><br>";
?>
<FORM ACTION="admin.php" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="userid" VALUE="<? print $userid; ?>">
<INPUT TYPE="HIDDEN" NAME="groupid" VALUE="<? print $groupid ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="<? print $action; ?>">
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<? print $cm->id ?>">
<INPUT TYPE="HIDDEN" NAME="wikipage" VALUE="<? print $wikipage?>">
<?
$remove_table=wiki_admin_remove_list($form->listall);
print_table($remove_table);
?>
<center>
<?
if(!count($remove_table->data)) {
print get_string("nocandidatestoremove","wiki",get_string("listall","wiki"))."<br><br>";
}
?>
<?
if($form->listall) {
print ' <input type="submit" name="listcandidates" value="'.get_string("listcandidates","wiki").'">'."\n";
} else {
print ' <input type="submit" name="listall" value="'.get_string("listall","wiki").'">'."\n";
}
?>
<input type="submit" name="proceed" value="<? print get_string("removeselectedpages","wiki"); ?>">
</center>

262
mod/wiki/restorelib.php Normal file
View file

@ -0,0 +1,262 @@
<?PHP //$Id$
//This php script contains all the stuff to backup/restore
//wiki mods
//This is the "graphical" structure of the wiki mod:
//
// wiki
// (CL,pk->id)
//
// wiki_entries
// (pk->id, fk->wikiid)
//
// wiki_pages
// (pk->pagename,version,wiki, fk->wiki)
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
// nt->nested field (recursive data)
// CL->course level info
// UL->user level info
// files->table may have files)
//
//-----------------------------------------------------------
function wiki_restore_mods($mod,$restore) {
global $CFG;
$status = true;
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the wiki record structure
$wiki->course = $restore->course_id;
$wiki->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$wiki->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
$wiki->pagename = backup_todb($info['MOD']['#']['PAGENAME']['0']['#']);
$wiki->wtype = backup_todb($info['MOD']['#']['WTYPE']['0']['#']);
$wiki->ewikiprinttitle = backup_todb($info['MOD']['#']['EWIKIPRINTTITLE']['0']['#']);
$wiki->ewikiallowsafehtml = backup_todb($info['MOD']['#']['HTMLMODE']['0']['#']);
$wiki->ewikiacceptbinary = backup_todb($info['MOD']['#']['EWIKIACCEPTBINARY']['0']['#']);
$wiki->initialcontent = backup_todb($info['MOD']['#']['INITIALCONTENT']['0']['#']);
$wiki->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the wiki
$newid = insert_record ("wiki",$wiki);
//Do some output
echo "<ul><li>".get_string("modulename","wiki")." \"".$wiki->name."\"<br>";
backup_flush(300);
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Restore wiki_entries
$status = wiki_entries_restore_mods($mod->id,$newid,$info,$restore);
} else {
$status = false;
}
//Finalize ul
echo "</ul>";
} else {
$status = false;
}
return $status;
}
//This function restores the wiki_entries
function wiki_entries_restore_mods($old_wiki_id,$new_wiki_id,$info,$restore) {
global $CFG;
$status = true;
//Get the entries array
$entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY'];
//Iterate over entries
for($i = 0; $i < sizeof($entries); $i++) {
$ent_info = $entries[$i];
//traverse_xmlize($ent_info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//We'll need this later!!
$oldid = backup_todb($ent_info['#']['ID']['0']['#']);
$olduserid = backup_todb($ent_info['#']['USERID']['0']['#']);
$oldgroupid = backup_todb($ent_info['#']['GROUPID']['0']['#']);
//Now, build the wiki_ENTRIES record structure
$entry->wikiid = $new_wiki_id;
$entry->course= $restore->course_id;
$entry->userid = backup_todb($ent_info['#']['USERID']['0']['#']);
$entry->groupid = backup_todb($ent_info['#']['GROUPID']['0']['#']);
$entry->pagename = backup_todb($ent_info['#']['PAGENAME']['0']['#']);
$entry->timemodified = backup_todb($ent_info['#']['TIMEMODIFIED']['0']['#']);
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$entry->userid);
if ($user) {
$entry->userid = $user->new_id;
}
$group = backup_getid($restore->backup_unique_code,"group",$entry->groupid);
if ($group) {
$entry->groupid = $group->new_id;
}
//If userinfo was selected, restore the entry
if ($restore->mods['wiki']->userinfo) {
//The structure is equal to the db, so insert the wiki_entries
$newid = insert_record ("wiki_entries",$entry);
//Do some output
if (($i+1) % 50 == 0) {
echo ".";
if (($i+1) % 1000 == 0) {
echo "<br>";
}
backup_flush(300);
}
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"wiki_entries",$oldid,$newid);
//Get old wiki id from backup_ids
$rec = get_record("backup_ids","backup_code",$restore->backup_unique_code,
"table_name","wiki",
"new_id",$new_wiki_id);
//Now copy moddata associated files
$status = wiki_restore_files ($rec->old_id, $new_wiki_id, $oldid, $newid, $restore);
//Restore wiki_pages
$status = wiki_pages_restore_mods($oldid,$newid,$ent_info,$restore);
} else {
$status = false;
}
}
}
return $status;
}
//This function restores the wiki_pages
function wiki_pages_restore_mods($old_entry_id,$new_entry_id,$info,$restore) {
global $CFG;
$status = true;
//Get the comments array
$pages = $info['#']['PAGES']['0']['#']['PAGE'];
//Iterate over pages
for($i = 0; $i < sizeof($pages); $i++) {
$pag_info = $pages[$i];
//traverse_xmlize($com_info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//We'll need this later!!
$oldid = backup_todb($pag_info['#']['PAGENAME']['0']['#']."_".$pag_info['#']['VERSION']['0']['#']."_".$pag_info['#']['WIKI']['0']['#']);
//Now, build the wiki_page record structure
$page->wiki = $new_entry_id;
$page->pagename = backup_todb($pag_info['#']['PAGENAME']['0']['#']);
$page->version = backup_todb($pag_info['#']['VERSION']['0']['#']);
$page->flags = backup_todb($pag_info['#']['FLAGS']['0']['#']);
$page->content = backup_todb($pag_info['#']['CONTENT']['0']['#']);
$page->author = backup_todb($pag_info['#']['AUTHOR']['0']['#']);
$page->created = backup_todb($pag_info['#']['CREATED']['0']['#']);
$page->lastmodified = backup_todb($pag_info['#']['LASTMODIFIED']['0']['#']);
$page->refs = backup_todb($pag_info['#']['REFS']['0']['#']);
$page->meta = backup_todb($pag_info['#']['META']['0']['#']);
$page->hits = backup_todb($pag_info['#']['HITS']['0']['#']);
//The structure is equal to the db, so insert the wiki_comments
insert_record ("wiki_pages",$page, false,"pagename");
#print "<pre>"; print_r($page); print "</pre>";
print ($r?"TRUE":"FALSE")."<br>\n";
#$newid = insert_record ("wiki_pages",$page);
#if($newid) {
# $newid = backup_todb($pag_info['#']['PAGENAME']['0']['#']."_".$pag_info['#']['VERSION']['0']['#']."_".$new_entry_id);
#}
//Do some output
if (($i+1) % 50 == 0) {
echo ".";
if (($i+1) % 1000 == 0) {
echo "<br>";
}
backup_flush(300);
}
#if ($newid) {
# //We have the newid, update backup_ids
# backup_putid($restore->backup_unique_code,"wiki_pages",$oldid,$newid);
#} else {
# $status = false;
#}
}
return $status;
}
function wiki_restore_files ($oldwikiid, $newwikiid, $oldentryid, $newentryid, $restore) {
global $CFG;
$status = true;
$todo = false;
$moddata_path = "";
$forum_path = "";
$temp_path = "";
//First, we check to "course_id" exists and create is as necessary
//in CFG->dataroot
$dest_dir = $CFG->dataroot."/".$restore->course_id;
$status = check_dir_exists($dest_dir,true);
//First, locate course's moddata directory
$moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
//Check it exists and create it
$status = check_dir_exists($moddata_path,true);
//Now, locate forum directory
if ($status) {
$wiki_path = $moddata_path."/wiki";
//Check it exists and create it
$status = check_dir_exists($wiki_path,true);
}
//Now locate the temp dir we are restoring from
if ($status) {
$temp_path = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code.
"/moddata/wiki/".$oldwikiid."/".$oldentryid;
//Check it exists
if (is_dir($temp_path)) {
$todo = true;
}
}
//If todo, we create the neccesary dirs in course moddata/forum
if ($status and $todo) {
//First this forum id
$this_wiki_path = $wiki_path."/".$newwikiid;
$status = check_dir_exists($this_wiki_path,true);
//Now this post id
$entry_wiki_path = $this_wiki_path."/".$newentryid;
//And now, copy temp_path to post_forum_path
$status = backup_copy_file($temp_path, $entry_wiki_path);
}
return $status;
}
?>

62
mod/wiki/revertpages.html Normal file
View file

@ -0,0 +1,62 @@
<?PHP
// Make sure all variables are defined
if (!isset($form->deleteversions)) {
$form->deleteversions = 1;
}
if (!isset($form->changesfield)) {
$form->changesfield = 72;
}
?>
<FORM ACTION="admin.php" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="userid" VALUE="<? print $userid; ?>">
<INPUT TYPE="HIDDEN" NAME="groupid" VALUE="<? print $groupid ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="<? print $action; ?>">
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<? print $cm->id ?>">
<INPUT TYPE="HIDDEN" NAME="wikipage" VALUE="<? print $wikipage?>">
<CENTER>
<?
if($err->remark) {
formerr($err->remark);
}
?>
<TABLE cellpadding=5>
<TR valign=top>
<TD align=right><P><B><?php print_string('authorfieldpattern','wiki') ?>:</B></P></TD>
<TD>
<INPUT type="text" name="authorfieldpattern" size=30 value="<?php p($form->authorfieldpattern) ?>">
<?php
helpbutton('revertauthorfieldpattern', get_string('authorfieldpattern', 'wiki'), 'wiki');
if (!empty($err->authorfieldpattern)) { formerr($err->authorfieldpattern); }
?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string('changesfield','wiki') ?>:</B></P></TD>
<TD>
<INPUT type="text" name="changesfield" size=30 value="<?php p($form->changesfield) ?>">
<? if (!empty($err->changesfield)) { formerr($err->changesfield); } ?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string('howtooperate', 'wiki') ?>:</B></P></TD>
<TD>
<?php
$operations=array( "lastonly" => get_string("revertlastonly","wiki"),
"allsince" => get_string("revertallsince","wiki"),
"the" => get_string("revertthe","wiki"));
choose_from_menu($operations, "howtooperate", $form->howtooperate, "");
?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string('deleteversions','wiki') ?>:</B></P></TD>
<TD>
<INPUT type="text" name="deleteversions" size=2 value="<?php p($form->deleteversions) ?>">
<? if (!empty($err->deleteversions)) { formerr($err->deleteversions); } ?>
</TD>
</TR>
</TABLE>
<input type="submit" name="proceed" value="<? print get_string("revertchanges","wiki"); ?>">
</center>

View file

@ -0,0 +1,18 @@
<?PHP
// Make sure all variables are defined
?>
<FORM ACTION="admin.php" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="userid" VALUE="<? print $userid; ?>">
<INPUT TYPE="HIDDEN" NAME="groupid" VALUE="<? print $groupid ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="<? print $action; ?>">
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<? print $cm->id ?>">
<INPUT TYPE="HIDDEN" NAME="wikipage" VALUE="<? print $wikipage?>">
<?
$pageflags_table=wiki_admin_setpageflags_list($pageflagstatus);
print_table($pageflags_table);
?>
<br>
<center>
<input type="submit" name="proceed" value="<? print get_string("setpageflags","wiki"); ?>">
</center>

22
mod/wiki/strippages.html Normal file
View file

@ -0,0 +1,22 @@
<?PHP
// Make sure all variables are defined
?>
<FORM ACTION="admin.php" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="userid" VALUE="<? print $userid; ?>">
<INPUT TYPE="HIDDEN" NAME="groupid" VALUE="<? print $groupid ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="<? print $action; ?>">
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<? print $cm->id ?>">
<INPUT TYPE="HIDDEN" NAME="wikipage" VALUE="<? print $wikipage?>">
<?
$strip_table=wiki_admin_strip_list($form->pagestostrip, $form->version, $err);
print_table($strip_table);
?>
<center>
<?
if(!count($strip_table->data)) {
print get_string("nothingtostrip","wiki")."<br><br>";
}
?>
<input type="submit" name="proceed" value="<? print get_string("strippages","wiki"); ?>">
</center>

11
mod/wiki/test.php Normal file
View file

@ -0,0 +1,11 @@
<?php
require_once("../../config.php");
require_once("$CFG->dirroot/course/lib.php"); // For side-blocks
require_once('wiki.class.php');
echo "Test Harness<br>";
$wiki = new cWiki(9);
print_object($wiki);
?>

11
mod/wiki/version.php Normal file
View file

@ -0,0 +1,11 @@
<?PHP // $Id$
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of Wiki
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2004053100; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
?>

335
mod/wiki/view.php Normal file
View file

@ -0,0 +1,335 @@
<?PHP // $Id$
/// Extended by Michael Schneider
/// This page prints a particular instance of wiki
require_once("../../config.php");
require_once("lib.php");
# require_once("$CFG->dirroot/course/lib.php"); // For side-blocks
optional_variable($ewiki_action,""); // Action on Wiki-Page
optional_variable($id); // Course Module ID, or
optional_variable($wid); // Wiki ID
optional_variable($wikipage, false); // Wiki Page Name
optional_variable($q,""); // Search Context
optional_variable($userid); // User wiki.
optional_variable($groupid); // Group wiki.
optional_variable($canceledit,""); // Editing has been cancelled
if($canceledit) {
$wikipage=$ewiki_id;
}
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $wiki = get_record("wiki", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (! $wiki = get_record("wiki", "id", $wid)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $wiki->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) {
error("Course Module ID was incorrect");
}
$id = $cm->id;
$_REQUEST["id"] = $id;
}
if ($course->category or !empty($CFG->forcelogin)) {
require_login($course->id);
}
/// Add the course module 'groupmode' to the wiki object, for easy access.
$wiki->groupmode = $cm->groupmode;
/// If the wiki entry doesn't exist, can this user create it?
if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) {
if (wiki_can_add_entry($wiki, $USER, $course, $userid, $groupid)) {
wiki_add_entry($wiki, $course, $userid, $groupid);
if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) {
error("Could not add wiki entry.");
}
}
else {
$wiki_entry_text = '<div align="center">'.get_string('nowikicreated', 'wiki').'</div>';
}
}
/// How shall we display the wiki-page ?
$moodle_format=FORMAT_MOODLE;
### SAVE ID from Moodle
$moodleID=@$_REQUEST["id"];
if ($wiki_entry) {
/// The wiki_entry->pagename is set to the specified value of the wiki,
/// or the default value in the 'lang' file if the specified value was empty.
define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
$wikipage = ($wikipage === false) ? EWIKI_PAGE_INDEX: $wikipage;
//////
/// ################# EWIKI Part ###########################
/// ### Prevent ewiki getting id as PageID...
unset($_REQUEST["id"]);
unset($_GET["id"]);
unset($_POST["id"]);
unset($_POST["id"]);
unset($_SERVER["QUERY_STRING"]);
unset($HTTP_GET_VARS["id"]);
unset($HTTP_POST_VARS["id"]);
global $ewiki_title;
/// #-- predefine some of the configuration constants
define("EWIKI_NAME", $wiki_entry->pagename);
/// Search Hilighting
if($ewiki_title=="SearchPages") {
$qArgument="&q=".urlencode($q);
}
/// Build the ewsiki script constant
/// ewbase will also be needed by EWIKI_SCRIPT_BINARY
$ewbase = $ME.'?id='.$moodleID;
if (isset($userid)) $ewbase .= '&userid='.$userid;
if (isset($groupid)) $ewbase .= '&groupid='.$groupid;
$ewscript = $ewbase.'&wikipage=';
define("EWIKI_SCRIPT", $ewscript);
/// # Settings for this specific Wiki
define("EWIKI_PRINT_TITLE", $wiki->ewikiprinttitle);
define("EWIKI_INIT_PAGES", wiki_content_dir($wiki));
/// # fix broken PHP setup
if (!function_exists("get_magic_quotes_gpc") || get_magic_quotes_gpc()) {
include($CFG->dirroot."/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php");
}
if (ini_get("register_globals")) {
# include($CFG->dirroot."/mod/wiki/ewiki/fragments/strike_register_globals.php");
}
# Database Handler
include_once($CFG->dirroot."/mod/wiki/ewikimoodlelib.php");
# Plugins
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/email_protect.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/patchsaving.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/notify.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/feature/imgresize_gd.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_highlight.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/f_fixhtml.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/aview/backlinks.php");
#include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/markup/css.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/markup/footnotes.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/action/diff.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/page/pageindex.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/page/orphanedpages.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/wantedpages.php");
# Binary Handling
if($wiki->ewikiacceptbinary) {
define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
define("EWIKI_ALLOW_BINARY",1);
define("EWIKI_IMAGE_CACHING",1);
#define("EWIKI_AUTOVIEW",1);
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/lib/mime_magic.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/aview/downloads.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/downloads.php");
#include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/db/binary_store.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php");
} else {
define("EWIKI_SCRIPT_BINARY", 0);
define("EWIKI_ALLOW_BINARY",0);
}
# The mighty Wiki itself
include_once($CFG->dirroot."/mod/wiki/ewiki/ewiki.php");
# Language-stuff: eWiki gets language from Browser. Lets correct it. Empty arrayelements do no harm
$ewiki_t["languages"]=array(current_language(), $course->lang, $CFG->lang,"en","c");
# Check Access Rights
$canedit = wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course);
if (!$canedit) {
# Protected Mode
unset($ewiki_plugins["action"]["edit"]);
unset($ewiki_plugins["action"]["info"]);
}
# HTML Handling
$ewiki_use_editor=0;
if($wiki->htmlmode == 0) {
# No HTML
$ewiki_config["htmlentities"]=array(); // HTML is managed by moodle
$moodle_format=FORMAT_TEXT;
}
if($wiki->htmlmode == 1) {
# Safe HTML
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_rescue_html.php");
$moodle_format=FORMAT_HTML;
}
if($wiki->htmlmode == 2) {
# HTML Only
$moodle_format=FORMAT_HTML;
$ewiki_use_editor=1;
$ewiki_config["htmlentities"]=array(); // HTML is allowed
$ewiki_config["wiki_link_regex"] = "\007 [!~]?(
\#?\[[^<>\[\]\n]+\] |
\^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} |
\b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* |
\w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x";
}
global $ewiki_author, $USER;
$ewiki_author=fullname($USER);
$content=ewiki_page($wikipage);
### RESTORE ID from Moodle
$_REQUEST["id"]=$moodleID;
$id=$moodleID;
/// ################# EWIKI Part ###########################
}
else {
$content = $wiki_entry_text;
}
/// Moodle Log
add_to_log($course->id, "wiki", $ewiki_action, "view.php?id=$cm->id&groupid=$groupid&userid=$userid&wikipage=$wikipage", $wiki->name." ".$ewiki_title);
/// Print the page header
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
$strwikis = get_string("modulenameplural", "wiki");
$strwiki = get_string("modulename", "wiki");
print_header("$course->shortname: $wiki_entry->pagename", "$course->fullname",
"$navigation <A HREF=\"index.php?id=$course->id\">$strwikis</A> -> <A HREF=\"view.php?id=$moodleID\">$wiki->name</a> -> $ewiki_title",
"", "", true, update_module_button($cm->id, $course->id, $strwiki),
navmenu($course, $cm));
/// Print Page
/// The top row contains links to other wikis, if applicable.
if ($wiki_list = wiki_get_other_wikis($wiki, $USER, $course, $wiki_entry->id)) {
$selected="";
if (isset($wiki_list['selected'])) {
$selected = $wiki_list['selected'];
unset($wiki_list['selected']);
}
echo '<tr><td colspan="2">';
echo '<form name="otherwikis" action="'.$CFG->wwwroot.'/mod/wiki/view.php">';
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>';
echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'">&nbsp;'
.$WIKI_TYPES[$wiki->wtype].' '
.get_string('modulename', 'wiki')." ".get_string('for',"wiki")." "
.wiki_get_owner($wiki_entry).':</td>';
echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'" align="right">'
.get_string('otherwikis', 'wiki').':&nbsp;&nbsp;';
$script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
choose_from_menu($wiki_list, "wikiselect", $selected, "choose", $script);
echo '</td>';
echo '</tr></table>';
echo '</form>';
echo '</td>';
echo '</tr>';
}
if ($wiki_entry) {
$specialpages=array("SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
/// Page Actions
echo '<table border="0" width="100%">';
echo '<tr>';
if ($canedit) {
$iconstr="";
$editicon= '<img hspace=1 alt="'.get_string("editthispage","wiki").'" height=16 width=16 border=0 src="'.$CFG->pixpath.'/t/edit.gif">';
$infoicon= '<img hspace=1 alt="'.get_string("pageinfo","wiki").'" height=16 width=16 border=0 src="'.$CFG->pixpath.'/i/info.gif">';
if($ewiki_action!="edit" && !in_array($wikipage, $specialpages)) {
$iconstr='<a title="'.get_string("editthispage","wiki").'" href="'.EWIKI_SCRIPT.'&wikipage=edit/'.$ewiki_id.'">'.$editicon."</a>";
} else {
$iconstr=$editicon;
}
if($ewiki_action!="info" && !in_array($wikipage, $specialpages)) {
$iconstr.='<a title="'.get_string("pageinfo","wiki").'" href="'.EWIKI_SCRIPT.'&wikipage=info/'.$ewiki_id.'">'.$infoicon."</a>";
} else {
$iconstr.=$infoicon;
}
echo "<td>$iconstr</td>";
}
echo '<td>';
wiki_print_page_actions($cm->id, $specialpages, $ewiki_id, $ewiki_action, $wiki->ewikiacceptbinary, $canedit);
echo '</td>';
/// Searchform
echo '<td align="center">';
wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
echo '</td>';
/// Internal Wikilinks
echo '<td align="center">';
wiki_print_wikilinks_block($cm->id, $wiki->ewikiacceptbinary);
echo '</td>';
/// Administrative Links
if($canedit) {
echo '<td align="center">';
wiki_print_administration_actions($cm->id, $userid, $groupid, $ewiki_title, $wiki->htmlmode!=2);
echo '</td>';
}
/// Formatting Rules
if($wiki->htmlmode!=2) {
echo '<td align="center">';
helpbutton('wikiusage', get_string('wikiusage', 'wiki'), 'wiki');
echo get_string("wikiusage","wiki");
echo '</td>';
}
echo '</tr></table>';
}
// The wiki Summary (Closes Bug #1496)
if($ewiki_title==$wiki_entry->pagename && !empty($wiki->summary)) {
print "<br>";
print_simple_box(format_text($wiki->summary, FORMAT_HTML), "center", "100%");
print "<br>";
}
// The wiki Contents
print_simple_box_start( "center", "100%", "$THEME->cellcontent", "20");
if($ewiki_action=="edit") {
# When editing, the filters shall not interfere the wiki-source
print $content;
} else {
print(format_text($content, $moodle_format));
}
print_simple_box_end();
/// Finish the page
print_footer($course);
?>

107
mod/wiki/wiki_styles.php Normal file
View file

@ -0,0 +1,107 @@
<?php
/*
This file contains the class definitions used by the wiki module.
Include these in your theme file, and modify them to your tastes.
*/
?>
<!-- <div> that surrounds entire wiki output -->
.wiki {
background-color: #FFFFFF;
padding: 6px;
}
<!-- action classes that work with the wiki <div> -->
.view {
}
.edit {
}
.info {
}
.links {
}
<!-- Defines the <div> tag surrounding the backlinks feature. -->
.wiki_backlinks {
border-top: 2px <?php echo $THEME->borders?> solid;
}
.indent {
}
<!-- defines the h2 class for the title -->
h2.page.title {
border-bottom: 2px <?php echo $THEME->borders?> solid;
}
<!-- Defines the table used for the version information -->
.version-info {
}
<!-- Defines the table cell used for the various version actions -->
.action-links {
}
<!-- Defines the table cell used for the various version actions -->
.control-links {
}
<!-- Defines the table row used for the version version row -->
.page-version {
}
<!-- Defines the table row used for the version author row -->
.page-author {
}
<!-- Defines the table row used for the version created row -->
.page-created {
}
<!-- Defines the table row used for the version lastmodified row -->
.page-lastmodified {
}
<!-- Defines the table row used for the version refs row -->
.page-refs {
}
<!-- Defines the table row used for the version flags row -->
.page-flags {
}
<!-- Defines the table row used for the version meta row -->
.page-meta {
}
<!-- Defines the <div> used for the chunked results -->
.chunked-result {
}
<!-- Defines the <div> used for the edit box -->
.edit-box {
}
<!-- Defines the <div> used for the image upload form -->
.image-upload {
}
<!-- Defines the <div> used for the preview page -->
.preview {
}
<!-- Defines the <span> used for the search not found -->
.NotFound {
}
<!-- Defines the <div> used for the todo list -->
.ewiki_page_todolist {
}
<!-- Defines the <table> used for the diff function -->
.diff {
}

854
mod/wiki/wikifiles.php Executable file
View file

@ -0,0 +1,854 @@
<?PHP // $Id$
// Manage all uploaded files in a course file area
// This file is a hack to files/index.php that removes
// the headers and adds some controls so that images
// can be selected within the Richtext editor.
// All the Moodle-specific stuff is in this top section
// Configuration and access control occurs here.
// Must define: USER, basedir, baseweb, html_header and html_footer
// USER is a persistent variable using sessions
require("../../config.php");
require("../../files/mimetypes.php");
require_variable($id);
optional_variable($file, "");
optional_variable($wdir, "");
optional_variable($action, "");
if (! $course = get_record("course", "id", $id) ) {
error("That's an invalid course id");
}
require_login($course->id);
if (! isteacher($course->id) ) {
error("Only teachers can edit files");
}
function html_footer() {
echo "</td></tr></table></body></html>";
}
function html_header($course, $wdir, $formfield=""){
global $CFG,$THEME;
if (! $site = get_site()) {
error("Invalid site!");
}
if ($course->id == $site->id) {
$strfiles = get_string("sitefiles");
} else {
$strfiles = get_string("files");
}
if ($wdir == "/") {
$fullnav = "$strfiles";
} else {
$dirs = explode("/", $wdir);
$numdirs = count($dirs);
$link = "";
$navigation = "";
for ($i=1; $i<$numdirs; $i++) {
$navigation .= " -> ";
$link .= "/".urlencode($dirs[$i]);
$navigation .= "<a href=\"".$_SERVER['PHP_SELF']."?id=$course->id&wdir=$link\">".$dirs[$i]."</a>";
}
$fullnav = "<a href=\"".$_SERVER['PHP_SELF']."?id=$course->id&wdir=/\">$strfiles</a> $navigation";
}
print_header();
?>
<script language="javascript" type="text/javascript">
<!--
function set_value(txt) {
opener.document.forms['form'].initialcontent.value = txt;
window.close();
}
-->
</script>
<?php
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%">';
echo '<tr>';
echo '<td bgcolor="'.$THEME->cellheading.'" class="navbar">';
echo '<font size="2"><b>'."$course->shortname -> $fullnav".'</b></font>';
echo '</td>';
echo '</tr>';
echo '</table>';
if ($course->id == $site->id) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
echo "<table border=0 align=center cellspacing=3 cellpadding=3 width=640>";
echo "<tr>";
echo "<td colspan=\"2\">";
}
if (! $basedir = make_upload_directory("$course->id")) {
error("The site administrator needs to fix the file permissions");
}
$baseweb = $CFG->wwwroot;
// End of configuration and access control
$regexp="\\.\\.";
if (ereg( $regexp, $file, $regs )| ereg( $regexp, $wdir,$regs )) {
$message = "Error: Directories can not contain \"..\"";
$wdir = "/";
$action = "";
}
if (!$wdir) {
$wdir="/";
}
switch ($action) {
case "upload":
html_header($course, $wdir);
if (!empty($_FILES['userfile'])) {
$userfile = $_FILES['userfile'];
} else {
$save = false;
}
if (!empty($save)) {
if (!is_uploaded_file($userfile['tmp_name']) or $userfile['size'] == 0) {
notify(get_string("uploadnofilefound"));
} else {
$userfile_name = clean_filename($userfile['name']);
if ($userfile_name) {
$newfile = "$basedir$wdir/$userfile_name";
if (move_uploaded_file($userfile['tmp_name'], $newfile)) {
chmod($newfile, 0666);
$a = NULL;
$a->file = "$userfile_name (".$userfile['type'].")";
$a->directory = $wdir;
print_string("uploadedfileto", "", $a);
} else {
notify(get_string("uploadproblem", "", $userfile_name));
}
}
}
displaydir($wdir);
} else {
$upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
$filesize = display_size($upload_max_filesize);
$struploadafile = get_string("uploadafile");
$struploadthisfile = get_string("uploadthisfile");
$strmaxsize = get_string("maxsize", "", $filesize);
$strcancel = get_string("cancel");
echo "<P>$struploadafile ($strmaxsize) --> <B>$wdir</B>";
echo "<TABLE><TR><TD COLSPAN=2>";
echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"post\" ACTION=\"".$_SERVER['PHP_SELF']."\">";
echo " <INPUT TYPE=hidden NAME=MAX_FILE_SIZE value=\"$upload_max_filesize\">";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=upload>";
echo " <INPUT NAME=\"userfile\" TYPE=\"file\" size=\"60\">";
echo " </TD><TR><TD WIDTH=10>";
echo " <INPUT TYPE=submit NAME=save VALUE=\"$struploadthisfile\">";
echo "</FORM>";
echo "</TD><TD WIDTH=100%>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=\"get\">";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
echo " <INPUT TYPE=submit VALUE=\"$strcancel\">";
echo "</FORM>";
echo "</TD></TR></TABLE>";
}
html_footer();
break;
case "delete":
if (!empty($confirm)) {
html_header($course, $wdir);
foreach ($USER->filelist as $file) {
$fullfile = $basedir.$file;
if (! fulldelete($fullfile)) {
echo "<BR>Error: Could not delete: $fullfile";
}
}
clearfilelist();
displaydir($wdir);
html_footer();
} else {
html_header($course, $wdir);
if (setfilelist($_POST)) {
echo "<p align=center>".get_string("deletecheckwarning").":</p>";
print_simple_box_start("center");
printfilelist($USER->filelist);
print_simple_box_end();
echo "<br />";
notice_yesno (get_string("deletecheckfiles"),
"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=delete&confirm=1",
"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=cancel");
} else {
displaydir($wdir);
}
html_footer();
}
break;
case "move":
html_header($course, $wdir);
if ($count = setfilelist($_POST)) {
$USER->fileop = $action;
$USER->filesource = $wdir;
echo "<p align=center>";
print_string("selectednowmove", "moodle", $count);
echo "</p>";
}
displaydir($wdir);
html_footer();
break;
case "paste":
html_header($course, $wdir);
if (isset($USER->fileop) and $USER->fileop == "move") {
foreach ($USER->filelist as $file) {
$shortfile = basename($file);
$oldfile = $basedir.$file;
$newfile = $basedir.$wdir."/".$shortfile;
if (!rename($oldfile, $newfile)) {
echo "<P>Error: $shortfile not moved";
}
}
}
clearfilelist();
displaydir($wdir);
html_footer();
break;
case "rename":
if (!empty($name)) {
html_header($course, $wdir);
$name = clean_filename($name);
if (file_exists($basedir.$wdir."/".$name)) {
echo "Error: $name already exists!";
} else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) {
echo "Error: could not rename $oldname to $name";
}
displaydir($wdir);
} else {
$strrename = get_string("rename");
$strcancel = get_string("cancel");
$strrenamefileto = get_string("renamefileto", "moodle", $file);
html_header($course, $wdir, "form.name");
echo "<P>$strrenamefileto:";
echo "<TABLE><TR><TD>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=\"post\" NAME=\"form\">";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=rename>";
echo " <INPUT TYPE=hidden NAME=oldname VALUE=\"$file\">";
echo " <INPUT TYPE=text NAME=name SIZE=35 VALUE=\"$file\">";
echo " <INPUT TYPE=submit VALUE=\"$strrename\">";
echo "</FORM>";
echo "</TD><TD>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
echo " <INPUT TYPE=submit VALUE=\"$strcancel\">";
echo "</FORM>";
echo "</TD></TR></TABLE>";
}
html_footer();
break;
case "mkdir":
if (!empty($name)) {
html_header($course, $wdir);
$name = clean_filename($name);
if (file_exists("$basedir$wdir/$name")) {
echo "Error: $name already exists!";
} else if (! make_upload_directory("$course->id/$wdir/$name")) {
echo "Error: could not create $name";
}
displaydir($wdir);
} else {
$strcreate = get_string("create");
$strcancel = get_string("cancel");
$strcreatefolder = get_string("createfolder", "moodle", $wdir);
html_header($course, $wdir, "form.name");
echo "<P>$strcreatefolder:";
echo "<TABLE><TR><TD>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=post NAME=form>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=mkdir>";
echo " <INPUT TYPE=text NAME=name SIZE=35>";
echo " <INPUT TYPE=submit VALUE=\"$strcreate\">";
echo "</FORM>";
echo "</TD><TD>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
echo " <INPUT TYPE=submit VALUE=\"$strcancel\">";
echo "</FORM>";
echo "</TD></TR></TABLE>";
}
html_footer();
break;
case "edit":
html_header($course, $wdir);
if (isset($text)) {
$fileptr = fopen($basedir.$file,"w");
fputs($fileptr, stripslashes($text));
fclose($fileptr);
displaydir($wdir);
} else {
$streditfile = get_string("edit", "", "<B>$file</B>");
$fileptr = fopen($basedir.$file, "r");
$contents = fread($fileptr, filesize($basedir.$file));
fclose($fileptr);
if (mimeinfo("type", $file) == "text/html") {
if ($usehtmleditor = can_use_richtext_editor()) {
$onsubmit = "onsubmit=\"copyrichtext(document.form.text);\"";
} else {
$onsubmit = "";
}
} else {
$usehtmleditor = false;
$onsubmit = "";
}
print_heading("$streditfile");
echo "<TABLE><TR><TD COLSPAN=2>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=\"post\" NAME=\"form\" $onsubmit>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
echo " <INPUT TYPE=hidden NAME=file VALUE=\"$file\">";
echo " <INPUT TYPE=hidden NAME=action VALUE=edit>";
print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents);
echo "</TD></TR><TR><TD>";
echo " <INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\">";
echo "</FORM>";
echo "</TD><TD>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
echo " <INPUT TYPE=submit VALUE=\"".get_string("cancel")."\">";
echo "</FORM>";
echo "</TD></TR></TABLE>";
if ($usehtmleditor) {
print_richedit_javascript("form", "text", "yes");
}
}
html_footer();
break;
case "zip":
if (!empty($name)) {
html_header($course, $wdir);
$name = clean_filename($name);
if (empty($CFG->zip)) { // Use built-in php-based zip function
$files = array();
foreach ($USER->filelist as $file) {
$files[] = "$basedir/$file";
}
include_once($CFG->libdir.'/pclzip/pclzip.lib.php');
$archive = new PclZip("$basedir/$wdir/$name");
if (($list = $archive->create($files,'',"$basedir/$wdir/")) == 0) {
error($archive->errorInfo(true));
}
} else { // Use external zip program
$files = "";
foreach ($USER->filelist as $file) {
$files .= basename($file);
$files .= " ";
}
$command = "cd $basedir/$wdir ; $CFG->zip -r $name $files";
Exec($command);
}
clearfilelist();
displaydir($wdir);
} else {
html_header($course, $wdir, "form.name");
if (setfilelist($_POST)) {
echo "<P ALIGN=CENTER>".get_string("youareabouttocreatezip").":</P>";
print_simple_box_start("center");
printfilelist($USER->filelist);
print_simple_box_end();
echo "<BR>";
echo "<P ALIGN=CENTER>".get_string("whattocallzip");
echo "<TABLE><TR><TD>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=post NAME=form>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
echo " <INPUT TYPE=hidden NAME=action VALUE=zip>";
echo " <INPUT TYPE=text NAME=name SIZE=35 VALUE=\"new.zip\">";
echo " <INPUT TYPE=submit VALUE=\"".get_string("createziparchive")."\">";
echo "</FORM>";
echo "</TD><TD>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
echo " <INPUT TYPE=submit VALUE=\"".get_string("cancel")."\">";
echo "</FORM>";
echo "</TD></TR></TABLE>";
} else {
displaydir($wdir);
clearfilelist();
}
}
html_footer();
break;
case "unzip":
html_header($course, $wdir);
if (!empty($file)) {
$strname = get_string("name");
$strsize = get_string("size");
$strmodified = get_string("modified");
$strstatus = get_string("status");
$strok = get_string("ok");
$strunpacking = get_string("unpacking", "", $file);
echo "<P ALIGN=CENTER>$strunpacking:</P>";
$file = basename($file);
if (empty($CFG->unzip)) { // Use built-in php-based unzip function
include_once($CFG->libdir.'/pclzip/pclzip.lib.php');
$archive = new PclZip("$basedir/$wdir/$file");
if (!$list = $archive->extract("$basedir/$wdir")) {
error($archive->errorInfo(true));
} else { // print some output
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=640>";
echo "<tr><th align=left>$strname</th>";
echo "<th align=right>$strsize</th>";
echo "<th align=right>$strmodified</th>";
echo "<th align=right>$strstatus</th></tr>";
foreach ($list as $item) {
echo "<tr>";
$item['filename'] = str_replace("$basedir/$wdir/", "", $item['filename']);
print_cell("left", $item['filename']);
if (! $item['folder']) {
print_cell("right", display_size($item['size']));
} else {
echo "<td>&nbsp;</td>";
}
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
print_cell("right", $filedate);
print_cell("right", $item['status']);
echo "</tr>";
}
echo "</table>";
}
} else { // Use external unzip program
print_simple_box_start("center");
echo "<PRE>";
$command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
passthru($command);
echo "</PRE>";
print_simple_box_end();
}
echo "<CENTER><FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
echo " <INPUT TYPE=submit VALUE=\"$strok\">";
echo "</FORM>";
echo "</CENTER>";
} else {
displaydir($wdir);
}
html_footer();
break;
case "listzip":
html_header($course, $wdir);
if (!empty($file)) {
$strname = get_string("name");
$strsize = get_string("size");
$strmodified = get_string("modified");
$strok = get_string("ok");
$strlistfiles = get_string("listfiles", "", $file);
echo "<P ALIGN=CENTER>$strlistfiles:</P>";
$file = basename($file);
include_once($CFG->libdir.'/pclzip/pclzip.lib.php');
$archive = new PclZip("$basedir/$wdir/$file");
if (!$list = $archive->listContent("$basedir/$wdir")) {
notify($archive->errorInfo(true));
} else {
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=640>";
echo "<tr><th align=left>$strname</th><th align=right>$strsize</th><th align=right>$strmodified</th></tr>";
foreach ($list as $item) {
echo "<tr>";
print_cell("left", $item['filename']);
if (! $item['folder']) {
print_cell("right", display_size($item['size']));
} else {
echo "<td>&nbsp;</td>";
}
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
print_cell("right", $filedate);
echo "</tr>";
}
echo "</table>";
}
echo "<br><center><form action=\"".$_SERVER['PHP_SELF']."\" method=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
echo " <INPUT TYPE=submit VALUE=\"$strok\">";
echo "</FORM>";
echo "</CENTER>";
} else {
displaydir($wdir);
}
html_footer();
break;
case "torte":
if($_POST)
{
while(list($key, $val) = each($_POST))
{
if(ereg("file([0-9]+)", $key, $regs))
{
$file = $val;
}
}
if(@filetype($CFG->dataroot ."/". $course->id . $file) == "file")
{
if(mimeinfo("icon", $file) == "image.gif")
{
$url = $CFG->wwwroot ."/file.php?file=/" .$course->id . $file;
runjavascript($url);
}
else
{
print "File is not a image!";
}
}
else
{
print "You cannot insert FOLDER into richtext editor!!!";
}
}
break;
case "cancel";
clearfilelist();
default:
html_header($course, $wdir);
displaydir($wdir);
html_footer();
break;
}
/// FILE FUNCTIONS ///////////////////////////////////////////////////////////
function fulldelete($location) {
if (is_dir($location)) {
$currdir = opendir($location);
while ($file = readdir($currdir)) {
if ($file <> ".." && $file <> ".") {
$fullfile = $location."/".$file;
if (is_dir($fullfile)) {
if (!fulldelete($fullfile)) {
return false;
}
} else {
if (!unlink($fullfile)) {
return false;
}
}
}
}
closedir($currdir);
if (! rmdir($location)) {
return false;
}
} else {
if (!unlink($location)) {
return false;
}
}
return true;
}
function setfilelist($VARS) {
global $USER;
$USER->filelist = array ();
$USER->fileop = "";
$count = 0;
foreach ($VARS as $key => $val) {
if (substr($key,0,4) == "file") {
$count++;
$USER->filelist[] = rawurldecode($val);
}
}
return $count;
}
function clearfilelist() {
global $USER;
$USER->filelist = array ();
$USER->fileop = "";
}
function printfilelist($filelist) {
global $basedir, $CFG;
foreach ($filelist as $file) {
if (is_dir($basedir.$file)) {
echo "<img src=\"$CFG->pixpath/f/folder.gif\" height=16 width=16> $file<br>";
$subfilelist = array();
$currdir = opendir($basedir.$file);
while ($subfile = readdir($currdir)) {
if ($subfile <> ".." && $subfile <> ".") {
$subfilelist[] = $file."/".$subfile;
}
}
printfilelist($subfilelist);
} else {
$icon = mimeinfo("icon", $file);
echo "<img src=\"$CFG->pixpath/f/$icon\" height=16 width=16> $file<br>";
}
}
}
function print_cell($alignment="center", $text="&nbsp;") {
echo "<TD ALIGN=\"$alignment\" NOWRAP>";
echo "<FONT SIZE=\"-1\" FACE=\"Arial, Helvetica\">";
echo "$text";
echo "</FONT>";
echo "</TD>\n";
}
function displaydir ($wdir) {
// $wdir == / or /a or /a/b/c/d etc
global $basedir;
global $id;
global $USER, $CFG;
$fullpath = $basedir.$wdir;
$directory = opendir($fullpath); // Find all files
while ($file = readdir($directory)) {
if ($file == "." || $file == "..") {
continue;
}
if (is_dir($fullpath."/".$file)) {
$dirlist[] = $file;
} else {
$filelist[] = $file;
}
}
closedir($directory);
$strname = get_string("name");
$strsize = get_string("size");
$strmodified = get_string("modified");
$straction = get_string("action");
$strmakeafolder = get_string("makeafolder");
$struploadafile = get_string("uploadafile");
$strwithchosenfiles = get_string("withchosenfiles");
$strmovetoanotherfolder = get_string("movetoanotherfolder");
$strmovefilestohere = get_string("movefilestohere");
$strdeletecompletely = get_string("deletecompletely");
$strcreateziparchive = get_string("createziparchive");
$strrename = get_string("rename");
$stredit = get_string("edit");
$strunzip = get_string("unzip");
$strlist = get_string("list");
$strchoose = get_string("choose");
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=post NAME=dirform>";
echo "<TABLE BORDER=0 cellspacing=2 cellpadding=2 width=640>";
echo "<TR>";
echo "<TH WIDTH=5></TH>";
echo "<TH ALIGN=left>$strname</TH>";
echo "<TH ALIGN=right>$strsize</TH>";
echo "<TH ALIGN=right>$strmodified</TH>";
echo "<TH ALIGN=right>$straction</TH>";
echo "</TR>\n";
if ($wdir == "/") {
$wdir = "";
}
$count = 0;
if (!empty($dirlist)) {
asort($dirlist);
foreach ($dirlist as $dir) {
$count++;
$filename = $fullpath."/".$dir;
$fileurl = rawurlencode($wdir."/".$dir);
$filesafe = rawurlencode($dir);
$filedate = userdate(filectime($filename), "%d %b %Y, %I:%M %p");
echo "<TR>";
print_cell("center", "<INPUT TYPE=checkbox NAME=\"file$count\" VALUE=\"$fileurl\">");
print_cell("left", "<A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$fileurl\"><IMG SRC=\"$CFG->pixpath/f/folder.gif\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"Folder\"></A> <A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$fileurl\">".htmlspecialchars($dir)."</A>");
print_cell("right", "-");
print_cell("right", $filedate);
print_cell("right", "<A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</A>");
echo "</TR>";
}
}
if (!empty($filelist)) {
asort($filelist);
foreach ($filelist as $file) {
$icon = mimeinfo("icon", $file);
$count++;
$filename = "$fullpath/$file";
$fileurl = "$wdir/$file";
$filesafe = rawurlencode($file);
$fileurlsafe = rawurlencode($fileurl);
$filedate = userdate(filectime($filename), "%d %b %Y, %I:%M %p");
if (substr($fileurl,0,1) == '/') {
$selectfile = substr($fileurl,1);
} else {
$selectfile = $fileurl;
}
if ($CFG->slasharguments) {
$ffurl = "/file.php/$id$fileurl";
} else {
$ffurl = "/file.php?file=/$id$fileurl";
}
echo "<tr>";
print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\">");
echo "<td align=left nowrap>";
link_to_popup_window ($ffurl, "display",
"<img src=\"$CFG->pixpath/f/$icon\" height=16 width=16 border=0 alt=\"file\">",
480, 640);
echo "<font size=\"-1\" face=\"Arial, Helvetica\">";
link_to_popup_window ($ffurl, "display", htmlspecialchars($file), 480, 640);
echo "</font></td>";
$file_size = filesize($filename);
print_cell("right", display_size($file_size));
print_cell("right", $filedate);
$edittext = "<b><a onMouseDown=\"return set_value('$selectfile')\" href=\"\">$strchoose</a></b>&nbsp;";
if ($icon == "text.gif" || $icon == "html.gif") {
$edittext .= "<a href=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$fileurl&action=edit\">$stredit</a>";
} else if ($icon == "zip.gif") {
$edittext .= "<a href=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$fileurl&action=unzip\">$strunzip</a>&nbsp;";
$edittext .= "<a href=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$fileurl&action=listzip\">$strlist</a> ";
}
print_cell("right", "$edittext <A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</A>");
echo "</tr>";
}
}
echo "</table>";
echo "<hr width=640 align=center noshade size=1>";
if (empty($wdir)) {
$wdir = "/";
}
echo "<TABLE BORDER=0 cellspacing=2 cellpadding=2 width=640>";
echo "<TR><TD>";
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$id\">";
echo "<INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\"> ";
$options = array (
"move" => "$strmovetoanotherfolder",
"delete" => "$strdeletecompletely",
"zip" => "$strcreateziparchive"
);
if (!empty($count)) {
choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:document.dirform.submit()");
}
echo "</FORM>";
echo "<TD ALIGN=center>";
if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) {
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
echo " <INPUT TYPE=hidden NAME=action VALUE=paste>";
echo " <INPUT TYPE=submit VALUE=\"$strmovefilestohere\">";
echo "</FORM>";
}
echo "<TD ALIGN=right>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
echo " <INPUT TYPE=hidden NAME=action VALUE=mkdir>";
echo " <INPUT TYPE=submit VALUE=\"$strmakeafolder\">";
echo "</FORM>";
echo "</TD>";
echo "<TD ALIGN=right>";
echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
echo " <INPUT TYPE=hidden NAME=action VALUE=upload>";
echo " <INPUT TYPE=submit VALUE=\"$struploadafile\">";
echo "</FORM>";
echo "</TD></TR>";
echo "</TABLE>";
echo "<HR WIDTH=640 ALIGN=CENTER NOSHADE SIZE=1>";
}
?>