cvs: php-gtk-web /wiki index.php

[email protected] ("Steph Fox")
Newsgroups php.gtk.webmaster
Message-ID <cvssfox1136866874@cvsserver>
sfox		Tue Jan 10 04:21:14 2006 UTC

  Modified files:              
    /php-gtk-web/wiki	index.php 
  Log:
  See if a bit of defensive javascript helps us any (ok, so there were two chances when it came to file name...)
  
http://cvs.php.net/viewcvs.cgi/php-gtk-web/wiki/index.php?r1=1.3&r2=1.4&diff_format=u
Index: php-gtk-web/wiki/index.php
diff -u php-gtk-web/wiki/index.php:1.3 php-gtk-web/wiki/index.php:1.4
--- php-gtk-web/wiki/index.php:1.3	Mon Nov 21 01:12:05 2005
+++ php-gtk-web/wiki/index.php	Tue Jan 10 04:21:14 2006
@@ -19,6 +19,44 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+?>
+
+<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
+<!--
+function check_post() {
+
+	var namevalue = document.editform.author.value;
+	var textvalue = document.editform.text.value;
+	var uc = /[A-Z]/;
+	var i, x = 0;
+
+	/* 'Describe ' opens an unedited page. Nobody should be leaving that in
+		place if they're performing a genuine page edit... */
+	if (textvalue.substr(0, 9) == 'Describe ') {
+		window.alert('No editing appears to have taken place');
+		return false;
+	}
+	/* Randomly generated names are more likely to end in a capital letter */
+	if (uc.test(namevalue.substring(namevalue.length - 1))) {
+		return window.confirm('Please confirm that the name given is valid');
+	}
+
+	/* Randomly generated names often exceed genuine use of capitalization */
+	for (i = 0; i < namevalue.length; i++) {
+		if (uc.test(namevalue.substring(i))) {
+			x++;
+			if (x > 3) {
+				return window.confirm('Please confirm that the name given is valid');
+			}
+		}
+	}
+
+	return true;
+}
+//-->
+</SCRIPT>
+
+<?php
 if (ini_get('register_globals')) {
   foreach($_REQUEST as $k=>$v) { unset(${$k}); }
 }
@@ -52,7 +90,7 @@
 $PageEditFmt=array("
   <div id='wikiedit'>
   <a id='top' name='top'></a><h1 class='wikiaction'>$[Editing \$PageName]</h1>
-  <form action='\$PageUrl' method='post'>
+  <form name = 'editform' action='\$PageUrl' onSubmit = 'return check_post();' method='post'>
   <input type='hidden' name='pagename' value='\$PageName' />
   <input type='hidden' name='action' value='edit' />
   \$EditMessageFmt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.