[phpwebapp-commits] CVS: web_app/session wbSession.php,1.6,1.7 class.Session.php,1.10,1.11 class.Req
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-22 16:26:21
|
Update of /cvsroot/phpwebapp/web_app/session In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9224/session Modified Files: wbSession.php class.Session.php class.Request.php class.Event.php Log Message: reformated and modified the copyleft notice Index: wbSession.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/wbSession.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wbSession.php 14 Jul 2004 14:45:41 -0000 1.6 --- wbSession.php 22 Jul 2004 16:25:36 -0000 1.7 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 28,56 **** { function onParse() ! { ! global $webPage; ! $session_url = WebApp::to_url(SESSION_PATH); ! $func_goto = ' <script type="text/javascript" language="javascript" ' ! . "src=\"${session_url}func.GoTo.js\"></script>\n"; ! $webPage->append_to_head($func_goto); ! } function onRender() ! { ! global $session, $event; ! //save dbVars in DB ! $session->saveDBVars(); ! //add the variable {{method}} ! $method = (DISPLAY_CGI_VARS ? "get" : "post"); ! WebApp::addVar("method", $method); ! WebApp::addVar("sourcePage", $event->targetPage); ! //add the template variable {{SESSION_VARS}} ! //which embeds the session into the page ! WebApp::addVar("SESSION_VARS", $session->to_JS()); ! } } ?> \ No newline at end of file --- 29,57 ---- { function onParse() ! { ! global $webPage; ! $session_url = WebApp::to_url(SESSION_PATH); ! $func_goto = ' <script type="text/javascript" language="javascript" ' ! . "src=\"${session_url}func.GoTo.js\"></script>\n"; ! $webPage->append_to_head($func_goto); ! } function onRender() ! { ! global $session, $event; ! //save dbVars in DB ! $session->saveDBVars(); ! //add the variable {{method}} ! $method = (DISPLAY_CGI_VARS ? "get" : "post"); ! WebApp::addVar("method", $method); ! WebApp::addVar("sourcePage", $event->targetPage); ! //add the template variable {{SESSION_VARS}} ! //which embeds the session into the page ! WebApp::addVar("SESSION_VARS", $session->to_JS()); ! } } ?> \ No newline at end of file Index: class.Session.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/class.Session.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** class.Session.php 15 Jul 2004 14:46:04 -0000 1.10 --- class.Session.php 22 Jul 2004 16:25:37 -0000 1.11 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 35,76 **** function Session() ! { ! global $request; ! $this->Vars = array(); ! $this->dbVars = array(); ! if ($request->firstTime) ! { ! //new session ! $this->init(); ! } ! else ! { ! $this->getVars($request->sessionVars); ! $this->getDBVars(); ! } ! $this->extractPhpVars($request->phpVars); ! } /** Initialize a new session. */ function init() ! { ! $ip = $_SERVER["REMOTE_ADDR"]; ! $sess_id = "IP: $ip; DATE: ".date("Y-m-d H:i:s"); ! $this->Vars["sess_id"] = $sess_id; ! if (USES_DB) //create a new record for the session ! { ! $this->create_table_session(); ! //insert a new record for this session ! $vars = serialize($this->dbVars); ! $db_cmd = "INSERT INTO session (id, vars) " ! . "VALUES ('$sess_id', '$vars')"; ! WebApp::execQuery($db_cmd); ! } ! } /** --- 36,77 ---- function Session() ! { ! global $request; ! $this->Vars = array(); ! $this->dbVars = array(); ! if ($request->firstTime) ! { ! //new session ! $this->init(); ! } ! else ! { ! $this->getVars($request->sessionVars); ! $this->getDBVars(); ! } ! $this->extractPhpVars($request->phpVars); ! } /** Initialize a new session. */ function init() ! { ! $ip = $_SERVER["REMOTE_ADDR"]; ! $sess_id = "IP: $ip; DATE: ".date("Y-m-d H:i:s"); ! $this->Vars["sess_id"] = $sess_id; ! if (USES_DB) //create a new record for the session ! { ! $this->create_table_session(); ! //insert a new record for this session ! $vars = serialize($this->dbVars); ! $db_cmd = "INSERT INTO session (id, vars) " ! . "VALUES ('$sess_id', '$vars')"; ! WebApp::execQuery($db_cmd); ! } ! } /** *************** *** 79,109 **** */ function create_table_session() ! { ! //get the name of the database ! $query = "SELECT DATABASE()"; ! $rs = WebApp::execQuery($query); ! $db_name = $rs->Field("DATABASE()"); ! //get a list of the tables in this database ! $query = "SHOW TABLES"; ! $rs = WebApp::execQuery($query); ! //search for the table 'session' ! $found = false; ! $table_name = "Tables_in_".$db_name; ! while (!$rs->EOF()) ! { ! $tab_name = $rs->Field($table_name); ! if ($tab_name=="session") ! { ! $found = true; ! break; ! } ! $rs->MoveNext(); ! } ! if ($found) return; //do nothing ! //not found, create the table 'session' ! $db_cmd = "CREATE TABLE session ( --- 80,110 ---- */ function create_table_session() ! { ! //get the name of the database ! $query = "SELECT DATABASE()"; ! $rs = WebApp::execQuery($query); ! $db_name = $rs->Field("DATABASE()"); ! //get a list of the tables in this database ! $query = "SHOW TABLES"; ! $rs = WebApp::execQuery($query); ! //search for the table 'session' ! $found = false; ! $table_name = "Tables_in_".$db_name; ! while (!$rs->EOF()) ! { ! $tab_name = $rs->Field($table_name); ! if ($tab_name=="session") ! { ! $found = true; ! break; ! } ! $rs->MoveNext(); ! } ! if ($found) return; //do nothing ! //not found, create the table 'session' ! $db_cmd = "CREATE TABLE session ( *************** *** 112,117 **** PRIMARY KEY (id) )"; ! WebApp::execQuery($db_cmd); ! } /** --- 113,118 ---- PRIMARY KEY (id) )"; ! WebApp::execQuery($db_cmd); ! } /** *************** *** 121,135 **** */ function str2arr($strVars) ! { ! $arrVars = array(); ! $arr = explode("&", $strVars); ! while (list($i,$strVar) = each($arr)) ! { ! if ($strVar=="") continue; ! list($var_name,$var_value) = split("=", $strVar, 2); ! $arrVars[$var_name] = $var_value; ! } ! return $arrVars; ! } /** --- 122,136 ---- */ function str2arr($strVars) ! { ! $arrVars = array(); ! $arr = explode("&", $strVars); ! while (list($i,$strVar) = each($arr)) ! { ! if ($strVar=="") continue; ! list($var_name,$var_value) = split("=", $strVar, 2); ! $arrVars[$var_name] = $var_value; ! } ! return $arrVars; ! } /** *************** *** 139,186 **** */ function getVars($sessVars) ! { ! $arrVars = $this->str2arr($sessVars); ! while (list($var_name,$var_value) = each($arrVars)) ! { ! $var_value = $this->js_decode($var_value); ! $this->addVar($var_name, $var_value); ! } ! } function js_decode($str) ! { ! $str = str_replace("\\\\", "\\", $str); ! $str = str_replace('\"', '"', $str); ! $str = str_replace("\'", "'", $str); ! $str = str_replace('\n', "\n", $str); ! return $str; ! } /** Replace some chars that are bad for JS code. */ function js_encode($str) ! { ! $str = str_replace("\\", "\\\\", $str); ! $str = str_replace("\n", '\n', $str); ! $str = str_replace("'", "\\'", $str); ! return $str; ! } /** Get dbVars from DB. Requires the table session(id,vars) in DB. */ function getDBVars() ! { ! if (USES_DB) ! { ! $id = $this->Vars["sess_id"]; ! $query = "SELECT vars FROM session WHERE id='$id'"; ! $rs = WebApp::execQuery($query); ! $vars = $rs->Field("vars"); ! $this->dbVars = unserialize($vars); ! if (!is_array($this->dbVars)) ! { ! //something went wrong ! $this->dbVars = array(); ! } ! } ! } /** --- 140,187 ---- */ function getVars($sessVars) ! { ! $arrVars = $this->str2arr($sessVars); ! while (list($var_name,$var_value) = each($arrVars)) ! { ! $var_value = $this->js_decode($var_value); ! $this->addVar($var_name, $var_value); ! } ! } function js_decode($str) ! { ! $str = str_replace("\\\\", "\\", $str); ! $str = str_replace('\"', '"', $str); ! $str = str_replace("\'", "'", $str); ! $str = str_replace('\n', "\n", $str); ! return $str; ! } /** Replace some chars that are bad for JS code. */ function js_encode($str) ! { ! $str = str_replace("\\", "\\\\", $str); ! $str = str_replace("\n", '\n', $str); ! $str = str_replace("'", "\\'", $str); ! return $str; ! } /** Get dbVars from DB. Requires the table session(id,vars) in DB. */ function getDBVars() ! { ! if (USES_DB) ! { ! $id = $this->Vars["sess_id"]; ! $query = "SELECT vars FROM session WHERE id='$id'"; ! $rs = WebApp::execQuery($query); ! $vars = $rs->Field("vars"); ! $this->dbVars = unserialize($vars); ! if (!is_array($this->dbVars)) ! { ! //something went wrong ! $this->dbVars = array(); ! } ! } ! } /** *************** *** 189,201 **** */ function extractPhpVars($phpVars) ! { ! $arrVars = $this->str2arr($phpVars); ! while (list($var_name,$var_value) = each($arrVars)) ! { ! //global PHP variable ! global $$var_name; ! $$var_name = $var_value; ! } ! } /** --- 190,202 ---- */ function extractPhpVars($phpVars) ! { ! $arrVars = $this->str2arr($phpVars); ! while (list($var_name,$var_value) = each($arrVars)) ! { ! //global PHP variable ! global $$var_name; ! $$var_name = $var_value; ! } ! } /** *************** *** 205,245 **** */ function addVar($var_name, $var_value, $db =false) ! { ! if ($db) //add DB var ! { ! if (isset($this->dbVars[$var_name])) ! { ! $msg ="Session::addVar(): DB var '$var_name' already exists."; ! print WebApp::warning_msg($msg); ! } ! if (isset($this->Vars[$var_name])) ! { ! $msg = "Session::addVar(): DB var '$var_name' shadows an existing JS var with the same name."; ! print WebApp::warning_msg($msg); ! } ! $this->dbVars[$var_name] = $var_value; ! } ! else //add JS var ! { ! if (isset($this->dbVars[$var_name])) ! { ! $msg = "Session::addVar(): JS var '$var_name' is shadowed by an existing DB var with the same name."; ! print WebApp::warning_msg($msg); ! } ! if (isset($this->Vars[$var_name])) ! { ! $msg = "Session::addVar(): JS var '$var_name' already exists."; ! print WebApp::warning_msg($msg); ! } ! $this->Vars[$var_name] = $var_value; ! } ! } /** Removes a variable from the session. */ function rmVar($var_name) ! { ! unset($this->Vars[$var_name]); ! unset($this->dbVars[$var_name]); ! } /** --- 206,246 ---- */ function addVar($var_name, $var_value, $db =false) ! { ! if ($db) //add DB var ! { ! if (isset($this->dbVars[$var_name])) ! { ! $msg ="Session::addVar(): DB var '$var_name' already exists."; ! print WebApp::warning_msg($msg); ! } ! if (isset($this->Vars[$var_name])) ! { ! $msg = "Session::addVar(): DB var '$var_name' shadows an existing JS var with the same name."; ! print WebApp::warning_msg($msg); ! } ! $this->dbVars[$var_name] = $var_value; ! } ! else //add JS var ! { ! if (isset($this->dbVars[$var_name])) ! { ! $msg = "Session::addVar(): JS var '$var_name' is shadowed by an existing DB var with the same name."; ! print WebApp::warning_msg($msg); ! } ! if (isset($this->Vars[$var_name])) ! { ! $msg = "Session::addVar(): JS var '$var_name' already exists."; ! print WebApp::warning_msg($msg); ! } ! $this->Vars[$var_name] = $var_value; ! } ! } /** Removes a variable from the session. */ function rmVar($var_name) ! { ! unset($this->Vars[$var_name]); ! unset($this->dbVars[$var_name]); ! } /** *************** *** 248,261 **** */ function setVar($var_name, $var_value) ! { ! if (isset($this->dbVars[$var_name])) ! { ! $this->dbVars[$var_name] = $var_value; ! } ! else ! { ! $this->Vars[$var_name] = $var_value; ! } ! } /** --- 249,262 ---- */ function setVar($var_name, $var_value) ! { ! if (isset($this->dbVars[$var_name])) ! { ! $this->dbVars[$var_name] = $var_value; ! } ! else ! { ! $this->Vars[$var_name] = $var_value; ! } ! } /** *************** *** 265,284 **** */ function getVar($var_name) ! { ! if (isset($this->dbVars[$var_name])) ! { ! $var_value = $this->dbVars[$var_name]; ! } ! else if (isset($this->Vars[$var_name])) ! { ! $var_value = $this->Vars[$var_name]; ! } ! else ! { ! $var_value = UNDEFINED; ! } ! return $var_value; ! } /** --- 266,285 ---- */ function getVar($var_name) ! { ! if (isset($this->dbVars[$var_name])) ! { ! $var_value = $this->dbVars[$var_name]; ! } ! else if (isset($this->Vars[$var_name])) ! { ! $var_value = $this->Vars[$var_name]; ! } ! else ! { ! $var_value = UNDEFINED; ! } ! return $var_value; ! } /** *************** *** 287,332 **** */ function to_JS() ! { ! $session_vars = '<script type="text/javascript" language="javascript">' ! . "\n//<![CDATA[\n" ! . " session = new Session();\n"; ! reset($this->Vars); ! //add each variable of the session ! while (list($var_name,$var_value) = each($this->Vars)) ! { ! $var_value = $this->js_encode($var_value); ! $session_vars .= " session.addVar('$var_name','$var_value');\n"; ! } ! $session_vars .= "//]]>\n" ! . "</script>"; ! return $session_vars; ! } /** Save dbVars in DB. */ function saveDBVars() ! { ! if (USES_DB) ! { ! $id = $this->Vars["sess_id"]; ! $vars = serialize($this->dbVars); ! $query = "UPDATE session SET vars='$vars' WHERE id='$id'"; ! WebApp::execQuery($query); ! } ! else ! { ! //no DB, no DB connection ! if (sizeof($this->dbVars) > 0) ! { ! //convert DB vars to JS vars ! $this->Vars = array_merge($this->Vars, $this->dbVars); ! $this->dbVars = array(); ! //give a warning ! print WebApp::warning_msg("session DB vars saved as JS vars," ! . " there is no DB connection, make 'true' the USES_DB " ! . " constant in 'config/const.Settings.php'."); ! } ! } ! } /** --- 288,333 ---- */ function to_JS() ! { ! $session_vars = '<script type="text/javascript" language="javascript">' ! . "\n//<![CDATA[\n" ! . " session = new Session();\n"; ! reset($this->Vars); ! //add each variable of the session ! while (list($var_name,$var_value) = each($this->Vars)) ! { ! $var_value = $this->js_encode($var_value); ! $session_vars .= " session.addVar('$var_name','$var_value');\n"; ! } ! $session_vars .= "//]]>\n" ! . "</script>"; ! return $session_vars; ! } /** Save dbVars in DB. */ function saveDBVars() ! { ! if (USES_DB) ! { ! $id = $this->Vars["sess_id"]; ! $vars = serialize($this->dbVars); ! $query = "UPDATE session SET vars='$vars' WHERE id='$id'"; ! WebApp::execQuery($query); ! } ! else ! { ! //no DB, no DB connection ! if (sizeof($this->dbVars) > 0) ! { ! //convert DB vars to JS vars ! $this->Vars = array_merge($this->Vars, $this->dbVars); ! $this->dbVars = array(); ! //give a warning ! print WebApp::warning_msg("session DB vars saved as JS vars," ! . " there is no DB connection, make 'true' the USES_DB " ! . " constant in 'config/const.Settings.php'."); ! } ! } ! } /** *************** *** 335,341 **** */ function to_HTML_table() ! { ! //build the table of vars ! $html = " <br /> <a name='session' id='session'> </a>[<a href='tree'>Top</a>] --- 336,342 ---- */ function to_HTML_table() ! { ! //build the table of vars ! $html = " <br /> <a name='session' id='session'> </a>[<a href='tree'>Top</a>] *************** *** 350,361 **** </tr>"; ! //add JS vars ! reset($this->Vars); ! while (list($var_name,$var_value) = each($this->Vars)) ! { ! //don't display the box state vars ! if (strpos($var_name, "->")===false) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'> </td> --- 351,362 ---- </tr>"; ! //add JS vars ! reset($this->Vars); ! while (list($var_name,$var_value) = each($this->Vars)) ! { ! //don't display the box state vars ! if (strpos($var_name, "->")===false) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'> </td> *************** *** 363,377 **** <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! } ! //add DB vars ! reset($this->dbVars); ! while (list($var_name,$var_value) = each($this->dbVars)) ! { ! //don't display the box state vars ! if (strpos($var_name, "->")===false) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'>DB</td> --- 364,378 ---- <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! } ! //add DB vars ! reset($this->dbVars); ! while (list($var_name,$var_value) = each($this->dbVars)) ! { ! //don't display the box state vars ! if (strpos($var_name, "->")===false) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'>DB</td> *************** *** 379,388 **** <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! } ! $html .= "</table>"; ! return $html; ! } } ?> \ No newline at end of file --- 380,389 ---- <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! } ! $html .= "</table>"; ! return $html; ! } } ?> \ No newline at end of file Index: class.Request.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/class.Request.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** class.Request.php 8 Sep 2003 13:18:23 -0000 1.6 --- class.Request.php 22 Jul 2004 16:25:37 -0000 1.7 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 37,55 **** function Request() ! { ! $browser_vars = (DISPLAY_CGI_VARS ? $_GET : $_POST); ! $this->sourcePage = ( isset($browser_vars["sourcePage"]) ? ! $browser_vars["sourcePage"] : UNDEFINED ); ! $this->targetPage = ( isset($browser_vars["targetPage"]) ? ! $browser_vars["targetPage"] : UNDEFINED ); ! $this->sessionVars = ( isset($browser_vars["sessionVars"]) ? ! $browser_vars["sessionVars"] : UNDEFINED ); ! $this->strEvent = ( isset($browser_vars["strEvent"]) ? ! $browser_vars["strEvent"] : UNDEFINED ); ! $this->phpVars = ( isset($browser_vars["phpVars"]) ? ! $browser_vars["phpVars"] : UNDEFINED ); ! $this->firstTime = ($this->targetPage==UNDEFINED ? true : false); ! } } ?> \ No newline at end of file --- 38,56 ---- function Request() ! { ! $browser_vars = (DISPLAY_CGI_VARS ? $_GET : $_POST); ! $this->sourcePage = ( isset($browser_vars["sourcePage"]) ? ! $browser_vars["sourcePage"] : UNDEFINED ); ! $this->targetPage = ( isset($browser_vars["targetPage"]) ? ! $browser_vars["targetPage"] : UNDEFINED ); ! $this->sessionVars = ( isset($browser_vars["sessionVars"]) ? ! $browser_vars["sessionVars"] : UNDEFINED ); ! $this->strEvent = ( isset($browser_vars["strEvent"]) ? ! $browser_vars["strEvent"] : UNDEFINED ); ! $this->phpVars = ( isset($browser_vars["phpVars"]) ? ! $browser_vars["phpVars"] : UNDEFINED ); ! $this->firstTime = ($this->targetPage==UNDEFINED ? true : false); ! } } ?> \ No newline at end of file Index: class.Event.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/class.Event.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.Event.php 25 Aug 2003 13:18:31 -0000 1.5 --- class.Event.php 22 Jul 2004 16:25:37 -0000 1.6 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 44,55 **** /** Constructs an event from an event string. */ function Event() ! { ! global $request; ! $this->sourcePage = $request->sourcePage; ! $this->targetPage = $request->targetPage; ! $this->parse($request->strEvent); ! } /** --- 45,56 ---- /** Constructs an event from an event string. */ function Event() ! { ! global $request; ! $this->sourcePage = $request->sourcePage; ! $this->targetPage = $request->targetPage; ! $this->parse($request->strEvent); ! } /** *************** *** 58,113 **** */ function parse($strEvent) ! { ! if ($strEvent==UNDEFINED) $strEvent = ""; ! list($x, $event_str) = split("=", $strEvent, 2); ! //extract event name and event args from $event_str ! $args_pos = strpos($event_str, "("); ! if ($args_pos) ! { ! $event_name = substr($event_str, 0, $args_pos); ! $event_args = substr($event_str, $args_pos); ! } ! else ! { ! $event_name = $event_str; ! $event_args = ""; ! } ! //extract event target and event name from $event_name ! $dot_pos = strpos($event_name, "."); ! if ($dot_pos) ! { ! $this->target = substr($event_name, 0, $dot_pos); ! $this->name = substr($event_name, $dot_pos+1); ! } ! else ! { ! $this->target = UNDEFINED; ! $this->name = $event_name; ! } ! //put the arguments in $this->args ! $this->args = array(); ! if ($event_args<>"") ! { ! //strip off parantheses ! $event_args = substr($event_args, 1, strlen($event_args)-2); ! $args = explode(";", $event_args); ! while (list($i,$arg) = each($args)) ! { ! if ($arg=="") continue; ! list($arg_name,$arg_value) = split("=", $arg, 2); ! $arg_value = $this->decode_arg_value($arg_value); ! $this->args[$arg_name] = $arg_value; ! } ! } ! } function decode_arg_value($str) ! { ! $str = str_replace('#semicolumn#', ';', $str); ! return $str; ! } /** --- 59,114 ---- */ function parse($strEvent) ! { ! if ($strEvent==UNDEFINED) $strEvent = ""; ! list($x, $event_str) = split("=", $strEvent, 2); ! //extract event name and event args from $event_str ! $args_pos = strpos($event_str, "("); ! if ($args_pos) ! { ! $event_name = substr($event_str, 0, $args_pos); ! $event_args = substr($event_str, $args_pos); ! } ! else ! { ! $event_name = $event_str; ! $event_args = ""; ! } ! //extract event target and event name from $event_name ! $dot_pos = strpos($event_name, "."); ! if ($dot_pos) ! { ! $this->target = substr($event_name, 0, $dot_pos); ! $this->name = substr($event_name, $dot_pos+1); ! } ! else ! { ! $this->target = UNDEFINED; ! $this->name = $event_name; ! } ! //put the arguments in $this->args ! $this->args = array(); ! if ($event_args<>"") ! { ! //strip off parantheses ! $event_args = substr($event_args, 1, strlen($event_args)-2); ! $args = explode(";", $event_args); ! while (list($i,$arg) = each($args)) ! { ! if ($arg=="") continue; ! list($arg_name,$arg_value) = split("=", $arg, 2); ! $arg_value = $this->decode_arg_value($arg_value); ! $this->args[$arg_name] = $arg_value; ! } ! } ! } function decode_arg_value($str) ! { ! $str = str_replace('#semicolumn#', ';', $str); ! return $str; ! } /** *************** *** 116,139 **** */ function getArgs() ! { ! while ( list($arg_name,$arg_value) = each($this->args) ) ! { ! $arg_values[] = $arg_value; ! } ! return $arg_values; ! } /** Prints out the event (for debug). */ function to_text() ! { ! print "Name: $this->name\n"; ! print "Target: $this->target\n"; ! print "Args: "; ! while (list($arg_name,$arg_value) = each($this->args)) ! { ! print "$arg_name=$arg_value;"; ! } ! print "\n\n"; ! } } ?> \ No newline at end of file --- 117,140 ---- */ function getArgs() ! { ! while ( list($arg_name,$arg_value) = each($this->args) ) ! { ! $arg_values[] = $arg_value; ! } ! return $arg_values; ! } /** Prints out the event (for debug). */ function to_text() ! { ! print "Name: $this->name\n"; ! print "Target: $this->target\n"; ! print "Args: "; ! while (list($arg_name,$arg_value) = each($this->args)) ! { ! print "$arg_name=$arg_value;"; ! } ! print "\n\n"; ! } } ?> \ No newline at end of file |