Add file order prompt

This commit is contained in:
Andrew Pamment 2017-09-29 06:14:21 +10:00
parent 8c7c432dd4
commit 784991b7bb
2 changed files with 22 additions and 1 deletions

View File

@ -231,3 +231,4 @@ File exists!\r\n
\r\n\e[1;37mAre you sure you want to reset \e[1;31mall messages \e[1;37min all bases to unread? \e[0m
\r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[1;31mNEW \e[0;32m
\r\nScan for new files? (Y/N) :
\r\n\e[1;37mOrder by (\e1;32mF\e[1;37m)ilename, (\e[1;32mU\e[1;37m)pload Date, (\e1;32mP\e[1;37m)opularity : \e[0m

View File

@ -854,7 +854,10 @@ void download(struct user_record *user) {
}
void list_files(struct user_record *user) {
char *sql = "select filename, description, size, dlcount, uploaddate from files where approved=1";
char *dsql = "select filename, description, size, dlcount, uploaddate from files where approved=1 ORDER BY uploaddate DESC";
char *fsql = "select filename, description, size, dlcount, uploaddate from files where approved=1 ORDER BY filename";
char *psql = "select filename, description, size, dlcount, uploaddate from files where approved=1 ORDER BY dlcount DESC";
char *sql;
char buffer[PATH_MAX];
sqlite3 *db;
sqlite3_stmt *res;
@ -869,8 +872,25 @@ void list_files(struct user_record *user) {
int k;
int match;
char ch;
struct file_entry **files_e;
s_printf(get_string(233));
ch = s_getc();
switch(tolower(ch)) {
case 'u':
sql = dsql;
break;
case 'p':
sql = psql;
break;
default:
sql = fsql;
break;
}
s_printf("\r\n");
snprintf(buffer, PATH_MAX, "%s/%s.sq3", conf.bbs_path, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->database);
rc = sqlite3_open(buffer, &db);