コード例 #1
0
function save_upload_form_config($data, &$errors = array(), &$form_errors = array())
{
    if (!is_array($data) or empty($data)) {
        return false;
    }
    $upload_form_config = get_upload_form_config();
    $updates = array();
    foreach ($data as $field => $value) {
        if (!isset($upload_form_config[$field])) {
            continue;
        }
        if (is_bool($upload_form_config[$field]['default'])) {
            if (isset($value)) {
                $value = true;
            } else {
                $value = false;
            }
            $updates[] = array('param' => $field, 'value' => boolean_to_string($value));
        } elseif ($upload_form_config[$field]['can_be_null'] and empty($value)) {
            $updates[] = array('param' => $field, 'value' => 'false');
        } else {
            $min = $upload_form_config[$field]['min'];
            $max = $upload_form_config[$field]['max'];
            $pattern = $upload_form_config[$field]['pattern'];
            if (preg_match($pattern, $value) and $value >= $min and $value <= $max) {
                $updates[] = array('param' => $field, 'value' => $value);
            } else {
                $errors[] = sprintf($upload_form_config[$field]['error_message'], $min, $max);
                $form_errors[$field] = '[' . $min . ' .. ' . $max . ']';
            }
        }
    }
    if (count($errors) == 0) {
        mass_updates(CONFIG_TABLE, array('primary' => array('param'), 'update' => array('value')), $updates);
        return true;
    }
    return false;
}
コード例 #2
0
ファイル: photos_add.php プロジェクト: lcorbasson/Piwigo
if (!defined("PHPWG_ROOT_PATH")) {
    die("Hacking attempt!");
}
include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php';
include_once PHPWG_ROOT_PATH . 'admin/include/image.class.php';
define('PHOTOS_ADD_BASE_URL', get_root_url() . 'admin.php?page=photos_add');
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok                      |
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
// +-----------------------------------------------------------------------+
// |                          Load configuration                           |
// +-----------------------------------------------------------------------+
$upload_form_config = get_upload_form_config();
// +-----------------------------------------------------------------------+
// |                                 Tabs                                  |
// +-----------------------------------------------------------------------+
if (isset($_GET['section'])) {
    $page['tab'] = $_GET['section'];
    // backward compatibility
    if ('ploader' == $page['tab']) {
        $page['tab'] = 'applications';
    }
} else {
    $page['tab'] = 'direct';
}
$tabsheet = new tabsheet();
$tabsheet->set_id('photos_add');
$tabsheet->select($page['tab']);