예제 #1
0
파일: picture.php 프로젝트: 4Vs/oc-server3
            // try saving file if smaller unchg_size and browser native format
            if (in_array(mb_strtolower($ext), array('gif', 'png', 'jpg', 'jpeg')) && $_FILES['file']['size'] < $opt['logic']['pictures']['unchg_size']) {
                $picture->setFilenames($_FILES['file']['name']);
                if (!move_uploaded_file($_FILES['file']['tmp_name'], $picture->getFilename())) {
                    $bError = true;
                }
            } else {
                $picture->setFilenames(mb_strtolower($fname) . '.jpg');
                if (!$picture->shrink($_FILES['file']['tmp_name'], PICTURE_MAX_LONG_SIDE)) {
                    $bError = true;
                }
            }
            //try to save in db
            if (!$bError && $picture->save()) {
                if ($redirect == '') {
                    $redirect = $picture->getPageLink();
                }
                $tpl->redirect($redirect);
            } else {
                $tpl->assign('errorfile', ERROR_UPLOAD_UNKNOWN);
                $bError = true;
            }
        }
    }
} else {
    if ($action == 'edit' || $action == 'delete') {
        $uuid = isset($_REQUEST['uuid']) ? $_REQUEST['uuid'] : 0;
        $picture = picture::fromUUID($uuid);
        if ($picture === null) {
            $tpl->error(ERROR_PICTURE_NOT_EXISTS);
        }
예제 #2
0
 $picture->setSpoiler(isset($_REQUEST['spoiler']) && $_REQUEST['spoiler'] == '1');
 // Ocprop
 $picture->setDisplay((isset($_REQUEST['notdisplay']) && $_REQUEST['notdisplay'] == '1') == false);
 // Ocprop
 $picture->setMapPreview(isset($_REQUEST['mappreview']) && $_REQUEST['mappreview'] == '1');
 $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
 // Ocprop
 if ($title == '' || $picture->getObjectType() == OBJECT_CACHELOG && trim($title) == '') {
     $tpl->assign('errortitle', true);
     $bError = true;
 } else {
     $picture->setTitle($title);
 }
 // ignore duplicates (http://redmine.opencaching.de/issues/251)
 if ($picture->is_duplicate()) {
     $tpl->redirect($picture->getPageLink());
 }
 if (!isset($_FILES['file'])) {
     // Ocprop
     $tpl->assign('errorfile', ERROR_UPLOAD_ERR_NO_FILE);
     $bError = true;
 } elseif ($_FILES['file']['error'] == UPLOAD_ERR_NO_FILE) {
     $tpl->assign('errorfile', ERROR_UPLOAD_ERR_NO_FILE);
     $bError = true;
 } elseif ($_FILES['file']['error'] == UPLOAD_ERR_FORM_SIZE || $_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE) {
     $tpl->assign('errorfile', ERROR_UPLOAD_ERR_SIZE);
     $bError = true;
 } elseif ($_FILES['file']['error'] != UPLOAD_ERR_OK) {
     $tpl->assign('errorfile', ERROR_UPLOAD_UNKNOWN);
     $bError = true;
 } elseif ($_FILES['file']['size'] > $opt['logic']['pictures']['maxsize']) {