diff --git a/botthread.c b/botthread.c index b9ad1a0..ccc765e 100644 --- a/botthread.c +++ b/botthread.c @@ -297,6 +297,10 @@ logFile = fopen(logFileName,"a"); writeLog(0,"Log Rotated"); } + else if (strcasecmp(cmd,"nextuser") == 0x0) { + sprintf(output,"MSG:TUveD:%s:The Next User is %s",chan,tmpChan->nextUser->user->userInfo.username); + tuveSendAllInChan(chan,0x0,output); + } return(0x0); } @@ -487,12 +491,14 @@ /* Find A Random Song */ getRandom: if (tmpChans->modes[CHAN_RANDOM] == 0x1) { - sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count FROM videos WHERE status = 0 AND rating <= %i",tmpChans->modes[CHAN_RATING]); + sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count,random_count FROM videos WHERE status = 0 AND rating <= %i",tmpChans->modes[CHAN_RATING]); if (tmpChans->modes[CHAN_EXCLUSIVE]) sprintf(output,"%s AND oid = %i",output,tmpChans->oid); //tmpChans->modes[CHAN_EXCLUSIVE]); if (tmpChans->modes[CHAN_CLASS]) sprintf(output,"%s AND classification = %i",output,tmpChans->modes[CHAN_CLASS]); - + + sprintf(output,"%s ORDER BY random_count ASC, RAND() LIMIT 1", output); + res = dbQuery(output,1); if (res == 0x0) { sprintf(output,"MSG:TUveD:%s:Sorry I'm Having SQL Troubles Today.",tmpChans->channel); @@ -503,10 +509,10 @@ tuveSendAllInChan(tmpChans->channel,0x0,output); } else { - mysql_data_seek(res,(random() % mysql_num_rows(res))); + //mysql_data_seek(res,(random() % mysql_num_rows(res))); row = mysql_fetch_row(res); - //sprintf(output,"UPDATE videos SET count = %i WHERE vid = %s\n",atoi(row[7])+1,row[4]); - //dbQuery(output,0); + sprintf(output,"UPDATE videos SET random_count = %i WHERE vid = %s\n",atoi(row[8])+1,row[4]); + dbQuery(output,0); tmpChans->count = MAX_COUNT; tuveBotSetSong(tmpChans->channel,"TUveD",row[0],row[1],atoi(row[3]),row[2],atoi(row[5]),atoi(row[6]),atoi(row[4])); } diff --git a/channel.c b/channel.c index 6cdea08..fa1953b 100644 --- a/channel.c +++ b/channel.c @@ -1,6 +1,6 @@ /* (c) 2007 Christopher Olsen - $Id$ + $Id: channel.c,v 1.65 2009/02/18 19:37:34 reddawg Exp $ */ #include diff --git a/main.c b/main.c index e4797ed..0f470fe 100644 --- a/main.c +++ b/main.c @@ -2,7 +2,7 @@ Copyright (c) 2002-2004, 2005, 2007 Ubix Technology Group All rights reserved. - $Id$ + $Id: main.c,v 1.21 2008/06/30 18:55:10 reddawg Exp $ *****************************************************************************************/ diff --git a/mysql.c b/mysql.c index 7c1ffef..71bed1b 100644 --- a/mysql.c +++ b/mysql.c @@ -9,20 +9,23 @@ int dbInit() { - conn = mysql_init(NULL); + conn = mysql_init(0x0); + if (conn == NULL) { writeLog(0,"mysql_init() failed (probably out of memory)\n."); return(0x1); - } + } + + my_bool reconnect = 1; + + if (mysql_options(conn,MYSQL_OPT_RECONNECT, &reconnect) != 0x0) + writeLog(0,"mysql_options() failed: To Set Reconnect\n"); if (!mysql_real_connect(conn,MYSQL_HOST_NAME,MYSQL_USERNAME,MYSQL_PASSWORD,MYSQL_DB_NAME,0,NULL,0)) { writeLog(0,"mysql_real_connect() failed: Error %u (%s)\n.", mysql_errno(conn), mysql_error(conn)); return(0x1); } - if (mysql_options(conn,MYSQL_OPT_RECONNECT,"true") != 0x0) { - writeLog(0,"mysql_options() failed: To Set Reconnect\n"); - } pthread_mutex_init(&mysqlMutex, NULL); diff --git a/socket.c b/socket.c index f15ecfc..e3c3590 100644 --- a/socket.c +++ b/socket.c @@ -2,7 +2,7 @@ tuved - Socket Server (c) 2007 Christopher Olsen - $Id$ + $Id: socket.c,v 1.30 2008/02/05 01:27:29 reddawg Exp $ */ #include diff --git a/tuve.c b/tuve.c index 0c09fe2..44cd5be 100644 --- a/tuve.c +++ b/tuve.c @@ -1,6 +1,6 @@ /* (c) 2007 Christopher Olsen - $Id$ + $Id: tuve.c,v 1.60 2008/10/07 12:59:56 reddawg Exp $ */ #include @@ -69,6 +69,11 @@ cmd = data; + if (cmd == NULL) { + // MrOlsen 2017-11-17 TEMP + return(0); + } + if (cmd[userConnection->recLen - 1] == '\n') cmd[userConnection->recLen - 1] = '\0';