$template->assign('selected_category', $selected_category);
// image level options
$selected_level = isset($_POST['level']) ? $_POST['level'] : 0;
$template->assign(array('level_options' => get_privacy_level_options(), 'level_options_selected' => array($selected_level)));
// +-----------------------------------------------------------------------+
// | Setup errors/warnings                                                 |
// +-----------------------------------------------------------------------+
// Errors
$setup_errors = array();
$error_message = ready_for_upload_message();
if (!empty($error_message)) {
    $setup_errors[] = $error_message;
}
if (!function_exists('gd_info')) {
    $setup_errors[] = l10n('GD library is missing');
}
$template->assign(array('setup_errors' => $setup_errors, 'CACHE_KEYS' => get_admin_client_cache_keys(array('categories'))));
// Warnings
if (isset($_GET['hide_warnings'])) {
    $_SESSION['upload_hide_warnings'] = true;
}
if (!isset($_SESSION['upload_hide_warnings'])) {
    $setup_warnings = array();
    if ($conf['use_exif'] and !function_exists('read_exif_data')) {
        $setup_warnings[] = l10n('Exif extension not available, admin should disable exif use');
    }
    if (get_ini_size('upload_max_filesize') > get_ini_size('post_max_size')) {
        $setup_warnings[] = l10n('In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting', get_ini_size('upload_max_filesize', false), get_ini_size('post_max_size', false));
    }
    $template->assign(array('setup_warnings' => $setup_warnings, 'hide_warnings_link' => PHOTOS_ADD_BASE_URL . '&hide_warnings=1'));
}
function file_upload_error_message($error_code)
{
    switch ($error_code) {
        case UPLOAD_ERR_INI_SIZE:
            return sprintf(l10n('The uploaded file exceeds the upload_max_filesize directive in php.ini: %sB'), get_ini_size('upload_max_filesize', false));
        case UPLOAD_ERR_FORM_SIZE:
            return l10n('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form');
        case UPLOAD_ERR_PARTIAL:
            return l10n('The uploaded file was only partially uploaded');
        case UPLOAD_ERR_NO_FILE:
            return l10n('No file was uploaded');
        case UPLOAD_ERR_NO_TMP_DIR:
            return l10n('Missing a temporary folder');
        case UPLOAD_ERR_CANT_WRITE:
            return l10n('Failed to write file to disk');
        case UPLOAD_ERR_EXTENSION:
            return l10n('File upload stopped by extension');
        default:
            return l10n('Unknown upload error');
    }
}