Jump to content

Something I been working on.... (IP Logins)


Kyle

Recommended Posts

  • Moderators

Hey Everyone,

I wanted to let you guys know that I'm working on little nice module. Basically, what this module does that whenever you login, the date and time, your IP Address, and your client will be recorded.

Here's a shot, you'll understand it.

So, if you are viewing Pilot ID 1, then you will see Pilot 1's Login history.

Same, You are viewing Pilot ID 2, then you will see Pilot 2's login history.

This is niffy stuff! :D, it's working so damn well and highly useful, whenever you can get all IP Logs and ban your pilots.

Here's how it works,

In the Login, to Process Login, I have added a DataClass to grab the info when they login. But I'm working on a different way so it won't get overwritten in updates. However, it's almost custom and you would lose everything in the update. Don't worry, I'll try my best to get it working, and it won't get overwritten in updates. Also, I'll try my best to integrate a pagination so you wouldn't get a long long list of login.

Lastly, I have to ask to anyone who keeps asking me when this will be released, I'll delay if you keep asking when it will be released. Give me time to do testing and making sure it works.

If you have any questions about it, or any requests, let me know! :D

I'll be putting this module to test on a live server later. I want to fill this niffy module in! :D

  • Like 2
Link to comment
Share on other sites

I like the way that you were able to get it set in the View Pilot (Admin Center), as I am constantly in there anyways. Jus ty a couple of questions for you Kyle. Is there a way to find out what page they most frequently visit, and how often they go there? I have a lot of pages, and I'd like to know if I need to keep some of them or just remove the pages if they aren't visiting them.

Link to comment
Share on other sites

  • Moderators

I like the way that you were able to get it set in the View Pilot (Admin Center), as I am constantly in there anyways. Jus ty a couple of questions for you Kyle. Is there a way to find out what page they most frequently visit, and how often they go there? I have a lot of pages, and I'd like to know if I need to keep some of them or just remove the pages if they aren't visiting them.

I would say you would need something like Page Visit Activity, Maybe on my next module I can look into it, later this year.

I want to work on this module first and build it till it's good enough.

Link to comment
Share on other sites

I like the way that you were able to get it set in the View Pilot (Admin Center), as I am constantly in there anyways. Jus ty a couple of questions for you Kyle. Is there a way to find out what page they most frequently visit, and how often they go there? I have a lot of pages, and I'd like to know if I need to keep some of them or just remove the pages if they aren't visiting them.

You can use Google Analytics for that ;)

Link to comment
Share on other sites

  • Moderators

Update...

Login History is Sorted by latest date first.

Next, will be looking into getting the JSON Table into it, like you see in the schedules and pilot list. So you don't want a long list of history. God Knows that pilots log in everyday! :lol:

Link to comment
Share on other sites

  • Moderators

Kyle when will you release laugh.gif

na just joking looks nice maby 1 change i would sugest lose the (json) behind the text wink.gif

:lol:

Thanks, Yeah I will remove it till I can get the tables and rows working later tonight.

Link to comment
Share on other sites

Guest lorathon

I have something similar to this. But I dont care about the browser what I cared about was pilots logging in with the same IP address. We have had problem pilots that come back with new names or have multiple accounts. The way I wrote it I can check the IP address against multiple logins.

Link to comment
Share on other sites

  • Moderators

I have something similar to this. But I dont care about the browser what I cared about was pilots logging in with the same IP address. We have had problem pilots that come back with new names or have multiple accounts. The way I wrote it I can check the IP address against multiple logins.

It just annoying when pilots join with different names or emails. It's always good to have an IP Address Tool to get these lying fools. :D

Nice one, in another VA we can limit the initial display to the last 10 logins, can your module be called to the public pilot profile, the reason i ask is because i currently list some goodies in that tpl to admins only and this would sit nicely in there i think.

Mark, I can take a look into it after I polish up the IP Login Module. You would have to add a Data.class, and get the IP by pilotid where you are looking at the profile, plus, some Admin Link serucity too.

All, Update!

I had to do some changes around. Since when you update phpVMS, you would lose this module. So I have changed and put the coding into a new module, however, for the PilotAdmin, I have removed the tab thing. So, I have created a one page that will use JSON to list all the login.

Heck, JSON been a hard thing to work with, but I had fun learning it!

I know, there are false and numbers, but I'm almost there. I have to add something that can grab by pilot id to get pilot ID with code and pilot names.

It'll be easier for you guys to keep this in all one and you can search by IP, Name, Code. ETC.

Link to comment
Share on other sites

  • Moderators

Need help here. So what I am trying to do, like JSON. The SQL query needs to be connected to the pilot tables.

	        $sql = 'SELECT p.*, p.pilotid, p.firstname, p.lastname,
			FROM ' . TABLE_PREFIX . 'pilotlogins p
			LEFT JOIN ' . TABLE_PREFIX . 'pilots AS p ON p.pilotid = p.pilotid ';

Does anyone know what I am doing wrong? Any help would be great!

Thanks!

Link to comment
Share on other sites

Guest lorathon

Try this. You can't use "p" twice. What is the pilotlogins table? Is that custom or part of a BETA?

$sql = 'SELECT l.*, p.pilotid, p.firstname, p.lastname,
        FROM '.TABLE_PREFIX.'pilotlogins l
        LEFT JOIN '.TABLE_PREFIX.'pilots AS p ON p.pilotid = l.pilotid ';

Link to comment
Share on other sites

  • Moderators

Try this. You can't use "p" twice. What is the pilotlogins table? Is that custom or part of a BETA?

$sql = 'SELECT l.*, p.pilotid, p.firstname, p.lastname,
        FROM '.TABLE_PREFIX.'pilotlogins l
        LEFT JOIN '.TABLE_PREFIX.'pilots AS p ON p.pilotid = l.pilotid ';

it's custom part, It's in phpvms_pilotlogins.

And the code you gave me, it doesn't show all the logins.

But I had it like this, and it works.

$sql = 'SELECT * FROM ' . TABLE_PREFIX . 'pilotlogins';

But with the JSON table and in the module file, I wanted to pull the data into Pilot Code, ID and their names.. I seen that you would have to join the tables to the pilots, so it can get it's data for pilot's first name, last name, and their pilot id.

It's like the schedules JSON, like it gets the Aircraft info by id, ETC.

Link to comment
Share on other sites

Guest lorathon

without see the structure of your custom table I am just shooring in the dark. Why the custom table? phpVMS_sessions has the session logs already.

To query from the phpvms_sessions would be...

$sql = 'SELECT s.*, p.*
       FROM '.TABLE_PREFIX.'sessions s
       LEFT JOIN '.TABLE_PREFIX.'pilots p ON p.pilotid = s.pilotid
       ';

$ret = DB::get_results($sql);

This will get the sessions rows joined with the pilot info (all of it)

You will have to call the PilotData::getPilotCode($code, $pilotid) to get the properly formatted pilot code (PVA0002)

If you have the pilotid column in your table then it would be

$sql = 'SELECT l.*, p.*
       FROM '.TABLE_PREFIX.'pilotlogins l
       LEFT JOIN '.TABLE_PREFIX.'pilots p ON p.pilotid = l.pilotid
       ';

$ret = DB::get_results($sql);

This will get the pilotlogins rows joined with the pilot info (all of it)

Link to comment
Share on other sites

  • Moderators

You will have to call the PilotData::getPilotCode($code, $pilotid) to get the properly formatted pilot code (PVA0002)

If you have the pilotid column in your table then it would be

$sql = 'SELECT l.*, p.*
       FROM '.TABLE_PREFIX.'pilotlogins l
       LEFT JOIN '.TABLE_PREFIX.'pilots p ON p.pilotid = l.pilotid
       ';

$ret = DB::get_results($sql);

This will get the pilotlogins rows joined with the pilot info (all of it)

Yep! It works now. So, I have to name the prefix, and join the tables.

But on the other side, I been looking though the pilotData.class to find a way to get the pilots name in by pilot id, I tried many ways to display the pilot's name, something like...

$pilotname = PilotData::getPilotData($row->pilotid, $firstname, $lastname);

But, it returned "ojectObject", somehow, I must be doing something wrong to parse the pilot's name by pilotid.

And thanks for your help as well! :D

Link to comment
Share on other sites

Guest lorathon

$sql = 'SELECT l.*, p.*
       FROM '.TABLE_PREFIX.'pilotlogins l
       LEFT JOIN '.TABLE_PREFIX.'pilots p ON p.pilotid = l.pilotid
       ';

$ret = DB::get_results($sql);

foreach($ret as $row) {
    $pilotcode = PilotData::getPilotCode($row->code, $row->pilotid);
    echo $pilotcode.' '.$row->firstname.' '.$row->lastname.'<br/>';
}

Run this. It should give you a list of the pilot codes and firstname lastname (PVA0002 Jeffrey Kobus). Everything you need is in the results of the query.

Link to comment
Share on other sites

  • Moderators

Little confused here, I putted the code you gave in my PilotLoginsData.class and it didn't give me all of the pilot logins.

This is what my current sql query to get all of the login.

	$sql = 'SELECT l.*, p.*
			FROM '.TABLE_PREFIX.'pilotlogins l
			LEFT JOIN '.TABLE_PREFIX.'pilots p ON p.pilotid = l.pilotid
			';

       $sql .= DB::build_where($params);


       if (strlen($order_by) > 0) {
           $sql .= ' ORDER BY ' . $order_by;
       }

       if (strlen($count) != 0) {
           $sql .= ' LIMIT ' . $count;
       }

       if (strlen($start) != 0) {
           $sql .= ' OFFSET ' . $start;
       }

       $ret = DB::get_results($sql);


       return $ret;

Where should I be putting that code you gave me?

Link to comment
Share on other sites

Guest lorathon

The code was just to show how to use the query results to retrieve the pilot code. If you are using json you will need to use this to add the pilot info to the json. Not the foreach but the PilotData::getPilotCode($code, $pilotid) function.

If you send me the files I can finish it for you. Or post the json loop.

Link to comment
Share on other sites

  • Moderators

The code was just to show how to use the query results to retrieve the pilot code. If you are using json you will need to use this to add the pilot info to the json. Not the foreach but the PilotData::getPilotCode($code, $pilotid) function.

If you send me the files I can finish it for you. Or post the json loop.

For the json loop, I believe this is what you need?

       # Add each row to the above array
       foreach ($pilotlogins as $row) 
	{

		$pilotid = PilotData::getPilotCode($row->code, $row->pilotid);



           $tmp = array(
			'id' => $row->id, 
			'cell' => array( # Each column, in order
			$row->id,
                               $pilotid,
			$pilotname,
			$row->datestamp, 
			$row->ip, 
			$row->client, 
			), 
		);

           $json['rows'][] = $tmp;
       }

Link to comment
Share on other sites

Guest lorathon

# Add each row to the above array
foreach ($pilotlogins as $row) {            
   $pilotid = PilotData::getPilotCode($row->code, $row->pilotid);
   $pilotname = $row->firstname.' '.$row->lastname; 

   $tmp = array(
          'id' => $row->id, 
          'cell' => array( # Each column, in order
                 $row->id,
                 $pilotid,
                 $pilotname,
                 $row->datestamp, 
                 $row->ip, 
                 $row->client, 
                 ), 
          );

    $json['rows'][] = $tmp;
}

If the $pilotlogins is filled correctly the above should add the pilot name as "FIRSTNAME LASTNAME".

Link to comment
Share on other sites

  • Moderators

Do we have a release imminent then?

Soon, As we speak. I'm just finishing up with the JSON table, and then I have to gather the stuff around it, and then add one more data class that you requested to show in profile, then I want to give it a run on a live server to make sure it's working.

I should have it out later tonight, or early time in phpVMS's timezone.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...