install/schemas/upgrade/1.1.6-1.1.7.php
changeset 1227 bdac73ed481e
parent 1181 91911e183685
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
     4 
     4 
     5 global $db, $session, $paths, $template, $plugins; // Common objects
     5 global $db, $session, $paths, $template, $plugins; // Common objects
     6 
     6 
     7 $q = $db->sql_query('SELECT user_id, username FROM ' . table_prefix . 'users;');
     7 $q = $db->sql_query('SELECT user_id, username FROM ' . table_prefix . 'users;');
     8 if ( !$q )
     8 if ( !$q )
     9   $db->_die();
     9 	$db->_die();
    10 
    10 
    11 $map = array();
    11 $map = array();
    12 while($row = $db->fetchrow())
    12 while($row = $db->fetchrow())
    13 {
    13 {
    14   $map[ $row['username'] ] = $row['user_id'];
    14 	$map[ $row['username'] ] = $row['user_id'];
    15 }
    15 }
    16 $db->free_result();
    16 $db->free_result();
    17 
    17 
    18 $q = $db->sql_query('SELECT author FROM ' . table_prefix . 'logs WHERE author_uid = 1;');
    18 $q = $db->sql_query('SELECT author FROM ' . table_prefix . 'logs WHERE author_uid = 1;');
    19 if ( !$q )
    19 if ( !$q )
    20   $db->_die();
    20 	$db->_die();
    21 
    21 
    22 $updated = array();
    22 $updated = array();
    23 
    23 
    24 while ( $row = $db->fetchrow($q) )
    24 while ( $row = $db->fetchrow($q) )
    25 {
    25 {
    26   if ( isset($map[ $row['author'] ]) && !is_valid_ip($row['author']) && !in_array($row['author'], $updated) )
    26 	if ( isset($map[ $row['author'] ]) && !is_valid_ip($row['author']) && !in_array($row['author'], $updated) )
    27   {
    27 	{
    28     $author = $db->escape($row['author']);
    28 		$author = $db->escape($row['author']);
    29     $sql = "UPDATE " . table_prefix . "logs SET author_uid = {$map[ $row['author'] ]} WHERE author = '$author';";
    29 		$sql = "UPDATE " . table_prefix . "logs SET author_uid = {$map[ $row['author'] ]} WHERE author = '$author';";
    30     if ( !$db->sql_query($sql) )
    30 		if ( !$db->sql_query($sql) )
    31       $db->_die();
    31 			$db->_die();
    32     $updated[] = $row['author'];
    32 		$updated[] = $row['author'];
    33   }
    33 	}
    34 }
    34 }
    35 
    35