Update of /cvsroot/phpwebapp/web_app
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25213
Modified Files:
class.WebApp.php
Log Message:
Index: class.WebApp.php
===================================================================
RCS file: /cvsroot/phpwebapp/web_app/class.WebApp.php,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** class.WebApp.php 24 Jun 2005 14:50:35 -0000 1.25
--- class.WebApp.php 30 Jun 2005 06:24:43 -0000 1.26
***************
*** 589,592 ****
--- 589,622 ----
/**
+ * When a string is inserted inside a JS code,
+ * enclosed in single quotes, like this: 'str',
+ * some characters inside the string must be replaced
+ * by some others, in order not to break the JS code.
+ * These replacements are: '\' to '\\', '\n\' is added
+ * before a new line, and single quotes are escaped
+ * by a slash.
+ */
+ function js_encode($str)
+ {
+ $str = str_replace("\\", "\\\\", $str);
+ $str = str_replace("\n", "\\n\\\n", $str);
+ $str = str_replace("'", "\\'", $str);
+ return $str;
+ }
+
+ /**
+ * Decodes a string that comes to PHP from JS code.
+ * Used in session to convert variable values.
+ */
+ function js_decode($str)
+ {
+ $str = str_replace("\\\\", "\\", $str);
+ $str = str_replace('\"', '"', $str);
+ $str = str_replace("\'", "'", $str);
+ $str = str_replace('\n', "\n", $str);
+ return $str;
+ }
+
+ /**
* Construct and return a link that can be used to access
* from outside a certain page of the application, in a certain
|