X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fuexport.php;h=e1fb22855a6066fa8b99336b837f29ef9ebbb0ea;hb=6797485f6eea4700d5801afdf7ed7567e4e3fdf1;hp=d8141534a474b87940ed9165532d5f46db5da04c;hpb=83a36cbd13a7c59b30164424579592a457cec7f5;p=friendica.git diff --git a/mod/uexport.php b/mod/uexport.php old mode 100644 new mode 100755 index d8141534a4..e1fb22855a --- a/mod/uexport.php +++ b/mod/uexport.php @@ -17,7 +17,7 @@ function uexport_init(&$a) { } $contact = array(); $r = q("SELECT * FROM `contact` WHERE `uid` = %d ", - local_user() + intval(local_user()) ); if(count($r)) { foreach($r as $rr) @@ -28,7 +28,7 @@ function uexport_init(&$a) { $profile = array(); $r = q("SELECT * FROM `profile` WHERE `uid` = %d ", - local_user() + intval(local_user()) ); if(count($r)) { foreach($r as $rr) @@ -36,22 +36,36 @@ function uexport_init(&$a) { $profile[][$k] = $v; } - $item = array(); - $r = q("SELECT * FROM `item` WHERE `uid` = %d ", - local_user() + $output = array('user' => $user, 'contact' => $contact, 'profile' => $profile ); + + header("Content-type: application/json"); + echo json_encode($output); + + $r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ", + intval(local_user()) ); - if(count($r)) { - foreach($r as $rr) - foreach($rr as $k => $v) - $item[][$k] = $v; - } + if(count($r)) + $total = $r[0]['total']; + // chunk the output to avoid exhausting memory + for($x = 0; $x < $total; $x += 500) { + $item = array(); + $r = q("SELECT * FROM `item` WHERE `uid` = %d LIMIT %d, %d", + intval(local_user()), + intval($x), + intval(500) + ); + if(count($r)) { + foreach($r as $rr) + foreach($rr as $k => $v) + $item[][$k] = $v; + } - $output = array('user' => $user, 'contact' => $contact, 'profile' => $profile, 'item' => $item ); + $output = array('item' => $item); + echo json_encode($output); + } - header("Content-type: text/json"); - echo str_replace('\\/','/',json_encode($output)); killme();