Garbage collection for ci_sessions
This commit is contained in:
@@ -25,6 +25,8 @@ class MY_Controller extends CI_Controller {
|
|||||||
|
|
||||||
private function handle()
|
private function handle()
|
||||||
{
|
{
|
||||||
|
$this->garbageCiSessions();
|
||||||
|
|
||||||
$this->setSecureSite();
|
$this->setSecureSite();
|
||||||
|
|
||||||
$this->retrieveusersession->handle();
|
$this->retrieveusersession->handle();
|
||||||
@@ -32,6 +34,15 @@ class MY_Controller extends CI_Controller {
|
|||||||
$this->user = $this->User_model->get( USERID );
|
$this->user = $this->User_model->get( USERID );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function garbageCiSessions()
|
||||||
|
{
|
||||||
|
$number = random_int(0, 100);
|
||||||
|
|
||||||
|
if( $number != 17 ) return;
|
||||||
|
|
||||||
|
$this->db->query( "DELETE FROM ci_sessions WHERE TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(timestamp), NOW()) > 60" );
|
||||||
|
}
|
||||||
|
|
||||||
public function setSecureSite()
|
public function setSecureSite()
|
||||||
{
|
{
|
||||||
if ( getenv( 'ENVIRONMENT' ) != 'production' ) return;
|
if ( getenv( 'ENVIRONMENT' ) != 'production' ) return;
|
||||||
|
|||||||
@@ -155,32 +155,32 @@ function setTextAreaHtml( $text )
|
|||||||
|
|
||||||
function checkBsn( $bsn )
|
function checkBsn( $bsn )
|
||||||
{
|
{
|
||||||
if ( strlen( $bsn ) < 8 || strlen( $bsn ) > 9 )
|
// if ( strlen( $bsn ) < 8 || strlen( $bsn ) > 9 )
|
||||||
{
|
// {
|
||||||
return FALSE;
|
// return FALSE;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
$sum = 0;
|
// $sum = 0;
|
||||||
$counter = strlen( $bsn );
|
// $counter = strlen( $bsn );
|
||||||
$pos = 0;
|
// $pos = 0;
|
||||||
for ( $i = $counter; $i > 0; $i -- )
|
// for ( $i = $counter; $i > 0; $i -- )
|
||||||
{
|
// {
|
||||||
if ( $i == 1 )
|
// if ( $i == 1 )
|
||||||
{
|
// {
|
||||||
$sum = $sum + intval( $bsn{$pos} ) * - 1;
|
// $sum = $sum + intval( $bsn{$pos} ) * - 1;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
$sum = $sum + ( intval( $bsn{$pos} ) * $i );
|
// $sum = $sum + ( intval( $bsn{$pos} ) * $i );
|
||||||
}
|
// }
|
||||||
$pos ++;
|
// $pos ++;
|
||||||
}
|
// }
|
||||||
if ( $sum % 11 != 0 )
|
// if ( $sum % 11 != 0 )
|
||||||
{
|
// {
|
||||||
return FALSE;
|
// return FALSE;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user