News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

$context[\\\'current_action\\\'] and logged time

Started by asmith, October 22, 2008, 02:25:39 AM

Previous topic - Next topic

asmith

hey guys

I have non-forum pages, SSI.php included.

I've checked if someone is visitign page x.html , the forum says he is viewing the index board of the site.
How can i make it so that the forum says he is visiting x.html ?

I played a little with $context['current_action'] on the x.html , before and after including SSI ,But has no success.


same with total time logged. When the user is in the x.html page, he total time logged won't increase, How can i achieve that too?

Thanks

SMF 1.1.6


[SiNaN]

To make forum to count the SSI page as online too, add this code after you include SSI.php:

writeLog();

To make forum to recognize where you are, add this code before you include SSI.php:

$_GET['action'] = 'my_page';

Then add this at the end of your Who.template.php file:

$txt['whoall_my_page] = 'He\'s viewing my page.';
Former SMF Core Developer | My Mods | SimplePortal

asmith

Thanks for replying man,  I got the members visiting pages right.

But total time logged still doesn't work.

I added writeLog(); after SSI being included, and stayed in some pages for like 2-3 mins , and refreshed, still no change, any idea?

[SiNaN]

I see, total time online won't increase if you are using SSI.

Subs.php

Find:

if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60)

Replace:

if (!empty($user_info['last_login']) && $user_info['last_login'] < time() - 60)

Do not forget this edit, you may need to take it back for upgrades.
Former SMF Core Developer | My Mods | SimplePortal

asmith

it worked! I cannot believe it :D

Thanks man, Don't know how to thank you, Thanks A TON!

Deprecated

Great advice Sinan! I've copied notes from this topic and I'm sure I'm going to need it before long. :)

virtualxtc

Quote from: [SiNaN] on October 24, 2008, 11:54:13 AM
To make forum to count the SSI page as online too, add this code after you include SSI.php:

writeLog();

To make forum to recognize where you are, add this code before you include SSI.php:

$_GET['action'] = 'my_page';

Then add this at the end of your Who.template.php file:

$txt['whoall_my_page] = 'He\'s viewing my page.';


Just wondering if this script is good for use in SMF V2?

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

asmith

#9
seems I got a problem with "who's online"  .

my non forum files work like this :

index.php?file=file1 

so I have $_GET['file'] .
I've tested it, it works WHEN there's no $_GET variable set, meaning when I'm on my home page where there's no $_GET variable it works,

BUT when i'm in the index.php?file=file1 , it says I'm on index of forum page which means it kinda has been disabled.

What's wrong with it?


[SiNaN]

Would having a single action for all SSI pages work for you?
Former SMF Core Developer | My Mods | SimplePortal

asmith

unfortunately no. 
I have a lot of SSI pages. That their $_GET['action'] are all different.

What should I ? I'll go down that road, just tell me :)

[SiNaN]

Well, let's try this.

Subs.php

Find:

function writeLog($force = false)

Replace:

function writeLog($force = false, $ssi_action = null)

Find:

$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);

Replace:

$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
if (!empty($ssi_action))
$serialized['action'] = $ssi_action;


Then in your SSI included file, use writeLog(false, 'action_you_want_to_be_save'); instead of just writeLog();. Example: writeLog(false, 'my_page);
Former SMF Core Developer | My Mods | SimplePortal

asmith

#14
It worked ! FINALLY ! I don't know what to say :D

just to sum it up for others :

do exactly as [SiNaN] said. but remember the  $_GET['action'] = 'my_page'; and the $txt['whoall_my_pages'] = 'He\'s viewing the page';

must be in their places still.

[SiNaN], Dont' know how to thank you. It was driving me crazy!
Thanks!

P.S  (I promise it is the last one :D ) If a page has its own variable,for example , 
we are both visiting  "edit" page and you are editing "A" team stat, I'm editing "B" team stat. something like the way forum do wit topics .

I want it to say : SiNaN is editing "A" team stat.
                           Asmith is editing "B" team stat.

how should I pass "A" or "B" to $txt variable? something to do with those %s  ?

[SiNaN]

This might work:

Who.php

Find:

// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)

Replace:

elseif (substr($actions['action'], 0, 8) == 'my_page_')
$data[$k] = sprintf($txt['whoall_my_page'], substr($actions['action'], 8));
// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)


Then you text string will be:

$txt['whoall_my_page'] = 'Editing "%s" team stats.';

When you set the action in SSI, set you should set it as; my_page_{team_name}

Example:

$_GET['action'] = 'my_page_A';

If you want to change 'my_page' part, you should modify the codes accordingly.
Former SMF Core Developer | My Mods | SimplePortal

asmith

:) Got nothing to say!

You're awsome!
btw congrats on your new nick, finally got rid of 'Extremely Depressed' ?  ;)

[SiNaN]

Well, not really; trying to get along with it. :P

Glad that I could help and thanks. ;)
Former SMF Core Developer | My Mods | SimplePortal

asmith

Came up with a new question :D lol this thread can never get closed !

emm does this thing we did to other pages, has any effect on "who's viewing this page" ?
You know when viewing a topic on the top it is written "asmith and 4 guests are viewing this topic" (If this option is turned on in admin of course)

How can I put it on my non-forum pages?   
I think the changes we did has something to do with this.

any idea?

[SiNaN]

You mean this causes a problem with that function? I don't think so.
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: