conf_update_param('gallery_locked', 'false'); $_SESSION['page_infos'] = array(l10n('Gallery unlocked')); redirect(get_root_url() . 'admin.php?page=maintenance'); break; case 'categories': images_integrity(); update_uppercats(); update_category('all'); update_global_rank(); invalidate_user_cache(true); break; case 'images': images_integrity(); update_path(); include_once PHPWG_ROOT_PATH . 'include/functions_rate.inc.php'; update_rating_score(); invalidate_user_cache(); break; case 'delete_orphan_tags': delete_orphan_tags(); break; case 'user_cache': invalidate_user_cache(); break; case 'history_detail': $query = ' DELETE FROM ' . HISTORY_TABLE . ' ;'; pwg_query($query); break;
/** * API method * Deletes rates of an user * @param mixed[] $params * @option int user_id * @option string anonymous_id (optional) */ function ws_rates_delete($params, &$service) { $query = ' DELETE FROM ' . RATE_TABLE . ' WHERE user_id=' . $params['user_id']; if (!empty($params['anonymous_id'])) { $query .= ' AND anonymous_id=\'' . $params['anonymous_id'] . '\''; } if (!empty($params['image_id'])) { $query .= ' AND element_id=' . $params['image_id']; } $changes = pwg_db_changes(pwg_query($query)); if ($changes) { include_once PHPWG_ROOT_PATH . 'include/functions_rate.inc.php'; update_rating_score(); } return $changes; }
/** * Rate a picture by the current user. * * @param int $image_id * @param float $rate * @return array as return by update_rating_score() */ function rate_picture($image_id, $rate) { global $conf, $user; if (!isset($rate) or !$conf['rate'] or !preg_match('/^[0-9]+$/', $rate) or !in_array($rate, $conf['rate_items'])) { return false; } $user_anonymous = is_autorize_status(ACCESS_CLASSIC) ? false : true; if ($user_anonymous and !$conf['rate_anonymous']) { return false; } $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]); if (count($ip_components) > 3) { array_pop($ip_components); } $anonymous_id = implode('.', $ip_components); if ($user_anonymous) { $save_anonymous_id = pwg_get_cookie_var('anonymous_rater', $anonymous_id); if ($anonymous_id != $save_anonymous_id) { // client has changed his IP adress or he's trying to fool us $query = ' SELECT element_id FROM ' . RATE_TABLE . ' WHERE user_id = ' . $user['id'] . ' AND anonymous_id = \'' . $anonymous_id . '\' ;'; $already_there = array_from_query($query, 'element_id'); if (count($already_there) > 0) { $query = ' DELETE FROM ' . RATE_TABLE . ' WHERE user_id = ' . $user['id'] . ' AND anonymous_id = \'' . $save_anonymous_id . '\' AND element_id IN (' . implode(',', $already_there) . ') ;'; pwg_query($query); } $query = ' UPDATE ' . RATE_TABLE . ' SET anonymous_id = \'' . $anonymous_id . '\' WHERE user_id = ' . $user['id'] . ' AND anonymous_id = \'' . $save_anonymous_id . '\' ;'; pwg_query($query); } // end client changed ip pwg_set_cookie_var('anonymous_rater', $anonymous_id); } // end anonymous user $query = ' DELETE FROM ' . RATE_TABLE . ' WHERE element_id = ' . $image_id . ' AND user_id = ' . $user['id'] . ' '; if ($user_anonymous) { $query .= ' AND anonymous_id = \'' . $anonymous_id . '\''; } pwg_query($query); $query = ' INSERT INTO ' . RATE_TABLE . ' (user_id,anonymous_id,element_id,rate,date) VALUES (' . $user['id'] . ',' . '\'' . $anonymous_id . '\',' . $image_id . ',' . $rate . ',NOW()) ;'; pwg_query($query); return update_rating_score($image_id); }