------------------------------------------------------------------------------------
--- "$Id: cservice.sql,v 1.86 2007/03/25 16:42:24 kewlio Exp $"
+-- "$Id: cservice.sql,v 1.87 2008/11/12 20:45:42 mrbean_ Exp $"
-- Channel service DB SQL file for PostgreSQL.
-- ChangeLog:
user_id INT4 CONSTRAINT lastseen_users_id_ref REFERENCES users ( id ),
last_seen INT4,
last_hostmask VARCHAR( 256 ),
+ last_ip VARCHAR( 256 ),
last_updated INT4 NOT NULL,
PRIMARY KEY (user_id)
);
--- /dev/null
+--
+-- Adds the last_ip column to the users_lastseen table
+
+ALTER TABLE users_lastseen ADD COLUMN last_ip VARCHAR( 256 );
+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: CHANINFOCommand.cc,v 1.60 2008/01/01 19:03:41 kewlio Exp $
+ * $Id: CHANINFOCommand.cc,v 1.61 2008/11/12 20:45:42 mrbean_ Exp $
*/
#include <string>
#include "dbHandle.h"
#include "cservice_config.h"
-const char CHANINFOCommand_cc_rcsId[] = "$Id: CHANINFOCommand.cc,v 1.60 2008/01/01 19:03:41 kewlio Exp $" ;
+const char CHANINFOCommand_cc_rcsId[] = "$Id: CHANINFOCommand.cc,v 1.61 2008/11/12 20:45:42 mrbean_ Exp $" ;
namespace gnuworld
{
} else {
bot->Notice(theClient, "Last Hostmask: %s",
theUser->getLastHostMask().c_str());
+ //Show ip only to admins
+ if(adminAccess > 0)
+ {
+ bot->Notice(theClient, "Last IP: %s",
+ theUser->getLastIP().c_str());
+ }
}
#ifdef USE_NOTES
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: LOGINCommand.cc,v 1.65 2008/01/01 13:49:19 kewlio Exp $
+ * $Id: LOGINCommand.cc,v 1.66 2008/11/12 20:45:42 mrbean_ Exp $
*/
#include <string>
#include "networkData.h"
#include "cservice_config.h"
#include "Network.h"
+#include "ip.h"
-const char LOGINCommand_cc_rcsId[] = "$Id: LOGINCommand.cc,v 1.65 2008/01/01 13:49:19 kewlio Exp $" ;
+const char LOGINCommand_cc_rcsId[] = "$Id: LOGINCommand.cc,v 1.66 2008/11/12 20:45:42 mrbean_ Exp $" ;
namespace gnuworld
{
}
}
/* update their details */
-theUser->setLastSeen(bot->currentTime(), theClient->getNickUserHost());
+theUser->setLastSeen(bot->currentTime(), theClient->getNickUserHost(),
+ theClient->getNickName() + "!" + theClient->getUserName() + "@" + xIP( theClient->getIP()).GetNumericIP());
theUser->setFlag(sqlUser::F_LOGGEDIN);
theUser->addAuthedClient(theClient);
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: SCANHOSTCommand.cc,v 1.6 2007/08/28 16:10:11 dan_karrels Exp $
+ * $Id: SCANHOSTCommand.cc,v 1.7 2008/11/12 20:45:42 mrbean_ Exp $
*/
string host = string_lower(st[1]);
stringstream scanhostQuery;
-scanhostQuery << "SELECT users.user_name, users_lastseen.last_hostmask FROM users, users_lastseen WHERE "
+scanhostQuery << "SELECT users.user_name, users_lastseen.last_hostmask, users_lastseen.last_ip FROM users, users_lastseen WHERE "
<< "users.id = users_lastseen.user_id AND "
- << "lower(users_lastseen.last_hostmask) LIKE '" << escapeSQLChars(searchSQL(host)) << "' LIMIT 50"
+ << "(lower(users_lastseen.last_hostmask) LIKE '" << escapeSQLChars(searchSQL(host)) << "'"
+ << " OR lower(users_lastseen.last_ip) LIKE '" << escapeSQLChars(searchSQL(host)) << "') LIMIT 50"
<< ends;
#ifdef LOG_SQL
for (unsigned int i = 0; i < bot->SQLDb->Tuples(); i++)
{
string username = bot->SQLDb->GetValue(i, 0);
- string lasthost = bot->SQLDb->GetValue(i, 1);
+ string lasthost = bot->SQLDb->GetValue(i, 1) + " - Last IP: " + bot->SQLDb->GetValue(i, 2);
scanResults.insert( std::make_pair(username, lasthost));
}
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlUser.cc,v 1.46 2007/08/28 16:10:12 dan_karrels Exp $
+ * $Id: sqlUser.cc,v 1.47 2008/11/12 20:45:42 mrbean_ Exp $
*/
#include <sstream>
<< "last_hostmask = '"
<< escapeSQLChars(last_hostmask)
<< "', "
+ << "last_ip = '"
+ << escapeSQLChars(last_ip)
+ << "', "
<< "last_updated = now()::abstime::int4 "
<< queryCondition
<< id
}
+const string sqlUser::getLastIP()
+{
+stringstream queryString;
+queryString << "SELECT last_ip"
+ << " FROM users_lastseen WHERE user_id = "
+ << id
+ << ends;
+#ifdef LOG_SQL
+ elog << "sqlUser::getLastIP> "
+ << queryString.str().c_str()
+ << endl;
+#endif
+
+if( SQLDb->Exec(queryString, true ) )
+//if( PGRES_TUPLES_OK == status )
+ {
+ /*
+ * If the user doesn't exist, we won't get any rows back.
+ */
+
+ if(SQLDb->Tuples() < 1)
+ {
+ return ("");
+ }
+
+ last_ip = SQLDb->GetValue(0, 0);
+
+ return (last_ip);
+ }
+
+return ("");
+
+}
void sqlUser::writeEvent(unsigned short eventType, sqlUser* theUser, const string& theMessage)
{
string userExtra = theUser ? theUser->getUserName() : "Not Logged In";
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlUser.h,v 1.41 2007/08/28 16:10:12 dan_karrels Exp $
+ * $Id: sqlUser.h,v 1.42 2008/11/12 20:45:42 mrbean_ Exp $
*/
#ifndef __SQLUSER_H
-#define __SQLUSER_H "$Id: sqlUser.h,v 1.41 2007/08/28 16:10:12 dan_karrels Exp $"
+#define __SQLUSER_H "$Id: sqlUser.h,v 1.42 2008/11/12 20:45:42 mrbean_ Exp $"
#include <string>
#include <vector>
{ password = _password; }
inline void setLastSeen( const time_t& _last_seen,
- const std::string& _last_hostmask )
+ const std::string& _last_hostmask,
+ const std::string& _last_ip)
{ last_seen = _last_seen;
last_hostmask = _last_hostmask ;
+ last_ip = _last_ip;
commitLastSeen(); }
inline void setLastSeen( const time_t& _last_seen )
bool commitLastSeenWithoutMask();
time_t getLastSeen();
const std::string getLastHostMask();
+ const std::string getLastIP();
bool Insert() ;
bool loadData( int );
time_t instantiated_ts;
std::string email ;
std::string last_hostmask ;
+ std::string last_ip;
unsigned int maxlogins;
time_t last_note;
unsigned int notes_sent;