mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-07-06 03:40:48 +02:00
Initial commit
Functional, without SSO
This commit is contained in:
1
sources/others/.htaccess
Normal file
1
sources/others/.htaccess
Normal file
@ -0,0 +1 @@
|
||||
Deny from all
|
46
sources/others/install/schema.php
Normal file
46
sources/others/install/schema.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
if (!isset($dbConnection))
|
||||
return;
|
||||
|
||||
$dbConnection->query("CREATE TABLE IF NOT EXISTS `LBC_User` (
|
||||
`id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`username` VARCHAR(100) COLLATE utf8_general_ci NOT NULL UNIQUE,
|
||||
`password` VARCHAR(40) NOT NULL,
|
||||
`options` TEXT DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_bin");
|
||||
|
||||
$dbConnection->query("CREATE TABLE IF NOT EXISTS `LBC_Alert` (
|
||||
`id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`idstr` CHAR(40) NOT NULL UNIQUE,
|
||||
`email` VARCHAR(100) COLLATE utf8_general_ci NOT NULL,
|
||||
`date_created` DATETIME NOT NULL,
|
||||
`title` VARCHAR(255) COLLATE utf8_general_ci NOT NULL,
|
||||
`url` VARCHAR(255) COLLATE utf8_bin NOT NULL,
|
||||
`interval` SMALLINT UNSIGNED NOT NULL,
|
||||
`time_last_ad` INTEGER UNSIGNED NOT NULL,
|
||||
`time_updated` INTEGER UNSIGNED NOT NULL,
|
||||
`price_min` INTEGER NOT NULL DEFAULT -1,
|
||||
`price_max` INTEGER NOT NULL DEFAULT -1,
|
||||
`price_strict` BOOLEAN NOT NULL,
|
||||
`cities` TEXT DEFAULT NULL,
|
||||
`suspend` BOOLEAN NOT NULL,
|
||||
`group` VARCHAR(255) COLLATE utf8_general_ci NOT NULL,
|
||||
`group_ads` BOOLEAN NOT NULL,
|
||||
`categories` TEXT DEFAULT NULL,
|
||||
`send_mail` BOOLEAN NOT NULL,
|
||||
`send_sms_free_mobile` BOOLEAN NOT NULL,
|
||||
`send_sms_ovh` BOOLEAN NOT NULL,
|
||||
`send_pushbullet` BOOLEAN NOT NULL,
|
||||
`send_notifymyandroid` TINYINT(1) NOT NULL,
|
||||
`send_pushover` TINYINT(1) NOT NULL,
|
||||
`last_id` TEXT DEFAULT NULL,
|
||||
`max_id` INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||
`user_id` MEDIUMINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `LBCKey_Alert_User`
|
||||
FOREIGN KEY `user_id` (`user_id`)
|
||||
REFERENCES `LBC_User` (`id`)
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_bin");
|
13
sources/others/update/2.6.2.php
Normal file
13
sources/others/update/2.6.2.php
Normal 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`");
|
||||
}
|
||||
}
|
||||
}
|
78
sources/others/update/2.6.php
Normal file
78
sources/others/update/2.6.php
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
29
sources/others/update/2.8.php
Normal file
29
sources/others/update/2.8.php
Normal 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`");
|
||||
}
|
||||
}
|
||||
}
|
13
sources/others/update/3.1.php
Normal file
13
sources/others/update/3.1.php
Normal 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`");
|
||||
}
|
||||
}
|
||||
}
|
30
sources/others/update/3.2.php
Normal file
30
sources/others/update/3.2.php
Normal 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)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
sources/others/update/update.php
Normal file
42
sources/others/update/update.php
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user