From 4f29d25ad1ef2b47c5372472edab4882b8ffd34d Mon Sep 17 00:00:00 2001 From: rurban Date: Thu, 3 Jun 2004 18:06:29 +0000 Subject: [PATCH] fix file locking issues (only needed on write) fixed immediate LANG and THEME in-session updates if not stored in prefs advanced editpage toolbars (search & replace broken) git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3601 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/WikiGroup.php | 7 ++- lib/WikiUserNew.php | 9 ++-- lib/XmlParser.php | 9 +++- lib/editpage.php | 113 +++++++++++++++++++++++++-------------- lib/pear/File_Passwd.php | 4 +- 5 files changed, 92 insertions(+), 50 deletions(-) diff --git a/lib/WikiGroup.php b/lib/WikiGroup.php index bfc7ab9df..dc59dd725 100644 --- a/lib/WikiGroup.php +++ b/lib/WikiGroup.php @@ -1,5 +1,5 @@ _file = new File_Passwd(AUTH_GROUP_FILE,true); + $this->_file = new File_Passwd(AUTH_GROUP_FILE,false,AUTH_GROUP_FILE.".lock"); } /** @@ -1014,6 +1014,9 @@ class GroupLdap extends WikiGroup { } // $Log: not supported by cvs2svn $ +// Revision 1.30 2004/06/03 09:39:51 rurban +// fix LDAP injection (wildcard in username) detected by Steve Christey, MITRE +// // Revision 1.29 2004/05/16 22:07:35 rurban // check more config-default and predefined constants // various PagePerm fixes: diff --git a/lib/WikiUserNew.php b/lib/WikiUserNew.php index b52c1f28a..d9ec2250f 100644 --- a/lib/WikiUserNew.php +++ b/lib/WikiUserNew.php @@ -1,5 +1,5 @@ _file) or !isa($this->_file,"File_Passwd")) - $this->_file = new File_Passwd($file, false); + $this->_file = new File_Passwd($file, false, $file.'.lock'); else return false; return $this; @@ -2920,11 +2920,14 @@ extends UserPreferences // $Log: not supported by cvs2svn $ +// Revision 1.85 2004/06/03 12:46:03 rurban +// fix signout, level must be 0 not -1 +// // Revision 1.84 2004/06/03 12:36:03 rurban // fix eval warning on signin // // Revision 1.83 2004/06/03 10:18:19 rurban -// fix FileUser locking issues, new config ENABLE_PAGEPERM +// fix User locking issues, new config ENABLE_PAGEPERM // // Revision 1.82 2004/06/03 09:39:51 rurban // fix LDAP injection (wildcard in username) detected by Steve Christey, MITRE diff --git a/lib/XmlParser.php b/lib/XmlParser.php index be11e1d1d..875c60dca 100644 --- a/lib/XmlParser.php +++ b/lib/XmlParser.php @@ -1,5 +1,5 @@ _parser = xml_parser_create($encoding); else $this->_parser = xml_parser_create(); - xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $GLOBALS[$charset]); + xml_parser_set_option($this->_parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['charset']); //xml_set_object($this->_parser, &$this); xml_set_element_handler($this->_parser, array(&$this, 'tag_open'), @@ -163,6 +163,11 @@ class XmlParser { } // $Log: not supported by cvs2svn $ +// Revision 1.2 2004/06/01 15:28:00 rurban +// AdminUser only ADMIN_USER not member of Administrators +// some RateIt improvements by dfrankow +// edit_toolbar buttons +// // Revision 1.1 2004/05/24 17:31:31 rurban // new XmlParser and HtmlParser, RssParser based on that. // diff --git a/lib/editpage.php b/lib/editpage.php index e3e9eb14f..65fefcc5f 100644 --- a/lib/editpage.php +++ b/lib/editpage.php @@ -1,5 +1,5 @@ getPreview(); // FIXME: convert to _MESSAGE? // FIXME: NOT_CURRENT_MESSAGE? - $tokens = array_merge($tokens, $this->getFormElements()); - // TODO: add this to the EDIT_TOOLBAR + //FIXME: enable Undo button for all other buttons also, not only the search/replace button if (defined('JS_SEARCHREPLACE') and JS_SEARCHREPLACE) { $tokens['JS_SEARCHREPLACE'] = 1; + $undo_btn = $GLOBALS['Theme']->getImageURL("ed_undo.gif"); + $undo_d_btn = $GLOBALS['Theme']->getImageURL("ed_undo_d.gif"); + // JS_SEARCHREPLACE from walterzorn.de $GLOBALS['Theme']->addMoreHeaders(Javascript(" -var wart=0, d, f, x='', replacewin, pretxt=new Array(), pretxt_anzahl=0; -var fag='', fr='', spn=''; +var f, sr_undo, replacewin, undo_buffer=new Array(), undo_buffer_index=0; function define_f() { f=document.getElementById('editpage'); f.editarea=document.getElementById('edit[content]'); - if(f.rck.style) f.rck.style.color='#ececec'; + sr_undo=document.getElementById('sr_undo'); + undo_enable(false); f.editarea.focus(); } +function undo_enable(bool) { + if (bool) { + sr_undo.src='".$undo_btn."'; + sr_undo.alt='" +._("Undo") +."'; + sr_undo.disabled = false; + } else { + sr_undo.src='".$undo_d_btn."'; + sr_undo.alt='" +._("Undo disabled") +."'; + sr_undo.disabled = true; + if(sr_undo.blur) sr_undo.blur(); + } +} function replace() { replacewin=window.open('','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,height=90,width=450'); - replacewin.window.document.write('"._("Search & Replace")."
'+fag+'"._("Search").":
'+fag+' "._("Replace with").":
   
'); + replacewin.window.document.write('" +._("Search & Replace") +."
'+'" +._("Search") +.":
'+' " +._("Replace with") +.":
   
'); replacewin.window.document.close(); } function do_replace() { - var txt=pretxt[pretxt_anzahl]=f.editarea.value, ein=new RegExp(replacewin.document.forms[0].ein.value,'g'), aus=replacewin.document.forms[0].aus.value; + var txt=undo_buffer[undo_buffer_index]=f.editarea.value, ein=new RegExp(replacewin.document.forms[0].ein.value,'g'), aus=replacewin.document.forms[0].aus.value; if(ein==''||ein==null) { replacewin.window.document.forms[0].ein.focus(); return; @@ -154,38 +182,31 @@ function do_replace() { replacewin.window.document.forms[0].ein.focus(); } function result(zahl,frage,txt,alert_txt) { - if(wart!=0&&wart.window) { - wart.window.close(); - wart=0; - } if(zahl>0) { if(window.confirm(frage)==true) { f.editarea.value=txt; - pretxt_anzahl++; - if(f.rck.style) f.rck.style.color='#000000'; - f.rck.value='"._("Undo")."'; + undo_buffer_index++; + undo_enable(true); } } else alert(alert_txt); } -function rueck() { - if(pretxt_anzahl==0) return; - else if(pretxt_anzahl>0) { - f.editarea.value=pretxt[pretxt_anzahl-1]; - pretxt[pretxt_anzahl]=null; - pretxt_anzahl--; - if(pretxt_anzahl==0) { +function do_undo() { + if(undo_buffer_index==0) return; + else if(undo_buffer_index>0) { + f.editarea.value=undo_buffer[undo_buffer_index-1]; + undo_buffer[undo_buffer_index]=null; + undo_buffer_index--; + if(undo_buffer_index==0) { alert('Operation undone.'); - if(f.rck.style) f.rck.style.color='#ececec'; - f.rck.value='("._("Undo").")'; - if(f.rck.blur) f.rck.blur(); + undo_enable(false); } } } +//save a snapshot in the undo buffer (unused) function speich() { - pretxt[pretxt_anzahl]=f.editarea.value; - pretxt_anzahl++; - if(f.rck.style) f.rck.style.color='#000000'; - f.rck.value='"._("Undo")."'; + undo_buffer[undo_buffer_index]=f.editarea.value; + undo_buffer_index++; + undo_enable(true); } ")); $GLOBALS['Theme']->addMoreAttr('body'," onload='define_f()'"); @@ -254,10 +275,10 @@ function speich() { ); $toolbar = "document.writeln(\"
\");\n"; - $btn = new SubmitImageButton(_("Save"), "edit[save]", '', $Theme->getImageURL("ed_save.gif")); + $btn = new SubmitImageButton(_("Save"), "edit[save]", 'toolbar', $Theme->getImageURL("ed_save.gif")); $btn->addTooltip(_("Save")); $toolbar.='document.writeln("'.addslashes($btn->asXml()).'");'."\n"; - $btn = new SubmitImageButton(_("Preview"), "edit[preview]", '', $Theme->getImageURL("ed_preview.gif")); + $btn = new SubmitImageButton(_("Preview"), "edit[preview]", 'toolbar', $Theme->getImageURL("ed_preview.gif")); $btn->addTooltip(_("Preview")); $toolbar.='document.writeln("'.addslashes($btn->asXml()).'");'."\n"; @@ -275,14 +296,19 @@ function speich() { } $toolbar.="addInfobox('" . addslashes( _("Click a button to get an example text") ) . "');\n"; if (defined('JS_SEARCHREPLACE') and JS_SEARCHREPLACE) { - $undo_btn = $Theme->getImageURL("ed_undo.gif"); - $redo_btn = $Theme->getImageURL("ed_redo.gif"); + //$undo_btn = $GLOBALS['Theme']->getImageURL("ed_undo.gif"); + $undo_d_btn = $GLOBALS['Theme']->getImageURL("ed_undo_d.gif"); + //$redo_btn = $Theme->getImageURL("ed_redo.gif"); $sr_btn = $Theme->getImageURL("ed_replace.gif"); - $sr_js = '' - . '' - . ''; + $sr_js = '' + // . '' + . ''; $toolbar.='document.writeln("'.addslashes($sr_js).'");'."\n"; } + // More: + // Button to generate pagenames, display in extra window as pulldown and insert + // Button to generate plugins, display in extra window as pulldown and insert + // Button to generate categories, display in extra window as pulldown and insert $toolbar.="document.writeln(\"
\");"; return Javascript($toolbar); } @@ -504,14 +530,19 @@ function speich() { $this->_wikicontent = $this->_content; $this->_content = $html->asXML(); } + + /**