function tlxAccountSearchAndSet() { global $DB, $json, $C; VerifyPrivileges(P_ACCOUNT_MODIFY, TRUE); $user_columns = $DB->GetColumns('tlx_account_fields'); $search_type = $_REQUEST['search'] == 'NULL' ? ST_EMPTY : ST_CONTAINS; $u = new UpdateBuilder('tlx_accounts'); if (in_array($_REQUEST['field'], $user_columns) || in_array($_REQUEST['set_field'], $user_columns)) { $u->AddJoin('tlx_accounts', 'tlx_account_fields', '', 'username'); } if ($_REQUEST['replace'] == 'NULL') { $_REQUEST['replace'] = null; } if ($_REQUEST['field'] == 'return_percent') { $_REQUEST['search'] = $_REQUEST['search'] / 100; } if ($_REQUEST['set_field'] == 'return_percent') { $_REQUEST['replace'] = $_REQUEST['replace'] / 100; } $u->AddSet($_REQUEST['set_field'], $_REQUEST['replace']); $u->AddWhere($_REQUEST['field'], $search_type, $_REQUEST['search']); $replacements = $DB->Update($u->Generate(), $u->binds); echo $json->encode(array('status' => JSON_SUCCESS, 'message' => "{$replacements} changes have been made")); }
protected function buildUPDATE($parsed) { $builder = new UpdateBuilder(); return $builder->build($parsed); }
function txGalleryIPE() { global $DB, $C; VerifyPrivileges(P_GALLERY_MODIFY, TRUE); // Format output $update = TRUE; $output = $_REQUEST['value']; switch ($_REQUEST['update']) { case 'date_scheduled': case 'date_deletion': case 'date_displayed': NullIfEmpty($_REQUEST['value']); $update = preg_match(RE_DATETIME, $_REQUEST['value']) || empty($_REQUEST['value']); $output = empty($_REQUEST['value']) ? '-' : date(DF_SHORT, strtotime($_REQUEST['value'])); break; case 'status': $output = ucfirst($_REQUEST['value']); if ($_REQUEST['value'] == 'approved') { $_REQUEST['update'] = array('status', 'date_approved'); $_REQUEST['value'] = array($_REQUEST['value'], MYSQL_NOW); } break; case 'type': case 'format': $output = ucfirst($_REQUEST['value']); break; case 'weight': case 'clicks': case 'thumbnails': $update = is_numeric($_REQUEST['value']); $output = number_format($_REQUEST['value'], 0, $C['dec_point'], $C['thousands_sep']); break; case 'description': case 'keywords': case 'tags': $output = StringChopTooltip(htmlspecialchars($_REQUEST['value']), 90); break; case 'gallery_url': $output = StringChopTooltip(htmlspecialchars($_REQUEST['value']), 100, true); break; case 'nickname': case 'email': $output = StringChopTooltip(htmlspecialchars($_REQUEST['value']), 40); break; case 'sponsor_id': NullIfEmpty($_REQUEST['value']); if ($_REQUEST['value'] == null) { $output = ''; } else { $output = $DB->Count('SELECT `name` FROM `tx_sponsors` WHERE `sponsor_id`=?', array($_REQUEST['value'])); } break; case 'categories': $_REQUEST['value'] = CategoryTagsFromIds(explode(',', $_REQUEST['value'])); $categories =& CategoriesFromTags($_REQUEST['value']); $names = array(); foreach ($categories as $category) { $names[] = $category['name']; } $output = StringChopTooltip(htmlspecialchars(join(', ', $names)), 90); break; case 'icons': if (isset($_REQUEST['multi'])) { $result = GetWhichGalleries(); while ($gallery = $DB->NextRow($result)) { $DB->Update('DELETE FROM `tx_gallery_icons` WHERE `gallery_id`=?', array($gallery['gallery_id'])); foreach (explode(',', $_REQUEST['value']) as $icon_id) { $icon_id = trim($icon_id); if (is_numeric($icon_id)) { $DB->Update('INSERT INTO `tx_gallery_icons` VALUES (?,?)', array($gallery['gallery_id'], $icon_id)); } } } $DB->Free($result); } else { $DB->Update('DELETE FROM `tx_gallery_icons` WHERE `gallery_id`=?', array($_REQUEST['gallery_id'])); foreach (explode(',', $_REQUEST['value']) as $icon_id) { $icon_id = trim($icon_id); if (is_numeric($icon_id)) { $DB->Update('INSERT INTO `tx_gallery_icons` VALUES (?,?)', array($_REQUEST['gallery_id'], $icon_id)); } } } echo '<img src="images/icons.png" alt="Icons" title="Icons" class="click-image function">'; return; break; } if ($update) { $update = new UpdateBuilder('tx_galleries'); if (is_array($_REQUEST['update'])) { foreach ($_REQUEST['update'] as $index => $field) { $update->AddSet($_REQUEST['update'][$index], $_REQUEST['value'][$index]); } } else { $update->AddSet($_REQUEST['update'], $_REQUEST['value']); } if (isset($_REQUEST['multi'])) { $update = GetWhichGalleries($update); } else { $update->AddWhere('gallery_id', ST_MATCHES, $_REQUEST['gallery_id']); } $DB->Update($update->Generate(), $update->binds); } echo $update ? $output : JSON_FAILURE; }