Jump to content

[SOLVED] Automated script


Aureole

Recommended Posts

I need to make a script that runs itself every Hour, how do I do this/is it possible?

 

EDIT: I read about Cron Jobs/Tabs on Google.com and I see them in my CPanel but I don't know how to work it... well it says Command to run:

 

What do I put there? An absolute url:

 

http://www.site.com/script.php

 

?

Link to comment
https://forums.phpfreaks.com/topic/72451-solved-automated-script/
Share on other sites

Nevermind I've got it working I think, now the question is would this work for a cron job/tab:

 

<?php

include('functions.swr3');

dbConnect();

$c_timestamp = date();

$query = "SELECT * FROM members WHERE mem_online='1'";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result) {
    $mem_id = $row['mem_id'];
$mem_last_action = $row['mem_last_action'];

    $inactivity = $c_timestamp - $mem_last_action;

if($inactivity > 3600) {
        $query = "UPDATE members SET mem_online='0' WHERE mem_id='{$mem_id}'";
        $result = mysql_query($query);
}
}

?>

 

It needs to go through all online members and if their timestamp is more than an Hour old then sign them out automagically.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.