diff --git a/www/account.php b/www/account.php index eef4e42..0b17cfd 100644 --- a/www/account.php +++ b/www/account.php @@ -1,6 +1,6 @@ "; + html_start_row(); print("
Command '$op' requires a login!\n"); @@ -123,6 +124,40 @@ $options = "+I$index+Q" . urlencode($search); switch ($op) { + case 'B' : // Batch update selected articles + if ($REQUEST_METHOD != "POST") + { + header("Location: $PHP_SELF?L$options"); + break; + } + + if (array_key_exists("IS_PUBLISHED", $_POST) && + $_POST["IS_PUBLISHED"] != "") + { + $modify_date = time(); + $modify_user = db_escape($LOGIN_USER); + $is_published = (int)$_POST["IS_PUBLISHED"]; + + $query = "is_published = $is_published, modify_date = $modify_date, " + ."modify_user = '$modify_user'"; + + db_query("BEGIN TRANSACTION"); + + reset($_POST); + while (list($key, $val) = each($_POST)) + if (substr($key, 0, 3) == "ID_") + { + $id = (int)substr($key, 3); + + db_query("UPDATE article SET $query WHERE id = $id"); + } + + db_query("COMMIT TRANSACTION"); + } + + header("Location: $PHP_SELF?L$options"); + break; + case 'D' : // Delete Article if ($REQUEST_METHOD == "POST") { @@ -294,7 +329,12 @@ switch ($op) } else { - $query .= "$prefix$logic (title LIKE \"%$keyword%\"" + if ($keyword == (int)$keyword) + $idsearch = " OR id = " . (int)$keyword; + else + $idsearch = ""; + + $query .= "$prefix$logic (title LIKE \"%$keyword%\"$idsearch" ." OR abstract LIKE \"%$keyword%\"" ." OR contents LIKE \"%$keyword%\")"; $prefix = $next; @@ -318,23 +358,26 @@ switch ($op) } if ($index >= $count) - $index = $count - ($count % $ARTICLE_PAGE_MAX); + $index = $count - ($count % $PAGE_MAX); if ($index < 0) $index = 0; $start = $index + 1; - $end = $index + $ARTICLE_PAGE_MAX; + $end = $index + $PAGE_MAX; if ($end > $count) $end = $count; - $prev = $index - $ARTICLE_PAGE_MAX; + $prev = $index - $PAGE_MAX; if ($prev < 0) $prev = 0; - $next = $index + $ARTICLE_PAGE_MAX; + $next = $index + $PAGE_MAX; print("
$count article(s) found, showing $start to $end:
\n"); - if ($count > $ARTICLE_PAGE_MAX) + if ($LOGIN_USER) + print("