Ejemplo n.º 1
0
        if ($_FILES['gallery']['size'] > 0) {
            $Upload->file('gallery', '`([a-z0-9()_-])+\\.(jpg|gif|png)+$`i', UNIQ_NAME, $CONFIG_GALLERY['weight_max']);
            if (!empty($Upload->error)) {
                redirect(HOST . DIR . '/gallery/admin_gallery_add.php?error=' . $Upload->error . '#errorh');
            } else {
                $path = $dir . $Upload->filename['gallery'];
                $error = $Upload->validate_img($path, $CONFIG_GALLERY['width_max'], $CONFIG_GALLERY['height_max'], DELETE_ON_ERROR);
                if (!empty($error)) {
                    redirect(HOST . DIR . '/gallery/admin_gallery_add.php?error=' . $error . '#errorh');
                } else {
                    $Gallery->Resize_pics($path);
                    if (!empty($Gallery->error)) {
                        redirect(HOST . DIR . '/gallery/admin_gallery_add.php?error=' . $Gallery->error . '#errorh');
                    }
                    $name = !empty($_POST['name']) ? strprotect($_POST['name']) : '';
                    $idpic = $Gallery->Add_pics($idcat_post, $name, $Upload->filename['gallery'], $User->get_attribute('user_id'));
                    if (!empty($Gallery->error)) {
                        redirect(HOST . DIR . '/gallery/admin_gallery_add.php?error=' . $Gallery->error . '#errorh');
                    }
                    $Cache->Generate_module_file('gallery');
                }
            }
        }
    }
    redirect(HOST . DIR . '/gallery/admin_gallery_add.php?add=' . $idpic);
} elseif (!empty($_POST['valid']) && !empty($nbr_pics_post)) {
    for ($i = 1; $i <= $nbr_pics_post; $i++) {
        $activ = !empty($_POST[$i . 'activ']) ? trim($_POST[$i . 'activ']) : '';
        $uniq = !empty($_POST[$i . 'uniq']) ? strprotect($_POST[$i . 'uniq']) : '';
        if ($activ && !empty($uniq)) {
            $name = !empty($_POST[$i . 'name']) ? strprotect($_POST[$i . 'name']) : 0;
Ejemplo n.º 2
0
    }
    if ($error != '') {
        AppContext::get_response()->redirect(GalleryUrlBuilder::get_link_cat_add($id_category, $error) . '#message_helper');
    } else {
        $path = $dir . $Upload->get_filename();
        $error = $Upload->check_img($config->get_max_width(), $config->get_max_height(), Upload::DELETE_ON_ERROR);
        if (!empty($error)) {
            //Erreur, on arrête ici
            AppContext::get_response()->redirect(GalleryUrlBuilder::get_link_cat_add($id_category, $error) . '#message_helper');
        } else {
            //Enregistrement de l'image dans la bdd.
            $Gallery->Resize_pics($path);
            if ($Gallery->get_error() != '') {
                AppContext::get_response()->redirect(GalleryUrlBuilder::get_link_cat_add($id_category, $Upload->get_error()) . '#message_helper');
            }
            $idpic = $Gallery->Add_pics($idcat_post, $name_post, $Upload->get_filename(), AppContext::get_current_user()->get_id());
            if ($Gallery->get_error() != '') {
                AppContext::get_response()->redirect(GalleryUrlBuilder::get_link_cat_add($id_category, $Upload->get_error()) . '#message_helper');
            }
            //Régénération du cache des photos aléatoires.
            GalleryMiniMenuCache::invalidate();
        }
    }
    AppContext::get_response()->redirect(Url::to_absolute('/gallery/gallery' . url('.php?add=1&cat=' . $idcat_post . '&id=' . $idpic, '-' . $idcat_post . '-' . $idpic . '.php?add=1', '&')));
} elseif ($g_add) {
    if (AppContext::get_current_user()->is_readonly()) {
        $controller = PHPBoostErrors::user_in_read_only();
        DispatchManager::redirect($controller);
    }
    $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_categories();
    $tpl = new FileTemplate('gallery/gallery_add.tpl');