aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2009-12-18 21:08:21 +0000
committerrvelices <rv-github@modusoptimus.com>2009-12-18 21:08:21 +0000
commit8b66788392652515532a89e0dd7e3af594272cb4 (patch)
tree2d93c632523b9d0dfe8c536747dd2fe6adfef6be /include/ws_functions.inc.php
parent2a9b358dc8ebe8f1a077c88e7e7e49813c34a829 (diff)
web method images.setPrivacyLevel (ws_images_setPrivacyLevel) is POST only
git-svn-id: http://piwigo.org/svn/branches/2.0@4512 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php51
1 files changed, 28 insertions, 23 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 26a205014..6e13af641 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -855,6 +855,10 @@ function ws_images_setPrivacyLevel($params, &$service)
{
return new PwgError(401, 'Access denied');
}
+ if (!$service->isPost())
+ {
+ return new PwgError(405, "This method requires HTTP POST");
+ }
$params['image_id'] = array_map( 'intval',$params['image_id'] );
if ( empty($params['image_id']) )
{
@@ -865,6 +869,7 @@ function ws_images_setPrivacyLevel($params, &$service)
{
return new PwgError(WS_ERR_INVALID_PARAM, "Invalid level");
}
+
$query = '
UPDATE '.IMAGES_TABLE.'
SET level='.(int)$params['level'].'
@@ -885,7 +890,7 @@ function ws_images_add_chunk($params, &$service)
// original_sum
// type {thumb, file, high}
// position
-
+
if (!is_admin() || is_adviser() )
{
return new PwgError(401, 'Access denied');
@@ -950,18 +955,18 @@ function merge_chunks($output_filepath, $original_sum, $type)
if (is_file($output_filepath))
{
unlink($output_filepath);
-
+
if (is_file($output_filepath))
{
new PwgError(500, '[merge_chunks] error while trying to remove existing '.$output_filepath);
exit();
}
}
-
+
$upload_dir = PHPWG_ROOT_PATH.'upload/buffer';
$pattern = '/'.$original_sum.'-'.$type.'/';
$chunks = array();
-
+
if ($handle = opendir($upload_dir))
{
while (false !== ($file = readdir($handle)))
@@ -982,21 +987,21 @@ function merge_chunks($output_filepath, $original_sum, $type)
}
$i = 0;
-
+
foreach ($chunks as $chunk)
{
$string = file_get_contents($chunk);
-
+
if (function_exists('memory_get_usage')) {
ws_logfile('[merge_chunks] memory_get_usage on chunk '.++$i.': '.memory_get_usage());
}
-
+
if (!file_put_contents($output_filepath, $string, FILE_APPEND))
{
new PwgError(500, '[merge_chunks] error while writting chunks for '.$output_filepath);
exit();
}
-
+
unlink($chunk);
}
@@ -1014,7 +1019,7 @@ function add_file($file_path, $type, $original_sum, $file_sum)
$file_path = file_path_for_type($file_path, $type);
$upload_dir = dirname($file_path);
-
+
if (!is_dir($upload_dir)) {
umask(0000);
$recursive = true;
@@ -1101,7 +1106,7 @@ SELECT
// update basic metadata from file
//
$update = array();
-
+
if ('high' == $params['type'])
{
$update['high_filesize'] = $infos['filesize'];
@@ -1120,7 +1125,7 @@ SELECT
if (count($update) > 0)
{
$update['id'] = $params['image_id'];
-
+
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
mass_updates(
IMAGES_TABLE,
@@ -1839,7 +1844,7 @@ function ws_add_image_category_relations($image_id, $categories_string, $replace
);
exit();
}
-
+
$query = '
SELECT
id
@@ -1857,9 +1862,9 @@ SELECT
);
exit();
}
-
+
$to_update_cat_ids = array();
-
+
// in case of replace mode, we first check the existing associations
$query = '
SELECT
@@ -1884,13 +1889,13 @@ DELETE
update_category($to_remove_cat_ids);
}
}
-
+
$new_cat_ids = array_diff($cat_ids, $existing_cat_ids);
if (count($new_cat_ids) == 0)
{
return true;
}
-
+
if ($search_current_ranks)
{
$query = '
@@ -1914,16 +1919,16 @@ SELECT
{
$current_rank_of[$cat_id] = 0;
}
-
+
if ('auto' == $rank_on_category[$cat_id])
{
$rank_on_category[$cat_id] = $current_rank_of[$cat_id] + 1;
}
}
}
-
+
$inserts = array();
-
+
foreach ($new_cat_ids as $cat_id)
{
array_push(
@@ -1935,14 +1940,14 @@ SELECT
)
);
}
-
+
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
mass_inserts(
IMAGE_CATEGORY_TABLE,
array_keys($inserts[0]),
$inserts
);
-
+
update_category($new_cat_ids);
}
@@ -2001,7 +2006,7 @@ function ws_categories_setInfo($params, &$service)
array($update)
);
}
-
+
}
function ws_logfile($string)
@@ -2011,7 +2016,7 @@ function ws_logfile($string)
if (!$conf['ws_enable_log']) {
return true;
}
-
+
file_put_contents(
$conf['ws_log_filepath'],
'['.date('c').'] '.$string."\n",