Skip to content
Permalink
Browse files

discard duplicate Ocprop picture uploads; updates #251

  • Loading branch information...
following5 committed Jan 5, 2016
1 parent 8cf4f41 commit 8ae37ab9d817309a5ad2513c881fbc69376cedcb
Showing with 21 additions and 0 deletions.
  1. +17 −0 htdocs/lib2/logic/picture.class.php
  2. +4 −0 htdocs/picture.php
@@ -355,6 +355,23 @@ function getAnyChanged()
return $this->rePicture->getAnyChanged();
}
// Test if the picture can be discarded as duplicate.
// This is a quick test for Ocprop dups and may be extended for any
// picture uploads by comparing the file sizes and contents.
function is_duplicate()
{
global $ocpropping;
return $ocpropping &&
sql_value("
SELECT COUNT(*) FROM `pictures`
WHERE `object_type`='&1' AND `object_id`='&2' AND `title`='&3'",
0,
$this->getObjectType(),
$this->getObjectId(),
$this->getTitle()) > 0;
}
// return true if successful (with insert)
function save($restore=false, $original_id=0, $original_url="")
{
@@ -88,6 +88,10 @@
else
$picture->setTitle($title);
// ignore duplicates (http://redmine.opencaching.de/issues/251)
if ($picture->is_duplicate())
$tpl->redirect($picture->getPageLink());
if (!isset($_FILES['file'])) // Ocprop
{
$tpl->assign('errorfile', ERROR_UPLOAD_ERR_NO_FILE);

0 comments on commit 8ae37ab

Please sign in to comment.
You can’t perform that action at this time.