Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions admin/template/import.list_all.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var flickrUserId = '{$flickrUserId}';
<label><input type="checkbox" name="fill_views" checked="checked"> {'View counter'|translate}</label>
<label><input type="checkbox" name="fill_level" checked="checked"> {'Privacy level'|translate}</label>
<label><input type="checkbox" name="fill_safety" checked="checked"> {'Safety level (as keyword)'|translate}</label>
<label><input type="checkbox" name="fill_comments" checked="checked"> {'Comments'|translate}</label>
</p>

<p>
Expand Down
31 changes: 30 additions & 1 deletion include/ws_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,36 @@ function ws_flickr2piwigo_importPhoto($params)
set_tags($tag_ids, $photo['image_id']);
}
}


// Associated comments
if (in_array('fill_comments', $photo['fills'])) {
$comments = $flickr->photosComments()->getList($photo['id']);
$logger->debug('Comments for '.$photo['image_id'].': '. json_encode($comments), FLICKR2PIWIGO);
if (isset($comments['comments']['comment'])) {
$n = count($comments['comments']['comment']);
$logger->debug('Comments for '.$photo['image_id'].': '.$n, FLICKR2PIWIGO);
foreach ($comments['comments']['comment'] as $com) {
$query = '
INSERT INTO '.COMMENTS_TABLE.'
(author, author_id, anonymous_id, content, date, validated, validation_date, image_id, website_url, email)
VALUES (
\''.$com['authorname'].'\',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use pwg_db_real_escape_string()? What if a name contains malicious SQL?

NULL,
\''. FLICKR2PIWIGO.'\',
\''.$com['_content'].'\',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably use pwg_db_real_escape_string().

\''.date('Y-m-d H:i:s', $com['datecreate']).'\',
\'true\',
NOW(),
'.$photo['image_id'].',
NULL,
NULL
)
';
pwg_query($query);
}
}
}

$logger->info('Import complete', FLICKR2PIWIGO);
return l10n('Photo "%s" imported', $photo['title']);
}