resize(1200, 1200); $thumb->save($fullpath); } function fgallery_watermark($fullpath) { if (FGALLERY_PHP4_MODE) return false; $wm_file = get_option('1_flash_gallery_watermark_path',''); if ($wm_file == '') return false; $wm_place = get_option('1_flash_gallery_watermark_place','C'); $thumb = PhpThumbFactory::create($fullpath); return $thumb->watermarkImageGD($fullpath,$fullpath,$wm_file,$wm_place); } global $wpdb; $siteurl = get_option('siteurl'); $wm = get_option('1_flash_gallery_watermark_enabled', 0); $extra_dir = str_replace($_SERVER['HTTP_HOST'],'',$siteurl); $extra_dir = str_replace('http://','',$extra_dir); define('EXTRA_DIR',$extra_dir.'/'); define('IMAGES_TABLE', $wpdb->prefix . "fgallery_images"); if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT']. EXTRA_DIR. '/wp-content/uploads/fgallery/'; $file_name = $_FILES['Filedata']['name']; $file_pathinfo = pathinfo($file_name); $filename = str_replace('.'.$file_pathinfo['extension'],'',$file_name); $file_name = date("YmdHis").'.'.$file_pathinfo['extension']; $targetFile = str_replace('//','/',$targetPath) . $file_name; if (isset($_REQUEST['resize']) && is_numeric($_REQUEST['resize'])) { $resize = $_REQUEST['resize']; } else { $resize = 0; } if (isset($_REQUEST['img_parent']) && is_numeric($_REQUEST['img_parent'])) { $img_parent = $_REQUEST['img_parent']; } else { $img_parent = 0; } $fileTypes = str_replace('*.','',$_REQUEST['fileext']); $fileTypes = str_replace(';','|',$fileTypes); $typesArray = split('\|',$fileTypes); $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array(strtolower($fileParts['extension']),$typesArray)) { // Uncomment the following line if you want to make the directory if it doesn't exist // mkdir(str_replace('//','/',$targetPath), 0755, true); if (move_uploaded_file($tempFile,$targetFile)) { $file = getimagesize($targetFile); $img_type = $file['mime']; if ($resize) fgallery_resemple($targetFile); if ($wm) fgallery_watermark($targetFile); $img_path = str_replace($_SERVER['DOCUMENT_ROOT']. EXTRA_DIR,'',$targetFile); $img_size = filesize($targetFile); $wpdb->insert(IMAGES_TABLE, array('img_caption'=>$filename , 'img_vs_folder' => 0, 'img_parent' => $img_parent, 'img_date' => date("Y-m-d H:i:s"), 'img_type' => $img_type, 'img_size' => $img_size, 'img_path' => $img_path)); $wpdb->print_error(); } echo $img_path.'_'.$wpdb->insert_id; } else { echo 'Invalid file type.'; } } ?>