} //================================================================ // Start of execution // convert path-file into // set default message $result = 0; $message = "OK"; // 'posting', 'theme', profile', 'rotate' $type = $_GET['type']; if ($type == 'rotate') { $div = $_GET['div']; $idx = $_GET['idx']; $url = $_GET['url']; $deg = $_GET['deg']; $ts = date("His"); $ret_url = rotate_image($url, $deg, $idx); echo '<script type="text/javascript">'; echo 'PhotoEditor.replaceImage(' . $div . ',' . $idx . ',"' . $ret_url . '?' . $ts . '",' . $deg . ');'; echo '</script>'; } else { // like '/opt/nas/s1/xx/xx/xx/<user_id>/file_name' with extension $src = $_GET['src']; if (file_exists($src)) { // like '/opt/nas/s1/xx/xx/xx/<user_id>/file_name' with extension $dst = $_GET['dst']; // dim = 'w1xh1:w2xh2:, ...' $dim = $_GET['dim']; $widths = array(); $heights = array(); $arr = explode(':', $dim); if (count($arr) > 0) {
// test for $ret_val return 0; } //================================================================ // Start of execution // convert path-file into // set default message $message = "OK"; $result = 0; // 'posting', 'theme', profile', 'rotate' $type = $_GET['type']; // like '/opt/nas/s1/xx/xx/xx/<user_id>/file_name' with extension $src = $_GET['src']; if ($type == 'rotate') { $deg = $_GET['deg']; $result = rotate_image($src, $deg); } else { // like '/opt/nas/s1/xx/xx/xx/<user_id>/file_name' with extension $dst = $_GET['dst']; // dim = 'w1xh1:w2xh2:, ...' $dim = $_GET['dim']; // lcd = '1 or 2 or 3 (176, 240, 320)' $lcd = $_GET['lcd']; $widths = array(); $heights = array(); $arr = explode(':', $dim); if (count($arr) == 0) { // error $message = "Missing parameters(dimension)"; $result = -9; } else {
} if (file_exists($album_thumb_to_delete)) { unlink($album_thumb_to_delete); } } die; } elseif ($_REQUEST["param"] == "restore_factory_settings") { include GALLERY_BK_PLUGIN_DIR . "/lib/restore_factory_settings.php"; die; } elseif ($_REQUEST["param"] == "rotate_image") { $image_name = esc_attr($_REQUEST["image_name"]); $img_width = intval($_REQUEST["image_width"]); $img_height = intval($_REQUEST["image_height"]); $uploaded_image_path = GALLERY_MAIN_UPLOAD_DIR . $image_name; $thumbnail_image_path = GALLERY_MAIN_THUMB_DIR . $image_name; rotate_image($uploaded_image_path, $thumbnail_image_path, $img_width, $img_height); die; } } } } } } } } } } function process_image_upload($image, $width, $height) { $temp_image_path = GALLERY_MAIN_UPLOAD_DIR . $image; $temp_image_name = $image;
/** * Rotate user avatar file * * @param integer the new avatar file ID * @param integer Degrees to rotate * @return object|string File object on success; * Error code on denied action: * 'only_own_profile' - User can update only own profile * 'wrong_file' - Request with wrong file ID * 'other_user' - Restricted to edit files from other users * 'rotate_error' - Some errors in rotate function */ function rotate_avatar($file_ID, $degrees) { $File =& $this->get_File_by_ID($file_ID, $error_code); if (!$File) { // The file cannot be used for this user, return error code return $error_code; } global $Messages; load_funcs('files/model/_image.funcs.php'); if (!rotate_image($File, $degrees)) { // Some errors were during rotate the avatar $Messages->add(T_('Profile picture could not be rotated!'), 'error'); return 'rotate_error'; } $Messages->add(T_('Profile picture has been rotated.'), 'success'); return true; }
print "<input type=\"hidden\" name=\"user1\" value=\"{$user1}\">"; print "<input type=\"hidden\" name=\"user2\" value=\"{$user2}\">"; print "<input type=\"hidden\" name=\"user3\" value=\"{$user3}\">"; print "<input type=\"hidden\" name=\"user4\" value=\"{$user4}\">"; print "<input type=\"hidden\" name=\"event\" value=\"{$event}\">"; print "<input type=\"hidden\" name=\"transitory_image_path\" value=\"{$path_to_primary_image}\">"; print "<input type=\"hidden\" name=\"file_name\" value=\"{$transitory_file_name}\">"; print "<p>{$lang_image_processor_php['finished_manipulation']}</p>"; print "<br>"; print "<input type=\"submit\" value=\"{$lang_image_processor_php['finished_manipulation_button']}\">"; print "</form>"; pagefooter(); } else { // The user desires to rotate the image. // We use the rotate image function. rotate_image($path_to_primary_image, $degrees); // Get width and height here. $source_image_size_and_type = getimagesize($path_to_primary_image) or die($lang_image_processor_php['file_corrupt']); $source_image_width = $source_image_size_and_type[0]; $source_image_height = $source_image_size_and_type[1]; $source_image_type = $source_image_size_and_type[2]; // Now we have to create the preview thumbnail. // The file has been rotated in the transitory directory. At this point, we // are ready to create the form that will allow the user to rotate the image. // It requires a preview thumbnail to be loaded. We will use the image_preview // function. $path_to_preview_image = image_preview($path_to_primary_image, $maximum_width); // Our preview thumbnail is now on the server. Let's create the // rotation form. make_form($_SERVER[PHP_SELF], $path_to_preview_image, $path_to_primary_image, $transitory_file_name); }
/** * Rotate user avatar file * * @param integer the new avatar file ID * @return mixed TRUE on success; * Error code on denied action: * 'only_own_profile' - User can update only own profile * 'wrong_file' - Request with wrong file ID * 'other_user' - Restricted to edit files from other users * 'rotate_error' - Some errors in rotate function */ function rotate_avatar($file_ID, $degrees) { global $current_User, $Messages; if (!$current_User->check_perm('users', 'edit') && $this->ID != $current_User->ID) { // user is only allowed to update him/herself $Messages->add(T_('You are only allowed to update your own profile!'), 'error'); return 'only_own_profile'; } if ($file_ID == NULL) { $Messages->add(T_('Your profile picture could not be rotated!'), 'error'); return 'wrong_file'; } $FileCache =& get_FileCache(); if (!($File = $FileCache->get_by_ID($file_ID, false))) { // File does't exist $Messages->add(T_('Your profile picture could not be rotated!'), 'error'); return 'wrong_file'; } if ($File->_FileRoot->type != 'user' || $File->_FileRoot->in_type_ID != $this->ID) { // don't allow use the pictures from other users $Messages->add(T_('Your profile picture could not be rotated!'), 'error'); return 'other_user'; } load_funcs('files/model/_image.funcs.php'); if (!rotate_image($File, $degrees)) { // Some errors were during rotate the avatar $Messages->add(T_('Your profile picture could not be rotated!'), 'error'); return 'rotate_error'; } $Messages->add(T_('Your profile picture has been rotated.'), 'success'); return true; }
case 'rotate_90_right': // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('image'); load_funcs('files/model/_image.funcs.php'); switch ($action) { case 'rotate_90_left': $degrees = 90; break; case 'rotate_180': $degrees = 180; break; case 'rotate_90_right': $degrees = 270; break; } if (rotate_image($selected_File, $degrees)) { // Image was rotated successfully header_redirect(regenerate_url('action,crumb_image', 'action=reload_parent', '', '&')); } break; case 'reload_parent': // Reload parent window to update rotated image $JS_additional = 'window.opener.location.reload(true);'; break; } // Add CSS: require_css('basic_styles.css', 'rsc_url'); // the REAL basic styles require_css('basic.css', 'rsc_url'); // Basic styles require_css('viewfile.css', 'rsc_url');