die('{"status":"thumb_error: ' . $thumb . '"}'); } } else { @unlink($file); fclose($out); die('{"status":"fwrite_error"}'); } fclose($out); } else { die('{"status":"fopen_error"}'); } } // new app if (isset($_POST['account']) && isset($_FILES['userfile']['name'])) { $path = $wpdb->get_var("SELECT path FROM {$wpdb->flaggallery} WHERE gid = {$gid}"); $filepart = flagGallery::fileinfo($_FILES['userfile']['name']); $filename = $filepart['basename']; $file = ABSPATH . trailingslashit($path) . $filename; // check if this filename already exist $i = 0; while (file_exists($file)) { $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' . $filepart['extension']; } $file = ABSPATH . trailingslashit($path) . $filename; // Open temp file if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $file)) { $alttext = esc_sql($account->alttext); $description = esc_sql($account->description); $exclude = intval($account->exclude); $location = esc_sql($account->location); $wpdb->query("INSERT INTO {$wpdb->flagpictures} (galleryid, filename, alttext, description, exclude, location) VALUES ('{$gid}', '{$filename}', '{$alttext}', '{$description}', '{$exclude}', '{$location}')");
/** * Upload function will be called via the Flash uploader * * @class flagAdmin * @param integer $galleryID * @return string $result */ static function swfupload_image($galleryID = 0) { global $wpdb; if ($galleryID == 0) { //@unlink($temp_file); return __('No gallery selected!', 'flag'); } // WPMU action if (flagAdmin::check_quota()) { return '0'; } // Check the upload if (!isset($_FILES['file']) || !is_uploaded_file($_FILES["file"]["tmp_name"]) || $_FILES["file"]["error"] === UPLOAD_ERR_OK) { flagAdmin::file_upload_error_message($_FILES['file']['error']); } // get the filename and extension $temp_file = $_FILES["file"]['tmp_name']; $filepart = flagGallery::fileinfo($_FILES['file']['name']); $filename = $filepart['basename']; // check for allowed extension $ext = array('jpeg', 'jpg', 'png', 'gif'); if (!in_array($filepart['extension'], $ext)) { return $filename . ' ' . __('is no valid image file!', 'flag'); } // get the path to the gallery $gallerypath = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->flaggallery} WHERE gid = %d ", $galleryID)); if (!$gallerypath) { @unlink($temp_file); return __('Failure in database, no gallery path set !', 'flag'); } // read list of images $imageslist = flagAdmin::scandir(WINABSPATH . $gallerypath); // check if this filename already exist $i = 0; while (in_array($filename, $imageslist)) { $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' . $filepart['extension']; } $dest_file = WINABSPATH . $gallerypath . '/' . $filename; // save temp file to gallery if (!@move_uploaded_file($temp_file, $dest_file)) { flagAdmin::check_safemode(WINABSPATH . $gallerypath); return __('Error, the file could not moved to : ', 'flag') . $dest_file; } if (!flagAdmin::chmod($dest_file)) { return __('Error, the file permissions could not set', 'flag'); } // add images to database $image_ids = flagAdmin::add_Images($galleryID, array($filename)); $return = ''; //create thumbnails foreach ($image_ids as $picture) { $return = flagAdmin::create_thumbnail($picture); } //add the preview image if needed if (intval($_POST['last']) == 1) { flagAdmin::set_gallery_preview($galleryID); } return intval($return) == 1 ? '' : $return; }