get_results("SELECT DISTINCT series FROM {$wpdb->prefix}buybooks WHERE series NOT LIKE ''", ARRAY_A);
if(@$_REQUEST['btbe_id'] > 0 && @$_REQUEST['realdelete'] == 1) {
$wpdb->delete($wpdb->prefix.'buybooks', array('id' => $_REQUEST['btbe_id']), '%d');
echo '
Book deleted.
Return to the Book List
';
exit;
}
if(@$_REQUEST['btbe_add'] == 1) {
if(empty($_REQUEST['title'])) {
$btbe_message = "You must enter a title!";
}
else {
$book = array(
'created' => date('Y-m-d H:i:s', time()),
'updated' => date('Y-m-d H:i:s', time()),
'title' => esc_attr(@$_REQUEST['title']),
'subtitle' => isset($_REQUEST['subtitle']) ? esc_attr(@$_REQUEST['subtitle']) : '',
'author' => isset($_REQUEST['author']) ? esc_attr(@$_REQUEST['author']) : '',
'series' => isset($_REQUEST['series']) ? esc_attr(@$_REQUEST['series']) : '',
'series_num' => isset($_REQUEST['series_num']) ? esc_attr(@$_REQUEST['series_num']) : '',
'blurb' => isset($_REQUEST['blurb']) ? esc_textarea(@$_REQUEST['blurb']) : '',
'cover' => isset($_REQUEST['cover']) ? esc_url(@$_REQUEST['cover']) : '',
'asin' => isset($_REQUEST['asin']) ? esc_attr(@$_REQUEST['asin']) : '',
'isbn' => isset($_REQUEST['isbn']) ? esc_attr(@$_REQUEST['isbn']) : '',
'book_page' => isset($_REQUEST['book_page']) ? esc_attr(@$_REQUEST['book_page']) : '',
'short_blurb' => isset($_REQUEST['short_blurb']) ? esc_textarea(@$_REQUEST['short_blurb']) : '',
);
$services = array();
foreach ($_REQUEST as $idx => $r) {
if(strpos($idx, 'sername') !== false) {
$int = filter_var($idx, FILTER_SANITIZE_NUMBER_INT);
$services[$int]['name'] = stripslashes($r);
}
if(strpos($idx, 'sericon') !== false) {
$int = filter_var($idx, FILTER_SANITIZE_NUMBER_INT);
$services[$int]['icon'] = $r;
}
if(strpos($idx, 'serlink') !== false) {
$int = filter_var($idx, FILTER_SANITIZE_NUMBER_INT);
$services[$int]['link'] = $r;
}
}
$book['services'] = json_encode($services);
if(@$_REQUEST['btbe_id'] != "") {
unset($book['created']);
$wpdb->update($wpdb->prefix.'buybooks', $book, array('id' => esc_sql($_REQUEST['btbe_id'])), array('%s','%s','%s','%s','%s','%s','%s','%s'));
}
else {
$wpdb->insert( $wpdb->prefix.'buybooks', $book, array( '%s','%s','%s','%s','%s','%s','%s','%s','%s' ) );
$_REQUEST['btbe_id'] = $wpdb->insert_id;
}
$btbe_message = 'Book saved! Add another or return to the Book List?';
}
}
if(@$_REQUEST['btbe_id'] > 0 && !isset($_REQUEST['btbe_add'])) {
$record = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}buybooks WHERE id = '".esc_sql($_REQUEST['btbe_id'])."'", ARRAY_A);
if(!$record) { echo 'Book not found!'; exit; }
$_REQUEST = array_merge($_REQUEST, $record);
$services = json_decode($record['services'], true);
}
?>
Update this Book
Add a Book
0 && @$_REQUEST['delete'] > 0) : ?>
Are you absolutely sure you want to delete this book? Yes, delete it!