aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/identity.php20
-rw-r--r--mod/uexport.php6
2 files changed, 21 insertions, 5 deletions
diff --git a/include/identity.php b/include/identity.php
index bce578d87..871d85700 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -604,15 +604,27 @@ function identity_basic_export($channel_id, $items = false) {
}
-function identity_export_year($channel_id,$year) {
+function identity_export_year($channel_id,$year,$month = 0) {
if(! $year)
return array();
+ if($month && $month <= 12) {
+ $target_month = sprintf('%02d',$month);
+ $target_month_plus = sprintf('%02d',$month+1);
+ }
+ else
+ $target_month = '01';
+
$ret = array();
- $mindate = datetime_convert('UTC','UTC',$year . '-01-01 00:00:00');
- $maxdate = datetime_convert('UTC','UTC',$year+1 . '-01-01 00:00:00');
- $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' ",
+
+ $mindate = datetime_convert('UTC','UTC',$year . '-' . $target_month . '-01 00:00:00');
+ if($month && $month < 12)
+ $maxdate = datetime_convert('UTC','UTC',$year . '-' . $target_month_plus . '-01 00:00:00');
+ else
+ $maxdate = datetime_convert('UTC','UTC',$year+1 . '-01-01 00:00:00');
+
+ $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' order by created",
intval($channel_id),
dbesc($mindate),
dbesc($maxdate)
diff --git a/mod/uexport.php b/mod/uexport.php
index 8217a17c4..a1fa31cfe 100644
--- a/mod/uexport.php
+++ b/mod/uexport.php
@@ -13,11 +13,15 @@ function uexport_init(&$a) {
$year = intval(argv(1));
}
+ if(argc() > 2 && intval(argv(2)) > 1 && intval(argv(2)) <= 12) {
+ $month = intval(argv(2));
+ }
+
header('content-type: application/octet_stream');
header('content-disposition: attachment; filename="' . $channel['channel_address'] . (($year) ? '-' . $year : '') . '.json"' );
if($year) {
- echo json_encode(identity_export_year(local_channel(),$year));
+ echo json_encode(identity_export_year(local_channel(),$year,$month));
killme();
}