0 ) { require_once( dirname(__FILE__) . '/../../../../wp-load.php' ); // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie']; elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; @header('Content-Type: text/html; charset=' . get_option('blog_charset')); require_once(ABSPATH. 'wp-admin/includes/image.php' ); // Connect image resize functions function wpdev_make_file_upload( &$file, $dir , $url ) { // The default error handler. if (! function_exists( 'wp_handle_upload_error' ) ) { function wp_handle_upload_error( &$file, $message ) { return array( 'error'=>$message ); } } // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. $upload_error_strings = array( false, __( "The uploaded file exceeds the upload_max_filesize directive in php.ini." ), __( "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form." ), __( "The uploaded file was only partially uploaded." ), __( "No file was uploaded." ), '', __( "Missing a temporary folder." ), __( "Failed to write file to disk." ), __( "File upload stopped by extension." )); // A successful upload will pass this test. It makes no sense to override this one. if ( $file['error'] > 0 ) return wp_handle_upload_error( $file, $upload_error_strings[$file['error']] ); // A non-empty file will pass this test. if ( !($file['size'] > 0 ) ) return wp_handle_upload_error( $file, __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.' )); // A properly uploaded file will pass this test. There should be no reason to override this one. if (! @ is_uploaded_file( $file['tmp_name'] ) ) return wp_handle_upload_error( $file, __( 'Specified file failed upload test.' )); // If you override this, you must provide $ext and $type!!!! $test_type = true; $mimes = false; // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. $wp_filetype = wp_check_filetype( $file['name'], $mimes ); extract( $wp_filetype ); if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) return wp_handle_upload_error( $file, __( 'File type does not meet security guidelines. Try another.' )); if ( !$ext ) $ext = ltrim(strrchr($file['name'], '.'), '.'); if ( !$type ) $type = $file['type']; // A writable uploads dir will pass this test. Again, there's no point overriding this one. if ( ! isset( $dir) ) return wp_handle_upload_error( $file, __('Source upload directory is not set') ); $filename = wp_unique_filename( $dir, $file['name'], null ); // Move the file to the uploads dir $new_file = $dir . "/$filename"; if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) return wp_handle_upload_error( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $dir ) ); // Set correct file permissions $stat = stat( dirname( $new_file )); $perms = $stat['mode'] & 0000666; @ chmod( $new_file, 0766 /*$perms */); // Compute the URL $url = $url . "/$filename"; return array( 'file' => $new_file, 'url' => $url, 'type' => $type ) ; } //debuge($_REQUEST); //////////// $file = wpdev_make_file_upload($_FILES['wpdev-async-upload'], $_REQUEST['dir_icons'], $_REQUEST['url_icons']); if ( isset($file['error']) ) { echo $file['error'] ; return 0; } $url = $file['url']; $type = $file['type']; $full_path_file = $file['file']; $name = $_FILES['wpdev-async-upload']['name']; $name_parts = pathinfo($name); $ext = $name_parts['extension']; $title = trim( substr( $name, 0, -(1 + strlen($ext)) ) ); $name_parts_real = pathinfo($full_path_file); $file_name_only = trim( substr( $name_parts_real['basename'], 0, -(1 + strlen($ext)) ) ); $imagesize_original = getimagesize( $full_path_file ); //debuge($imagesize_original, '$imagesize_original'); //debuge($_REQUEST['size_w'], $_REQUEST["size_h"], $_REQUEST["crop"]); if ( ( $imagesize_original[0] < $_REQUEST['size_w']) || ( $imagesize_original[1] < $_REQUEST['size_h']) ) { $_REQUEST['size_w'] = $imagesize_original[0]-1; $_REQUEST["size_h"] = $imagesize_original[1]-1; } //debuge($_REQUEST['size_w'], $_REQUEST["size_h"], $_REQUEST["crop"]); $resized = image_resize( $full_path_file, $_REQUEST['size_w'], $_REQUEST["size_h"], $_REQUEST["crop"] ); //debuge($resized); if (! $resized ) { //$_REQUEST['dir_icons'], $_REQUEST['url_icons'] $previos_name = $file_name_only. '.'.$ext ; $renamed = $file_name_only. '-'.$_REQUEST['size_w'].'x'. $_REQUEST["size_h"].'.'.$ext ; if (! copy($_REQUEST['dir_icons'] . '/' . $previos_name, $_REQUEST['dir_icons'] . '/' . $renamed) ) { echo '
Cant rename file ' . $previos_name . ' to ' . $renamed . '.
Its can make problem of showing resized thumb of image.
Please upload lager file.
'; } } else { @ chmod( $resized, 0766 /*$perms */); } $result = '
'; if ($resized ) $result .= ''. $title .''; else $result .= ''. $title .''; $result .= $file_name_only . '.' . $ext ; $result .= ''. ''. ''. '
'. '' . __('Delete'). '' . // '' . __('Hide'). ''. '
'. '
' ; $result .= '
'; echo $result; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Getting Ajax requests ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $action = $_POST['ajax_action']; if ( isset($action) ) { //require_once( dirname(__FILE__) . '/../../../../wp-load.php' ); //@header('Content-Type: text/html; charset=' . get_option('blog_charset')); switch ( $action ) : case 'delete-image' : // get file path $path = $_POST['file_name_dir'] . '/' . $_POST['file_name_org']; // generate icon path $name_parts = pathinfo($path); $ext = $name_parts['extension']; $file_name_only = trim( substr( $name_parts['basename'], 0, -(1 + strlen($ext)) ) ); $path_icon = $_POST['file_name_dir'] . '/' . $file_name_only . $_POST['fileicon_size'] ; if (file_exists($path)) unlink( $path ); if (file_exists($path_icon)) unlink( $path_icon ); die( 1 ); break; endswitch; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // MAIN CLASS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (!class_exists('wpdev_flash_uploader')) { class wpdev_flash_uploader { var $icons_url; var $icons_dir; var $is_dir_exist; var $max_width; var $max_height; var $is_crop_img; var $sentence; function wpdev_flash_uploader($sentence, $is_client = false, $is_admin = true){ $this->is_dir_exist = false; $this->sentence = $sentence; $this->print_js(); } // S E T ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // set directory where to upload images function set_dir($my_path ){ $this->icons_dir = $my_path[0]; $this->icons_url = $my_path[1]; $this->is_dir_exist = $this->wpdev_mk_dir($this->icons_dir); } // set max width and height for croping function set_sizes($mw, $mh, $img_c = 1){ $this->max_width = $mw; $this->max_height = $mh; $this->is_crop_img = $img_c; } // Main ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Print JS files at head function print_js() { wp_print_scripts('swfupload-all'); wp_print_scripts('swfupload-handlers'); ?>
sentence ); ?>:
wpdev_rm_dir( $file ); else unlink( $file ); } rmdir( $dir ); } } } ?>