PHP 4.0 Bug #8434 Updated: PHP has encountered an Access Violation at 01292466
| From: | dbeu@php.net | Date: | Mon, 08 Jan 2001 13:59:28 +0000 |
| Subject: | PHP 4.0 Bug #8434 Updated: PHP has encountered an Access Violation at 01292466 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-43371@lists.php.net to get a copy of this message | ||
ID: 8434
Updated by: dbeu
Reported By: svanpoeck@mailplanet.net
Old-Status: Open
Status: Feedback
Bug Type: IIS related
Assigned To:
Comments:
can you please cut down the code to the min. needed to reproduce it?
Previous Comments:
---------------------------------------------------------------------------
[2000-12-27 07:27:56] svanpoeck@mailplanet.net
Still having same bug in PHP-4.0.4 Win ISAPI module...
Randomly showing error "PHP has encountered an Access Violation at 01292466" (the number
changes every time the error occurs) upon call to PHP ISAPI engin. The error can occur on any of my
30+ scripts on this site.
This problem persists since at least 3.0.3pl1. When will this nightmare be over ?? I have to switch
back to a CGI environment, which slows down PHP execution far too much...
Restarting IISAdmin does get the engine running properly again... until the next "Access
Violation"...
Almost all of the bug reports concerning this error have not even been assigned to anyone. Does this
mean you're not going to try to get rid of this problem ?
If you have any questions regarding the script below, do not hesitate to contact me!
All in all: thanks for bringing us PHP and keep up the good work !
Steven VAN POECK
One piece of code on which the error occurs:
--------------------------------------------
include( "common.php" );
// Call session (if any)
session_save_path("tmp");
session_start();
// Empty basket
$sql = "DELETE FROM panier WHERE client_id='$user'";
mysql_pconnect( $db_host, $db_user, $db_pass );
$result = mysql_db_query( $db_dag, $sql );
check_error( $result );
// Set user state to "D" (deconnected)
$sql = "UPDATE client SET state='D' WHERE id='$user'";
mysql_pconnect( $db_host, $db_user, $db_pass );
$result = mysql_db_query( $db_dag, $sql );
check_error( $result );
// destroy session (if any)
session_destroy();
// Get highest client ID
$sql = "SELECT MAX(id) AS max_id FROM client";
mysql_pconnect( $db_host, $db_user, $db_pass );
$result = mysql_db_query( $db_dag, $sql );
check_error( $result );
$data = mysql_fetch_object( $result );
$last_client = $data->max_id;
// Define new client ID
if( substr($last_client, 1) < 50000000 ){
$numero_client = P50000101; /* For very first client */
}else{
$numero_client = "P".(substr($last_client, 1) + 1);
}
// Get password of the day
$today = date("Y-m-d", time());
$mdp = create_pass();
// Define timestamp for expiration time
$exp_time = time()+1800;
$sql = "INSERT INTO client VALUES( '$numero_client', PASSWORD('$mdp'),
'$today', '$today', '0', 'DP', '$exp_time',
'C')";
mysql_pconnect( $db_host, $db_user, $db_pass );
$result = mysql_db_query( $db_dag, $sql );
check_error( $result );
// Initialise session
session_save_path( "tmp" );
session_register("user");
$user = $numero_client;
session_register("key");
$key = $mdp;
session_register("type");
$type = "p_";
session_register( "cadeau_1" );
$cadeau_1 = 0;
// Send user to the site
header(
"Location:/pcgi/display_rubr.php?".SID."&rubr=".urlencode(${$type."rubr_def"})
);
-------------------------------------------------------
The function "create_pass()":
-------------------------------------------------------
function create_pass(){
global $db_host, $db_user, $db_pass, $db_adm;
$alpha = array('a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q',
'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z');
$n = 0;
$flag = 0;
// Select all passwords
$today = date("Y-m-d", time());
$sql = "SELECT * FROM mdp_jour";
mysql_pconnect( $db_host, $db_user, $db_pass );
$result = mysql_db_query( $db_adm, $sql );
while( $data = mysql_fetch_object( $result ) ){
// Verify if today's password already exists
// If so, use that one
if( date("Y-m-d", time()) == $data->date ){
$pass = $data->mdp;
$flag = 1;
}
}
if( $flag != 1){
// No password for today yet
// So have to make one
while( $n < 4 ){
reset( $alpha );
mt_srand((double)microtime()*1000000);
$pass = mt_rand(0, 25);
$password .= $alpha[$pass];
$n++;
}
// Select all passwords
$sql = "SELECT * FROM mdp_jour";
mysql_pconnect( $db_host, $db_user, $db_pass );
$result = mysql_db_query( $db_adm, $sql );
while( $data = mysql_fetch_object( $result ) ){
// Verify if created password already exists
// If so, recreate another password
if( eregi( $data->mdp, $password ) ){
create_pass();
}
}
// If not, generated password is unique. Write to DB
if( $flag == 0 ){
$pass = $password;
$sql = "INSERT INTO mdp_jour VALUES('', '$today',
'$password')";
mysql_pconnect( $db_host, $db_user, $db_pass );
$result = mysql_db_query( $db_adm, $sql );
check_error( $result );
}
}
return $pass;
}
----------------------------------------------------------
You'll need 2 databases:
DB1 ($db_dag in the script):
------- Table "panier":
Field Type Null Key Default Extra Privileges
id int(11) unsigned zerofill PRI auto_increment select,insert,update,references
client_id varchar(10) 0 select,insert,update,references
produit_ref varchar(50) select,insert,update,references
produit_prix_ttc float(5,2) unsigned 0 select,insert,update,references
prix_gift enum('1','0') 1 select,insert,update,references
produit_n int(3) unsigned 0 select,insert,update,references
expire int(13) 0 select,insert,update,references
-------- Table "client":
Field Type Null Key Default Extra Privileges
id varchar(10) PRI select,insert,update,references
pass varchar(255) select,insert,update,references
crea date 0000-00-00 select,insert,update,references
mod date 0000-00-00 select,insert,update,references
visits int(5) unsigned zerofill MUL 0 select,insert,update,references
type enum('DP','DAG') DP select,insert,update,references
expire int(13) 0 select,insert,update,references
state enum('C','D') D select,insert,update,references
DB2 ($db_adm in the script):
------- Table "mdp_jour":
Field Type Null Key Default Extra Privileges
id int(5) unsigned zerofill 0 select,insert,update,references
date date 0000-00-00 select,insert,update,references
mdp char(5) select,insert,update,references
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=8434