aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2008-10-07 22:01:14 +0000
committerplegall <plg@piwigo.org>2008-10-07 22:01:14 +0000
commit3eecf04629ce2a48208e2f9fe3189eba535d6597 (patch)
tree59008f2abfc607591cecec4dacdb6e5efdec8ae7 /include/ws_functions.inc.php
parent42c665eefff16db088cf341758e62643ac3ad074 (diff)
feature 889 added: pwg.images.exist check the existence of a photo in the
database based on its md5sum. (avoid failing on pwg.images.add). git-svn-id: http://piwigo.org/svn/trunk@2683 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 57a12ac3b..f14aff70a 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -1457,4 +1457,43 @@ function ws_tags_add($params, &$service)
return $creation_output;
}
+
+function ws_images_exist($params, &$service)
+{
+ if (!is_admin() or is_adviser())
+ {
+ return new PwgError(401, 'Access denied');
+ }
+
+ // search among photos the list of photos already added, based on md5sum
+ // list
+ $md5sums = preg_split(
+ '/[\s,;\|]/',
+ $params['md5sum_list'],
+ -1,
+ PREG_SPLIT_NO_EMPTY
+ );
+
+ $query = '
+SELECT
+ id,
+ md5sum
+ FROM '.IMAGES_TABLE.'
+ WHERE md5sum IN (\''.implode("','", $md5sums).'\')
+;';
+ $id_of_md5 = simple_hash_from_query($query, 'md5sum', 'id');
+
+ $result = array();
+
+ foreach ($md5sums as $md5sum)
+ {
+ $result[$md5sum] = null;
+ if (isset($id_of_md5[$md5sum]))
+ {
+ $result[$md5sum] = $id_of_md5[$md5sum];
+ }
+ }
+
+ return $result;
+}
?>