示例#1
0
function CategoryTagsFromList($list, &$skipped)
{
    global $DB;
    $tags = array(MIXED_CATEGORY);
    $list = FormatCommaSeparated($list);
    foreach (explode(',', $list) as $name) {
        $name = trim($name);
        if (empty($name)) {
            continue;
        }
        $category = $DB->Row('SELECT * FROM `tx_categories` WHERE `name`=?', array($name));
        if ($category) {
            $tags[] = $category['tag'];
        } else {
            $skipped[] = $name;
        }
    }
    return join(' ', array_unique($tags));
}
示例#2
0
function lxEditLinkField()
{
    global $DB, $C;
    VerifyAdministrator();
    $validator = new Validator();
    $validator->Register($_REQUEST['name'], V_EMPTY, 'The Field Name must be filled in');
    $validator->Register($_REQUEST['name'], V_REGEX, 'The Field Name can contain only letters, numbers, and underscores', '/^[a-z0-9_]+$/i');
    $validator->Register($_REQUEST['label'], V_EMPTY, 'The Label field must be filled in');
    if ($_REQUEST['type'] == FT_SELECT || $_REQUEST['type'] == FT_MULTI_SELECT) {
        $validator->Register($_REQUEST['options'], V_EMPTY, 'The Options field must be filled in for this field type');
    }
    if ($_REQUEST['validation'] != V_NONE) {
        $validator->Register($_REQUEST['validation_message'], V_EMPTY, 'The Validation Error field must be filled in');
    }
    if ($_REQUEST['name'] != $_REQUEST['old_name']) {
        // Get pre-defined fields so there are no duplicates
        $predefined = $DB->GetColumns('lx_links');
        $validator->Register(in_array($_REQUEST['name'], $predefined), V_FALSE, 'The field name you have selected conflicts with a pre-defined field name');
        $field_count = $DB->Count('SELECT COUNT(*) FROM lx_link_field_defs WHERE name=?', array($_REQUEST['name']));
        $validator->Register($field_count, V_ZERO, 'A field with this name already exists');
    }
    if (!$validator->Validate()) {
        $GLOBALS['errstr'] = join('<br />', $validator->GetErrors());
        lxShEditLinkField();
        return;
    }
    $_REQUEST['options'] = FormatCommaSeparated($_REQUEST['options']);
    if ($_REQUEST['name'] != $_REQUEST['old_name']) {
        $DB->Update("ALTER TABLE lx_link_fields CHANGE {$_REQUEST['old_name']} {$_REQUEST['name']} TEXT");
    }
    $DB->Update('UPDATE lx_link_field_defs SET ' . 'name=?, ' . 'label=?, ' . 'type=?, ' . 'tag_attributes=?, ' . 'options=?, ' . 'validation=?, ' . 'validation_extras=?, ' . 'validation_message=?, ' . 'on_submit=?, ' . 'on_edit=?, ' . 'on_details=?, ' . 'required=? ' . 'WHERE field_id=?', array($_REQUEST['name'], $_REQUEST['label'], $_REQUEST['type'], $_REQUEST['tag_attributes'], $_REQUEST['options'], $_REQUEST['validation'], $_REQUEST['validation_extras'], $_REQUEST['validation_message'], intval($_REQUEST['on_submit']), intval($_REQUEST['on_edit']), intval($_REQUEST['on_details']), intval($_REQUEST['required']), $_REQUEST['field_id']));
    $GLOBALS['message'] = 'Link field has been successfully updated';
    $GLOBALS['added'] = true;
    lxShEditLinkField();
}
示例#3
0
function &ValidateCategoryInput($adding = FALSE)
{
    global $DB;
    if ($_REQUEST['movies_preview_size'] == 'custom') {
        $_REQUEST['movies_preview_size'] = $_REQUEST['movies_preview_size_custom'];
    }
    if ($_REQUEST['pics_preview_size'] == 'custom') {
        $_REQUEST['pics_preview_size'] = $_REQUEST['pics_preview_size_custom'];
    }
    $_REQUEST['pics_extensions'] = FormatCommaSeparated($_REQUEST['pics_extensions']);
    $_REQUEST['movies_extensions'] = FormatCommaSeparated($_REQUEST['movies_extensions']);
    $v = new Validator();
    $v->Register($_REQUEST['name'], V_EMPTY, 'The Category Name(s) field must be filled in');
    $v->Register($_REQUEST['per_day'], V_NUMERIC, 'The Submissions Per Day field must be numeric');
    if (strpos($_REQUEST['name'], ',') !== FALSE) {
        $v->SetError('Category names may not contain commas');
    }
    $names = array();
    foreach (explode("\n", $_REQUEST['name']) as $name) {
        $name = trim($name);
        if (strtoupper($name) == 'MIXED') {
            $v->SetError('The word MIXED is reserved and cannot be used as a category name');
        }
        if (preg_match('~^-~', $name)) {
            $v->SetError('Category names cannot start with a dash (-) character');
        }
        if ($adding) {
            if ($DB->Count('SELECT COUNT(*) FROM `tx_categories` WHERE `name`=?', array($name)) < 1) {
                $names[] = $name;
            }
        } else {
            $names[] = $name;
        }
    }
    $_REQUEST['name'] = join("\n", $names);
    if (isset($_REQUEST['pics_allowed'])) {
        $v->Register($_REQUEST['pics_extensions'], V_EMPTY, 'The Pictures File Extensions field must be filled in');
        $v->Register($_REQUEST['pics_minimum'], V_NUMERIC, 'The Pictures Minimum Thumbs field must be numeric');
        $v->Register($_REQUEST['pics_maximum'], V_NUMERIC, 'The Pictures Maximum Thumbs field must be numeric');
        $v->Register($_REQUEST['pics_file_size'], V_NUMERIC, 'The Pictures Minimum Filesize field must be numeric');
        if (isset($_REQUEST['pics_preview_allowed'])) {
            $v->Register($_REQUEST['pics_preview_size'], V_REGEX, 'The Pictures Preview Dimensions must in WIDTHxHEIGHT format', '~^\\d+x\\d+$~');
        }
    }
    if (isset($_REQUEST['movies_allowed'])) {
        $v->Register($_REQUEST['movies_extensions'], V_EMPTY, 'The Movies File Extensions field must be filled in');
        $v->Register($_REQUEST['movies_minimum'], V_NUMERIC, 'The Movies Minimum Thumbs field must be numeric');
        $v->Register($_REQUEST['movies_maximum'], V_NUMERIC, 'The Movies Maximum Thumbs field must be numeric');
        $v->Register($_REQUEST['movies_file_size'], V_NUMERIC, 'The Movies Minimum Filesize field must be numeric');
        if (isset($_REQUEST['movies_preview_allowed'])) {
            $v->Register($_REQUEST['movies_preview_size'], V_REGEX, 'The Movies Preview Dimensions must in WIDTHxHEIGHT format', '~^\\d+x\\d+$~');
        }
    }
    return $v;
}
示例#4
0
 function compile_categories_tag($tag_args)
 {
     global $DB;
     $defaults = array('amount' => 'all', 'order' => 'name');
     $attrs = $this->parse_attributes($tag_args);
     $attrs = array_merge($defaults, $attrs);
     if (empty($attrs['var'])) {
         return $this->syntax_error("categories: missing 'var' attribute");
     }
     $s = new SelectBuilder('*', 'tlx_categories_build');
     if (strtolower($attrs['amount']) != 'all') {
         $s->SetLimit($attrs['amount']);
     }
     if ($attrs['exclude']) {
         $attrs['exclude'] = FormatCommaSeparated($attrs['exclude']);
         $s->AddWhere('name', ST_NOT_IN, $attrs['exclude']);
     }
     if ($attrs['startswith']) {
         $s->AddWhere('name', ST_STARTS, $attrs['startswith']);
     }
     $s->SetOrderString($attrs['order'], $DB->GetColumns('tlx_categories_build'));
     $query = $DB->Prepare($s->Generate(), $s->binds);
     $attrs['var'] = $this->parse_vars($attrs['var']);
     return S_PHP . " if( !isset(\$GLOBALS['_prep_category_build']) )" . NEWLINE . "{" . NEWLINE . "PrepareCategoriesBuild();" . NEWLINE . "}" . NEWLINE . " {$attrs['var']} =& \$GLOBALS['DB']->FetchAll(\"{$query}\"); " . E_PHP;
 }
示例#5
0
文件: index.php 项目: hackingman/TGPX
function txGalleryFieldEdit()
{
    global $DB, $C;
    VerifyAdministrator();
    $v =& ValidateUserDefined('tx_gallery_field_defs', 'tx_galleries', TRUE);
    if (!$v->Validate()) {
        return $v->ValidationError('txShGalleryFieldEdit');
    }
    $_REQUEST['options'] = FormatCommaSeparated($_REQUEST['options']);
    if ($_REQUEST['name'] != $_REQUEST['old_name']) {
        $DB->Update("ALTER TABLE `tx_gallery_fields` CHANGE # # TEXT", array($_REQUEST['old_name'], $_REQUEST['name']));
    }
    $DB->Update('UPDATE `tx_gallery_field_defs` SET ' . '`name`=?, ' . '`label`=?, ' . '`type`=?, ' . '`tag_attributes`=?, ' . '`options`=?, ' . '`validation`=?, ' . '`validation_extras`=?, ' . '`validation_message`=?, ' . '`on_submit`=?, ' . '`required`=? ' . 'WHERE `field_id`=?', array($_REQUEST['name'], $_REQUEST['label'], $_REQUEST['type'], $_REQUEST['tag_attributes'], $_REQUEST['options'], $_REQUEST['validation'], $_REQUEST['validation_extras'], $_REQUEST['validation_message'], intval($_REQUEST['on_submit']), intval($_REQUEST['required']), $_REQUEST['field_id']));
    $GLOBALS['message'] = 'Gallery field has been successfully updated';
    $GLOBALS['added'] = true;
    txShGalleryFieldEdit();
}