function showMenu() { ?> <!DOCTYPE html> <html lang="en"> <head> <title>MySQL Export by Mangesh Sangapu</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <body> <form action = "migration.php" method = "POST"> <div class="container"> <div class="jumbotron"> <h1>WordPress Buddy for Microsoft Azure</h1> <p>WordPress Migration and Utility Tools</p> </div> <div class="row"> <div class="col-sm-4"> <h3>Databases Listed with Connection Strings</h3> <p><?php $myMigration = new migration(); $myMigration->displayAllDatabases(); ?> </p> </div> <div class="col-sm-4"> <h3>Export all databases</h3> <p><input type = "submit" name="action" value="Export all databases"/></input></p> </div> <div class="col-sm-4"> <h3>.sql files on the server</h3> <p><?php listfiles(); ?> </p> <p><button type="reset" onclick="location.href='deleteExports.php'">Delete all</button></p> </div> </div> <div class="row"> <div class="col-sm-4"></div> <div class="col-sm-4"> <h3>Import to Mangesh Test</h3> <p><input type = "submit" name="action" value="Import Mangesh"/></input></p> </div> <div class="col-sm-4"></div> </div> </div> </form> </body> </html> <?php }
</script> <?php exit; //no action } else { foreach ($_REQUEST as $key => $value) { ${$key} = $value; } //var_dump($_REQUEST);exit; switch ($action) { case "updatePassword": $myMigration = new migration($db); $myMigration->updateUserPassword($uid, $pass); break; case "homeAndSite": $myMigration = new migration($db); $myMigration->updateHomeSiteurl($home, $site); break; case "updatePlugins": $myMigration = new migration($db); $myMigration->updatePlugins($plugins); break; case "disablePlugins": $myMigration = new migration($db); $myMigration->updatePlugins(); break; default: break; } }
public static function migrateNotes($v1GameId, $v2GameId, $maps) { $noteIdMap = array(); $noteIdMap[0] = 0; $commentIdMap = array(); $commentIdMap[0] = 0; $userIdMap = array(); $userIdMap[0] = 0; $notes = migration_dbconnection::queryArray("SELECT * FROM notes WHERE game_id = '{$v1GameId}'", "v1"); $properNotes = array(); $commentNotes = array(); for ($i = 0; $i < count($notes); $i++) { if (!$userIdMap[$notes[$i]->owner_id]) { $userIdMap[$notes[$i]->owner_id] = migration::forceMigratePlayer($notes[$i]->owner_id); } if ($notes[$i]->parent_note_id) { $commentNotes[] = $notes[$i]; } else { $properNotes[] = $notes[$i]; } } for ($i = 0; $i < count($properNotes); $i++) { $noteIdMap[$properNotes[$i]->note_id] = 0; //set it to 0 in case of failure if ($properNotes[$i]->incomplete) { continue; } $newNoteId = migration_dbconnection::queryInsert("INSERT INTO notes (game_id, user_id, name, description, media_id, created) VALUES ('{$v2GameId}','{$userIdMap[$properNotes[$i]->owner_id]}','" . addslashes($properNotes[$i]->title) . "','" . addslashes($properNotes[$i]->title) . "','0','{$properNotes[$i]->created}');", "v2"); $notetags = migration_dbconnection::queryArray("SELECT * FROM note_tags WHERE note_id = '{$properNotes[$i]->note_id}';", "v1"); for ($j = 0; $j < count($notetags); $j++) { migration_dbconnection::queryInsert("INSERT INTO object_tags (game_id, object_type, object_id, tag_id, created) VALUES ('{$v2GameId}','NOTE','{$newNoteId}','{$maps->note_tags[$notetags[$j]->tag_id]}',CURRENT_TIMESTAMP);", "v2"); } $noteIdMap[$properNotes[$i]->note_id] = $newNoteId; } for ($i = 0; $i < count($commentNotes); $i++) { $commentIdMap[$commentNotes[$i]->note_id] = 0; //set it to 0 in case of failure $newCommentId = migration_dbconnection::queryInsert("INSERT INTO note_comments (game_id, note_id, user_id, name, description, created) VALUES ('{$v2GameId}','{$noteIdMap[$commentNotes[$i]->parent_note_id]}','{$userIdMap[$commentNotes[$i]->owner_id]}','" . addslashes($commentNotes[$i]->title) . "','" . addslashes($commentNotes[$i]->title) . "',CURRENT_TIMESTAMP)", "v2"); $commentIdMap[$commentNotes[$i]->note_id] = $newCommentId; } $content = migration_dbconnection::queryArray("SELECT * FROM note_content WHERE game_id = '{$v1GameId}'", "v1"); for ($i = 0; $i < count($content); $i++) { if ($noteId = $noteIdMap[$content[$i]->note_id]) { if ($content[$i]->type == 'TEXT') { //content belongs to note migration_dbconnection::query("UPDATE notes SET description = '{$content[$i]->text}' WHERE note_id = '{$noteId}'", "v2"); } else { //assume some type of media migration_dbconnection::query("UPDATE notes SET media_id = '{$maps->media[$content[$i]->media_id]}' WHERE note_id = '{$noteId}'", "v2"); } } else { if ($commentId = $commentIdMap[$content[$i]->note_id]) { if ($content[$i]->type == 'TEXT') { //content belongs to comment migration_dbconnection::query("UPDATE note_comments SET description = '{$content[$i]->text}' WHERE note_comment_id = '{$commentId}'", "v2"); } } else { continue; } } //orphan } return $noteIdMap; }