Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: PN/CPG Matched UIDs  (Read 5962 times)

0 Members and 1 Guest are viewing this topic.

AutoWebMedia

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • AutoWebMedia.com
PN/CPG Matched UIDs
« on: April 05, 2006, 11:51:39 am »

I have noticed that my pn_uid is not the traditional 1,2,3,4,5,6....etc.  After some years of use they are more like 1,2,3,4,43,6,7,43,9,200,10....

When I use the pnCPG "Update Coppermine users from Postnuke", it assumes that my users are sequential and assigns a CPG user_id sequentially.  What I've done here is try to modify the code to SELECT the pn_uid and INSERT it to user_id.  It seems to work, but not 100%, wondered if someone could sanity check my mods.  I think the problem is related to $teller.

In pnadmin.php I changed this:

Code: [Select]
// Load Postnuke users
$results = mysql_query( "SELECT pn_uname,pn_email FROM $_pn_prf LIMIT 0 , 999999" );

//store the result in a PHP array for multiple use
$dbdata=array();
$dbdata1=array();
$usr_num = 0;
while($row = mysql_fetch_array($results)) {
$usr_num ++;
$dbdata[$usr_num]=$row[0];
$dbdata1[$usr_num]=$row[1];
}

// is there another database owner, let's connect
if ($_dbhost !==""){
$link = mysql_connect($_dbhost, $_dbuser, $_dbpw) or mysql_error();
}
$true = mysql_select_db($db) ;

$teller = 0;
while ($teller < $usr_num ){

$teller ++ ;
$username = $dbdata[$teller];
$usermail = $dbdata1[$teller];

// Check if already added to Coppermine
$results1 = mysql_query( "SELECT * FROM $_cpg_prf WHERE user_name=$username " );
$num_rows1 = mysql_num_rows($results1);


// if not there, add the account
if ($num_rows1 < 1){
$cpg_pwd = ranpass() ;
$adding = mysql_query("INSERT INTO $_cpg_prf(user_group, user_active,user_name, user_password,user_lastvisit, user_regdate,user_email) VALUES ('2','YES', '$username','$cpg_pwd',NOW(), NOW(),'$usermail')");

To this:

Code: [Select]
// Load Postnuke users
$results = mysql_query( "SELECT pn_uid,pn_uname,pn_email FROM $_pn_prf LIMIT 0 , 999999" );

//store the result in a PHP array for multiple use
$dbdata=array();
$dbdata1=array();
$dbdata2=array();
$usr_num = 0;
while($row = mysql_fetch_array($results)) {
$usr_num ++;
$dbdata[$usr_num]=$row[0];
$dbdata1[$usr_num]=$row[1];
}

// is there another database owner, let's connect
if ($_dbhost !==""){
$link = mysql_connect($_dbhost, $_dbuser, $_dbpw) or mysql_error();
}
$true = mysql_select_db($db) ;

$teller = 0;
while ($teller < $usr_num ){

$teller ++ ;
$pnuserid = $dbdata[$teller];
$username = $dbdata1[$teller];
$usermail = $dbdata2[$teller];

// Check if already added to Coppermine
$results1 = mysql_query( "SELECT * FROM $_cpg_prf WHERE user_name=$username " );
$num_rows1 = mysql_num_rows($results1);


// if not there, add the account
if ($num_rows1 < 1){
$cpg_pwd = ranpass() ;
$adding = mysql_query("INSERT INTO $_cpg_prf(user_id, user_group, user_active,user_name, user_password,user_lastvisit, user_regdate,user_email) VALUES ('$pnuserid', '2','YES', '$username','$cpg_pwd',NOW(), NOW(),'$usermail')");

My concern is that I have 5660 CPG users, and 5669 PN users...
Logged
PhilT

AutoWebMedia

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • AutoWebMedia.com
Re: PN/CPG Matched UIDs
« Reply #1 on: April 05, 2006, 12:05:11 pm »

So the above covers the pnCPG "Update Coppermine users from Postnuke"....  Any ideas on how as a (new) user gets created in CPG it can have the same user_id and pn_uid?
Logged
PhilT

casNuy

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 671
  • My other hobby
    • Nuy Community
Re: PN/CPG Matched UIDs
« Reply #2 on: April 06, 2006, 08:03:42 pm »

I have tried to match the UID's. This nvere made much sense since i needed it to be an option also for existing users hence i synchronize on username.
This is most likley the reason why you have a difference in users.
In the following statement it is checked if the suer exists :
Code: [Select]
$results1 = mysql_query( "SELECT * FROM $_cpg_prf WHERE user_name=$username " );

in your case it needs to be :
Code: [Select]
$results1 = mysql_query( "SELECT * FROM $_cpg_prf WHERE user_id=$pnuserid " );

Still be carefull, you might connect different people this way.

The answer for Phil is that I will not vhange the code to accomodate this functionality.

Cas
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.