aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2008-09-25 23:01:35 +0000
committerplegall <plg@piwigo.org>2008-09-25 23:01:35 +0000
commitd04fd1d44ef631d69098c007dd3706df04a7f73b (patch)
treef13d8638708961545d66280ffcf277e21b9982c5 /include
parent9ebc3be5bd594781cec6a4322103fb5af92d311c (diff)
feature 868 added: pwg.images.add checks if the same file has not alread
been uploaded. git-svn-id: http://piwigo.org/svn/trunk@2592 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index f125515c6..82635a213 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -902,6 +902,18 @@ function ws_images_add($params, &$service)
// fwrite($fh_log, 'input: '.$params['file_sum']."\n");
// fwrite($fh_log, 'input: '.$params['thumbnail_sum']."\n");
+ // does the image already exists ?
+ $query = '
+SELECT
+ COUNT(*) AS counter
+ FROM '.IMAGES_TABLE.'
+ WHERE md5sum = \''.$params['file_sum'].'\'
+;';
+ list($counter) = mysql_fetch_row(pwg_query($query));
+ if ($counter != 0) {
+ return new PwgError(500, 'file already exists');
+ }
+
// current date
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
@@ -986,6 +998,7 @@ function ws_images_add($params, &$service)
'filesize' => floor(filesize($file_path)/1024),
'width' => $width,
'height' => $height,
+ 'md5sum' => $params['file_sum'],
);
$info_columns = array(