Esempio n. 1
0
            $_POST['price'] = abs($_POST['price']);
        }
        if (file_exists($filename)) {
            $new_name = tempnam("../upload", $filename);
            move_uploaded_file($_FILES['pic']['tmp_name'], $new_name);
            $id = Pictures::add_conflict($filename, $new_name, $_POST['tag'], $_POST['title'], $_POST['price'], $user['id']);
            http_redirect(Pictures::$CONFLICT_URL . "?conflictid={$id}");
        } else {
            if (move_uploaded_file($_FILES['pic']['tmp_name'], $filename)) {
                if ($id = Pictures::create_picture($_POST['title'], 128, 128, $_POST['tag'], $relfilename, $_POST['price'], $user['id'])) {
                    $main = ".550.jpg";
                    $side = ".128.jpg";
                    $thumb = ".128_128.jpg";
                    Pictures::resize_image($filename, $filename . $main, 550, 10000000);
                    Pictures::resize_image($filename, $filename . $side, 128, 10000000);
                    Pictures::resize_image($filename, $filename . $thumb, 128, 128);
                    http_redirect(Pictures::$VIEW_PIC_URL . "?picid={$id}");
                    $file_uploaded = True;
                } else {
                    $flash['error'] = "Couldn't create your picture, something wrong with the database";
                }
            } else {
                $flash['error'] = "Couldn't move picture";
            }
        }
    }
}
if (!$file_uploaded) {
    our_header("upload");
    ?>
<div class="column prepend-1 span-24 first last" >