diff --git a/inc/class.npu_uploader.php b/inc/class.npu_uploader.php index b12d118..1e713f4 100644 --- a/inc/class.npu_uploader.php +++ b/inc/class.npu_uploader.php @@ -10,17 +10,17 @@ class UploaderNggAdmin extends nggAdmin { // Public Variables - public $arrImageIds = array(); - public $arrImageNames = array(); - public $arrThumbReturn = array(); + static public $arrImageIds = array(); + static public $arrImageNames = array(); + static public $arrThumbReturn = array(); + static public $strGalleryPath = ''; public $arrEXIF = array(); public $arrErrorMsg = array(); public $arrErrorMsg_widg = array(); public $strFileName = ''; - public $strGalleryPath = ''; public $blnRedirectPage = false; - function upload_images() { + static function upload_images() { global $wpdb; // Image Array $imageslist = array(); @@ -41,7 +41,8 @@ function upload_images() { return; } // Read Image List - $dirlist = $this->scandir( WINABSPATH . $gallerypath ); + $dirlist = UploaderNggAdmin::scandir(WINABSPATH . $gallerypath); + foreach( $_FILES as $key => $value ) { if ( $_FILES[$key]['error'] == 0 ) { $entropy = ''; @@ -75,10 +76,10 @@ function upload_images() { // Save Temporary File if ( !@move_uploaded_file( $_FILES[$key]['tmp_name'], $dest_file ) ) { self::show_error( __( 'Error, the file could not moved to: ', 'nextgen-public-uploader' ) . $dest_file ); - $this->check_safemode( WINABSPATH.$gallerypath ); + self::check_safemode( WINABSPATH.$gallerypath ); continue; } - if ( ! $this->chmod( $dest_file ) ) { + if ( ! self::chmod( $dest_file ) ) { self::show_error( __( 'Error, the file permissions could not set.', 'nextgen-public-uploader' ) ); continue; } @@ -94,22 +95,24 @@ function upload_images() { $npu_exclude_id = 1; } // Add Images to Database - $image_ids = $this->add_Images( $galleryID, $imageslist ); - $this->arrThumbReturn = array(); + $image_ids = self::add_Images( $galleryID, $imageslist ); + + self::$arrThumbReturn = array(); + foreach ( $image_ids as $pid ) { $wpdb->query( "UPDATE $wpdb->nggpictures SET exclude = '$npu_exclude_id' WHERE pid = '$pid'" ); - $this->arrThumbReturn[] = $this->create_thumbnail( $pid ); + self::$arrThumbReturn[] = self::create_thumbnail( $pid ); } - $this->arrImageIds = array(); - $this->arrImageIds = $image_ids; - $this->arrImageNames = array(); - $this->arrImageNames = $imageslist; - $this->strGalleryPath = $gallerypath; + self::$arrImageIds = array(); + self::$arrImageIds = $image_ids; + self::$arrImageNames = array(); + self::$arrImageNames = $imageslist; + self::$strGalleryPath = $gallerypath; } return; } // End Function - function upload_images_widget() { + static function upload_images_widget() { global $wpdb; // Image Array $imageslist = array(); @@ -130,7 +133,7 @@ function upload_images_widget() { return; } // Read Image List - $dirlist = $this->scandir( WINABSPATH . $gallerypath ); + $dirlist = self::scandir( WINABSPATH . $gallerypath ); foreach( $_FILES as $key => $value ) { if ( $_FILES[$key]['error'] == 0 ) { $temp_file = $_FILES[$key]['tmp_name']; @@ -159,10 +162,10 @@ function upload_images_widget() { // Save Temporary File if ( ! @move_uploaded_file( $_FILES[$key]['tmp_name'], $dest_file ) ) { self::show_error( __( 'Error, the file could not moved to: ', 'nextgen-public-uploader' ) . $dest_file ); - $this->check_safemode( WINABSPATH . $gallerypath ); + self::check_safemode( WINABSPATH . $gallerypath ); continue; } - if ( ! $this->chmod( $dest_file ) ) { + if ( ! self::chmod( $dest_file ) ) { self::show_error( __( 'Error, the file permissions could not set.', 'nextgen-public-uploader' ) ); continue; } @@ -178,19 +181,19 @@ function upload_images_widget() { $npu_exclude_id = 1; } // Add Images to Database - $image_ids = $this->add_Images( $galleryID, $imageslist ); - $this->arrThumbReturn = array(); + $image_ids = self::add_Images( $galleryID, $imageslist ); + self::$arrThumbReturn = array(); foreach ( $image_ids as $pid ) { //TODO: prepare $wpdb->query( "UPDATE $wpdb->nggpictures SET exclude = '$npu_exclude_id' WHERE pid = '$pid'" ); - $this->arrThumbReturn[] = $this->create_thumbnail( $pid ); + self::$arrThumbReturn[] = self::create_thumbnail($pid); } - $this->arrImageIds = array(); - $this->arrImageIds = $image_ids; - $this->arrImageNames = array(); - $this->arrImageNames = $imageslist; - $this->strGalleryPath = $gallerypath; + self::$arrImageIds = array(); + self::$arrImageIds = $image_ids; + self::$arrImageNames = array(); + self::$arrImageNames = $imageslist; + self::$strGalleryPath = $gallerypath; } return; } // End Function diff --git a/inc/npu-upload.php b/inc/npu-upload.php index a08c29f..18e091e 100644 --- a/inc/npu-upload.php +++ b/inc/npu-upload.php @@ -96,8 +96,9 @@ public function display_uploader( $gal_id, $strDetailsPage = false, $blnShowAltT } if ( !is_user_logged_in() && get_option( 'npu_user_role_select' ) != 99 ) { $strOutput .= '