coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 bridging => Topic started by: lexon on February 03, 2007, 10:10:20 PM

Title: Randomly unable to access gallery for some users
Post by: lexon on February 03, 2007, 10:10:20 PM
Hi,
I am managing a gallery that is bridged with phpbb 2.0.22. I started having problems with users not being able to access the gallery after they log in. They get redirected back to the forum and my guess is that cpg doesn't recognise the login status. However, this only happens with users I added after bridging. I use the following script to add users:

<?php

$link 
mysqli_connect("localhost""db""pwd");
mysqli_select_db($link"mydb");
if (!
$link) {
 echo 
"db access error";
 exit;
}

$file = @fopen('users.txt''r');
if (!
$file) {
 echo 
"Error a";
 exit;
}

$file_write = @fopen('login_info.txt''r+');
if (!
$file_write) {
 echo 
"Error b";
 exit;
}


while(!
feof($file)) {
 
fscanf($file"%s\t%s\t%s\n", &$lastname, &$firstname, &$email);
 echo 
$lastname."asdf".$firstname.$email.$cell."<br />";
 
 
$result mysqli_query($link"SELECT user_id FROM phpbb_users ORDER BY user_id desc LIMIT 1");
 if(!
$result) {
  echo 
"Error 1";
  exit;
 }

 
$row mysqli_fetch_array($result);
 
$row['user_id']++;

 
$randnum1 rand();
 
$userpwd $lastname.$randnum1.$firstname;
 
$md5pwd md5($userpwd);

 
$username $firstname.'.'.$lastname;

 
$result mysqli_query($link"INSERT INTO `phpbb_users` (`user_id`, `user_active`, `username`, `user_password`, `user_session_time`, `user_session_page`, `user_lastvisit`, `user_regdate`, `user_level`, `user_posts`, `user_timezone`, `user_style`, `user_lang`, `user_dateformat`, `user_new_privmsg`, `user_unread_privmsg`, `user_last_privmsg`, `user_login_tries`, `user_last_login_try`, `user_emailtime`, `user_viewemail`, `user_attachsig`, `user_allowhtml`, `user_allowbbcode`, `user_allowsmile`, `user_allowavatar`, `user_allow_pm`, `user_allow_viewonline`, `user_notify`, `user_notify_pm`, `user_popup_pm`, `user_rank`, `user_avatar`, `user_avatar_type`, `user_email`, `user_icq`, `user_website`, `user_from`, `user_sig`, `user_sig_bbcode_uid`, `user_aim`, `user_yim`, `user_msnm`, `user_occ`, `user_interests`, `user_actkey`, `user_newpasswd`) 
                                VALUES ('
{$row['user_id']}', '1', '{$username}', '{$md5pwd}', '0', '0', UNIX_TIMESTAMP('0'), UNIX_TIMESTAMP('0'), '0', '0', '0.00', '1', 'english', 'D M d, Y g:i a', '0', '0', '0', '0', '0', NULL, '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', '1', '0', NULL, '0', '{$email}', NULL, NULL, NULL, NULL, '', '', '', '', '', '', '', '1');");

 if(!
$result) {
  echo 
"Error 2 with {$row['user_id']}";
   exit;
 }

 
$to_store $username.",".$userpwd.",".$email."\n";

 
fputs($file_write$to_store);

}

?>


It is designed to read from users.txt with a list of predetermined users and generate the username and passwords accordingly. Before the problem occured I used the exact same script to generate 80+ users and they all worked fine. Is there something wrong with this script or is it something to do with cpg? O btw, the users that can't access the gallery can do everything fine in the forum.

Thanks in advance

LeX
Title: Re: Randomly unable to access gallery for some users
Post by: Nibbler on February 03, 2007, 10:25:04 PM
Your script does not insert an entry into the groups table or the user_groups table for the new user. It should. Refer to phpbb's registration code to see how to do this.
Title: Re: Randomly unable to access gallery for some users
Post by: lexon on February 03, 2007, 11:12:05 PM
Thanx for pointing that out. My stupidity. But it's always good to learn something....

Problem Fixed!

LeX