mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 12:48:08 +09:00
* Replace rand() with random_int() * Replace mt_rand() with random_int() * Whoops
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* FOSSBilling
|
|
*
|
|
* @copyright FOSSBilling (https://www.fossbilling.org)
|
|
* @license Apache-2.0
|
|
*
|
|
* This file may contain code previously used in the BoxBilling project.
|
|
* Copyright BoxBilling, Inc 2011-2021
|
|
*
|
|
* This source file is subject to the Apache-2.0 License that is bundled
|
|
* with this source code in the file LICENSE
|
|
*/
|
|
|
|
|
|
class Model_ClientPasswordResetTable implements \Box\InjectionAwareInterface
|
|
{
|
|
/**
|
|
* @var \Box_Di
|
|
*/
|
|
protected $di;
|
|
|
|
/**
|
|
* @param Box_Di $di
|
|
*/
|
|
public function setDi($di)
|
|
{
|
|
$this->di = $di;
|
|
}
|
|
|
|
/**
|
|
* @return Box_Di
|
|
*/
|
|
public function getDi()
|
|
{
|
|
return $this->di;
|
|
}
|
|
|
|
public function generate(Model_Client $client, $ip)
|
|
{
|
|
$r = $this->di['db']->findOne('ClientPasswordReset', 'client_id', $client->id);
|
|
if(!$r instanceof Model_ClientPasswordReset) {
|
|
$r = $this->di['db']->dispense('ClientPasswordReset');
|
|
$r->created_at = date('Y-m-d H:i:s');
|
|
$r->client_id = $client->id;
|
|
}
|
|
|
|
$r->ip = $ip;
|
|
$r->hash = sha1(random_int(50, random_int(10, 99)));
|
|
$r->updated_at = date('Y-m-d H:i:s');
|
|
$this->di['db']->store($r);
|
|
|
|
return $r;
|
|
}
|
|
|
|
public function rmByClient(Model_Client $client)
|
|
{
|
|
$models = $this->di['db']->find('ClientPasswordReset', 'client_id = ?', array($client->id));
|
|
foreach($models as $model){
|
|
$this->di['db']->trash($model);
|
|
}
|
|
}
|
|
|
|
} |