cvs: bugtracker /htdocs .htaccess config.php /includes cache.php database_mysqli.php user.php /includes/cache users.php /template/generic/user
convert.php verify.php

From: Date: Sun, 10 Aug 2008 23:39:58 +0000
Subject: cvs: bugtracker /htdocs .htaccess config.php /includes cache.php database_mysqli.php user.php /includes/cache users.php /template/generic/user
convert.php verify.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-2363@lists.php.net to get a copy of this message
bcarlyon Sun Aug 10 23:39:58 2008 UTC Modified files: /bugtracker/htdocs .htaccess config.php /bugtracker/includes cache.php database_mysqli.php user.php /bugtracker/includes/cache users.php /bugtracker/template/generic/user convert.php verify.php Log: Rejigged the cache control, and cache single element return, (need to add return element) Fixed convert account

http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/.htaccess?r1=1.5&r2=1.6&diff_format=u Index: bugtracker/htdocs/.htaccess diff -u bugtracker/htdocs/.htaccess:1.5 bugtracker/htdocs/.htaccess:1.6 --- bugtracker/htdocs/.htaccess:1.5 Sun Aug 10 21:38:40 2008 +++ bugtracker/htdocs/.htaccess Sun Aug 10 23:39:57 2008 @@ -4,6 +4,7 @@ RewriteRule offline.html offline.html [L] RewriteRule cache.php cache.php [L] RewriteRule test.html test.html [L] +RewriteRule cake.php cake.php [L] #smaller rewrites, higher priority you know RewriteCond %{REQUEST_URI} !=/bug/comment/ http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/config.php?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/htdocs/config.php diff -u bugtracker/htdocs/config.php:1.3 bugtracker/htdocs/config.php:1.4 --- bugtracker/htdocs/config.php:1.3 Wed Jul 16 04:19:20 2008 +++ bugtracker/htdocs/config.php Sun Aug 10 23:39:57 2008 @@ -10,8 +10,12 @@ ); define('CONFIG_ARRAY','configuration'); -define('USER_TABLE','user'); -define('TEMP_USER_TABLE','temp_account'); +define('USER_TABLE', 'user'); +define('TEMP_USER_TABLE', 'temp_account'); + +// partial implemneted define +define('BUG_TABLE', 'bug'); +define('COMMENT_TABLE', 'bug_comment'); $recaptcha_key = '6LdlXwAAAAAAAA_SQn5B7hqK8bd3mrBERvmbvsZO'; $recaptcha_prv = '6LdlXwAAAAAAAD5Tvwhyk0I2GKVgJE5UonW3oYDY'; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache.php?r1=1.5&r2=1.6&diff_format=u Index: bugtracker/includes/cache.php diff -u bugtracker/includes/cache.php:1.5 bugtracker/includes/cache.php:1.6 --- bugtracker/includes/cache.php:1.5 Thu Jul 31 13:11:04 2008 +++ bugtracker/includes/cache.php Sun Aug 10 23:39:58 2008 @@ -50,16 +50,19 @@ { $thiscache = $this->$thecache; - if ($ref < 0) + if ($ref < 0 && is_numeric($ref)) { //$ref is negative $ref = sizeof($thiscache) + $ref; } - return $thiscache[$ref]; + if (isset($thiscache[$ref])) + return $thiscache[$ref]; + else + return FALSE; } - //add to cache extend replced + //add to cache extend replced or more better: alias replace function add_to_cache($thecache, $data, $ref = '') { $thiscache = $this->$thecache; http://cvs.php.net/viewvc.cgi/bugtracker/includes/database_mysqli.php?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/includes/database_mysqli.php diff -u bugtracker/includes/database_mysqli.php:1.3 bugtracker/includes/database_mysqli.php:1.4 --- bugtracker/includes/database_mysqli.php:1.3 Wed Jul 16 04:19:20 2008 +++ bugtracker/includes/database_mysqli.php Sun Aug 10 23:39:58 2008 @@ -60,7 +60,7 @@ { $this->insert_id = mysqli_insert_id($this->connect_id); } - else if (substr($query,0,6) == 'UPDATE') + if ( (substr($query,0,6) == 'UPDATE') || (substr($query,0,11) == 'INSERT INTO') || (substr($query,0,11) == 'DELETE FROM') ) { $this->affected_rows = mysqli_affected_rows($this->connect_id); } http://cvs.php.net/viewvc.cgi/bugtracker/includes/user.php?r1=1.8&r2=1.9&diff_format=u Index: bugtracker/includes/user.php diff -u bugtracker/includes/user.php:1.8 bugtracker/includes/user.php:1.9 --- bugtracker/includes/user.php:1.8 Sun Aug 10 21:38:41 2008 +++ bugtracker/includes/user.php Sun Aug 10 23:39:58 2008 @@ -29,7 +29,7 @@ } function temp_account($handle,$email,$password) { - global $db,$user_data,$email_data; + global $db,$cache,$email_data; //first check to see if this temp account exists $handle = 'T' . $handle; $this->handle = $handle; @@ -37,11 +37,16 @@ $exist = FALSE; $safe_handle = TRUE; - if (in_array($handle,$user_data)) + //$users = array(); + $check = $cache->obtain('users',$handle); + //should be an array if true + +// if (is_array($check)) + if ($check['handle'] == $handle) { //then the user handle is in the cache //lets see if the email matches - if ($user_data[$handle]['email'] == $email) + if ($check['email'] == $email) { //then it is the same user $exist = TRUE; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/users.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/includes/cache/users.php diff -u bugtracker/includes/cache/users.php:1.2 bugtracker/includes/cache/users.php:1.3 --- bugtracker/includes/cache/users.php:1.2 Thu Aug 7 13:31:55 2008 +++ bugtracker/includes/cache/users.php Sun Aug 10 23:39:58 2008 @@ -1,10 +1,14 @@ <?php $users["barrycarlyon"]["handle"] = "barrycarlyon"; + $cacher["users"]['barrycarlyon']["handle"] = "barrycarlyon"; $users["barrycarlyon"]["email"] = "barry@barrycarlyon.co.uk"; + $cacher["users"]['barrycarlyon']["email"] = "barry@barrycarlyon.co.uk"; $users["Tlars_strojny"]["handle"] = "Tlars_strojny"; + $cacher["users"]["Tlars_strojny"]["handle"] = "Tlars_strojny"; $users["Tlars_strojny"]["email"] = "lars@strojny.net"; + $cacher["users"]["Tlars_strojny"]["email"] = "lars@strojny.net"; $users["T_"]["handle"] = "T_"; $users["T_"]["email"] = ""; http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/user/convert.php?r1=1.5&r2=1.6&diff_format=u Index: bugtracker/template/generic/user/convert.php diff -u bugtracker/template/generic/user/convert.php:1.5 bugtracker/template/generic/user/convert.php:1.6 --- bugtracker/template/generic/user/convert.php:1.5 Sun Aug 10 21:38:41 2008 +++ bugtracker/template/generic/user/convert.php Sun Aug 10 23:39:58 2008 @@ -6,11 +6,12 @@ $temp_handle = loadvar('temp_handle',''); $redirect_convert = TRUE; -if ($temp_handle) +if ($temp_handle && $user->logged_in_temp) { $user_data = array(); $user_data['temp_handle'] = loadvar('temp_handle',$user->handle); //there is hope that the handle might still be there, assuming the cookie is not invalid now, and no user on the address line + // altered the if above to check for logged_in_temp as per user lib and hence the cookie $user_data['handle'] = loadvar('handle',''); $user_data['password'] = loadvar('password',''); http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/user/verify.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/template/generic/user/verify.php diff -u bugtracker/template/generic/user/verify.php:1.2 bugtracker/template/generic/user/verify.php:1.3 --- bugtracker/template/generic/user/verify.php:1.2 Sun Aug 10 21:38:41 2008 +++ bugtracker/template/generic/user/verify.php Sun Aug 10 23:39:58 2008 @@ -1,8 +1,5 @@ <?php -print 'in veriy'; -exit; - //file to verify a user //this needs to verify to the normal user db in case of a password change between temp user and real user @@ -14,17 +11,22 @@ $tehkey = loadvar('tehkey'); $error = TRUE; +$content = ''; + +$template->page_title .= 'Verify'; +$template->content_title = 'Verify'; if ($email && $tehkey) { //we have everything we need to go for verify - $query = 'SELECT password FROM ' . USER_TABLE . ' WHERE email = \'' . $email . '\''; + $query = 'SELECT handle, password FROM ' . USER_TABLE . ' WHERE email = \'' . $email . '\''; $db->get_data($query); if ($db->total_rows) { //woo exists for this email add. //password is md5ed already $password = $db->fetch_row(); + $handle = $password['handle']; $password = $password['password']; $ourkey = md5( md5($email) . '_' . md5($password) ); @@ -37,15 +39,40 @@ { $content .= '<div id="success">Your verify keys match for this email address'; $content .= '<br />And you account has been updated'; - $content .= '<br />You should now be able to login'; - $content .= '</div>'; + $content .= '<br />One moment whilst we convert your old entires to your new handle, and remove your temporary status'; //update user history + $content .= '<br />Fake log entry'; + //recover old handle + $query = 'SELECT handle FROM ' . TEMP_USER_TABLE . ' WHERE email = \'' . $email . '\''; + $db->get_data($query); + $old = $db->fetch_row(); + $old_handle = $old['handle']; + unset($old); //deregister the temp account $query = 'DELETE FROM ' . TEMP_USER_TABLE . ' WHERE email = \'' . $email . '\''; $db->get_data($query); //no result processing required :-) + if ($db->affected_rows) + $content .= '<br />Successful removal of temporary account'; + else + $content .= '<br />Failed removal of temporary account'; + + //search the bug and comment tables for handle updates + $content .= '<br />Upating Reported By, in the bug table'; + $query = 'UPDATE ' . BUG_TABLE . ' SET reported_by = \'' . $handle . '\' WHERE reported_by = \'' . $old_handle . '\''; + $db->get_data($query); + $content .= '<br />Updated ' . $db->affected_rows . ' rows'; + //logical no need to update the other two fields of handleness + $query = 'UPDATE ' . COMMENT_TABLE . ' SET handle = \'' . $handle . '\' WHERE handle = \'' . $old_handle . '\''; + $db->get_data($query); + $content .= '<br />Updated ' . $db->affected_rows . ' rows'; + + $content .= '<br />You should now be able to login'; + $content .= '</div>'; + + //recache the users files $error = FALSE; } @@ -55,7 +82,9 @@ if ($error) { - $tempate_data['form_error'] = 'For some reason, your email verification could not be completed'; +// $tempate_data['sy_error'] = 'For some reason, your email verification could not be completed'; + trigger_error('For some reason, your email verification could not be completed',E_USER_ERROR); } -?> +$template->prehtml = $content; +
« previous php.webmaster (#2363) next »