Allastra
Forum Replies Created
-
Forum: Reviews
In reply to: [Easy Watermark] DONT INSTALL THIS – BUGGEDI’m having the same issue, with the added problem that it thinks the images have been restored, but they all still have the watermark. there’s no backup as they were removed in the “restore” process.
- This reply was modified 6 years, 7 months ago by Allastra.
Not sure, as it turns out its not exactly working. I’ve still got an error coming up, though i think it’s because the file is too large.
Though the _____ is not a valid file was never an error I was getting…
here’s my class.npu_uploader.php file, hope it helps
<?php // Get NextGEN Gallery Functions require_once (NGGALLERY_ABSPATH."/admin/functions.php"); class UploaderNggAdmin extends nggAdmin { // Public Variables public $arrImageIds = false; public $strGalleryPath = false; public $arrImageNames = false; public $strFileName = false; public $blnRedirectPage = false; public $arrThumbReturn = false; public $arrEXIF = false; public $arrErrorMsg = array(); public $arrErrorMsg_widg = array(); function upload_images() { global $wpdb; // Image Array $imageslist = array(); // Get Gallery ID $galleryID = (int) $_POST['galleryselect']; if ($galleryID == 0) { if(get_option('npu_default_gallery')) { $galleryID = get_option('npu_default_gallery'); } else { nggGallery::show_error(__('No gallery selected.','nggallery')); return; } } // Get Gallery Path $gallerypath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' "); if (!$gallerypath){ nggGallery::show_error(__('Failure in database, no gallery path set.','nggallery')); return; } // Read Image List $dirlist = $this->scandir(WINABSPATH.$gallerypath); foreach ($_FILES as $key => $value) { if ($_FILES[$key]['error'] == 0) { $entropy = ''; $temp_file = $_FILES[$key]['tmp_name']; $filepart = pathinfo ( strtolower($_FILES[$key]['name']) ); // Required Until PHP 5.2.0 $filepart['filename'] = substr($filepart["basename"],0 ,strlen($filepart["basename"]) - (strlen($filepart["extension"]) + 1) ); // Random hash generation added by [https://www.linus-neumann.de/2011/04/19/ngg_pu_patch] $randPool = '0123456789abcdefghijklmnopqrstuvwxyz'; for($i = 0; $i<20; $i++) $entropy .= $randPool[mt_rand(0,strlen($randPool)-1)]; $filename = sanitize_title($filepart['filename']) . '-' . sha1(md5($entropy)). '.' .$filepart['extension']; // Allowed Extensions $ext = array('jpeg', 'jpg', 'png', 'gif', 'tiff', 'bmp' ); if ( !in_array($filepart['extension'], $ext) || !@getimagesize($temp_file) ){ //nggGallery::show_error('<strong>'.$_FILES[$key]['name'].' </strong>'.__('is not a valid file.','nggallery')); continue; } // Check If File Exists $i = 0; while (in_array($filename,$dirlist)) { $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' .$filepart['extension']; } $dest_file = WINABSPATH . $gallerypath . '/' . $filename; // Check Folder Permissions if (!is_writeable(WINABSPATH.$gallerypath)) { //$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH.$gallerypath); nggGallery::show_error($message); return; } // Save Temporary File if (!@move_uploaded_file($_FILES[$key]['tmp_name'], $dest_file)){ // nggGallery::show_error(__('Error, the file could not moved to : ','nggallery').$dest_file); $this->check_safemode(WINABSPATH.$gallerypath); continue; } if (!$this->chmod ($dest_file)) { // nggGallery::show_error(__('Error, the file permissions could not set.','nggallery')); continue; } // Add to Image and Dir List $imageslist[] = $filename; $dirlist[] = $filename; } } if (count($imageslist) > 0) { if ( ! get_option('npu_exclude_select') ) { $npu_exclude_id = 0; } else { $npu_exclude_id = 1; } // Add Images to Database $image_ids = $this->add_Images($galleryID, $imageslist); $this->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); } $this->arrImageIds = array(); $this->arrImageIds = $image_ids; $this->arrImageNames =array(); $this->arrImageNames = $imageslist; $this->strGalleryPath = $gallerypath; } return; } // End Function function upload_images_widget() { global $wpdb; // Image Array $imageslist = array(); // Get Gallery ID $galleryID = (int) $_POST['galleryselect']; if ($galleryID == 0) { if(get_option('npu_default_gallery')) { $galleryID = get_option('npu_default_gallery'); } else { //nggGallery::show_error(__('No gallery selected.','nggallery')); return; } } // Get Gallery Path $gallerypath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' "); if (!$gallerypath){ // nggGallery::show_error(__('Failure in database, no gallery path set.','nggallery')); return; } // Read Image List $dirlist = $this->scandir(WINABSPATH.$gallerypath); foreach ($_FILES as $key => $value) { if ($_FILES[$key]['error'] == 0) { $temp_file = $_FILES[$key]['tmp_name']; $filepart = pathinfo ( strtolower($_FILES[$key]['name']) ); // Required Until PHP 5.2.0 $filepart['filename'] = substr($filepart["basename"],0 ,strlen($filepart["basename"]) - (strlen($filepart["extension"]) + 1) ); $filename = sanitize_title($filepart['filename']) . '.' . $filepart['extension']; // Allowed Extensions $ext = array('jpeg', 'jpg', 'png', 'gif'); if ( !in_array($filepart['extension'], $ext) || !@getimagesize($temp_file) ){ //nggGallery::show_error('<strong>'.$_FILES[$key]['name'].' </strong>'.__('is not a valid file.','nggallery')); continue; } // Check If File Exists $i = 0; while (in_array($filename,$dirlist)) { $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' .$filepart['extension']; } $dest_file = WINABSPATH . $gallerypath . '/' . $filename; // Check Folder Permissions if (!is_writeable(WINABSPATH.$gallerypath)) { // $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH.$gallerypath); // nggGallery::show_error($message); return; } // Save Temporary File if (!@move_uploaded_file($_FILES[$key]['tmp_name'], $dest_file)){ // nggGallery::show_error(__('Error, the file could not moved to : ','nggallery').$dest_file); $this->check_safemode(WINABSPATH.$gallerypath); continue; } if (!$this->chmod ($dest_file)) { // nggGallery::show_error(__('Error, the file permissions could not set.','nggallery')); continue; } // Add to Image and Dir List $imageslist[] = $filename; $dirlist[] = $filename; } } if (count($imageslist) > 0) { if ( ! get_option('npu_exclude_select') ) { $npu_exclude_id = 0; } else { $npu_exclude_id = 1; } // Add Images to Database $image_ids = $this->add_Images($galleryID, $imageslist); $this->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); } $this->arrImageIds = array(); $this->arrImageIds = $image_ids; $this->arrImageNames =array(); $this->arrImageNames = $imageslist; $this->strGalleryPath = $gallerypath; } return; } // End Function }
Nevermind i’ve got it working now ?? Thanks sometimes it just helps talking stuff out while i work ?? (there are echo statements all over npu-uploader, removing them so they only returned if there was an error helped ??
Hey all,
I’ve got it down to it’s echoing out an error even though it’s uploading the file fine.
No file has been selected. Please select a file first before hitting the upload button.No file has been selected. Please select a file first before hitting the upload button.No file has been selected. Please select a file first before hitting the upload button.
pops up right before my success message… why is it repeating a million times and where might i find the code that echos this.
i activated the updated Jetpack and I am still having the same error.
Doctor+Who+Valentine_c53894_4430284.jpg is not a valid file.
Warning: Invalid argument supplied for foreach() in [npu-upload.php path] on line 469
Doctor+Who+Valentine_c53894_4430284.jpg is not a valid file.Warning: Invalid argument supplied for foreach() in [npu-upload.php path] on line 469
at header
Doctor+Who+Valentine_c53894_4430284.jpg is not a valid file.
Warning: Invalid argument supplied for foreach() in [/npu-upload.php file path] on line 469
above gallery on page
You must select a file to uploadYou must select a file to uploadYou must select a file to upload
Your File Has been added successfullybefore uploader form
also note that the line given must be created as part of the loop as there is no line 469 in that file.
I’m having the same problem, however I do not have Jetpack enabled.