Initial commit

Functional, without SSO
This commit is contained in:
Jimmy Monin
2016-09-18 11:03:26 +02:00
commit 57708e3169
253 changed files with 30787 additions and 0 deletions

View File

@ -0,0 +1,13 @@
<?php
require_once __DIR__."/update.php";
class Update_262 extends Update
{
public function update()
{
if ("db" == $this->_storage) {
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` ADD `last_id` INTEGER UNSIGNED NOT NULL DEFAULT '0' AFTER `send_pushbullet`");
}
}
}

View File

@ -0,0 +1,78 @@
<?php
require_once __DIR__."/update.php";
class Update_26 extends Update
{
public function update()
{
if ("db" == $this->_storage) {
$this->_dbConnection->query("ALTER TABLE `LBC_User` ADD `options` TEXT NULL DEFAULT NULL AFTER `password`");
$users = $this->_dbConnection->query("SELECT * FROM `LBC_User`");
while ($user = $users->fetch_object()) {
$options = array();
if (!empty($user->free_mobile_user) && !empty($user->free_mobile_key)) {
$options["notification"]["freeMobile"] = array(
"user" => $user->free_mobile_user,
"key" => $user->free_mobile_key
);
} else {
$options["notification"]["freeMobile"] = false;
}
if (isset($user->unique_ads)) {
$options["unique_ads"] = (bool) $user->unique_ads;
}
$this->_dbConnection->query("UPDATE `LBC_User` SET
`options` = '".$this->_dbConnection->real_escape_string(json_encode($options))."'
WHERE id = ".$user->id);
}
$this->_dbConnection->query("ALTER TABLE `LBC_User` DROP `free_mobile_user`");
$this->_dbConnection->query("ALTER TABLE `LBC_User` DROP `free_mobile_key`");
$this->_dbConnection->query("ALTER TABLE `LBC_User` DROP `unique_ads`");
// mise à jour table Alert
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` CHANGE `send_sms` `send_sms_free_mobile` TINYINT(1) NOT NULL");
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` ADD `send_sms_ovh` TINYINT(1) NOT NULL AFTER `send_sms_free_mobile`");
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` ADD `send_pushbullet` TINYINT(1) NOT NULL AFTER `send_sms_ovh`");
} elseif ("files" == $this->_storage) {
$dir = DOCUMENT_ROOT.DS."var".DS."configs";
if (is_dir($dir)) {
foreach (scandir($dir) AS $file) {
if (preg_match("#user_.+\.json$#", $file)) {
$data = json_decode(trim(file_get_contents($dir.DS.$file)), true);
if (is_array($data)) {
$options = array();
if (!empty($data["free_mobile_user"]) && !empty($data["free_mobile_key"])) {
$options["notification"]["freeMobile"] = array(
"user" => $data["free_mobile_user"],
"key" => $data["free_mobile_key"]
);
} else {
$options["notification"]["freeMobile"] = false;
}
if (isset($data["unique_ads"])) {
$options["unique_ads"] = (bool) $data["unique_ads"];
}
file_put_contents($dir.DS.$file, json_encode($options));
}
} elseif (preg_match("#.+\.csv$#", $file)) {
// mise à jour fichier alert : send_sms" > "send_sms_free_mobile
file_put_contents($dir.DS.$file, str_replace(
"send_sms", "send_sms_free_mobile",
file_get_contents($dir.DS.$file)
));
}
}
}
}
// suppression des fichiers obsolètes.
if (is_file(DOCUMENT_ROOT.DS."app".DS."user".DS."scripts".DS."sms.php")) {
unlink(DOCUMENT_ROOT.DS."app".DS."user".DS."scripts".DS."sms.php");
}
if (is_file(DOCUMENT_ROOT.DS."app".DS."user".DS."scripts".DS."sms.phtml")) {
unlink(DOCUMENT_ROOT.DS."app".DS."user".DS."views".DS."sms.phtml");
}
}
}

View File

@ -0,0 +1,29 @@
<?php
require_once __DIR__."/update.php";
class Update_28 extends Update
{
public function update()
{
$delete_files = array(
"/lib/Lbc/Item.php", // fichier inutile depuis 2.7
"/lib/Lbc/Parser.php", // fichier inutile depuis 2.7
"/lib/AdService/Autoloader.php",
"/lib/Message/SMS/FreeMobile.php",
"/lib/Message/SMS/Ovh.php",
"/lib/Message/Abstract.php",
"/lib/Message/Pushbullet.php",
);
foreach ($delete_files AS $file) {
if (is_file(DOCUMENT_ROOT.$file)) {
@unlink(DOCUMENT_ROOT.$file);
}
}
if ("db" == $this->_storage) {
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` ADD `send_notifymyandroid` TINYINT(1) NOT NULL AFTER `send_pushbullet`");
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` ADD `send_pushover` TINYINT(1) NOT NULL AFTER `send_notifymyandroid`");
}
}
}

View File

@ -0,0 +1,13 @@
<?php
require_once __DIR__."/update.php";
class Update_31 extends Update
{
public function update()
{
if ("db" == $this->_storage) {
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` ADD `max_id` INTEGER UNSIGNED NOT NULL DEFAULT '0' AFTER `last_id`");
}
}
}

View File

@ -0,0 +1,30 @@
<?php
require_once __DIR__."/update.php";
class Update_32 extends Update
{
public function update()
{
if ("db" == $this->_storage) {
$this->_dbConnection->query("ALTER TABLE `LBC_Alert` CHANGE `last_id` `last_id` TEXT NULL DEFAULT NULL");
$this->_dbConnection->query('UPDATE `LBC_Alert` SET `url` = REPLACE(`url`, "http://www.leboncoin.fr/", "https://www.leboncoin.fr/")');
} elseif ("files" == $this->_storage) {
$dir = DOCUMENT_ROOT.DS."var".DS."configs";
if (is_dir($dir)) {
$files = glob($dir.DS."*.csv");
foreach ($files AS $file) {
file_put_contents(
$file,
str_replace(
"http://www.leboncoin.fr",
"https://www.leboncoin.fr",
file_get_contents($file)
)
);
}
}
}
}
}

View File

@ -0,0 +1,42 @@
<?php
abstract class Update
{
/**
* @var Config_Lite
*/
protected $_config;
/**
* @var string
*/
protected $_storage;
/**
* @var mysqli
*/
protected $_dbConnection;
/**
* @var \App\Storage\User
*/
protected $_userStorage;
/**
* gloal, c'est mal, mais ça conviendra pour l'instant.
*/
public function __construct()
{
global $config, $userStorage;
$this->_config = $config;
$this->_storage = $config->get("storage", "type", "files");
$this->_userStorage = $userStorage;
if ("db" == $this->_storage) {
global $dbConnection;
$this->_dbConnection = $dbConnection;
}
}
abstract public function update();
}