Support > cpg1.5 permissions
Allow user for 31 days
tortech:
How to allow user to show gallery only for 31 days since the day of first time visit.
Αndré:
By default Coppermine just saves the registration date and the date of the last visit. Is it okay that we check against the registration date, or do you really need to check against the first visit?
tortech:
For me is necessery to store in database the day of first visit (when user watch gallery).
From this day program must count each day and after 31 days user stays unregistered.
How to do it programatically?
--- Quote from: Αndré on March 21, 2012, 03:08:06 pm ---By default Coppermine just saves the registration date and the date of the last visit. Is it okay that we check against the registration date, or do you really need to check against the first visit?
--- End quote ---
Αndré:
Open bridge/coppermine.inc.php, find
--- Code: --- // If exists update lastvisit value, session, and login
if (mysql_num_rows($results)) {
--- End code ---
and below, add
--- Code: --- switch($CONFIG['login_method']){
case 'both':
$where = "(user_name = '$username' OR user_email = '$username') AND BINARY user_password = '$encpassword' AND user_active = 'YES'";
break;
case 'email':
$where = "user_email = '$username' AND BINARY user_password = '$encpassword' AND user_active = 'YES'";
break;
case 'username':
default:
$where = "user_name = '$username' AND BINARY user_password = '$encpassword' AND user_active = 'YES'";
break;
}
list($lastvisit, $regdate) = mysql_fetch_row(cpg_db_query("SELECT {$this->field['lastvisit']}, {$this->field['regdate']} FROM {$this->usertable} WHERE ".$where));
if (!$lastvisit) {
cpg_db_query("UPDATE {$this->usertable} SET user_regdate = NOW() WHERE ".$where);
} else {
if ($regdate < time() - 60*60*24*31) {
return false;
}
}
--- End code ---
This code will update the registration date on first login and then will check against it on each login.
Αndré:
To kick users that are already logged in open bridge/coppermine.inc.php, find
--- Code: --- // Clean up old sessions every 5 minutes at maximum
if ($CONFIG['session_cleanup'] < time() - 300) {
--- End code ---
and below, add
--- Code: --- $sql = "DELETE FROM {$this->sessionstable} WHERE user_id IN (SELECT {$this->field['user_id']} FROM {$this->usertable} WHERE {$this->field['regdate']} < ".(time() - 60*60*24*31).")";
cpg_db_query($sql, $this->link_id);
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version