Example #1
0
function gnavi_submit_uploader($field, $del_photo, $preview_name, $num, $errmsg)
{
    global $gnavi_canresize, $photos_dir, $array_allowed_mimetypes, $gnavi_fsize, $gnavi_width, $gnavi_height, $array_allowed_exts;
    $tmp_name = '';
    $ext = '';
    // Check if upload file name specified
    if (empty($field) || $field == "") {
        die("UPLOAD error: file name not specified");
    }
    if ($_FILES[$field]['name'] == '') {
        // No photo uploaded
        if ($preview_name != '' && is_readable("{$photos_dir}/{$preview_name}")) {
            if ($del_photo == 1) {
                @unlink("{$photos_dir}/{$preview_name}");
            } else {
                $tmp_name = $preview_name;
                $ext = substr(strrchr($tmp_name, '.'), 1);
            }
        }
    } else {
        if ($_FILES[$field]['tmp_name'] == "") {
            // Fail to upload (wrong file name etc.)
            $errmsg .= "<br />File {$num} " . _MD_GNAV_MSG_FILEERROR;
        } else {
            if ($preview_name != '' && is_readable("{$photos_dir}/{$preview_name}")) {
                @unlink("{$photos_dir}/{$preview_name}");
            }
            if ($gnavi_canresize) {
                $uploader = new MyXoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $gnavi_fsize, null, null, $array_allowed_exts);
            } else {
                $uploader = new MyXoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $gnavi_fsize, $gnavi_width, $gnavi_height, $array_allowed_exts);
            }
            $uploader->setPrefix('tmp_');
            if ($uploader->fetchMedia($field) && $uploader->upload()) {
                // Succeed to upload
                $tmp_name = $uploader->getSavedFileName();
                $ext = substr(strrchr($tmp_name, '.'), 1);
            } else {
                // Fail to upload (sizeover etc.)
                $errmsg .= "<br />" . $uploader->getErrors();
                @unlink($uploader->getSavedDestination());
            }
            if (!is_readable("{$photos_dir}/{$tmp_name}")) {
                $errmsg .= "<br />File {$num} " . _MD_GNAV_MSG_FILEREADERROR;
            }
        }
    }
    return array($tmp_name, $ext, $errmsg);
}
Example #2
0
    myalbum_header();
}
include_once "../../class/xoopsformloader.php";
include_once "../../include/xoopscodes.php";
// Preview
if ($caller != 'imagemanager' && !empty($_POST['preview'])) {
    $photo['description'] = $myts->stripSlashesGPC($_POST["desc_text"]);
    $photo['title'] = $myts->stripSlashesGPC($_POST["title"]);
    $photo['cid'] = empty($_POST['cid']) ? 0 : intval($_POST['cid']);
    $field = $_POST['xoops_upload_file'][0];
    if (is_readable($_FILES[$field]['tmp_name'])) {
        // new preview
        if ($myalbum_canresize) {
            $uploader = new MyXoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $myalbum_fsize, null, null, $array_allowed_exts);
        } else {
            $uploader = new MyXoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $myalbum_fsize, $myalbum_width, $myalbum_height, $array_allowed_exts);
        }
        $uploader->setPrefix('tmp_');
        if ($uploader->fetchMedia($field) && $uploader->upload()) {
            $tmp_name = $uploader->getSavedFileName();
            $preview_name = str_replace('tmp_', 'tmp_prev_', $tmp_name);
            myalbum_modify_photo("{$photos_dir}/{$tmp_name}", "{$photos_dir}/{$preview_name}");
            list($imgsrc, $width_spec, $ahref) = myalbum_get_img_attribs_for_preview($preview_name);
        } else {
            @unlink($uploader->getSavedDestination());
            $imgsrc = "{$mod_url}/images/pixel_trans.gif";
            $width_spec = "width='{$myalbum_thumbsize}' height='{$myalbum_thumbsize}'";
            $ahref = '';
        }
    } else {
        if ($preview_name != '' && is_readable("{$photos_dir}/{$preview_name}")) {
Example #3
0
 } else {
     $valid = 2;
 }
 $cid = empty($_POST['cid']) ? 0 : intval($_POST['cid']);
 // Check if upload file name specified
 $field = $_POST["xoops_upload_file"][0];
 if (empty($field) || $field == "") {
     die("UPLOAD error: file name not specified");
 }
 $field = $_POST['xoops_upload_file'][0];
 // Check if file uploaded
 if ($_FILES[$field]['tmp_name'] != "" && $_FILES[$field]['tmp_name'] != "none") {
     if ($myalbum_canresize) {
         $uploader = new MyXoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $myalbum_fsize, null, null, $array_allowed_exts);
     } else {
         $uploader = new MyXoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $myalbum_fsize, $myalbum_width, $myalbum_height, $array_allowed_exts);
     }
     $uploader->setPrefix('tmp_');
     if ($uploader->fetchMedia($field) && $uploader->upload()) {
         // remove old file.
         $prs = $xoopsDB->query("SELECT ext FROM {$table_photos} WHERE lid={$lid}");
         list($ext) = $xoopsDB->fetchRow($prs);
         @unlink("{$photos_dir}/{$lid}.{$ext}");
         @unlink("{$thumbs_dir}/{$lid}.{$ext}");
         @unlink("{$thumbs_dir}/{$lid}.gif");
         // The original file name will be the title if title is empty
         if (trim($_POST["title"]) === "") {
             $_POST['title'] = $uploader->getMediaName();
         }
         $title = $myts->stripSlashesGPC($_POST["title"]);
         $desc_text = $myts->stripSlashesGPC($_POST["desc_text"]);