phplib-commit Mailing List for PHPLIB (Page 3)
Brought to you by:
nhruby,
richardarcher
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(76) |
Sep
(7) |
Oct
(2) |
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(7) |
Feb
(7) |
Mar
(14) |
Apr
(27) |
May
(2) |
Jun
(2) |
Jul
(5) |
Aug
(6) |
Sep
(1) |
Oct
(9) |
Nov
(4) |
Dec
|
| 2003 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2005 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
(1) |
Apr
(3) |
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
(6) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Layne W. <lay...@us...> - 2002-08-07 19:34:02
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv25099/php
Modified Files:
db_mysql.inc
Log Message:
Fixed [ #542808 ] nextid()'s lock() in db_mysql.inc
Fixed [ #542811 ] nextid() uses mysql_query
In layout_html.inc removed an overlooked calltime pass by reference;
all other calls to defval() were correct
Index: db_mysql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_mysql.inc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** db_mysql.inc 25 Apr 2002 07:36:56 -0000 1.10
--- db_mysql.inc 7 Aug 2002 19:33:57 -0000 1.11
***************
*** 245,292 ****
/* public: sequence numbers */
function nextid($seq_name) {
! $this->connect();
!
! if ($this->lock($this->Seq_Table)) {
! /* get sequence number (locked) and increment */
! $q = sprintf("select nextid from %s where seq_name = '%s'",
! $this->Seq_Table,
! $seq_name);
! $id = @mysql_query($q, $this->Link_ID);
! if (!$id) {
! $this->halt('query failed in nextid: '.$q);
return 0;
}
! $res = @mysql_fetch_array($id);
!
! /* No current value, make one */
! if (!is_array($res)) {
! $currentid = 0;
! $q = sprintf("insert into %s values('%s', %s)",
$this->Seq_Table,
$seq_name,
$currentid);
! $id = @mysql_query($q, $this->Link_ID);
! if (!$id) {
! $this->halt('query failed in nextid: '.$q);
! return 0;
! }
! } else {
! $currentid = $res["nextid"];
! }
! $nextid = $currentid + 1;
! $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
! $this->Seq_Table,
! $nextid,
! $seq_name);
! $id = @mysql_query($q, $this->Link_ID);
! if (!$id) {
$this->halt('query failed in nextid: '.$q);
return 0;
}
- $this->unlock();
} else {
! $this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
return 0;
}
return $nextid;
}
--- 245,296 ----
/* public: sequence numbers */
function nextid($seq_name) {
! /* if no current lock, lock sequence table */
! if(!$this->locked) {
! if($this->lock($this->Seq_Table)) {
! $locked = true;
! } else {
! $this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
return 0;
}
! }
!
! /* get sequence number and increment */
! $q = sprintf("select nextid from %s where seq_name = '%s'",
! $this->Seq_Table,
! $seq_name);
! if(!$this->query($q)) {
! $this->halt('query failed in nextid: '.$q);
! return 0;
! }
!
! /* No current value, make one */
! if(!$this->next_record()) {
! $currentid = 0;
! $q = sprintf("insert into %s values('%s', %s)",
$this->Seq_Table,
$seq_name,
$currentid);
! if(!$this->query($q)) {
$this->halt('query failed in nextid: '.$q);
return 0;
}
} else {
! $currentid = $this->f("nextid");
! }
! $nextid = $currentid + 1;
! $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
! $this->Seq_Table,
! $nextid,
! $seq_name);
! if(!$this->query($q)) {
! $this->halt('query failed in nextid: '.$q);
return 0;
}
+
+ /* if nextid() locked the sequence table, unlock it */
+ if($locked) {
+ $this->unlock();
+ }
+
return $nextid;
}
|
|
From: Layne W. <lay...@us...> - 2002-08-07 19:31:37
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv23671/php
Modified Files:
layout_html.inc
Log Message:
Fixed [ #542808 ] nextid()'s lock() in db_mysql.inc
Fixed [ #542811 ] nextid() uses mysql_query
In layout_html.inc removed an overlooked calltime pass by reference;
all other calls to defval() were correct
Index: layout_html.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/layout_html.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** layout_html.inc 19 Mar 2002 22:32:25 -0000 1.3
--- layout_html.inc 7 Aug 2002 19:31:33 -0000 1.4
***************
*** 662,666 ****
$this->defval($BORDER, $this->picture_def['BORDER']);
$this->defval($ALIGN, $this->picture_def['ALIGN']);
! $this->defval(&$HVSPACE, $this->picture_def['HVSPACE']);
$this->defval($ALT, $this->picture_def['ALT']);
--- 662,666 ----
$this->defval($BORDER, $this->picture_def['BORDER']);
$this->defval($ALIGN, $this->picture_def['ALIGN']);
! $this->defval($HVSPACE, $this->picture_def['HVSPACE']);
$this->defval($ALT, $this->picture_def['ALT']);
|
|
From: Layne W. <lay...@us...> - 2002-08-07 19:31:37
|
Update of /cvsroot/phplib/php-lib-stable
In directory usw-pr-cvs1:/tmp/cvs-serv23671
Modified Files:
CHANGES
Log Message:
Fixed [ #542808 ] nextid()'s lock() in db_mysql.inc
Fixed [ #542811 ] nextid() uses mysql_query
In layout_html.inc removed an overlooked calltime pass by reference;
all other calls to defval() were correct
Index: CHANGES
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/CHANGES,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** CHANGES 3 Jun 2002 04:39:02 -0000 1.19
--- CHANGES 7 Aug 2002 19:31:33 -0000 1.20
***************
*** 1,4 ****
--- 1,10 ----
$Id$
+ 07-Aug-2002 layne_weathers
+ - Fixed [ #542808 ] nextid()'s lock() in db_mysql.inc
+ - Fixed [ #542811 ] nextid() uses mysql_query
+ - in layout_html.inc removed an overlooked calltime pass by reference;
+ all other calls to defval() were correct
+
03-June-2002 Giancarlo Pinerolo
- session.inc fallback_mode only applies when cookies are disabled.
***************
*** 8,12 ****
- session.inc now has the block_alien_sid = true/false switch. It
blocks the creation of a new session by a sid provided by the user.
-
03-Apr-2002 layne_weathers
--- 14,17 ----
|
|
From: Richard A. <ric...@us...> - 2002-07-11 23:47:25
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv25628
Modified Files:
db_odbc.inc
Log Message:
Merging in major changes from -devel tree.
These changes are extensive and only minimally tested.
They are intended to be mostly back-compatible, but there are probably some issues.
Some specifics:
Brings the style up to date with the MySQL class.
Fixes numerous bugs, especially in num_rows.
Add pseudo-locking and sequence numbers.
Pulled db-specific constants out into class vars.
Extended metadata function in line with -devel classes.
Normalised error message reporting.
Probably lots of other stuff.
Index: db_odbc.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_odbc.inc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** db_odbc.inc 14 Mar 2002 20:41:07 -0000 1.4
--- db_odbc.inc 11 Jul 2002 23:47:21 -0000 1.5
***************
*** 10,29 ****
class DB_Sql {
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
- var $UseODBCCursor = 0;
! var $Link_ID = 0;
! var $Query_ID = 0;
var $Record = array();
var $Row = 0;
!
var $Errno = 0;
var $Error = "";
! var $Auto_Free = 0; ## set this to 1 to automatically free results
! var $PConnect = 0; ## Set to 1 to use persistent database connections
/* public: constructor */
--- 10,52 ----
class DB_Sql {
+
+ /* public: connection parameters */
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
! /* public: configuration parameters */
! var $Auto_Free = 0; ## Set to 1 to automatically free results
! var $PConnect = 0; ## Set to 1 to use persistent database connections
! var $Debug = 0; ## Set to 1 for debugging messages
! var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
! var $Seq_Table = "db_sequence"; ## Name of the sequence table
! var $Seq_ID_Col = "p_nextid"; ## Name of the Sequence ID column in $Seq_Table
! var $Seq_Name_Col = "p_seq_name"; ## Name of the Sequence Name column in $Seq_Table
! var $Lock_Table = "db_sequence"; ## Name of the lock table
! var $Lock_Name_Col = "p_seq_name"; ## Name of the lock Name column
! var $Lock_ID_Col = "p_nextid"; ## Name of the lock Name column
! var $Lock_Timeout = 5; ## Wait this long for a lock
! var $Lock_Override = 1; ## Set to 1 to override lock after $Lock_Timeout seconds
! var $UseODBCCursor = 0; ## Set to 1 to enable execution of stored procedures on the server
!
! /* public: result array and current row number */
var $Record = array();
var $Row = 0;
! var $RowCount = -1; ## used to remember num_rows() return value
!
! /* public: current error number and error text */
var $Errno = 0;
var $Error = "";
! /* public: this is an api revision, not a CVS revision. */
! var $type = "odbc";
! var $revision = "1.2";
!
! /* private: link and query handles */
! var $Link_ID = 0;
! var $Query_ID = 0;
!
/* public: constructor */
***************
*** 32,36 ****
}
! function connect() {
if ( 0 == $this->Link_ID ) {
if(!$this->PConnect) {
--- 55,80 ----
}
! /* public: some trivial reporting */
! function link_id() {
! return $this->Link_ID;
! }
!
! function query_id() {
! return $this->Query_ID;
! }
!
! /* public: connection management */
! function connect($Database = "", $Host = "", $User = "", $Password = "") {
! /* Handle defaults */
! if ("" == $Database)
! $Database = $this->Database;
! if ("" == $Host)
! $Host = $this->Host;
! if ("" == $User)
! $User = $this->User;
! if ("" == $Password)
! $Password = $this->Password;
!
! /* establish connection, select database */
if ( 0 == $this->Link_ID ) {
if(!$this->PConnect) {
***************
*** 43,50 ****
}
}
}
-
- function query($Query_String) {
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
--- 87,102 ----
}
}
+
+ return $this->Link_ID;
}
+ /* public: discard the query result */
+ function free() {
+ odbc_free_result($this->Query_ID);
+ $this->Query_ID = 0;
+ }
+
+ /* public: perform a query */
+ function query($Query_String) {
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
***************
*** 55,61 ****
return 0;
! $this->connect();
!
! # printf("<br>Debug: query = %s<br>\n", $Query_String);
# re...@ne... suggested that we use this instead of the odbc_exec().
--- 107,121 ----
return 0;
! if (!$this->connect()) {
! return 0; /* we already complained in connect() about that. */
! };
!
! # New query, discard previous result.
! if ($this->Query_ID) {
! $this->free();
! }
!
! if ($this->Debug)
! printf("Debug: query = %s<br>\n", $Query_String);
# re...@ne... suggested that we use this instead of the odbc_exec().
***************
*** 64,136 ****
# $this->Query_Ok = odbc_execute($this->Query_ID);
! $this->Query_ID = odbc_exec($this->Link_ID,$Query_String);
! $this->Row = 0;
odbc_binmode($this->Query_ID, 1);
odbc_longreadlen($this->Query_ID, 4096);
if (!$this->Query_ID) {
- $this->Errno = 1;
- $this->Error = "General Error (The ODBC interface cannot return detailed error messages).";
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
!
function next_record() {
$this->Record = array();
! $stat = odbc_fetch_into($this->Query_ID, ++$this->Row, &$this->Record);
if (!$stat) {
if ($this->Auto_Free) {
! odbc_free_result($this->Query_ID);
! $this->Query_ID = 0;
! };
} else {
- // add to Record[<key>]
$count = odbc_num_fields($this->Query_ID);
! for ($i=1; $i<=$count; $i++)
! $this->Record[strtolower(odbc_field_name ($this->Query_ID, $i)) ] = $this->Record[ $i - 1 ];
}
return $stat;
}
!
! function seek($pos) {
$this->Row = $pos;
}
! function metadata($table) {
! $count = 0;
! $id = 0;
! $res = array();
! $this->connect();
! $id = odbc_exec($this->Link_ID, "select * from $table");
! if (!$id) {
! $this->Errno = 1;
! $this->Error = "General Error (The ODBC interface cannot return detailed error messages).";
! $this->halt("Metadata query failed.");
! }
! $count = odbc_num_fields($id);
! for ($i=1; $i<=$count; $i++) {
! $res[$i]["table"] = $table;
! $name = odbc_field_name ($id, $i);
! $res[$i]["name"] = $name;
! $res[$i]["type"] = odbc_field_type ($id, $name);
! $res[$i]["len"] = 0; // can we determine the width of this column?
! $res[$i]["flags"] = ""; // any optional flags to report?
}
!
! odbc_free_result($id);
! return $res;
}
function affected_rows() {
return odbc_num_rows($this->Query_ID);
}
!
function num_rows() {
# Many ODBC drivers don't support odbc_num_rows() on SELECT statements.
$num_rows = odbc_num_rows($this->Query_ID);
- //printf ($num_rows."<br>");
# This is a workaround. It is intended to be ugly.
--- 124,337 ----
# $this->Query_Ok = odbc_execute($this->Query_ID);
! $this->Query_ID = odbc_exec($this->Link_ID, $Query_String);
! $this->RowCount = -1; # reset num_rows() return value
! $this->Row = 0;
! $this->Errno = 0;
! $this->Error = "";
odbc_binmode($this->Query_ID, 1);
odbc_longreadlen($this->Query_ID, 4096);
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
+
+ # Will return nada if it fails. That's fine.
return $this->Query_ID;
}
!
! /* public: walk result set */
function next_record() {
+ if (!$this->Query_ID) {
+ $this->halt("next_record called with no query pending.");
+ return 0;
+ }
+
$this->Record = array();
! $this->Row += 1;
! $stat = odbc_fetch_row($this->Query_ID, $this->Row);
! $this->Errno = 0;
! $this->Error = "";
!
if (!$stat) {
if ($this->Auto_Free) {
! $this->free();
! }
} else {
$count = odbc_num_fields($this->Query_ID);
! for ($i=1; $i<=$count; $i++) {
! $this->Record[strtolower(odbc_field_name($this->Query_ID, $i))] = odbc_result($this->Query_ID, $i);
! }
}
return $stat;
}
!
! /* public: position in result set */
! function seek($pos = 0) {
$this->Row = $pos;
+ return 1;
}
! /* public: get the time in msecs */
! function getmicrotime() {
! list($usec, $sec) = explode(" ", microtime());
! return (float)$usec + (float)$sec;
! }
! /* public: table locking */
! /*
! ODBC is not guaranteed do table locking natively. This function emulates
! locking with certain constraints. The intention is to provide at least the
! minimum functionality required to implement sequences via nextid().
!
! This function maintains a list of locked tables in a lock table. To lock
! a table it inserts a row into the lock table with the locked table name
! suffixed with '_p_lock' as a primary key and with a value of 0.
! The suffix and value are used so that the sequence table can be used as
! the lock table if desired.
! While this row exists a lock will not be granted to another process.
! To protect against threads failing to release a lock, if a lock is not
! obtained within $this->Lock_Timeout seconds the lock may be deleted.
! The timeout value needs to be set to a reasonable length based on the
! expected transaction time on the locked table.
!
! This method will only be effective if the locked table is accessed
! exclusively via this class. This is not a database-enforced lock and
! there is nothing preventing other applications from modifying a table
! while it is 'locked'.
!
! The function uses microtime to prevent multiple threads all hitting the
! table simultaneously on the tick of a second.
!
! The function halt()s if a lock cannot be obtained.
! */
! function lock($table, $mode="write") {
! if (!$this->connect()) {
! return 0; /* we already complained in connect() about that. */
! };
!
! $getsql = sprintf("INSERT into %s (%s, %s) VALUES ('%s', 0)",
! $this->Lock_Table,
! $this->Lock_Name_Col,
! $this->Lock_ID_Col,
! strtolower($table)."_p_lock");
! $delsql = sprintf("DELETE FROM %s where %s='%s' AND %s=0",
! $this->Lock_Table,
! $this->Lock_Name_Col,
! strtolower($table)."_p_lock",
! $this->Lock_ID_Col);
! $selsql = sprintf("SELECT * FROM %s where %s='%s' AND %s=0",
! $this->Lock_Table,
! $this->Lock_Name_Col,
! strtolower($table)."_p_lock",
! $this->Lock_ID_Col);
! $timeout = $this->getmicrotime() + $this->Lock_Timeout;
! $got_lock = 0;
! $override = $this->Lock_Override;
! while (!$got_lock) {
! $got_lock = @odbc_exec($this->Link_ID, $getsql);
! if ($this->Debug && !$got_lock) {
! echo "missed lock... looping\n";
! flush();
! }
! $currtime = $this->getmicrotime();
! if (!$got_lock) {
! if ($timeout < $currtime) {
! if (!$override) {
! # try to select existing lock
! if (!@odbc_exec($this->Link_ID, $selsql)) {
! # lock select failed. Either the table does not exist or the lock was
! # released just this instant. Try to get a lock to see which...
! $got_lock = @odbc_exec($this->Link_ID, $getsql);
! if (!$got_lock) {
! $this->halt("Lock select failed. Does the table $this->Lock_Table exist?");
! }
! return $got_lock;
! }
! $this->halt("lock() failed.");
! return 0;
! } else {
! # delete existing lock
! if ($this->Debug) {
! echo "overriding lock\n";
! }
!
! if (!@odbc_exec($this->Link_ID, $delsql)) {
! # lock override failed. Either the table does not exist or the lock was
! # released just this instant. Try to get a lock to see which...
! $got_lock = @odbc_exec($this->Link_ID, $getsql);
! if (!$got_lock) {
! $this->halt("Lock override failed. Does the table $this->Lock_Table exist?");
! }
! return $got_lock;
! } else {
! # just deleted the lock so try to get it straight away
! $got_lock = @odbc_exec($this->Link_ID, $getsql);
! $timeout = $currtime + $this->Lock_Timeout; # reset the timer
! $override = 0; # override once only
! # fall through to wait loop
! }
! }
! }
! }
!
! if (!$got_lock) {
! $waittime = $currtime + 0.5;
! while ($waittime > $this->getmicrotime()) {
! ;
! }
! }
}
! if ($this->Debug && !$got_lock) {
! echo "missed lock... bug!\n";
! } else {
! echo "got lock\n";
! flush();
! }
! return $got_lock;
}
+ function unlock($table = "") {
+ if (!$this->connect()) {
+ return 0; /* we already complained in connect() about that. */
+ };
+
+ # Note: this unlocks ALL tables if $table is blank!
+ if ($table == "") {
+ $delsql = sprintf("DELETE FROM %s where %s LIKE '%%_p_lock' AND %s=0",
+ $this->Lock_Table,
+ $this->Lock_Name_Col,
+ $this->Lock_ID_Col);
+ } else {
+ $delsql = sprintf("DELETE FROM %s where %s='%s' AND %s=0",
+ $this->Lock_Table,
+ $this->Lock_Name_Col,
+ strtolower($table)."_p_lock",
+ $this->Lock_ID_Col);
+ }
+
+ $res = @odbc_exec($this->Link_ID, $delsql);
+ if (!$res) {
+ $this->halt("unlock() failed.");
+ }
+ return $res;
+ }
+
+ /* public: evaluate the result (size, width) */
function affected_rows() {
return odbc_num_rows($this->Query_ID);
}
!
function num_rows() {
+ # Due to a strange problem with the odbc_fetch_row function it is only
+ # possible to walk through the result set once. By storing the row count
+ # this problem is avoided.
+ # Once the number of rows has been calculated it is stored in $RowCount.
+ if ($this->RowCount != -1) {
+ return $this->RowCount;
+ }
+
# Many ODBC drivers don't support odbc_num_rows() on SELECT statements.
$num_rows = odbc_num_rows($this->Query_ID);
# This is a workaround. It is intended to be ugly.
***************
*** 158,191 ****
}
return $num_rows;
}
!
function num_fields() {
return count($this->Record)/2;
}
function nf() {
return $this->num_rows();
}
!
function np() {
print $this->num_rows();
}
!
! function f($Field_Name) {
! return $this->Record[strtolower($Field_Name)];
}
!
! function p($Field_Name) {
! print $this->f($Field_Name);
}
!
function halt($msg) {
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
printf("<b>ODBC Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
- die("Session halted.");
}
}
?>
--- 359,585 ----
}
+ $this->RowCount = $num_rows;
return $num_rows;
}
!
function num_fields() {
+ # NOTE: this only works after next_record has been called!
return count($this->Record)/2;
}
+ /* public: shorthand notation */
function nf() {
return $this->num_rows();
}
!
function np() {
print $this->num_rows();
}
!
! function f($Name) {
! if (isset($this->Record[$Name])) {
! return $this->Record[strtolower($Name)];
! }
! return "";
}
!
! function p($Name) {
! print $this->f($Name);
}
!
! /* public: sequence numbers */
! function nextid($seq_name) {
! if (!$this->connect()) {
! return 0; /* we already complained in connect() about that. */
! };
!
! if ($this->lock($this->Seq_Table)) {
! /* get sequence number (locked) and increment */
! $q = sprintf("select %s from %s where %s = '%s'",
! $this->Seq_ID_Col,
! $this->Seq_Table,
! $this->Seq_Name_Col,
! $seq_name);
! $id = odbc_exec($this->Link_ID, $q);
! $res = 0;
! if (odbc_fetch_row($id, 1)) {
! $res = array();
! $count = odbc_num_fields($id);
! for ($i=1; $i<=$count; $i++) {
! $res[strtolower(odbc_field_name($id, $i))] = odbc_result($id, $i);
! }
! }
!
! /* No current value, make one */
! if (!is_array($res)) {
! $currentid = 0;
! $q = sprintf("insert into %s ( %s, %s ) values('%s', %s)",
! $this->Seq_Table,
! $this->Seq_Name_Col,
! $this->Seq_ID_Col,
! $seq_name,
! $currentid);
! $id = odbc_exec($this->Link_ID, $q);
! } else {
! $currentid = $res[$this->Seq_ID_Col];
! }
! $nextid = $currentid + 1;
! $q = sprintf("update %s set %s = '%s' where %s = '%s'",
! $this->Seq_Table,
! $this->Seq_ID_Col,
! $nextid,
! $this->Seq_Name_Col,
! $seq_name);
! $id = odbc_exec($this->Link_ID, $q);
! $this->unlock();
! } else {
! $this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
! return 0;
! }
! return $nextid;
! }
!
! /* public: return table metadata */
! function metadata($table = "", $full = false) {
! $count = 0;
! $id = 0;
! $res = array();
!
! /*
! * Due to compatibility problems with Table we changed the behavior
! * of metadata();
! * If $full is set, metadata returns additional information
! *
! * This information is always returned:
! * $result[]:
! * [0]["table"] table name
! * [0]["name"] field name
! * [0]["type"] field type
! * [0]["len"] field length
! * [0]["flags"] field flags
! *
! * If $full is set this information is also returned:
! * $result[]:
! * ["num_fields"] number of metadata records
! * [0]["php_type"] the corresponding PHP-type
! * [0]["php_subtype"] the subtype of PHP-type
! * ["meta"][field name] index of field named "field name"
! * This one could be used if you have a field name, but no index.
! * Test: if (isset($result['meta']['myfield'])) { ...
! * [unique] = field names which have an unique key, separated by space
! */
!
! // if no $table specified, assume that we are working with a query result
! if ($table) {
! $this->connect();
! $id = odbc_exec($this->Link_ID, "select * from $table");
! if (!$id) {
! $this->halt("Metadata query failed.");
! return false;
! }
! } else {
! $id = $this->Query_ID;
! if (!$id) {
! $this->halt("No query specified.");
! return false;
! }
! }
!
! $count = odbc_num_fields($id);
!
! for ($i=1; $i<=$count; $i++) {
! $res[$i]["table"] = $table;
! $res[$i]["name"] = odbc_field_name ($id, $i);
! $res[$i]["type"] = odbc_field_type ($id, $i);
! $res[$i]["len"] = odbc_field_len ($id, $i);
! $res[$i]["flags"] = ""; // any optional flags to report?
! }
!
! if ($full) {
! $uniq = array();
! $res["num_fields"] = $count;
!
! # ODBC result set starts at 1
! for ($i=1; $i<=$count; $i++) {
! $res["meta"][$res[$i]["name"]] = $i;
! switch ($res[$i]["type"]) {
! case "var string":
! case "string" :
! case "char" :
! $res[$i]["php_type"]="string";
! $res[$i]["php_subtype"]="";
! break;
! case "timestamp" :
! case "datetime" :
! case "date" :
! case "time" :
! $res[$i]["php_type"]="string";
! $res[$i]["php_subtype"]="date";
! break;
! case "blob" :
! $res[$i]["php_type"]="string";
! $res[$i]["php_subtype"]="blob";
! break;
! case "real" :
! $res[$i]["php_type"]="double";
! $res[$i]["php_subtype"]="";
! break;
! case "long" :
! default :
! $res[$i]["php_type"]="int";
! $res[$i]["php_subtype"]="";
! break;
! }
! if ( ereg("(unique_key|primary_key)",$res[$i]["flags"]) ) {
! $uniq[]=$res[$i]["name"];
! }
! }
! $res["unique"]=join(" ",$uniq);
! }
!
! // free the result only if we were called on a table
! if ($table) {
! odbc_free_result($id);
! }
! return $res;
! }
!
! /* public: find available table names */
! function table_names() {
! $this->connect();
! $h = odbc_tables($this->Link_ID);
! $i = 0;
! while(odbc_fetch_row($h)) {
! if (odbc_result($h, 4) == "TABLE") {
! $return[$i]["table_name"] = odbc_result($h, 3);
! $return[$i]["tablespace_name"] = odbc_result($h, 1);
! $return[$i]["database"] = odbc_result($h, 1);
! $i += 1;
! }
! }
! odbc_free_result($h);
! return $return;
! }
!
! /* private: error handling */
function halt($msg) {
+ $this->Errno = 1;
+ $this->Error = "General Error (The ODBC interface cannot return detailed error messages).";
+ if ($this->Halt_On_Error == "no")
+ return;
+
+ $this->haltmsg($msg);
+
+ if ($this->Halt_On_Error != "report")
+ die("Session halted.");
+ }
+
+ function haltmsg($msg) {
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
printf("<b>ODBC Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
}
+
}
?>
|
|
From: Richard A. <ric...@us...> - 2002-07-11 22:38:15
|
Update of /cvsroot/phplib/php-lib-stable/doc/sgml In directory usw-pr-cvs1:/tmp/cvs-serv14027 Modified Files: 04-template.sgml Log Message: add comments for clear_var and unset_var Index: 04-template.sgml =================================================================== RCS file: /cvsroot/phplib/php-lib-stable/doc/sgml/04-template.sgml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 04-template.sgml 10 Aug 2001 04:59:18 -0000 1.3 --- 04-template.sgml 11 Jul 2002 22:38:12 -0000 1.4 *************** *** 115,118 **** --- 115,130 ---- $varname/$value pairs. + <tag>clear_var($varname)</tag> + <p> + The functions clears the value of a variable. It may be + called with either a $varname string or with an array of + $varname strings. + + <tag>unset_var($varname)</tag> + <p> + The functions unsets a variable. It may be + called with either a $varname string or with an array of + $varname strings. + <tag>subst($varname)</tag> <p> |
|
From: Richard A. <ric...@us...> - 2002-07-11 22:29:55
|
Update of /cvsroot/phplib/php-lib-stable/php In directory usw-pr-cvs1:/tmp/cvs-serv13538 Modified Files: template.inc Log Message: Merge in changes from -devel: * changed debug handling so set, get and internals can be tracked separately (rha) * added debug statements throughout to track most function calls (rha) * debug output contained raw HTML -- is now escaped with htmlentities (rha) * Alter regex in set_block to remove more whitespace around BEGIN/END tags to improve HTML layout (rha) * Add "append" option to set_var, works just like append in parse (dale at linuxwebpro.com, rha) * Altered parse so that append is honored if passed an array (Brian) * Converted comments and documentation to phpdoc style (rha) * Added clear_var to set the value of variables to "" (rha) * Added unset_var to usset variables (rha) Index: template.inc =================================================================== RCS file: /cvsroot/phplib/php-lib-stable/php/template.inc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** template.inc 25 Apr 2002 12:49:17 -0000 1.11 --- template.inc 11 Jul 2002 22:29:51 -0000 1.12 *************** *** 23,27 **** * set_unknowns had "keep" as default instead of "remove" (from phplib-devel) * set_file failed to check for empty strings if passed an array of filenames (phplib-devel) ! * remove @ from call to preg_replace in subst -- report errors if there are any. (NickM) * set_block unnecessarily required a newline in the template file (Marc Tardif) * pparse now calls this->finish to replace undefined vars (Layne Weathers) --- 23,27 ---- * set_unknowns had "keep" as default instead of "remove" (from phplib-devel) * set_file failed to check for empty strings if passed an array of filenames (phplib-devel) ! * remove @ from call to preg_replace in subst -- report errors if there are any (NickM) * set_block unnecessarily required a newline in the template file (Marc Tardif) [...1132 lines suppressed...] ! */ function haltmsg($msg) { printf("<b>Template Error:</b> %s<br>\n", $msg); --- 946,961 ---- ! /****************************************************************************** ! * This function prints an error message. ! * It can be overridden by your subclass of Template. It will be called with an ! * error message to display. ! * ! * usage: haltmsg(string $msg) ! * ! * @param $msg a string containing the error message to display ! * @access public ! * @return void ! * @see halt ! */ function haltmsg($msg) { printf("<b>Template Error:</b> %s<br>\n", $msg); |
|
From: Richard A. <ric...@us...> - 2002-07-11 22:27:57
|
Update of /cvsroot/phplib/php-lib/php/ext In directory usw-pr-cvs1:/tmp/cvs-serv12578 Modified Files: template.inc Log Message: edit change log in preparation for merge into -stable Index: template.inc =================================================================== RCS file: /cvsroot/phplib/php-lib/php/ext/template.inc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** template.inc 11 Jul 2002 22:20:28 -0000 1.9 --- template.inc 11 Jul 2002 22:27:54 -0000 1.10 *************** *** 11,19 **** /* ! * Change log since version 7.2d * Bug fixes to version 7.2c compiled by Richard Archer <rh...@ju...>: * (credits given to first person to post a diff to phplib mailing list) * ! * Normalised all comments and whitespace * replaced "$handle" with "$varname" and "$h" with "$v" throughout (from phplib-devel) * added braces around all one-line if statements in: get_undefined, loadfile and halt (rha) --- 11,20 ---- /* ! * Change log since version 7.2c ! * * Bug fixes to version 7.2c compiled by Richard Archer <rh...@ju...>: * (credits given to first person to post a diff to phplib mailing list) * ! * Normalised all comments and whitespace (rha) * replaced "$handle" with "$varname" and "$h" with "$v" throughout (from phplib-devel) * added braces around all one-line if statements in: get_undefined, loadfile and halt (rha) *************** *** 22,26 **** * set_unknowns had "keep" as default instead of "remove" (from phplib-devel) * set_file failed to check for empty strings if passed an array of filenames (phplib-devel) ! * remove @ from call to preg_replace in subst -- report errors if there are any. (NickM) * set_block unnecessarily required a newline in the template file (Marc Tardif) * pparse now calls this->finish to replace undefined vars (Layne Weathers) --- 23,27 ---- * set_unknowns had "keep" as default instead of "remove" (from phplib-devel) * set_file failed to check for empty strings if passed an array of filenames (phplib-devel) ! * remove @ from call to preg_replace in subst -- report errors if there are any (NickM) * set_block unnecessarily required a newline in the template file (Marc Tardif) * pparse now calls this->finish to replace undefined vars (Layne Weathers) *************** *** 30,36 **** * in finish, the replacement string referenced an unset variable (rha) * loadfile would try to load a file if the varval had been set to "" (rha) ! * in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha) * more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings (rha) * * changed debug handling so set, get and internals can be tracked separately (rha) * added debug statements throughout to track most function calls (rha) --- 31,40 ---- * in finish, the replacement string referenced an unset variable (rha) * loadfile would try to load a file if the varval had been set to "" (rha) ! * in get_undefined, only match non-whitespace in variable tags as in finish (Layne Weathers & rha) * more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings (rha) * + * + * Changes in functionality which go beyond bug fixes: + * * changed debug handling so set, get and internals can be tracked separately (rha) * added debug statements throughout to track most function calls (rha) *************** *** 39,45 **** * Add "append" option to set_var, works just like append in parse (dale at linuxwebpro.com, rha) * Altered parse so that append is honored if passed an array (Brian) ! * Converted comments and documentation to phpdoc style. (rha) ! * Added clear_var to set the value of variables to "". (rha) ! * Added unset_var to usset variables. (rha) * */ --- 43,49 ---- * Add "append" option to set_var, works just like append in parse (dale at linuxwebpro.com, rha) * Altered parse so that append is honored if passed an array (Brian) ! * Converted comments and documentation to phpdoc style (rha) ! * Added clear_var to set the value of variables to "" (rha) ! * Added unset_var to usset variables (rha) * */ |
|
From: Richard A. <ric...@us...> - 2002-07-11 22:20:32
|
Update of /cvsroot/phplib/php-lib/php/ext
In directory usw-pr-cvs1:/tmp/cvs-serv11136
Modified Files:
template.inc
Log Message:
Added clear_var to set the value of variables to "".
Added unset_var to usset variables.
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib/php/ext/template.inc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** template.inc 25 Apr 2002 12:53:38 -0000 1.8
--- template.inc 11 Jul 2002 22:20:28 -0000 1.9
***************
*** 33,37 ****
* more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings (rha)
*
- *
* changed debug handling so set, get and internals can be tracked separately (rha)
* added debug statements throughout to track most function calls (rha)
--- 33,36 ----
***************
*** 41,44 ****
--- 40,45 ----
* Altered parse so that append is honored if passed an array (Brian)
* Converted comments and documentation to phpdoc style. (rha)
+ * Added clear_var to set the value of variables to "". (rha)
+ * Added unset_var to usset variables. (rha)
*
*/
***************
*** 371,374 ****
--- 372,459 ----
$this->varvals[$k] = $v;
}
+ }
+ }
+ }
+ }
+
+
+ /******************************************************************************
+ * This functions clears the value of a variable.
+ *
+ * It may be called with either a varname as a string or an array with the
+ * values being the varnames to be cleared.
+ *
+ * The function sets the value of the variable in the $varkeys and $varvals
+ * hashes to "". It is not necessary for a variable to exist in these hashes
+ * before calling this function.
+ *
+ *
+ * usage: clear_var(string $varname)
+ * or
+ * usage: clear_var(array $varname = (string $varname))
+ *
+ * @param $varname either a string containing a varname or an array of varnames.
+ * @access public
+ * @return void
+ */
+ function clear_var($varname) {
+ if (!is_array($varname)) {
+ if (!empty($varname)) {
+ if ($this->debug & 1) {
+ printf("<b>clear_var:</b> (with scalar) <b>%s</b><br>\n", $varname);
+ }
+ $this->set_var($varname, "");
+ }
+ } else {
+ reset($varname);
+ while(list($k, $v) = each($varname)) {
+ if (!empty($v)) {
+ if ($this->debug & 1) {
+ printf("<b>clear_var:</b> (with array) <b>%s</b><br>\n", $v);
+ }
+ $this->set_var($v, "");
+ }
+ }
+ }
+ }
+
+
+ /******************************************************************************
+ * This functions unsets a variable completely.
+ *
+ * It may be called with either a varname as a string or an array with the
+ * values being the varnames to be cleared.
+ *
+ * The function removes the variable from the $varkeys and $varvals hashes.
+ * It is not necessary for a variable to exist in these hashes before calling
+ * this function.
+ *
+ *
+ * usage: unset_var(string $varname)
+ * or
+ * usage: unset_var(array $varname = (string $varname))
+ *
+ * @param $varname either a string containing a varname or an array of varnames.
+ * @access public
+ * @return void
+ */
+ function unset_var($varname) {
+ if (!is_array($varname)) {
+ if (!empty($varname)) {
+ if ($this->debug & 1) {
+ printf("<b>unset_var:</b> (with scalar) <b>%s</b><br>\n", $varname);
+ }
+ unset($this->varkeys[$varname]);
+ unset($this->varvals[$varname]);
+ }
+ } else {
+ reset($varname);
+ while(list($k, $v) = each($varname)) {
+ if (!empty($v)) {
+ if ($this->debug & 1) {
+ printf("<b>unset_var:</b> (with array) <b>%s</b><br>\n", $v);
+ }
+ unset($this->varkeys[$v]);
+ unset($this->varvals[$v]);
}
}
|
|
From: Giancarlo P. <pi...@us...> - 2002-06-03 04:39:06
|
Update of /cvsroot/phplib/php-lib-stable
In directory usw-pr-cvs1:/tmp/cvs-serv16982
Modified Files:
CHANGES
Log Message:
fallback_mode only when really no cookies avail + global switch to permit creation
of IDs provided by user
Index: CHANGES
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/CHANGES,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** CHANGES 3 Apr 2002 22:53:35 -0000 1.18
--- CHANGES 3 Jun 2002 04:39:02 -0000 1.19
***************
*** 1,4 ****
--- 1,13 ----
$Id$
+ 03-June-2002 Giancarlo Pinerolo
+ - session.inc fallback_mode only applies when cookies are disabled.
+ Session in URL cannot force fallback mode anymore when cookies are
+ avail. There no switch for that. If needed use a dedicated subclass
+ with mode=get in affected scripts or trusted environs.
+ - session.inc now has the block_alien_sid = true/false switch. It
+ blocks the creation of a new session by a sid provided by the user.
+
+
03-Apr-2002 layne_weathers
- in auth.inc, allow cancel_login to come from GET as well as POST
|
|
From: Giancarlo P. <pi...@us...> - 2002-06-03 04:35:54
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv16406
Modified Files:
session.inc
Log Message:
fallback_mode only really w/o cookies, switch to permit creation of IDs provided
by the user
Index: session.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/session.inc,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** session.inc 29 May 2002 15:11:20 -0000 1.16
--- session.inc 3 Jun 2002 04:35:50 -0000 1.17
***************
*** 20,24 ****
var $fallback_mode; ## If this doesn't work, fall back...
var $lifetime = 0; ## 0 = do session cookies, else minutes
-
var $cookie_domain = ""; ## If set, the domain for which the
## session cookie is set.
--- 20,23 ----
***************
*** 34,37 ****
--- 33,38 ----
var $allowcache_expire = 1440; ## If you allowcache, data expires in this
## many minutes.
+ var $block_alien_sid = true; ## do not accept IDs in URL for session creation
+
var $that_class = ""; ## Name of data storage container
***************
*** 112,115 ****
--- 113,124 ----
}
+ ### do not accept user provided ids for creation
+ if($id != "" && $this->block_alien_sid) { # somehow an id was provided by the user
+ if($this->that->ac_get_value($id, $this->name) == "") {
+ # no - the id doesn't exist in the database: Ignore it!
+ $id = "";
+ }
+ }
+
if ( "" == $id ) {
$this->newid=true;
***************
*** 129,140 ****
if ( isset($HTTP_SERVER_VARS["QUERY_STRING"]) && ("" != $HTTP_SERVER_VARS["QUERY_STRING"]) ) {
$HTTP_SERVER_VARS["QUERY_STRING"] = ereg_replace(
! "(^|&)".quotemeta(urlencode($this->name))."=".$id."(&|$)",
"\\1", $HTTP_SERVER_VARS["QUERY_STRING"]);
}
break;
case "get":
if ( isset($HTTP_SERVER_VARS["QUERY_STRING"]) && ("" != $HTTP_SERVER_VARS["QUERY_STRING"]) ) {
$HTTP_SERVER_VARS["QUERY_STRING"] = ereg_replace(
! "(^|&)".quotemeta(urlencode($this->name))."=".$id."(&|$)",
"\\1", $HTTP_SERVER_VARS["QUERY_STRING"]);
}
--- 138,159 ----
if ( isset($HTTP_SERVER_VARS["QUERY_STRING"]) && ("" != $HTTP_SERVER_VARS["QUERY_STRING"]) ) {
$HTTP_SERVER_VARS["QUERY_STRING"] = ereg_replace(
! "(^|&)".quotemeta(urlencode($this->name))."=(.)*(&|$)", ## subst *any* preexistent sess
"\\1", $HTTP_SERVER_VARS["QUERY_STRING"]);
}
break;
case "get":
+ #we don't trust user input; session in url doesn't
+ #mean cookies are disabled
+ if ($this->newid &&( 0 == $this->lifetime )) { ## even if not a newid
+ SetCookie($this->name, $id, 0, "/", $this->cookie_domain);
+ }
+ if ( 0 < $this->lifetime ) {
+ SetCookie($this->name, $id, time()+$this->lifetime*60, "/", $this->cookie_domain);
+ }
+
if ( isset($HTTP_SERVER_VARS["QUERY_STRING"]) && ("" != $HTTP_SERVER_VARS["QUERY_STRING"]) ) {
$HTTP_SERVER_VARS["QUERY_STRING"] = ereg_replace(
! # "(^|&)".quotemeta(urlencode($this->name))."=".$id."(&|$)",
! "(^|&)".quotemeta(urlencode($this->name))."=(.)*(&|$)", ## subst *any* preexistent sess
"\\1", $HTTP_SERVER_VARS["QUERY_STRING"]);
}
***************
*** 184,188 ****
// Remove existing session info from url
$url = ereg_replace(
! "([&?])".quotemeta(urlencode($this->name))."=".$this->id."(&|$)",
"\\1", $url);
--- 203,208 ----
// Remove existing session info from url
$url = ereg_replace(
! # "([&?])".quotemeta(urlencode($this->name))."=".$this->id."(&|$)",
! "([&?])".quotemeta(urlencode($this->name))."=(.)*(&|$)", # we clean any(also bogus) sess in url
"\\1", $url);
***************
*** 387,424 ****
global $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $HTTP_GET_VARS,
$HTTP_SERVER_VARS;
!
if ( isset($this->fallback_mode)
&& ("get" == $this->fallback_mode)
&& ("cookie" == $this->mode)
&& (! isset($HTTP_COOKIE_VARS[$this->name])) ) {
! // Looks like no cookie here - check GET/POST params
! if ( isset($HTTP_GET_VARS[$this->name])
! || isset($HTTP_POST_VARS[$this->name]) ) {
! // Session info passed via GET/POST - go to fallback_mode
! $this->mode = $this->fallback_mode;
! } else {
! // It seems to be the first load of this page -
! // no cookie and no GET/POST params
!
! // Generate session ID and setup cookie.
! $this->get_id($sid);
!
! // Next line is to generate correct self_url() later
! $this->mode = $this->fallback_mode;
!
if ( isset($HTTP_SERVER_VARS["HTTPS"])
! && $HTTP_SERVER_VARS["HTTPS"] == 'on' ) {
! ## You will need to fix suexec as well, if you
! ## use Apache and CGI PHP
! $PROTOCOL = 'https';
} else {
! $PROTOCOL = 'http';
}
header("Status: 302 Moved Temporarily");
header("Location: " . $PROTOCOL . "://" .
! $HTTP_SERVER_VARS["HTTP_HOST"] . $this->self_url());
exit;
! }
}
}
--- 407,437 ----
global $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $HTTP_GET_VARS,
$HTTP_SERVER_VARS;
! # set the mode for this run
if ( isset($this->fallback_mode)
&& ("get" == $this->fallback_mode)
&& ("cookie" == $this->mode)
&& (! isset($HTTP_COOKIE_VARS[$this->name])) ) {
+ $this->mode = $this->fallback_mode;
+ }
! if ($this->mode=="get") ## now it catches also when primary mode is get
! {
! $this->get_id($sid);
! if ($this->newid)
! {
if ( isset($HTTP_SERVER_VARS["HTTPS"])
! && $HTTP_SERVER_VARS["HTTPS"] == 'on' ) {
! ## You will need to fix suexec as well, if you
! ## use Apache and CGI PHP
! $PROTOCOL = 'https';
} else {
! $PROTOCOL = 'http';
}
+ $this->freeze();
header("Status: 302 Moved Temporarily");
header("Location: " . $PROTOCOL . "://" .
! $HTTP_SERVER_VARS["HTTP_HOST"] . $this->self_url());
exit;
! }
}
}
|
|
From: Giancarlo P. <pi...@us...> - 2002-05-29 15:11:23
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv31824
Modified Files:
session.inc
Log Message:
corrected typo
Index: session.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/session.inc,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** session.inc 29 May 2002 14:19:29 -0000 1.15
--- session.inc 29 May 2002 15:11:20 -0000 1.16
***************
*** 119,123 ****
switch ($this->mode) {
case "cookie":
! if ( $$this->newid && ( 0 == $this->lifetime ) ) {
SetCookie($this->name, $id, 0, "/", $this->cookie_domain);
}
--- 119,123 ----
switch ($this->mode) {
case "cookie":
! if ( $this->newid && ( 0 == $this->lifetime ) ) {
SetCookie($this->name, $id, 0, "/", $this->cookie_domain);
}
|
|
From: Giancarlo P. <pi...@us...> - 2002-05-29 14:19:34
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv12697
Modified Files:
session.inc
Log Message:
$newid now is a class variable, useful flag to incertept new session issuing
Index: session.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/session.inc,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** session.inc 19 Mar 2002 22:32:25 -0000 1.14
--- session.inc 29 May 2002 14:19:29 -0000 1.15
***************
*** 42,45 ****
--- 42,46 ----
var $name; ## Session name
var $id; ## Unique Session ID
+ var $newid; ## Newly Generated ID Flag
var $that;
***************
*** 87,96 ****
function get_id($id = "") {
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
! $newid=true;
$this->name = $this->cookiename==""?$this->classname:$this->cookiename;
if ( "" == $id ) {
! $newid=false;
switch ($this->mode) {
case "get":
--- 88,97 ----
function get_id($id = "") {
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
! $this->newid=true;
$this->name = $this->cookiename==""?$this->classname:$this->cookiename;
if ( "" == $id ) {
! $this->newid=false;
switch ($this->mode) {
case "get":
***************
*** 112,116 ****
if ( "" == $id ) {
! $newid=true;
$id = $this->that->ac_newid(md5(uniqid($this->magic)), $this->name);
}
--- 113,117 ----
if ( "" == $id ) {
! $this->newid=true;
$id = $this->that->ac_newid(md5(uniqid($this->magic)), $this->name);
}
***************
*** 118,122 ****
switch ($this->mode) {
case "cookie":
! if ( $newid && ( 0 == $this->lifetime ) ) {
SetCookie($this->name, $id, 0, "/", $this->cookie_domain);
}
--- 119,123 ----
switch ($this->mode) {
case "cookie":
! if ( $$this->newid && ( 0 == $this->lifetime ) ) {
SetCookie($this->name, $id, 0, "/", $this->cookie_domain);
}
|
|
From: Richard A. <ric...@us...> - 2002-04-28 20:05:22
|
Update of /cvsroot/phplib/php-lib/php/html
In directory usw-pr-cvs1:/tmp/cvs-serv22711
Modified Files:
table.inc
Log Message:
synch with -stable tree
Index: table.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib/php/html/table.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** table.inc 25 Apr 2002 04:55:52 -0000 1.3
--- table.inc 28 Apr 2002 08:12:54 -0000 1.4
***************
*** 8,27 ****
*
* $Id$
! *
* History: 990617: Modularized entire table class. Modularity breaks larger
! * objects into smaller, autonomous objects in order to
! * exercise OOP requirements of code reuse. This give
! * programmers the ability to use the high-level code, or
* get down and dirty with the low-level code.
! * Everything I have changed should maintain backwards
* compatibility, except for show_table_heading_row_result(),
[...1061 lines suppressed...]
--- 970,975 ----
# Function : table_row_add_extra
#--------------------------------------------------------------------------
! # Purpose : Virtual function for derived classes. This function is called
! # after all cells have been created. It allows the programmer to
# add additional HTML code to the row before it is closed.
# Arguments: $row
***************
*** 958,962 ****
# $data
# $class - [optional] Used for CSS control.
! # Returns :
# Comments :
# History :
--- 977,981 ----
# $data
# $class - [optional] Used for CSS control.
! # Returns :
# Comments :
# History :
|
|
From: Richard A. <ric...@us...> - 2002-04-28 19:44:55
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv21555
Modified Files:
oohforms.inc
Log Message:
register_globals off fix for oohforms
from Vinay Kumar / SANIsoft
Index: oohforms.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/oohforms.inc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** oohforms.inc 28 Apr 2002 03:59:32 -0000 1.4
--- oohforms.inc 28 Apr 2002 04:05:30 -0000 1.5
***************
*** 17,23 ****
function marshal_dispatch($m, $func) {
$vname = $this->name;
! global $$vname;
! return $this->$func($$vname);
}
--- 17,23 ----
function marshal_dispatch($m, $func) {
+ global $HTTP_POST_VARS;
$vname = $this->name;
! return $this->$func($HTTP_POST_VARS["$vname"]);
}
|
|
From: Richard A. <ric...@us...> - 2002-04-28 19:43:59
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv16892
Modified Files:
of_checkbox.inc of_file.inc of_radio.inc of_select.inc
of_text.inc of_textarea.inc oohforms.inc
Log Message:
clean up code in oohforms.inc:
add braces around one-line conditionals
remove spaces before newlines
one space after a comma in function params
Index: of_checkbox.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_checkbox.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_checkbox.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_checkbox.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 18,22 ****
function self_get($val, $which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
--- 18,22 ----
function self_get($val, $which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
***************
*** 24,31 ****
if (is_array($this->value)) {
reset($this->value);
! while (list($k,$v) = each($this->value)) {
if ($v==$val) {
! $str .= " checked";
! break;
}
}
--- 24,31 ----
if (is_array($this->value)) {
reset($this->value);
! while (list($k, $v) = each($this->value)) {
if ($v==$val) {
! $str .= " checked";
! break;
}
}
***************
*** 34,44 ****
$str .= "<input type='checkbox' name='$this->name'";
$str .= " value='$this->value'";
! if ($this->checked)
$str .= " checked";
}
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">\n";
!
$count = 1;
return $str;
--- 34,46 ----
$str .= "<input type='checkbox' name='$this->name'";
$str .= " value='$this->value'";
! if ($this->checked) {
$str .= " checked";
+ }
}
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">\n";
!
$count = 1;
return $str;
***************
*** 47,51 ****
function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
$t="";
--- 49,53 ----
function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
$t="";
***************
*** 54,58 ****
if (is_array($this->value)) {
reset($this->value);
! while (list($k,$v) = each($this->value)) {
if ($v==$val) {
$x = 1;
--- 56,60 ----
if (is_array($this->value)) {
reset($this->value);
! while (list($k, $v) = each($this->value)) {
if ($v==$val) {
$x = 1;
***************
*** 76,87 ****
return $str;
}
!
function self_load_defaults($val) {
! if ($this->multiple)
$this->value = $val;
! elseif (isset($val) && (!$this->value || $val==$this->value))
$this->checked=1;
! else
$this->checked=0;
}
--- 78,90 ----
return $str;
}
!
function self_load_defaults($val) {
! if ($this->multiple) {
$this->value = $val;
! } elseif (isset($val) && (!$this->value || $val==$this->value)) {
$this->checked=1;
! } else {
$this->checked=0;
+ }
}
Index: of_file.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_file.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_file.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_file.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 16,28 ****
}
! function self_get($val,$which, &$count) {
$str = "";
!
$str .= "<input type='hidden' name='MAX_FILE_SIZE' value=$this->size>\n";
$str .= "<input type='file' name='$this->name'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
$count = 2;
return $str;
--- 16,29 ----
}
! function self_get($val, $which, &$count) {
$str = "";
!
$str .= "<input type='hidden' name='MAX_FILE_SIZE' value=$this->size>\n";
$str .= "<input type='file' name='$this->name'";
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
$count = 2;
return $str;
Index: of_radio.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_radio.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_radio.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_radio.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 1,5 ****
<?php
/* OOHForms: radio
! *
* Copyright (c) 1998 by Jay Bloodworth
*
--- 1,5 ----
<?php
/* OOHForms: radio
! *
* Copyright (c) 1998 by Jay Bloodworth
*
***************
*** 18,27 ****
function self_get($val, $which, &$count) {
$str = "";
!
$str .= "<input type='radio' name='$this->name' value='$val'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
! if ($this->value==$val)
$str .= " checked";
$str .= ">";
--- 18,29 ----
function self_get($val, $which, &$count) {
$str = "";
!
$str .= "<input type='radio' name='$this->name' value='$val'";
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
! }
! if ($this->value==$val) {
$str .= " checked";
+ }
$str .= ">";
***************
*** 30,36 ****
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
!
$x = 0;
if ($this->value==$val) {
--- 32,38 ----
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
if ($this->value==$val) {
***************
*** 42,46 ****
}
$str .= "<tr><td> </tr></td></table>\n";
!
$count = $x;
return $str;
--- 44,48 ----
}
$str .= "<tr><td> </tr></td></table>\n";
!
$count = $x;
return $str;
***************
*** 49,53 ****
function self_get_js($ndx_array) {
$str = "";
!
if ($this->valid_e) {
$n = $this->name;
--- 51,55 ----
function self_get_js($ndx_array) {
$str = "";
!
if ($this->valid_e) {
$n = $this->name;
***************
*** 67,71 ****
function self_validate($val) {
! if ($this->valid_e && !isset($val)) return $this->valid_e;
return false;
}
--- 69,75 ----
function self_validate($val) {
! if ($this->valid_e && !isset($val)) {
! return $this->valid_e;
! }
return false;
}
Index: of_select.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_select.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_select.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_select.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 16,25 ****
function of_select($a) {
$this->setup_element($a);
! if ($a["type"]=="select multiple") $this->multiple=1;
}
!
! function self_get($val,$which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
--- 16,27 ----
function of_select($a) {
$this->setup_element($a);
! if ($a["type"]=="select multiple") {
! $this->multiple=1;
! }
}
!
! function self_get($val, $which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
***************
*** 30,51 ****
}
$str .= "<$t name='$n'";
! if ($this->size)
$str .= " size='$this->size'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
reset($this->options);
! while (list($k,$o) = each($this->options)) {
$str .= "<option";
! if (is_array($o))
$str .= " value='" . $o["value"] . "'";
! if (!$this->multiple && ($this->value==$o["value"] || $this->value==$o))
$str .= " selected";
! elseif ($this->multiple && is_array($this->value)) {
reset($this->value);
! while (list($tk,$v) = each($this->value)) {
! if ($v==$o["value"] || $v==$o) {
! $str .= " selected"; break;
}
}
--- 32,56 ----
}
$str .= "<$t name='$n'";
! if ($this->size) {
$str .= " size='$this->size'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
reset($this->options);
! while (list($k, $o) = each($this->options)) {
$str .= "<option";
! if (is_array($o)) {
$str .= " value='" . $o["value"] . "'";
! }
! if (!$this->multiple && ($this->value==$o["value"] || $this->value==$o)) {
$str .= " selected";
! } elseif ($this->multiple && is_array($this->value)) {
reset($this->value);
! while (list($tk, $v) = each($this->value)) {
! if ($v==$o["value"] || $v==$o) {
! $str .= " selected"; break;
}
}
***************
*** 54,65 ****
}
$str .= "</select>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
!
$x = 0;
$n = $this->name . ($this->multiple ? "[]" : "");
--- 59,70 ----
}
$str .= "</select>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
$n = $this->name . ($this->multiple ? "[]" : "");
***************
*** 67,74 ****
$str .= "<table border=1>\n";
reset($v_array);
! while (list($tk,$tv) = each($v_array)) {
reset($this->options);
! while (list($k,$v) = each($this->options)) {
! if ((is_array($v) &&
(($tmp=$v["value"])==$tv || $v["label"]==$tv))
|| ($tmp=$v)==$tv) {
--- 72,79 ----
$str .= "<table border=1>\n";
reset($v_array);
! while (list($tk, $tv) = each($v_array)) {
reset($this->options);
! while (list($k, $v) = each($this->options)) {
! if ((is_array($v) &&
(($tmp=$v["value"])==$tv || $v["label"]==$tv))
|| ($tmp=$v)==$tv) {
***************
*** 80,84 ****
}
$str .= "</table>\n";
!
$count = $x;
return $str;
--- 85,89 ----
}
$str .= "</table>\n";
!
$count = $x;
return $str;
***************
*** 87,91 ****
function self_get_js($ndx_array) {
$str = "";
!
if (!$this->multiple && $this->valid_e) {
$str .= "if (f.$this->name.selectedIndex == 0) {\n";
--- 92,96 ----
function self_get_js($ndx_array) {
$str = "";
!
if (!$this->multiple && $this->valid_e) {
$str .= "if (f.$this->name.selectedIndex == 0) {\n";
***************
*** 95,99 ****
$str .= "}\n";
}
!
return $str;
}
--- 100,104 ----
$str .= "}\n";
}
!
return $str;
}
***************
*** 103,107 ****
reset($this->options);
$o = current($this->options);
! if ($val==$o["value"] || $val==$o) return $this->valid_e;
}
return false;
--- 108,114 ----
reset($this->options);
$o = current($this->options);
! if ($val==$o["value"] || $val==$o) {
! return $this->valid_e;
! }
}
return false;
Index: of_text.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_text.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_text.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_text.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 21,61 ****
function of_text($a) {
$this->setup_element($a);
! if ($a["type"]=="password")
$this->pass=1;
}
! function self_get($val,$which, &$count) {
$str = "";
!
! if (is_array($this->value))
$v = htmlspecialchars($this->value[$which]);
! else
$v = htmlspecialchars($this->value);
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input name='$n' value=\"$v\"";
$str .= ($this->pass)? " type='password'" : " type='text'";
! if ($this->maxlength)
$str .= " maxlength='$this->maxlength'";
! if ($this->size)
$str .= " size='$this->size'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
$count = 1;
return $str;
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
!
! if (is_array($this->value))
$v = $this->value[$which];
! else
$v = $this->value;
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input type='hidden' name='$n' value='$v'>\n";
$str .= "<table border=1><tr><td>$v</td></tr></table>\n";
!
$count = 1;
return $str;
--- 21,67 ----
function of_text($a) {
$this->setup_element($a);
! if ($a["type"]=="password") {
$this->pass=1;
+ }
}
! function self_get($val, $which, &$count) {
$str = "";
!
! if (is_array($this->value)) {
$v = htmlspecialchars($this->value[$which]);
! } else {
$v = htmlspecialchars($this->value);
+ }
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input name='$n' value=\"$v\"";
$str .= ($this->pass)? " type='password'" : " type='text'";
! if ($this->maxlength) {
$str .= " maxlength='$this->maxlength'";
! }
! if ($this->size) {
$str .= " size='$this->size'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
$count = 1;
return $str;
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
!
! if (is_array($this->value)) {
$v = $this->value[$which];
! } else {
$v = $this->value;
+ }
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input type='hidden' name='$n' value='$v'>\n";
$str .= "<table border=1><tr><td>$v</td></tr></table>\n";
!
$count = 1;
return $str;
***************
*** 64,70 ****
function self_get_js($ndx_array) {
$str = "";
!
reset($ndx_array);
! while (list($k,$n) = each($ndx_array)) {
if ($this->length_e) {
$str .= "if (f.elements[${n}].value.length < $this->minlength) {\n";
--- 70,76 ----
function self_get_js($ndx_array) {
$str = "";
!
reset($ndx_array);
! while (list($k, $n) = each($ndx_array)) {
if ($this->length_e) {
$str .= "if (f.elements[${n}].value.length < $this->minlength) {\n";
***************
*** 76,80 ****
$flags = ($this->icase ? "gi" : "g");
$str .= "if (window.RegExp) {\n";
! $str .= " var reg = new RegExp(\"$this->valid_regex\",\"$flags\");\n";
$str .= " if (!reg.test(f.elements[${n}].value)) {\n";
$str .= " alert(\"$this->valid_e\");\n";
--- 82,86 ----
$flags = ($this->icase ? "gi" : "g");
$str .= "if (window.RegExp) {\n";
! $str .= " var reg = new RegExp(\"$this->valid_regex\", \"$flags\");\n";
$str .= " if (!reg.test(f.elements[${n}].value)) {\n";
$str .= " alert(\"$this->valid_e\");\n";
***************
*** 84,105 ****
}
}
!
return $str;
}
function self_validate($val) {
! if (!is_array($val)) $val = array($val);
reset($val);
! while (list($k,$v) = each($val)) {
! if ($this->length_e && (strlen($v) < $this->minlength))
return $this->length_e;
! if ($this->valid_e && (($this->icase &&
! !eregi($this->valid_regex,$v)) ||
(!$this->icase &&
! !ereg($this->valid_regex,$v))))
return $this->valid_e;
}
return false;
! }
} // end TEXT
--- 90,115 ----
}
}
!
return $str;
}
function self_validate($val) {
! if (!is_array($val)) {
! $val = array($val);
! }
reset($val);
! while (list($k, $v) = each($val)) {
! if ($this->length_e && (strlen($v) < $this->minlength)) {
return $this->length_e;
! }
! if ($this->valid_e && (($this->icase &&
! !eregi($this->valid_regex, $v)) ||
(!$this->icase &&
! !ereg($this->valid_regex, $v)))) {
return $this->valid_e;
+ }
}
return false;
! }
} // end TEXT
Index: of_textarea.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_textarea.inc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** of_textarea.inc 9 Aug 2001 01:07:13 -0000 1.2
--- of_textarea.inc 28 Apr 2002 03:59:32 -0000 1.3
***************
*** 18,36 ****
}
! function self_get($val,$which, &$count) {
$str = "";
$str .= "<textarea name='$this->name'";
$str .= " rows='$this->rows' cols='$this->cols'";
! if ($this->wrap)
$str .= " wrap='$this->wrap'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">" . htmlspecialchars($this->value) ."</textarea>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
$str .= "<input type='hidden' name='$this->name'";
--- 18,38 ----
}
! function self_get($val, $which, &$count) {
$str = "";
$str .= "<textarea name='$this->name'";
$str .= " rows='$this->rows' cols='$this->cols'";
! if ($this->wrap) {
$str .= " wrap='$this->wrap'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">" . htmlspecialchars($this->value) ."</textarea>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
$str .= "<input type='hidden' name='$this->name'";
***************
*** 41,45 ****
$str .= nl2br($this->value);
$str .= "\n</td></tr></table>\n";
!
$count = 1;
return $str;
--- 43,47 ----
$str .= nl2br($this->value);
$str .= "\n</td></tr></table>\n";
!
$count = 1;
return $str;
Index: oohforms.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/oohforms.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** oohforms.inc 19 Mar 2002 22:32:25 -0000 1.3
--- oohforms.inc 28 Apr 2002 03:59:32 -0000 1.4
***************
*** 1,9 ****
<?php
/* OOH! Forms!
! *
* Object Oriented HTML Forms
*
* Copyright (c) 1998 by Jay Bloodworth
! *
* $Id$
*/
--- 1,9 ----
<?php
/* OOH! Forms!
! *
* Object Oriented HTML Forms
*
* Copyright (c) 1998 by Jay Bloodworth
! *
* $Id$
*/
***************
*** 15,28 ****
var $multiple;
var $extrahtml;
!
! function marshal_dispatch($m,$func) {
$vname = $this->name;
global $$vname;
return $this->$func($$vname);
}
!
function self_get($val, $which, &$count) {
}
!
function self_show($val, $which) {
$count = 0;
--- 15,28 ----
var $multiple;
var $extrahtml;
!
! function marshal_dispatch($m, $func) {
$vname = $this->name;
global $$vname;
return $this->$func($$vname);
}
!
function self_get($val, $which, &$count) {
}
!
function self_show($val, $which) {
$count = 0;
***************
*** 47,51 ****
function self_get_js($ndx_array) {
}
!
function self_print_js($ndx_array) {
print $this->self_get_js($ndx_array);
--- 47,51 ----
function self_get_js($ndx_array) {
}
!
function self_print_js($ndx_array) {
print $this->self_get_js($ndx_array);
***************
*** 54,58 ****
// Note that this function is generally quite simple since
// most of the work of dealing with different types of values
! // is now done in show_self. It still needs to be overidable,
// however, for elements like checkbox that deal with state
// differently
--- 54,58 ----
// Note that this function is generally quite simple since
// most of the work of dealing with different types of values
! // is now done in show_self. It still needs to be overridable,
// however, for elements like checkbox that deal with state
// differently
***************
*** 68,74 ****
"extra_html"=>"extrahtml");
reset($a);
! while (list($k,$v) = each($a)) {
! if ($cv_tab[$k]=="ignore") continue;
! else $k = ($cv_tab[$k] ? $cv_tab[$k] : $k);
$this->$k = $v;
}
--- 68,77 ----
"extra_html"=>"extrahtml");
reset($a);
! while (list($k, $v) = each($a)) {
! if ($cv_tab[$k]=="ignore") {
! continue;
! } else {
! $k = ($cv_tab[$k] ? $cv_tab[$k] : $k);
! }
$this->$k = $v;
}
***************
*** 85,89 ****
}
! function self_get($val,$which, &$count) {
$str = "";
--- 88,92 ----
}
! function self_get($val, $which, &$count) {
$str = "";
***************
*** 91,101 ****
$n = $this->name . ($this->multiple ? "[]" : "");
reset($v);
! while (list($k,$tv) = each($v)) {
$str .= "<input type='hidden' name='$n' value='$tv'";
! if ($this->extrahtml)
$str .=" $this->extrahtml";
$str .= ">";
}
!
return $str;
}
--- 94,105 ----
$n = $this->name . ($this->multiple ? "[]" : "");
reset($v);
! while (list($k, $tv) = each($v)) {
$str .= "<input type='hidden' name='$n' value='$tv'";
! if ($this->extrahtml) {
$str .=" $this->extrahtml";
+ }
$str .= ">";
}
!
return $str;
}
***************
*** 112,119 ****
function self_get($val, $which, &$count) {
$str = "<input name='$this->name' type=reset value='$val'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
return $str;
}
--- 116,124 ----
function self_get($val, $which, &$count) {
$str = "<input name='$this->name' type=reset value='$val'";
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
return $str;
}
***************
*** 124,128 ****
var $src;
! function of_submit($a) {
$this->setup_element($a);
}
--- 129,133 ----
var $src;
! function of_submit($a) {
$this->setup_element($a);
}
***************
*** 130,147 ****
function self_get($val, $which, &$count) {
$str = "";
!
$sv = empty($val) ? $this->value : $val;
$str .= "<input name='$this->name' value='$sv'";
! if ($this->src)
$str .= " type='image' src='$this->src'";
! else
$str .= " type='submit'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
return $str;
}
!
function self_load_defaults($val) {
// SUBMIT will not change its value
--- 135,154 ----
function self_get($val, $which, &$count) {
$str = "";
!
$sv = empty($val) ? $this->value : $val;
$str .= "<input name='$this->name' value='$sv'";
! if ($this->src) {
$str .= " type='image' src='$this->src'";
! } else {
$str .= " type='submit'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
return $str;
}
!
function self_load_defaults($val) {
// SUBMIT will not change its value
***************
*** 156,169 ****
var $n;
! function get_start($jvs_name="",$method="",$action="",$target="",$form_name="") {
global $HTTP_SERVER_VARS;
!
$str = "";
!
$this->jvs_name = "";
$this->n = 0;
! if (!$method) $method = "POST";
! if (!$action) $action = $HTTP_SERVER_VARS["PHP_SELF"];
! if (!$target) $target = "_self";
$str .= "<form name='$form_name' ";
--- 163,182 ----
var $n;
! function get_start($jvs_name="", $method="", $action="", $target="", $form_name="") {
global $HTTP_SERVER_VARS;
!
$str = "";
!
$this->jvs_name = "";
$this->n = 0;
! if (!$method) {
! $method = "POST";
! }
! if (!$action) {
! $action = $HTTP_SERVER_VARS["PHP_SELF"];
! }
! if (!$target) {
! $target = "_self";
! }
$str .= "<form name='$form_name' ";
***************
*** 179,200 ****
$str .= " onsubmit=\"return ${jvs_name}_Validator(this)\"";
}
!
$str .= ">";
!
return $str;
}
! function start($jvs_name="",$method="",$action="",$target="",$form_name="") {
! print $this->get_start($jvs_name,$method,$action,$target,$form_name);
}
! function get_finish($after="",$before="") {
global $sess;
$str = "";
!
if ($this->hidden) {
reset($this->hidden);
! while (list($k,$elname) = each($this->hidden))
$str .= $this->get_element($elname);
}
if (is_object($sess) && ($sess->mode == "get")) {
--- 192,214 ----
$str .= " onsubmit=\"return ${jvs_name}_Validator(this)\"";
}
!
$str .= ">";
!
return $str;
}
! function start($jvs_name="", $method="", $action="", $target="", $form_name="") {
! print $this->get_start($jvs_name, $method, $action, $target, $form_name);
}
! function get_finish($after="", $before="") {
global $sess;
$str = "";
!
if ($this->hidden) {
reset($this->hidden);
! while (list($k, $elname) = each($this->hidden)) {
$str .= $this->get_element($elname);
+ }
}
if (is_object($sess) && ($sess->mode == "get")) {
***************
*** 208,245 ****
$str .= "function ${jvs_name}_Validator(f) {\n";
! if (strlen($before))
$str .= "$before\n";
reset($this->elements);
! while (list($k,$elrec) = each($this->elements)) {
$el = $elrec["ob"];
$str .= $el->self_get_js($elrec["ndx_array"]);
}
! if (strlen($after))
$str .= "$after\n";
$str .= "}\n//-->\n</script>";
}
!
return $str;
}
!
! function finish($after="",$before="") {
print $this->get_finish($after, $before);
}
!
function add_element($el) {
! if (!is_array($el))
return false;
!
$cv_tab = array("select multiple"=>"select", "image"=>"submit");
! if ($t = $cv_tab[$el["type"]])
$t = ("of_" . $t);
! else
$t = ("of_" . $el["type"]);
!
// translate names like $foo[int] to $foo{int} so that they can cause no
// harm in $this->elements
# Original match
! # if (preg_match("/(\w+)\[(d+)\]/i", $el[name], $regs)) {
if (ereg("([a-zA-Z_]+)\[([0-9]+)\]", $el["name"], $regs)) {
$el["name"] = sprintf("%s{%s}", $regs[1], $regs[2]);
--- 222,263 ----
$str .= "function ${jvs_name}_Validator(f) {\n";
! if (strlen($before)) {
$str .= "$before\n";
+ }
reset($this->elements);
! while (list($k, $elrec) = each($this->elements)) {
$el = $elrec["ob"];
$str .= $el->self_get_js($elrec["ndx_array"]);
}
! if (strlen($after)) {
$str .= "$after\n";
+ }
$str .= "}\n//-->\n</script>";
}
!
return $str;
}
!
! function finish($after="", $before="") {
print $this->get_finish($after, $before);
}
!
function add_element($el) {
! if (!is_array($el)) {
return false;
! }
!
$cv_tab = array("select multiple"=>"select", "image"=>"submit");
! if ($t = $cv_tab[$el["type"]]) {
$t = ("of_" . $t);
! } else {
$t = ("of_" . $el["type"]);
! }
!
// translate names like $foo[int] to $foo{int} so that they can cause no
// harm in $this->elements
# Original match
! # if (preg_match("/(\w+)\[(d+)\]/i", $el[name], $regs)) {
if (ereg("([a-zA-Z_]+)\[([0-9]+)\]", $el["name"], $regs)) {
$el["name"] = sprintf("%s{%s}", $regs[1], $regs[2]);
***************
*** 248,263 ****
$el = new $t($el);
$el->type = $t; # as suggested by Michael Graham (ma...@th...)
! if ($el->isfile)
$this->isfile = true;
$this->elements[$el->name]["ob"] = $el;
! if ($el->hidden)
$this->hidden[] = $el->name;
}
! function get_element($name,$value=false) {
$str = "";
$x = 0;
$flag_nametranslation = false;
!
// see add_element: translate $foo[int] to $foo{int}
# Original pattern
--- 266,283 ----
$el = new $t($el);
$el->type = $t; # as suggested by Michael Graham (ma...@th...)
! if ($el->isfile) {
$this->isfile = true;
+ }
$this->elements[$el->name]["ob"] = $el;
! if ($el->hidden) {
$this->hidden[] = $el->name;
+ }
}
! function get_element($name, $value=false) {
$str = "";
$x = 0;
$flag_nametranslation = false;
!
// see add_element: translate $foo[int] to $foo{int}
# Original pattern
***************
*** 268,292 ****
$flag_nametranslation = true;
}
-
- if (!isset($this->elements[$name]))
- return false;
! if (!isset($this->elements[$name]["which"]))
$this->elements[$name]["which"] = 0;
!
$el = $this->elements[$name]["ob"];
! if (true == $flag_nametranslation)
! $el->name = $org_name;
! if (false == $value)
! $value = $el->value;
! if ($this->elements[$name]["frozen"])
! $str .= $el->self_get_frozen($value,$this->elements[$name]["which"]++, $x);
! else
! $str .= $el->self_get($value,$this->elements[$name]["which"]++, $x);
$this->elements[$name]["ndx_array"][] = $this->n;
$this->n += $x;
!
return $str;
}
--- 288,317 ----
$flag_nametranslation = true;
}
! if (!isset($this->elements[$name])) {
! return false;
! }
!
! if (!isset($this->elements[$name]["which"])) {
$this->elements[$name]["which"] = 0;
! }
!
$el = $this->elements[$name]["ob"];
! if (true == $flag_nametranslation) {
! $el->name = $org_name;
! }
! if (false == $value) {
! $value = $el->value;
! }
! if ($this->elements[$name]["frozen"]) {
! $str .= $el->self_get_frozen($value, $this->elements[$name]["which"]++, $x);
! } else {
! $str .= $el->self_get($value, $this->elements[$name]["which"]++, $x);
! }
$this->elements[$name]["ndx_array"][] = $this->n;
$this->n += $x;
!
return $str;
}
***************
*** 308,312 ****
}
! function validate($default=false,$vallist="") {
if ($vallist) {
reset($vallist);
--- 333,337 ----
}
! function validate($default=false, $vallist="") {
if ($vallist) {
reset($vallist);
***************
*** 318,323 ****
while ($elrec) {
$el = $elrec["ob"];
! if ($res = $el->marshal_dispatch($this->method,"self_validate"))
! return $res;
if ($vallist) {
next($vallist);
--- 343,349 ----
while ($elrec) {
$el = $elrec["ob"];
! if ($res = $el->marshal_dispatch($this->method, "self_validate")) {
! return $res;
! }
if ($vallist) {
next($vallist);
***************
*** 341,345 ****
while ($elrec) {
$el = $elrec["ob"];
! $el->marshal_dispatch($this->method,"self_load_defaults");
$this->elements[$el->name]["ob"] = $el; // no refs -> must copy back
if ($deflist) {
--- 367,371 ----
while ($elrec) {
$el = $elrec["ob"];
! $el->marshal_dispatch($this->method, "self_load_defaults");
$this->elements[$el->name]["ob"] = $el; // no refs -> must copy back
if ($deflist) {
|
|
From: Richard A. <ric...@us...> - 2002-04-28 19:40:06
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv19284
Modified Files:
table.inc
Log Message:
Add option to pass full row data to table_row_open. Default is to pass column names, as was the behaviour prior to this change.
Delete trailing whitespace
Index: table.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/table.inc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** table.inc 25 Apr 2002 04:55:34 -0000 1.4
--- table.inc 28 Apr 2002 08:13:58 -0000 1.5
***************
*** 8,27 ****
*
* $Id$
! *
* History: 990617: Modularized entire table class. Modularity breaks larger
! * objects into smaller, autonomous objects in order to
! * exercise OOP requirements of code reuse. This give
! * programmers the ability to use the high-level code, or
* get down and dirty with the low-level code.
! * Everything I have changed should maintain backwards
* compatibility, except for show_table_heading_row_result(),
[...1061 lines suppressed...]
--- 970,975 ----
# Function : table_row_add_extra
#--------------------------------------------------------------------------
! # Purpose : Virtual function for derived classes. This function is called
! # after all cells have been created. It allows the programmer to
# add additional HTML code to the row before it is closed.
# Arguments: $row
***************
*** 958,962 ****
# $data
# $class - [optional] Used for CSS control.
! # Returns :
# Comments :
# History :
--- 977,981 ----
# $data
# $class - [optional] Used for CSS control.
! # Returns :
# Comments :
# History :
|
|
From: Richard A. <ric...@us...> - 2002-04-26 12:30:08
|
Update of /cvsroot/phplib/php-lib/php/html
In directory usw-pr-cvs1:/tmp/cvs-serv29455
Modified Files:
menu.inc
Log Message:
Sync with -stable
Index: menu.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib/php/html/menu.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** menu.inc 20 Aug 2001 06:38:10 -0000 1.3
--- menu.inc 26 Apr 2002 12:30:05 -0000 1.4
***************
*** 54,61 ****
*/
function get() {
! global $PHP_SELF;
# Determine normalized current position in tree
! $this->map = $this->normalize_pos($PHP_SELF);
# Determine menu levels up from current position
--- 54,61 ----
*/
function get() {
! global $HTTP_SERVER_VARS;
# Determine normalized current position in tree
! $this->map = $this->normalize_pos($HTTP_SERVER_VARS["PHP_SELF"]);
# Determine menu levels up from current position
***************
*** 169,177 ****
*/
function get_title() {
! global $PHP_SELF;
$this->title = "";
# Determine normalized current position in tree
! $this->map = $this->normalize_pos($PHP_SELF);
# Determine menu levels up from current position
--- 169,177 ----
*/
function get_title() {
! global $HTTP_SERVER_VARS;
$this->title = "";
# Determine normalized current position in tree
! $this->map = $this->normalize_pos($HTTP_SERVER_VARS["PHP_SELF"]);
# Determine menu levels up from current position
***************
*** 295,298 ****
--- 295,299 ----
while(list($k, $v) = each($this->urlmap)) {
$base = dirname($v);
+ $base = str_replace("\\","/",$base);
if ($base == "/") {
$base = "";
|
|
From: Richard A. <ric...@us...> - 2002-04-26 12:29:43
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv29407
Modified Files:
menu.inc
Log Message:
Bug #488605 - replace \ with / after dirname.
Note: I don't have a Windows box, so this is untested.
Index: menu.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/menu.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** menu.inc 19 Mar 2002 22:32:25 -0000 1.3
--- menu.inc 26 Apr 2002 12:29:40 -0000 1.4
***************
*** 295,298 ****
--- 295,299 ----
while(list($k, $v) = each($this->urlmap)) {
$base = dirname($v);
+ $base = str_replace("\\","/",$base);
if ($base == "/") {
$base = "";
|
|
From: Richard A. <ric...@us...> - 2002-04-25 12:53:42
|
Update of /cvsroot/phplib/php-lib/php/ext
In directory usw-pr-cvs1:/tmp/cvs-serv4500a
Modified Files:
template.inc
Log Message:
more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib/php/ext/template.inc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** template.inc 25 Apr 2002 11:59:46 -0000 1.7
--- template.inc 25 Apr 2002 12:53:38 -0000 1.8
***************
*** 30,36 ****
* in finish, the replacement string referenced an unset variable (rha)
* loadfile would try to load a file if the varval had been set to "" (rha)
- * '$n' in variable values was being stripped by subst in PHP 4.0.4+ (John Mandeville)
- * '\n' was also being stripped. Fix by replacing with &#(36|92); in set_var and unreplacing in finish (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
*
*
--- 30,35 ----
* in finish, the replacement string referenced an unset variable (rha)
* loadfile would try to load a file if the varval had been set to "" (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
+ * more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings (rha)
*
*
***************
*** 352,356 ****
printf("<b>set_var:</b> (with scalar) <b>%s</b> = '%s'<br>\n", $varname, htmlentities($value));
}
- $value = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $value);
$this->varkeys[$varname] = "/".$this->varname($varname)."/";
if ($append && isset($this->varvals[$varname])) {
--- 351,354 ----
***************
*** 367,371 ****
printf("<b>set_var:</b> (with array) <b>%s</b> = '%s'<br>\n", $k, htmlentities($v));
}
- $v = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $v);
$this->varkeys[$k] = "/".$this->varname($k)."/";
if ($append && isset($this->varvals[$k])) {
--- 365,368 ----
***************
*** 396,399 ****
--- 393,397 ----
*/
function subst($varname) {
+ $varvals_quoted = array();
if ($this->debug & 4) {
echo "<p><b>subst:</b> varname = $varname</p>\n";
***************
*** 404,409 ****
}
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $this->varvals, $str);
return $str;
}
--- 402,413 ----
}
+ // quote the replacement strings to prevent bogus stripping of special chars
+ reset($this->varvals);
+ while(list($k, $v) = each($this->varvals)) {
+ $varvals_quoted[$k] = preg_replace(array('/\\\\/', '/\$/'), array('\\\\\\\\', '\\\\$'), $v);
+ }
+
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $varvals_quoted, $str);
return $str;
}
***************
*** 678,682 ****
}
- $str = preg_replace(array('/$([0-9])/', '/\([0-9])/'), array('$\1', '\\\1'), $str);
return $str;
}
--- 682,685 ----
|
|
From: Richard A. <ric...@us...> - 2002-04-25 12:49:20
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv2803
Modified Files:
template.inc
Log Message:
more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/template.inc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** template.inc 25 Apr 2002 11:56:40 -0000 1.10
--- template.inc 25 Apr 2002 12:49:17 -0000 1.11
***************
*** 31,37 ****
* in finish, the replacement string referenced an unset variable (rha)
* loadfile would try to load a file if the varval had been set to "" (rha)
- * '$n' in variable values was being stripped by subst in PHP 4.0.4+ (John Mandeville)
- * '\n' was also being stripped. Fix by replacing with &#(36|92); in set_var and unreplacing in finish (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
*
*/
--- 31,36 ----
* in finish, the replacement string referenced an unset variable (rha)
* loadfile would try to load a file if the varval had been set to "" (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
+ * more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings (rha)
*
*/
***************
*** 166,170 ****
if (!empty($varname)) {
if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
- $value = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $value);
$this->varkeys[$varname] = "/".$this->varname($varname)."/";
$this->varvals[$varname] = $value;
--- 165,168 ----
***************
*** 175,179 ****
if (!empty($k)) {
if ($this->debug) print "array: set *$k* to *$v*<br>\n";
- $v = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $v);
$this->varkeys[$k] = "/".$this->varname($k)."/";
$this->varvals[$k] = $v;
--- 173,176 ----
***************
*** 189,192 ****
--- 186,190 ----
*/
function subst($varname) {
+ $varvals_quoted = array();
if (!$this->loadfile($varname)) {
$this->halt("subst: unable to load $varname.");
***************
*** 194,199 ****
}
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $this->varvals, $str);
return $str;
}
--- 192,203 ----
}
+ // quote the replacement strings to prevent bogus stripping of special chars
+ reset($this->varvals);
+ while(list($k, $v) = each($this->varvals)) {
+ $varvals_quoted[$k] = preg_replace(array('/\\\\/', '/\$/'), array('\\\\\\\\', '\\\\$'), $v);
+ }
+
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $varvals_quoted, $str);
return $str;
}
***************
*** 337,341 ****
}
- $str = preg_replace(array('/$([0-9])/', '/\([0-9])/'), array('$\1', '\\\1'), $str);
return $str;
}
--- 341,344 ----
|
|
From: Richard A. <ric...@us...> - 2002-04-25 11:59:50
|
Update of /cvsroot/phplib/php-lib/php/ext
In directory usw-pr-cvs1:/tmp/cvs-serv18192
Modified Files:
template.inc
Log Message:
back out last change
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib/php/ext/template.inc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** template.inc 25 Apr 2002 10:47:59 -0000 1.6
--- template.inc 25 Apr 2002 11:59:46 -0000 1.7
***************
*** 33,37 ****
* '\n' was also being stripped. Fix by replacing with &#(36|92); in set_var and unreplacing in finish (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
- * new method of preventing '\' stripping instead of nasty &#(36|92); hack (Scott Lahteine)
*
*
--- 33,36 ----
***************
*** 353,356 ****
--- 352,356 ----
printf("<b>set_var:</b> (with scalar) <b>%s</b> = '%s'<br>\n", $varname, htmlentities($value));
}
+ $value = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $value);
$this->varkeys[$varname] = "/".$this->varname($varname)."/";
if ($append && isset($this->varvals[$varname])) {
***************
*** 367,370 ****
--- 367,371 ----
printf("<b>set_var:</b> (with array) <b>%s</b> = '%s'<br>\n", $k, htmlentities($v));
}
+ $v = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $v);
$this->varkeys[$k] = "/".$this->varname($k)."/";
if ($append && isset($this->varvals[$k])) {
***************
*** 395,399 ****
*/
function subst($varname) {
- $varvals_quoted = array();
if ($this->debug & 4) {
echo "<p><b>subst:</b> varname = $varname</p>\n";
--- 396,399 ----
***************
*** 404,414 ****
}
- // quote the replacement strings to prevent bogus stripping of special chars
- while(list($k, $v) = each($this->varvals)) {
- $varvals_quoted[$k] = preg_quote($v);
- }
-
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $varvals_quoted, $str);
return $str;
}
--- 404,409 ----
}
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $this->varvals, $str);
return $str;
}
***************
*** 683,686 ****
--- 678,682 ----
}
+ $str = preg_replace(array('/$([0-9])/', '/\([0-9])/'), array('$\1', '\\\1'), $str);
return $str;
}
|
|
From: Richard A. <ric...@us...> - 2002-04-25 11:56:44
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv17308
Modified Files:
template.inc
Log Message:
back out last change
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/template.inc,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** template.inc 25 Apr 2002 10:47:20 -0000 1.9
--- template.inc 25 Apr 2002 11:56:40 -0000 1.10
***************
*** 34,38 ****
* '\n' was also being stripped. Fix by replacing with &#(36|92); in set_var and unreplacing in finish (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
- * new method of preventing '\' stripping instead of nasty &#(36|92); hack (Scott Lahteine)
*
*/
--- 34,37 ----
***************
*** 167,170 ****
--- 166,170 ----
if (!empty($varname)) {
if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
+ $value = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $value);
$this->varkeys[$varname] = "/".$this->varname($varname)."/";
$this->varvals[$varname] = $value;
***************
*** 175,178 ****
--- 175,179 ----
if (!empty($k)) {
if ($this->debug) print "array: set *$k* to *$v*<br>\n";
+ $v = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $v);
$this->varkeys[$k] = "/".$this->varname($k)."/";
$this->varvals[$k] = $v;
***************
*** 188,192 ****
*/
function subst($varname) {
- $varvals_quoted = array();
if (!$this->loadfile($varname)) {
$this->halt("subst: unable to load $varname.");
--- 189,192 ----
***************
*** 194,204 ****
}
- // quote the replacement strings to prevent bogus stripping of special chars
- while(list($k, $v) = each($this->varvals)) {
- $varvals_quoted[$k] = preg_quote($v);
- }
-
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $varvals_quoted, $str);
return $str;
}
--- 194,199 ----
}
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $this->varvals, $str);
return $str;
}
***************
*** 342,345 ****
--- 337,341 ----
}
+ $str = preg_replace(array('/$([0-9])/', '/\([0-9])/'), array('$\1', '\\\1'), $str);
return $str;
}
|
|
From: Richard A. <ric...@us...> - 2002-04-25 10:48:02
|
Update of /cvsroot/phplib/php-lib/php/ext
In directory usw-pr-cvs1:/tmp/cvs-serv28494
Modified Files:
template.inc
Log Message:
sync with -stable tree
Bug #542612
new method of preventing '\' stripping instead of nasty &#(36|92); hack
(by Scott Lahteine)
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib/php/ext/template.inc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** template.inc 10 Aug 2001 05:31:49 -0000 1.5
--- template.inc 25 Apr 2002 10:47:59 -0000 1.6
***************
*** 33,36 ****
--- 33,37 ----
* '\n' was also being stripped. Fix by replacing with &#(36|92); in set_var and unreplacing in finish (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
+ * new method of preventing '\' stripping instead of nasty &#(36|92); hack (Scott Lahteine)
*
*
***************
*** 352,356 ****
printf("<b>set_var:</b> (with scalar) <b>%s</b> = '%s'<br>\n", $varname, htmlentities($value));
}
- $value = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $value);
$this->varkeys[$varname] = "/".$this->varname($varname)."/";
if ($append && isset($this->varvals[$varname])) {
--- 353,356 ----
***************
*** 367,371 ****
printf("<b>set_var:</b> (with array) <b>%s</b> = '%s'<br>\n", $k, htmlentities($v));
}
- $v = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $v);
$this->varkeys[$k] = "/".$this->varname($k)."/";
if ($append && isset($this->varvals[$k])) {
--- 367,370 ----
***************
*** 396,399 ****
--- 395,399 ----
*/
function subst($varname) {
+ $varvals_quoted = array();
if ($this->debug & 4) {
echo "<p><b>subst:</b> varname = $varname</p>\n";
***************
*** 404,409 ****
}
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $this->varvals, $str);
return $str;
}
--- 404,414 ----
}
+ // quote the replacement strings to prevent bogus stripping of special chars
+ while(list($k, $v) = each($this->varvals)) {
+ $varvals_quoted[$k] = preg_quote($v);
+ }
+
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $varvals_quoted, $str);
return $str;
}
***************
*** 678,682 ****
}
- $str = preg_replace(array('/$([0-9])/', '/\([0-9])/'), array('$\1', '\\\1'), $str);
return $str;
}
--- 683,686 ----
|
|
From: Richard A. <ric...@us...> - 2002-04-25 10:47:24
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv28308
Modified Files:
template.inc
Log Message:
Bug #542612
new method of preventing '\' stripping instead of nasty &#(36|92); hack
(by Scott Lahteine)
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/template.inc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** template.inc 10 Aug 2001 04:57:30 -0000 1.8
--- template.inc 25 Apr 2002 10:47:20 -0000 1.9
***************
*** 34,37 ****
--- 34,38 ----
* '\n' was also being stripped. Fix by replacing with &#(36|92); in set_var and unreplacing in finish (rha)
* in get_undefined, only match non-whitespace in variable tags as in finish. (Layne Weathers & rha)
+ * new method of preventing '\' stripping instead of nasty &#(36|92); hack (Scott Lahteine)
*
*/
***************
*** 166,170 ****
if (!empty($varname)) {
if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
- $value = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $value);
$this->varkeys[$varname] = "/".$this->varname($varname)."/";
$this->varvals[$varname] = $value;
--- 167,170 ----
***************
*** 175,179 ****
if (!empty($k)) {
if ($this->debug) print "array: set *$k* to *$v*<br>\n";
- $v = preg_replace(array('/\$([0-9])/', '/\\\\([0-9])/'), array('$\1', '\\1'), $v);
$this->varkeys[$k] = "/".$this->varname($k)."/";
$this->varvals[$k] = $v;
--- 175,178 ----
***************
*** 189,192 ****
--- 188,192 ----
*/
function subst($varname) {
+ $varvals_quoted = array();
if (!$this->loadfile($varname)) {
$this->halt("subst: unable to load $varname.");
***************
*** 194,199 ****
}
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $this->varvals, $str);
return $str;
}
--- 194,204 ----
}
+ // quote the replacement strings to prevent bogus stripping of special chars
+ while(list($k, $v) = each($this->varvals)) {
+ $varvals_quoted[$k] = preg_quote($v);
+ }
+
$str = $this->get_var($varname);
! $str = preg_replace($this->varkeys, $varvals_quoted, $str);
return $str;
}
***************
*** 337,341 ****
}
- $str = preg_replace(array('/$([0-9])/', '/\([0-9])/'), array('$\1', '\\\1'), $str);
return $str;
}
--- 342,345 ----
|
|
From: Richard A. <ric...@us...> - 2002-04-25 07:37:00
|
Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv3127
Modified Files:
db_mysql.inc
Log Message:
Patch #511458 from Thomas L. Kjeldsen
Addresses two issues:
nextid() does not test if mysql_query fails
Under some circumstances, ie very heavy load, MySQL may fail on at simple SELECT-query. If this happens, nextid() just assumes there is no entry for $seq_name in $this->Seq_Table and tries to create a new entry. It will fail, but $currentid is set to 0 and the subsequent update will immediately set the nextid-value to 1.
halt() does not unlock tables if they are locked
Halt() does not unlock tables before die(). Under heavy load it seems to result in a mass use of http deamons that just end up sleeping - leaving no free http deamons after a short time.
Index: db_mysql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_mysql.inc,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** db_mysql.inc 14 Mar 2002 20:36:43 -0000 1.9
--- db_mysql.inc 25 Apr 2002 07:36:56 -0000 1.10
***************
*** 40,44 ****
var $Link_ID = 0;
var $Query_ID = 0;
!
/* public: constructor */
--- 40,45 ----
var $Link_ID = 0;
var $Query_ID = 0;
!
! var $locked = false; ## set to true while we have a lock
/* public: constructor */
***************
*** 192,199 ****
--- 193,205 ----
return false;
}
+ $this->locked = true;
return true;
}
function unlock() {
+
+ // set before unlock to avoid potential loop
+ $this->locked = false;
+
if(!$this->query("unlock tables")) {
$this->halt("unlock() failed.");
***************
*** 247,250 ****
--- 253,260 ----
$seq_name);
$id = @mysql_query($q, $this->Link_ID);
+ if (!$id) {
+ $this->halt('query failed in nextid: '.$q);
+ return 0;
+ }
$res = @mysql_fetch_array($id);
***************
*** 257,260 ****
--- 267,274 ----
$currentid);
$id = @mysql_query($q, $this->Link_ID);
+ if (!$id) {
+ $this->halt('query failed in nextid: '.$q);
+ return 0;
+ }
} else {
$currentid = $res["nextid"];
***************
*** 266,269 ****
--- 280,287 ----
$seq_name);
$id = @mysql_query($q, $this->Link_ID);
+ if (!$id) {
+ $this->halt('query failed in nextid: '.$q);
+ return 0;
+ }
$this->unlock();
} else {
***************
*** 374,377 ****
--- 392,400 ----
$this->Error = @mysql_error($this->Link_ID);
$this->Errno = @mysql_errno($this->Link_ID);
+
+ if ($this->locked) {
+ $this->unlock();
+ }
+
if ($this->Halt_On_Error == "no")
return;
|