예제 #1
0
 protected function buildSELECT($parsed)
 {
     $builder = new SelectBuilder();
     return $builder->build($parsed);
 }
예제 #2
0
function &GenerateQuery()
{
    global $DB, $configuration;
    $s = new SelectBuilder('*', 'tlx_accounts');
    if (count($configuration['status']) > 0 && count($configuration['status']) < 5) {
        $s->AddWhere('status', ST_IN, join(',', array_keys($configuration['status'])));
    }
    if (preg_match(RE_DATETIME, $configuration['date_added_start']) && preg_match(RE_DATETIME, $configuration['date_added_end'])) {
        $s->AddWhere('date_added', ST_BETWEEN, "{$configuration['date_added_start']},{$configuration['date_added_end']}");
    }
    if (preg_match(RE_DATETIME, $configuration['date_scanned_start']) && preg_match(RE_DATETIME, $configuration['date_scanned_end'])) {
        $s->AddWhere('date_scanned', ST_BETWEEN, "{$configuration['date_scanned_start']},{$configuration['date_scanned_end']}");
    }
    // Specific categories selected
    if (!IsEmptyString($configuration['categories'][0])) {
        $s->AddWhere('category_id', ST_IN, join(',', $configuration['categories']));
    }
    return $s;
}
예제 #3
0
function txGalleryBreakdown()
{
    global $DB, $json, $C;
    VerifyPrivileges(P_GALLERY, TRUE);
    $out = array('status' => JSON_SUCCESS, 'breakdown' => array());
    switch ($_REQUEST['group']) {
        case 'category':
            $categories =& $DB->FetchAll('SELECT * FROM `tx_categories` ORDER BY `name`');
            $breakdown = array();
            foreach ($categories as $category) {
                $s = new SelectBuilder('COUNT(*) AS `amount`', 'tx_galleries');
                if ($_REQUEST['status']) {
                    $s->AddWhere('status', ST_MATCHES, $_REQUEST['status']);
                }
                if ($_REQUEST['type']) {
                    $s->AddWhere('type', ST_MATCHES, $_REQUEST['type']);
                }
                $s->AddFulltextWhere('categories', $category['tag']);
                $amount = $DB->Count($s->Generate(), $s->binds);
                $breakdown[] = array('grouper' => htmlspecialchars($category['name']), 'amount' => number_format($amount, 0, $C['dec_point'], $C['thousands_sep']), 'sorter' => $amount);
            }
            usort($breakdown, 'txBreakdownCmp');
            $out['breakdown'] =& $breakdown;
            break;
        case 'sponsor':
            $s = new SelectBuilder("`name` AS `grouper`,COUNT(*) AS `amount`", 'tx_galleries');
            $s->AddJoin('tx_galleries', 'tx_sponsors', 'LEFT', 'sponsor_id');
            if ($_REQUEST['type']) {
                $s->AddWhere('type', ST_MATCHES, $_REQUEST['type']);
            }
            if ($_REQUEST['status']) {
                $s->AddWhere('status', ST_MATCHES, $_REQUEST['status']);
            }
            $s->AddGroup('tx_galleries.sponsor_id');
            $s->AddOrder('amount', 'DESC');
            $result = $DB->Query($s->Generate(), $s->binds);
            while ($breakdown = $DB->NextRow($result)) {
                $breakdown['amount'] = number_format($breakdown['amount'], 0, $C['dec_point'], $C['thousands_sep']);
                $breakdown['grouper'] = $breakdown['grouper'] ? ucfirst(htmlspecialchars($breakdown['grouper'])) : '-';
                $out['breakdown'][] = $breakdown;
            }
            $DB->Free($result);
            break;
        default:
            $group_field = array('added' => 'DATE_FORMAT(date_added, \'%Y-%m-%d\')', 'displayed' => 'DATE_FORMAT(date_displayed, \'%Y-%m-%d\')', 'format' => 'format');
            $s = new SelectBuilder("{$group_field[$_REQUEST['group']]} AS `grouper`,COUNT(*) AS `amount`", 'tx_galleries');
            if ($_REQUEST['type']) {
                $s->AddWhere('type', ST_MATCHES, $_REQUEST['type']);
            }
            if ($_REQUEST['status']) {
                $s->AddWhere('status', ST_MATCHES, $_REQUEST['status']);
            }
            $result = $DB->Query($s->Generate() . " GROUP BY {$group_field[$_REQUEST['group']]} ORDER BY " . (in_array($_REQUEST['group'], array('added', 'displayed')) ? '`grouper`' : '`amount`') . " DESC", $s->binds);
            while ($breakdown = $DB->NextRow($result)) {
                $breakdown['amount'] = number_format($breakdown['amount'], 0, $C['dec_point'], $C['thousands_sep']);
                $breakdown['grouper'] = $breakdown['grouper'] ? ucfirst(htmlspecialchars($breakdown['grouper'])) : '-';
                $out['breakdown'][] = $breakdown;
            }
            $DB->Free($result);
            break;
    }
    $type = $_REQUEST['type'] ? ucfirst(htmlspecialchars($_REQUEST['type'])) : 'Overall';
    $status = $_REQUEST['status'] ? ucfirst(htmlspecialchars($_REQUEST['status'])) : '';
    $by = ucfirst(htmlspecialchars($_REQUEST['group']));
    $out['type'] = "{$type} {$status} Galleries By {$by}";
    echo $json->encode($out);
}
예제 #4
0
파일: ajax.php 프로젝트: hackingman/LinkX
/**
* Quick user search for the link submission form
*/
function lxQuickUserSearch()
{
    global $DB, $json;
    $out = array('status' => JSON_SUCCESS, 'results' => array());
    $select = new SelectBuilder('*', 'lx_users');
    $select->AddMultiWhere(array('username', 'email'), array(ST_CONTAINS, ST_CONTAINS), array($_REQUEST['term'], $_REQUEST['term']), TRUE);
    $select->AddOrder('username');
    $result = $DB->Query($select->Generate(), $select->binds);
    while ($account = $DB->NextRow($result)) {
        ArrayHSC($account);
        $out['results'][] = $account;
    }
    $DB->Free($result);
    echo $json->encode($out);
}
예제 #5
0
function AccountSearchSelect(&$s, $request = null)
{
    global $DB;
    if ($request != null) {
        $_REQUEST = array_merge($_REQUEST, $request);
    }
    $last_hour = gmdate('G', TIME_NOW - 3600);
    $this_hour = gmdate('G', TIME_NOW);
    $sorters = array_merge($DB->GetColumns('tlx_accounts', TRUE, TRUE), $DB->GetColumns('tlx_account_fields', TRUE, TRUE), $DB->GetColumns('tlx_account_hourly_stats', TRUE, TRUE), array('username' => '`tlx_accounts`.`username`', 'avg_rating' => '`ratings_total`/`ratings`', 'raw_in_last_hr' => '`raw_in_' . $last_hour . '`', 'unique_in_last_hr' => '`unique_in_' . $last_hour . '`', 'raw_out_last_hr' => '`raw_out_' . $last_hour . '`', 'unique_out_last_hr' => '`unique_out_' . $last_hour . '`', 'clicks_last_hr' => '`clicks_' . $last_hour . '`', 'raw_in_this_hr' => '`raw_in_' . $this_hour . '`', 'unique_in_this_hr' => '`unique_in_' . $this_hour . '`', 'raw_out_this_hr' => '`raw_out_' . $this_hour . '`', 'unique_out_this_hr' => '`unique_out_' . $this_hour . '`', 'clicks_this_hr' => '`clicks_' . $this_hour . '`'));
    if (preg_match('~(.*?)_days_(\\d+)~', $_REQUEST['order'], $matches)) {
        $sorters[$_REQUEST['order']] = "SUM(`{$matches[1]}`)";
    }
    $s = new SelectBuilder('*,' . $sorters[$_REQUEST['order']] . ' AS `sorter`', 'tlx_accounts');
    $fulltext = array('title,description,keywords');
    $user = $DB->GetColumns('tlx_account_fields');
    if ($_REQUEST['field'] == 'avg_rating') {
        $_REQUEST['field'] = 'ratings_total/ratings';
    }
    if ($_REQUEST['field'] == 'return_percent') {
        $_REQUEST['search'] = $_REQUEST['search'] / 100;
    }
    // Special handling of date searches (transform MM-DD-YYYY to YYYY-MM-DD format)
    if (preg_match('~^date_~', $_REQUEST['field'])) {
        $_REQUEST['search'] = trim($_REQUEST['search']);
        if (preg_match('~^(\\d\\d)-(\\d\\d)-(\\d\\d\\d\\d)$~', $_REQUEST['search'], $date)) {
            $_REQUEST['search_type'] = ST_BETWEEN;
            $_REQUEST['search'] = "{$date[3]}-{$date[1]}-{$date[2]} 00:00:00,{$date[3]}-{$date[1]}-{$date[2]} 23:59:59";
        } else {
            if (preg_match('~^\\d\\d\\d\\d-\\d\\d-\\d\\d$~', $_REQUEST['search'])) {
                $_REQUEST['search_type'] = ST_BETWEEN;
                $_REQUEST['search'] = "{$_REQUEST['search']} 00:00:00,{$_REQUEST['search']} 23:59:59";
            }
        }
        $_REQUEST['search'] = preg_replace('~(\\d\\d)-(\\d\\d)-(\\d\\d\\d\\d)~', '\\3-\\1-\\2', $_REQUEST['search']);
    }
    if (preg_match('~_days_\\d+~', $_REQUEST['order'])) {
        $s->AddJoin('tlx_accounts', 'tlx_account_daily_stats', 'LEFT', 'username');
        $s->AddGroup('tlx_accounts.username');
        $s->AddWhereString("`date_stats` >= DATE_ADD('" . MYSQL_CURDATE . "', INTERVAL -{$matches[2]} DAY)");
    } else {
        if (preg_match('~(raw_|unique_|clicks_)~', $_REQUEST['order'])) {
            $s->AddJoin('tlx_accounts', 'tlx_account_hourly_stats', '', 'username');
        }
    }
    if (in_array($_REQUEST['field'], $user) || in_array($_REQUEST['order'], $user)) {
        $s->AddJoin('tlx_accounts', 'tlx_account_fields', '', 'username');
    }
    if (in_array($_REQUEST['field'], $user)) {
        $s->AddWhere($_REQUEST['field'], $_REQUEST['search_type'], $_REQUEST['search'], $_REQUEST['search_type'] != ST_EMPTY);
    } else {
        if (in_array($_REQUEST['field'], $fulltext)) {
            $s->AddFulltextWhere($_REQUEST['field'], $_REQUEST['search'], $_REQUEST['search_type'] != ST_EMPTY);
        } else {
            $s->AddWhere($_REQUEST['field'], $_REQUEST['search_type'], $_REQUEST['search'], $_REQUEST['search_type'] != ST_EMPTY);
        }
    }
    $s_checked = count($_REQUEST['status']);
    if ($s_checked > 0 && $s_checked < 3) {
        $s->AddWhere('status', ST_IN, join(',', $_REQUEST['status']));
    }
    if (isset($_REQUEST['locked'])) {
        $s->AddWhere('locked', ST_MATCHES, 1);
    }
    if (isset($_REQUEST['disabled'])) {
        $s->AddWhere('disabled', ST_MATCHES, 1);
    }
    if (isset($_REQUEST['edited'])) {
        $s->AddWhere('edited', ST_MATCHES, 1);
    }
    if (count($_REQUEST['categories']) > 0 && !in_array('', $_REQUEST['categories'])) {
        $s->AddWhere('category_id', isset($_REQUEST['cat_exclude']) ? ST_NOT_IN : ST_IN, join(',', $_REQUEST['categories']));
    }
    $_REQUEST['order'] = 'sorter';
    $_REQUEST['order_next'] = 'tlx_accounts.username';
    return TRUE;
}
예제 #6
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;
 }
예제 #7
0
파일: index.php 프로젝트: hackingman/LinkX
function lxLinkSearchAndDelete()
{
    global $DB, $C;
    VerifyPrivileges(P_LINK_REMOVE);
    $select = new SelectBuilder('*', 'lx_links');
    $select->AddJoin('lx_links', 'lx_link_cats', '', 'link_id');
    $select->AddJoin('lx_links', 'lx_link_fields', '', 'link_id');
    $select->AddWhere($_REQUEST['field'], $_REQUEST['search_type'], $_REQUEST['find']);
    if ($_REQUEST['category_only']) {
        $select->AddWhere('category_id', ST_MATCHES, $_REQUEST['category_id']);
    }
    if ($select->error) {
        lxShTasksLink($select->errstr);
        return;
    }
    $updates = 0;
    $result = $DB->Query($select->Generate(), $select->binds);
    while ($link = $DB->NextRow($result)) {
        DeleteLink($link['link_id'], TRUE, $link);
        $updates++;
    }
    $DB->Free($result);
    $GLOBALS['message'] = "Search and delete completed; {$updates} link" . ($updates != 1 ? 's have' : ' has') . " been deleted";
    lxShTasksLink();
}
예제 #8
0
function GetWhichPartners()
{
    global $DB;
    $result = null;
    $req = $_REQUEST;
    if (IsEmptyString($_REQUEST['which'])) {
        parse_str($_REQUEST['results'], $req);
    }
    switch ($req['which']) {
        case 'matching':
            // Extract search form information
            $search_form = array();
            parse_str($_REQUEST['search_form'], $search_form);
            // Build select query
            $select = new SelectBuilder('*', 'tx_partners');
            $select->AddWhere($search_form['field'], $search_form['search_type'], $search_form['search'], $search_form['search_type'] != ST_EMPTY);
            $select->AddWhere('status', ST_MATCHES, $search_form['status'], TRUE);
            // Execute the query
            $result = $DB->Query($select->Generate(), $select->binds);
            break;
        case 'all':
            $result = $DB->Query('SELECT * FROM `tx_partners`');
            break;
        default:
            $bind_list = CreateBindList($req['username']);
            $result = $DB->Query('SELECT * FROM `tx_partners` WHERE `username` IN (' . $bind_list . ')', $req['username']);
            break;
    }
    return $result;
}
예제 #9
0
function &GenerateQuery()
{
    global $DB, $configuration;
    $s = new SelectBuilder('*', 'tx_galleries');
    $s->AddWhere('allow_scan', ST_MATCHES, 1);
    if (count($configuration['status']) > 0 && count($configuration['status']) < 5) {
        $s->AddWhere('status', ST_IN, join(',', array_keys($configuration['status'])));
    }
    if (count($configuration['type']) == 1) {
        $keys = array_keys($configuration['type']);
        $s->AddWhere('type', ST_MATCHES, $keys[0]);
    }
    if (count($configuration['format']) == 1) {
        $keys = array_keys($configuration['format']);
        $s->AddWhere('format', ST_MATCHES, $keys[0]);
    }
    if (is_numeric($configuration['id_start']) && is_numeric($configuration['id_end'])) {
        $s->AddWhere('gallery_id', ST_BETWEEN, "{$configuration['id_start']},{$configuration['id_end']}");
    }
    if (preg_match(RE_DATETIME, $configuration['date_added_start']) && preg_match(RE_DATETIME, $configuration['date_added_end'])) {
        $s->AddWhere('date_added', ST_BETWEEN, "{$configuration['date_added_start']},{$configuration['date_added_end']}");
    }
    if (preg_match(RE_DATETIME, $configuration['date_approved_start']) && preg_match(RE_DATETIME, $configuration['date_approved_end'])) {
        $s->AddWhere('date_approved', ST_BETWEEN, "{$configuration['date_approved_start']},{$configuration['date_approved_end']}");
    }
    if (preg_match(RE_DATETIME, $configuration['date_scanned_start']) && preg_match(RE_DATETIME, $configuration['date_scanned_end'])) {
        $s->AddWhere('date_scanned', ST_BETWEEN, "{$configuration['date_scanned_start']},{$configuration['date_scanned_end']}");
    }
    // Only galleries submitted by partners
    if ($configuration['only_parter']) {
        $s->AddWhere('partner', ST_NOT_EMPTY);
    }
    // Only galleries that currently have a zero thumbnail count
    if ($configuration['only_zerothumb']) {
        $s->AddWhere('thumbnails', ST_MATCHES, 0);
    }
    // Only galleries that have not yet been scanned
    if ($configuration['only_notscanned']) {
        $s->AddWhere('date_scanned', ST_NULL);
    }
    // Specific categories selected
    if (!IsEmptyString($configuration['categories'][0])) {
        $tags = array();
        foreach ($configuration['categories'] as $category_id) {
            $tags[] = $DB->Count('SELECT `tag` FROM `tx_categories` WHERE `category_id`=?', array($category_id));
        }
        if (count($tags)) {
            $s->AddFulltextWhere('categories', join(' ', $tags));
        }
    }
    // Specific sponsors selected
    if (!IsEmptyString($configuration['sponsors'][0])) {
        $s->AddWhere('sponsor_id', ST_IN, join(',', array_unique($configuration['sponsors'])));
    }
    // Only galleries that do not currently have a preview thumbnail
    if ($configuration['only_nothumb']) {
        $s->AddWhere('has_preview', ST_MATCHES, 0);
    }
    return $s;
}
예제 #10
0
파일: index.php 프로젝트: hackingman/TGPX
function txCategoryEdit()
{
    global $C, $DB;
    VerifyPrivileges(P_CATEGORY_MODIFY);
    $v =& ValidateCategoryInput();
    if (!$v->Validate()) {
        return $v->ValidationError('txShCategoryEdit');
    }
    UpdateThumbSizes();
    // Bulk update
    if (isset($_REQUEST['apply_all']) || isset($_REQUEST['apply_matched'])) {
        $GLOBALS['message'] = 'All categories have been successfully updated';
        $select = new SelectBuilder('*', 'tx_categories');
        if (isset($_REQUEST['apply_matched'])) {
            $search = array();
            parse_str($_REQUEST['apply_matched'], $search);
            $select->AddWhere($search['field'], $search['search_type'], $search['search'], $search['search_type'] != ST_EMPTY);
            $GLOBALS['message'] = 'Matched categories have been successfully updated';
        }
        $result = $DB->Query($select->Generate(), $select->binds);
        while ($category = $DB->NextRow($result)) {
            $DB->Update('UPDATE `tx_categories` SET ' . '`pics_allowed`=?, ' . '`pics_extensions`=?, ' . '`pics_minimum`=?, ' . '`pics_maximum`=?, ' . '`pics_file_size`=?, ' . '`pics_preview_size`=?, ' . '`pics_preview_allowed`=?, ' . '`pics_annotation`=?, ' . '`movies_allowed`=?, ' . '`movies_extensions`=?, ' . '`movies_minimum`=?, ' . '`movies_maximum`=?, ' . '`movies_file_size`=?, ' . '`movies_preview_size`=?, ' . '`movies_preview_allowed`=?, ' . '`movies_annotation`=?, ' . '`per_day`=?, ' . '`hidden`=?, ' . '`meta_description`=?, ' . '`meta_keywords`=? ' . 'WHERE `category_id`=?', array(intval($_REQUEST['pics_allowed']), $_REQUEST['pics_extensions'], $_REQUEST['pics_minimum'], $_REQUEST['pics_maximum'], $_REQUEST['pics_file_size'], $_REQUEST['pics_preview_size'], intval($_REQUEST['pics_preview_allowed']), $_REQUEST['pics_annotation'], intval($_REQUEST['movies_allowed']), $_REQUEST['movies_extensions'], $_REQUEST['movies_minimum'], $_REQUEST['movies_maximum'], $_REQUEST['movies_file_size'], $_REQUEST['movies_preview_size'], intval($_REQUEST['movies_preview_allowed']), $_REQUEST['movies_annotation'], $_REQUEST['per_day'], intval($_REQUEST['hidden']), $_REQUEST['meta_description'], $_REQUEST['meta_keywords'], $category['category_id']));
        }
        $DB->Free($result);
    } else {
        $_REQUEST['name'] = trim($_REQUEST['name']);
        $DB->Update('UPDATE `tx_categories` SET ' . '`name`=?, ' . '`pics_allowed`=?, ' . '`pics_extensions`=?, ' . '`pics_minimum`=?, ' . '`pics_maximum`=?, ' . '`pics_file_size`=?, ' . '`pics_preview_size`=?, ' . '`pics_preview_allowed`=?, ' . '`pics_annotation`=?, ' . '`movies_allowed`=?, ' . '`movies_extensions`=?, ' . '`movies_minimum`=?, ' . '`movies_maximum`=?, ' . '`movies_file_size`=?, ' . '`movies_preview_size`=?, ' . '`movies_preview_allowed`=?, ' . '`movies_annotation`=?, ' . '`per_day`=?, ' . '`hidden`=?, ' . '`meta_description`=?, ' . '`meta_keywords`=? ' . 'WHERE `category_id`=?', array($_REQUEST['name'], intval($_REQUEST['pics_allowed']), $_REQUEST['pics_extensions'], $_REQUEST['pics_minimum'], $_REQUEST['pics_maximum'], $_REQUEST['pics_file_size'], $_REQUEST['pics_preview_size'], intval($_REQUEST['pics_preview_allowed']), $_REQUEST['pics_annotation'], intval($_REQUEST['movies_allowed']), $_REQUEST['movies_extensions'], $_REQUEST['movies_minimum'], $_REQUEST['movies_maximum'], $_REQUEST['movies_file_size'], $_REQUEST['movies_preview_size'], intval($_REQUEST['movies_preview_allowed']), $_REQUEST['movies_annotation'], $_REQUEST['per_day'], intval($_REQUEST['hidden']), $_REQUEST['meta_description'], $_REQUEST['meta_keywords'], $_REQUEST['category_id']));
        $GLOBALS['message'] = 'Category has been successfully updated';
    }
    $GLOBALS['added'] = true;
    txShCategoryEdit();
}
예제 #11
0
 function compile_ad_tag($tag_args)
 {
     global $DB;
     $defaults = array('pagedupes' => 'false', 'weight' => 'any', 'order' => 'times_displayed, (unique_clicks/times_displayed) DESC');
     $attrs = $this->parse_attributes($tag_args);
     $attrs = array_merge($defaults, $attrs);
     // Convert boolean values
     $attrs['pagedupes'] = $this->to_bool($attrs['pagedupes']);
     // Prepare RAND() values in order
     $attrs['order'] = preg_replace('~rand\\(\\)~i', 'RAND(%RAND%)', $attrs['order']);
     $s = new SelectBuilder('*,`lx_ads`.`ad_id` AS `ad_id`', 'lx_ads');
     // Process pagedupes
     if ($attrs['pagedupes'] === FALSE) {
         $s->AddJoin('lx_ads', 'lx_ads_used_page', 'LEFT', 'ad_id');
         $s->AddWhere('lx_ads_used_page.ad_id', ST_NULL, null);
     }
     // Process tags attribute
     if (isset($attrs['tags'])) {
         $s->AddFulltextWhere('tags', $attrs['tags']);
     }
     // Process weight attribute
     if (isset($attrs['weight']) && $attrs['weight'] != 'any') {
         $s->AddWhereString("`weight` {$attrs['weight']}");
     }
     $s->SetOrderString($attrs['order'], $DB->GetColumns('lx_ads'));
     $s->SetLimit('1');
     $query = $DB->Prepare($s->Generate(), $s->binds);
     // Perform replacements for placeholders
     $replacements = array('%RAND%' => '".rand()."');
     foreach ($replacements as $find => $replace) {
         $query = str_replace($find, $replace, $query);
     }
     return S_PHP . " if( !isset(\$GLOBALS['_CLEAR_PAGE_USED_']) )\n{\n" . "\$GLOBALS['DB']->Update('DELETE FROM `lx_ads_used_page`');\n" . "\$GLOBALS['_CLEAR_PAGE_USED_'] = TRUE;\n" . "}\n" . "\$_temp_ad = \$GLOBALS['DB']->Row(\"{$query}\");\n" . "if( \$_temp_ad )\n{\n" . "\$GLOBALS['DB']->Update(\"UPDATE `lx_ads` SET `times_displayed`=`times_displayed`+1 WHERE `ad_id`=?\", array(\$_temp_ad['ad_id']));\n" . "\$GLOBALS['DB']->Update(\"REPLACE INTO `lx_ads_used_page` VALUES (?)\", array(\$_temp_ad['ad_id']));\n" . "echo \$_temp_ad['ad_html'];\n" . "}\n" . E_PHP;
 }
예제 #12
0
function tlxCategoryEdit()
{
    global $C, $DB;
    VerifyPrivileges(P_CATEGORY_MODIFY);
    $v =& ValidateCategoryInput();
    if (!$v->Validate()) {
        return $v->ValidationError('tlxShCategoryEdit');
    }
    // Bulk update
    if (isset($_REQUEST['apply_all']) || isset($_REQUEST['apply_matched'])) {
        $GLOBALS['message'] = 'All categories have been successfully updated';
        $select = new SelectBuilder('*', 'tlx_categories');
        if (isset($_REQUEST['apply_matched'])) {
            $search = array();
            parse_str($_REQUEST['apply_matched'], $search);
            $select->AddWhere($search['field'], $search['search_type'], $search['search'], $search['search_type'] != ST_EMPTY);
            $GLOBALS['message'] = 'Matched categories have been successfully updated';
        }
        $result = $DB->Query($select->Generate(), $select->binds);
        while ($category = $DB->NextRow($result)) {
            $DB->Update('UPDATE `tlx_categories` SET ' . '`hidden`=?, ' . '`forward_url`=?, ' . '`page_url`=?, ' . '`banner_max_width`=?, ' . '`banner_max_height`=?, ' . '`banner_max_bytes`=?, ' . '`banner_force_size`=?, ' . '`download_banners`=?, ' . '`host_banners`=?, ' . '`allow_redirect`=?, ' . '`title_min_length`=?, ' . '`title_max_length`=?, ' . '`desc_min_length`=?, ' . '`desc_max_length`=?, ' . '`recip_required`=? ' . 'WHERE `category_id`=?', array(intval($_REQUEST['hidden']), $_REQUEST['forward_url'], $_REQUEST['page_url'], $_REQUEST['banner_max_width'], $_REQUEST['banner_max_height'], $_REQUEST['banner_max_bytes'], intval($_REQUEST['banner_force_size']), intval($_REQUEST['download_banners']), intval($_REQUEST['host_banners']), intval($_REQUEST['allow_redirect']), $_REQUEST['title_min_length'], $_REQUEST['title_max_length'], $_REQUEST['desc_min_length'], $_REQUEST['desc_max_length'], intval($_REQUEST['recip_required']), $category['category_id']));
        }
        $DB->Free($result);
    } else {
        $_REQUEST['name'] = trim($_REQUEST['name']);
        $DB->Update('UPDATE `tlx_categories` SET ' . '`name`=?, ' . '`hidden`=?, ' . '`forward_url`=?, ' . '`page_url`=?, ' . '`banner_max_width`=?, ' . '`banner_max_height`=?, ' . '`banner_max_bytes`=?, ' . '`banner_force_size`=?, ' . '`download_banners`=?, ' . '`host_banners`=?, ' . '`allow_redirect`=?, ' . '`title_min_length`=?, ' . '`title_max_length`=?, ' . '`desc_min_length`=?, ' . '`desc_max_length`=?, ' . '`recip_required`=? ' . 'WHERE `category_id`=?', array($_REQUEST['name'], intval($_REQUEST['hidden']), $_REQUEST['forward_url'], $_REQUEST['page_url'], $_REQUEST['banner_max_width'], $_REQUEST['banner_max_height'], $_REQUEST['banner_max_bytes'], intval($_REQUEST['banner_force_size']), intval($_REQUEST['download_banners']), intval($_REQUEST['host_banners']), intval($_REQUEST['allow_redirect']), $_REQUEST['title_min_length'], $_REQUEST['title_max_length'], $_REQUEST['desc_min_length'], $_REQUEST['desc_max_length'], intval($_REQUEST['recip_required']), $_REQUEST['category_id']));
        $GLOBALS['message'] = 'Category has been successfully updated';
    }
    $GLOBALS['added'] = true;
    tlxShCategoryEdit();
}