diff --git a/botthread.c b/botthread.c index b719abd..de32ae9 100644 --- a/botthread.c +++ b/botthread.c @@ -162,7 +162,8 @@ } else { row = mysql_fetch_row(res); - tmpChan->modes[CHAN_EXCLUSIVE] = atoi(row[0]); + tmpChan->modes[CHAN_EXCLUSIVE] = 1; + tmpChan->oid = atoi(row[0]); sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cExclusive",chan,userConnection->userInfo.username,dMS[1]); tuveSendAllInChan(chan,0x0,output); } @@ -274,6 +275,13 @@ if (res != 0x0) mysql_free_result(res); } + else if (strcasecmp(cmd,"rotatelog") == 0x0) { + writeLog(0,"Rotating Log File"); + fclose(logFile); + sprintf(logFileName,"./logs/tuved.%i.log",time(NULL)); + logFile = fopen(logFileName,"a"); + writeLog(0,"Log Rotated"); + } return(0x0); } @@ -460,7 +468,7 @@ if (tmpChans->modes[CHAN_RANDOM] == 0x1) { sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count FROM videos WHERE rating <= %i",tmpChans->modes[CHAN_RATING]); if (tmpChans->modes[CHAN_EXCLUSIVE]) - sprintf(output,"%s AND oid = %i",output,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]); diff --git a/channel.c b/channel.c index 5e3ae85..1c42ce3 100644 --- a/channel.c +++ b/channel.c @@ -248,6 +248,10 @@ if (tmpUsers->next != 0x0) tmpUsers->next->prev = tmpUsers->prev; +/* Undo Live + if (tmpChannel->modes[CHAN_LIVE] != 0) && (tmpChannel->d +*/ + if (tmpChannel->nextUser == tmpUsers) { if (tmpChannel->modes[CHAN_SCHEDULED] == 1) tmpChannel->modes[CHAN_SCHEDULED] = 0; @@ -398,7 +402,10 @@ sprintf(output,"MODE:%s:C:%i",tmpChannel->channel,tmpChannel->modes[CHAN_CLASS]); sSendData(userConnection,output); - sprintf(output,"MODE:%s:E:%i",tmpChannel->channel,tmpChannel->modes[CHAN_EXCLUSIVE]); + if (tmpChannel->modes[CHAN_EXCLUSIVE] != 0) + sprintf(output,"MODE:%s:E:%i",tmpChannel->channel,tmpChannel->oid); + else + sprintf(output,"MODE:%s:E:0",tmpChannel->channel); sSendData(userConnection,output); diff --git a/main.c b/main.c index d846c06..a3acffd 100644 --- a/main.c +++ b/main.c @@ -21,6 +21,7 @@ int channelCount = 0; int songCount = 0; int playCount = 0; +char logFileName[64]; void usage(); @@ -62,8 +63,10 @@ /* Prepare log file */ - if (logFile == 0x0) - logFile = fopen(LOG_FILE,"a"); + if (logFile == 0x0) { + sprintf(logFileName,"./logs/tuved.%i.log",time(NULL)); + logFile = fopen(logFileName,"a"); + } /* Fork into background unless specified not to do so */ if (doFork == 1) diff --git a/tuve.c b/tuve.c index 6e50c85..f27e111 100644 --- a/tuve.c +++ b/tuve.c @@ -344,6 +344,14 @@ } } } + else if (strcasecmp(cmd,"QUIT") == 0x0) { + if (strlen(data) > 0) + tuveDelUserChans(userConnection,data); + else + tuveDelUserChans(userConnection,"Leaving"); + close(userConnection->fd); + sRemoveConnection(userConnection->fd); + } else { sSendData(userConnection,"invalid command"); writeLog(1,"Invalid CMD: [%s]\n",cmd); diff --git a/tuved.h b/tuved.h index f00a8a2..92bcfed 100644 --- a/tuved.h +++ b/tuved.h @@ -84,6 +84,7 @@ int vid; // Video ID int comTime; // Total Ad Time int comDelay; // Video Play Counter For Next Ad + int oid; // Channels OID short count; // Counter For Querying A User For A Video short maxTime; // Maximum Length For A Video short vidClass; // Video Class - For Skip Protection @@ -137,6 +138,7 @@ extern tuveChanList_t *channels; extern pthread_mutex_t chanMutex; extern time_t startTime; +extern char logFileName[64]; /* Socket Functions */ ssize_t sReadSocket(int socketFD,void *buffer,size_t length); @@ -148,6 +150,7 @@ int sSendPing(time_t); // Sends Ping To All Sockets int sCleanConnections(); // Cleans Up The Dead Connections int sSendData(myConnections_t *con,char const * __restrict fmt, ...); // Sends Data To A Socket +int sRemoveConnection(int socketFD); int tuveGetData(myConnections_t *userConnection); /* * End Socket functions