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