uimport: fix file formatting

This commit is contained in:
Fabrixxm 2013-04-02 09:44:19 -04:00
parent 13e315e004
commit 1442fecd14
1 changed files with 230 additions and 237 deletions

View File

@ -1,4 +1,5 @@
<?php
/**
* import account file exported from mod/uexport
* args:
@ -10,7 +11,8 @@ define("IMPORT_DEBUG", False);
function last_insert_id() {
global $db;
if (IMPORT_DEBUG) return 1;
if (IMPORT_DEBUG)
return 1;
if ($db->mysqli) {
$thedb = $db->getdb();
return $thedb->insert_id;
@ -54,13 +56,15 @@ function last_insert_id(){
* @param array $arr Column=>Value array from json
*/
function db_import_assoc($table, $arr) {
if (isset($arr['id'])) unset($arr['id']);
if (isset($arr['id']))
unset($arr['id']);
check_cols($table, $arr);
$cols = implode("`,`", array_map('dbesc', array_keys($arr)));
$vals = implode("','", array_map('dbesc', array_values($arr)));
$query = "INSERT INTO `$table` (`$cols`) VALUES ('$vals')";
logger("uimport: $query", LOGGER_TRACE);
if (IMPORT_DEBUG) return true;
if (IMPORT_DEBUG)
return true;
return q($query);
}
@ -72,7 +76,6 @@ function import_cleanup($newuid) {
q("DELETE FROM `group` WHERE uid = %d", $newuid);
q("DELETE FROM `group_member` WHERE uid = %d", $newuid);
q("DELETE FROM `pconfig` WHERE uid = %d", $newuid);
}
function import_account(&$a, $file) {
@ -243,17 +246,9 @@ function import_account(&$a, $file) {
$p = new Photo($photo['data'], $photo['type']);
$r = $p->store(
$photo['uid'],
$photo['contact-id'], //0
$photo['resource-id'],
$photo['filename'],
$photo['album'],
$photo['scale'],
$photo['profile'], //1
$photo['allow_cid'],
$photo['allow_gid'],
$photo['deny_cid'],
$photo['deny_gid']
$photo['uid'], $photo['contact-id'], //0
$photo['resource-id'], $photo['filename'], $photo['album'], $photo['scale'], $photo['profile'], //1
$photo['allow_cid'], $photo['allow_gid'], $photo['deny_cid'], $photo['deny_gid']
);
if ($r === false) {
@ -274,6 +269,4 @@ function import_account(&$a, $file) {
info(t("Done. You can now login with your username and password"));
goaway($a->get_baseurl() . "/login");
}