mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Add patch to version 3.8.0a4
This commit is contained in:
82
lib/classes/patch/3805.php
Normal file
82
lib/classes/patch/3805.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2012 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Entities\AuthFailure;
|
||||||
|
|
||||||
|
class patch_3805 implements patchInterface
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
private $release = '3.8.0.a4';
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $concern = array(base::APPLICATION_BOX);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function apply(base $appbox, Application $app)
|
||||||
|
{
|
||||||
|
$conn = $app['phraseanet.appbox']->get_connection();
|
||||||
|
$sql = 'SELECT date, login, ip, locked FROM badlog ORDER BY id ASC';
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
$n = 0;
|
||||||
|
|
||||||
|
foreach ($rs as $row) {
|
||||||
|
$date = Datetime::createFromFormat('Y-m-d h:i:s', $row['date']);
|
||||||
|
$failure = new AuthFailure();
|
||||||
|
if ($date) {
|
||||||
|
$failure->setCreated($date);
|
||||||
|
}
|
||||||
|
$failure->setIp($row['ip']);
|
||||||
|
$failure->setLocked(!!$row['locked']);
|
||||||
|
$failure->setUsername($row['login']);
|
||||||
|
|
||||||
|
$app['EM']->persist($failure);
|
||||||
|
|
||||||
|
if (0 === $n++ % 1000) {
|
||||||
|
$app['EM']->flush();
|
||||||
|
$app['EM']->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$app['EM']->flush();
|
||||||
|
$app['EM']->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,77 +2,6 @@
|
|||||||
<databases>
|
<databases>
|
||||||
<appbox>
|
<appbox>
|
||||||
<tables>
|
<tables>
|
||||||
<table name="badlog">
|
|
||||||
<fields>
|
|
||||||
<field>
|
|
||||||
<name>id</name>
|
|
||||||
<type>int(11) unsigned</type>
|
|
||||||
<null></null>
|
|
||||||
<extra>auto_increment</extra>
|
|
||||||
<default></default>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>date</name>
|
|
||||||
<type>datetime</type>
|
|
||||||
<null></null>
|
|
||||||
<extra></extra>
|
|
||||||
<default>0000-00-00 00:00:00</default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>login</name>
|
|
||||||
<type>varchar(64)</type>
|
|
||||||
<null></null>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
<collation>utf8_bin</collation>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>ip</name>
|
|
||||||
<type>varchar(64)</type>
|
|
||||||
<null>YES</null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>info1</name>
|
|
||||||
<type>mediumtext</type>
|
|
||||||
<null></null>
|
|
||||||
<extra></extra>
|
|
||||||
|
|
||||||
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>info2</name>
|
|
||||||
<type>mediumtext</type>
|
|
||||||
<null></null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>locked</name>
|
|
||||||
<type>tinyint(1) unsigned</type>
|
|
||||||
<null></null>
|
|
||||||
<extra></extra>
|
|
||||||
<default>0</default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
<indexes>
|
|
||||||
<index>
|
|
||||||
<name>id</name>
|
|
||||||
<type>UNIQUE</type>
|
|
||||||
<fields>
|
|
||||||
<field>id</field>
|
|
||||||
</fields>
|
|
||||||
</index>
|
|
||||||
</indexes>
|
|
||||||
<engine>InnoDB</engine>
|
|
||||||
</table>
|
|
||||||
<table name="bas">
|
<table name="bas">
|
||||||
<fields>
|
<fields>
|
||||||
<field>
|
<field>
|
||||||
|
|||||||
Reference in New Issue
Block a user