Example #1
0
    alterTable($dbw->tableName('user_newtalk'), "user_id", $from_id, $newid);
    alterTable($dbw->tableName('watchlist'), "wl_user", $from_id, $newid);
} else {
    # Change user name in local and shared DB if not merging
    alterTable('user', "user_name", $from_text, $to_text);
    $dbw->selectDB($wgSharedDB);
    alterTable('user', "user_name", $from_text, $to_text);
}
# Change user names in remaining tables
$dbw->selectDB($wgDBname);
alterTable('revision', "rev_user_text", $from_text, $to_text);
alterTable('image', "img_user_text", $from_text, $to_text);
alterTable('recentchanges', "rc_user_text", $from_text, $to_text);
alterTable('archive', "ar_user_text", $from_text, $to_text);
alterTable('filearchive', "fa_user_text", $from_text, $to_text);
alterTable('oldimage', "oi_user_text", $from_text, $to_text);
# Move user pages if there is no exisitng page at the new location
$query = 'UPDATE LOW_PRIORITY IGNORE page set page_title=' . str_replace(' ', '_', $to_text) . ' where page_namespace in (2, 3) and page_title = ' . str_replace(' ', '_', $from_text) . ';';
if (isset($options['verbose'])) {
    print $query . "\n";
}
if (!isset($options['dryrun'])) {
    $dbw->query($query);
}
# Fixme -- this should be done via internal MediaWiki page move
/*
$query = 'UPDATE LOW_PRIORITY IGNORE page set page_title=concat('. $to_text. ',' .
	'substring(page_title, '. (strlen($options['from']) + 1) .')) ' .
	'WHERE (page_namespace = 2 OR page_namespace = 3) and page_title like "'.
	$dbw->escapeLike($options['from']). '/%";';
Example #2
0
createTable('members', 'id INT AUTO_INCREMENT PRIMARY KEY,
              user VARCHAR(16),
              pass VARCHAR(16),
              quiz_score Integer(2),
              INDEX(user(6))');
createTable('messages', 'id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
              user VARCHAR(16),
              pm CHAR(1),
              time INT UNSIGNED,
              message VARCHAR(4096),
              INDEX(user(6))');
createTable('friends', 'user VARCHAR(16),
              friend VARCHAR(16),
              INDEX(user(6)),
              INDEX(friend(6))');
createTable('profiles', 'user VARCHAR(16),
              text VARCHAR(4096),
              INDEX(user(6))');
createTable('charities', 'charity_name VARCHAR (50),
                Reg_No integer(2),
                charity_purpose VARCHAR (150),
                charity_location VARCHAR (150),
                CHY integer(2),
                CRO integer(2),
                INDEX(charity_name(6))');
alterTable();
?>
    <br>...done.
  </body>
</html>
            }
            printr($aTmpAttrNew);
            echo "<hr>";
            printr($aAddAttr);
            /*$aAddAttr = array_diff($aTmpAttrNew, $aTmpAttrOld);
            					$aDropAttr = array_diff($aTmpAttrOld, $aTmpAttrNew);
            
            					if (!empty($aAddAttr))
            					{
            						printr($aAddAttr);
            						$aResultAddCol["$table_name"][] = MergeWithDefault("change", $aTmpAttrNew['type'], $aTmpAttrNew);
            					}*/
            unset($aAddAttr);
            unset($aDropAttr);
        }
        #------Конец проверки на изменение поля или атрибутов поля---------------------------------------------------------
        #---------------------------------------------------------------
        #---------------------------------------------------------------
    }
    # Конец действий со сравниваемыми таблицами
    unset($aColName);
    unset($aColNameOld);
    //}
}
// printr($aResultAddIndex);
$sResultAddDropCol = alterTable($aResultAddCol);
$sResultStr = "<!-- " . date(DATE_RSS) . " -->\n<ddl>\n";
$sResultStr .= $sResultAddTable . $sResultAddDropCol . $sResultAddIndex . $sResultDropTable;
$sResultStr .= "\n</ddl>\n<!-- " . str_repeat("#", 80) . " -->\n";
file_put_contents('changeset4qdb_build.xml', $sResultStr, FILE_APPEND);
// file_put_contents('databaseOld.xml', $db); # Перезаписываем старую базу на новую. УБРАТЬ КОМЕНТАРИЙ В КОНЦЕ!!
Example #4
0
    alterTable($dbr->tableName('image'), "img_user", $row->user_id, $newid, 'img_user_text');
    alterTable($dbr->tableName('ipblocks'), "ipb_user", $row->user_id, $newid);
    alterTable($dbr->tableName('logging'), "log_user", $row->user_id, $newid);
    alterTable($dbr->tableName('oldimage'), "oi_user", $row->user_id, $newid);
    alterTable($dbr->tableName('recentchanges'), "rc_user", $row->user_id, $newid, 'rc_user_text');
    alterTable($dbr->tableName('revision'), "rev_user", $row->user_id, $newid);
    alterTable($dbr->tableName('user_groups'), "ug_user", $row->user_id, $newid);
    alterTable($dbr->tableName('user_newtalk'), "user_id", $row->user_id, $newid);
    alterTable($dbr->tableName('watchlist'), "wl_user", $row->user_id, $newid);
    if (!empty($new_local_username) && $new_local_username != $row->user_name) {
        alterTable($dbr->tableName('revision'), "rev_user_text", "\"{$row->user_name}\"", "\"{$new_local_username}\"");
        alterTable($dbr->tableName('image'), "img_user_text", "\"{$row->user_name}\"", "\"{$new_local_username}\"");
        alterTable($dbr->tableName('recentchanges'), "rc_user_text", "\"{$row->user_name}\"", "\"{$new_local_username}\"");
        alterTable($dbr->tableName('archive'), "ar_user_text", "\"{$row->user_name}\"", "\"{$new_local_username}\"");
        alterTable($dbr->tableName('filearchive'), "fa_user_text", "\"{$row->user_name}\"", "\"{$new_local_username}\"");
        alterTable($dbr->tableName('oldimage'), "oi_user_text", "\"{$row->user_name}\"", "\"{$new_local_username}\"");
    }
    if (!empty($single)) {
        echo "Done.\n";
        exit;
    }
}
#We only announce collisions if we aren't handling them, or if we're in verbose mode
if (count($collisions) >= 1 && $options["collision-action"] == "different") {
    # || $options['verbose'])){
    print "There were collisions for these names:\n";
    foreach ($collisions as $description) {
        print "{$description}\n";
    }
}
print "\nUsers migrated (unless collisions were reported).  Now, you should set the \$wgSharedDB variable to {$shared_db}\n\n";
Example #5
0
function complex($data = '')
{
    $data = crc32($data);
    $data = sha1($data);
    $data = md5($data);
    $array = str_split($data);
    $intSet = getDataPointers(count($array));
    $stringSet = getDataPointers(count($array), 'string');
    $pointer = array_shift($intSet);
    if (is_int(intval($array[$pointer])) === true) {
        $array[$pointer] = alterTable($array[$pointer]);
    }
    $pointer = array_shift($intSet);
    if (is_int(intval($array[$pointer])) === true) {
        $array[$pointer] = alterTable($array[$pointer]);
    }
    $pointer = array_shift($intSet);
    if (is_int(intval($array[$pointer])) === true) {
        $array[$pointer] = alterTable($array[$pointer]);
    }
    $pointer = array_shift($stringSet);
    if (is_int(intval($array[$pointer])) === true) {
        $array[$pointer] = alterTable($array[$pointer]);
    }
    $pointer = array_shift($stringSet);
    if (is_int(intval($array[$pointer])) === true) {
        $array[$pointer] = alterTable($array[$pointer]);
    }
    $pointer = array_shift($stringSet);
    if (is_int(intval($array[$pointer])) === true) {
        $array[$pointer] = alterTable($array[$pointer]);
    }
    $string = implode('', $array);
    return $string;
}