diff --git a/VERSION b/VERSION index 40c06cc..d1e9cf3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.8.0 +v3.7.0 diff --git a/controllers/internals/LinkShortener.php b/controllers/internals/LinkShortener.php deleted file mode 100644 index 296d116..0000000 --- a/controllers/internals/LinkShortener.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * This source file is subject to the GPL-3.0 license that is bundled - * with this source code in the file LICENSE. - */ - -namespace controllers\internals; - -use Exception; -use Monolog\Handler\StreamHandler; -use Monolog\Logger; -use PHPMailer\PHPMailer\PHPMailer; -use PHPMailer\PHPMailer\SMTP; - -/** - * Mailing class. - */ -class LinkShortener -{ - /** - * Shorten an URL using the configured YOURLS instance - */ - public static function shorten($url) - { - $api_url = URL_SHORTENER['HOST'] . '/yourls-api.php'; - - $data = [ - 'action' => 'shorturl', - 'format' => 'json', - 'username' => URL_SHORTENER['USER'], - 'password' => URL_SHORTENER['PASS'], - 'url' => $url, - ]; - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $api_url); - curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Enable follow location - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result - curl_setopt($ch, CURLOPT_POST, 1); // This is a POST request - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - $response = curl_exec($ch); - curl_close($ch); - - try - { - $response = json_decode($response, true, 512, JSON_THROW_ON_ERROR); - } - catch (\Exception $e) - { - return false; - } - - $shortlink = $response['shorturl'] ?? false; - return $shortlink; - } -} diff --git a/controllers/internals/Scheduled.php b/controllers/internals/Scheduled.php index df688d5..1b61a90 100644 --- a/controllers/internals/Scheduled.php +++ b/controllers/internals/Scheduled.php @@ -450,8 +450,7 @@ use Monolog\Logger; $users_smsstops = []; $users_settings = []; $users_phones = []; - $users_phone_groups = []; - $shortlink_cache = []; + $users_phone_groups = []; $now = new \DateTime(); $now = $now->format('Y-m-d H:i:s'); @@ -644,33 +643,6 @@ use Monolog\Logger; $text = Tool::convert_to_gsm0338($text); } - // If the text contain http links we must replace them - if (ENABLE_URL_SHORTENER && ((int) ($users_settings[$id_user]['shorten_url'] ?? false))) - { - $http_links = Tool::search_http_links($text); - if ($http_links !== false) - { - foreach ($http_links as $http_link) - { - if (!array_key_exists($http_link, $shortlink_cache)) - { - $shortlkink = LinkShortener::shorten($http_link); - - // If link shortening failed, keep original one - if ($shortlkink === false) - { - continue; - } - - $shortlink_cache[$http_link] = $shortlkink; - } - - $shortlink = $shortlink_cache[$http_link]; - $text = str_replace($http_link, $shortlink, $text); - } - } - } - /* Choose phone if no phone defined for message Phones are choosen using type, priority and remaining volume : diff --git a/controllers/internals/Setting.php b/controllers/internals/Setting.php index d5d9e29..84f62cf 100644 --- a/controllers/internals/Setting.php +++ b/controllers/internals/Setting.php @@ -35,18 +35,6 @@ namespace controllers\internals; return $settings_array; } - /** - * Get a user setting by his name for a user. - * - * @param int $id_user : user id - * - * @return array - */ - public function get_by_name_for_user(int $id_user, string $name) - { - return $this->get_model()->get_by_name_for_user($id_user, $name); - } - /** * Update a setting by his name and user id. * diff --git a/controllers/internals/Tool.php b/controllers/internals/Tool.php index 7f5473c..a09fab6 100644 --- a/controllers/internals/Tool.php +++ b/controllers/internals/Tool.php @@ -85,22 +85,6 @@ use BenMorel\GsmCharsetConverter\Converter; return '' . self::s($number_format, false, true, false) . ''; } - /** - * Check for http link in a text - * - * @param string $text : Text to search a link in - * - * @return bool|array : False if no link in the text, or an array of all http links - */ - public static function search_http_links($text) - { - $regex = "#http(s?)://\S+#i"; - $matches = []; - $nb_matches = preg_match_all($regex, $text, $matches); - - return $nb_matches > 0 ? $matches[0] : false; - } - /** * Cette fonction fait la correspondance entre un type d'evenement et une icone font awesome. * diff --git a/controllers/publics/Setting.php b/controllers/publics/Setting.php index fbf710e..c5a34e6 100644 --- a/controllers/publics/Setting.php +++ b/controllers/publics/Setting.php @@ -75,27 +75,12 @@ namespace controllers\publics; $setting_value = json_encode($setting_value); } - // If setting dont exists yet, create it, else update - $setting = $this->internal_setting->get_by_name_for_user($_SESSION['user']['id'], $setting_name); - if (!$setting) + $update_setting_result = $this->internal_setting->update_for_user($_SESSION['user']['id'], $setting_name, $setting_value); + if (false === $update_setting_result) { - $success = $this->internal_setting->create($_SESSION['user']['id'], $setting_name, $setting_value); - if (false === $success) - { - \FlashMessage\FlashMessage::push('danger', 'Impossible de mettre à jour ce réglage.'); + \FlashMessage\FlashMessage::push('danger', 'Impossible de mettre à jour ce réglage.'); - return $this->redirect(\descartes\Router::url('Setting', 'show')); - } - } - else - { - $update_setting_result = $this->internal_setting->update_for_user($_SESSION['user']['id'], $setting_name, $setting_value); - if (false === $update_setting_result) - { - \FlashMessage\FlashMessage::push('danger', 'Impossible de mettre à jour ce réglage.'); - - return $this->redirect(\descartes\Router::url('Setting', 'show')); - } + return $this->redirect(\descartes\Router::url('Setting', 'show')); } $settings = $this->internal_setting->gets_for_user($_SESSION['user']['id']); diff --git a/env.php.dist b/env.php.dist index afd6dd5..2c13aab 100644 --- a/env.php.dist +++ b/env.php.dist @@ -24,7 +24,6 @@ 'APP_SECRET' => '%APP_SECRET%', 'ENABLE_COMMAND' => false, 'ENABLE_ACCOUNT_DELETION' => true, - 'ENABLE_URL_SHORTENER' => %APP_URL_SHORTENER%, //E-mail types 'EMAIL_RESET_PASSWORD' => [ @@ -86,7 +85,6 @@ 'force_gsm_alphabet' => 0, 'phone_limit' => 0, 'phone_priority' => 0, - 'shorten_url' => 0, ], ]; diff --git a/env.prod.php.dist b/env.prod.php.dist index 628b500..8ff5fd5 100644 --- a/env.prod.php.dist +++ b/env.prod.php.dist @@ -21,11 +21,4 @@ 'FROM' => '%APP_MAIL_FROM%', ], - //YOURLS url shortener settings - 'URL_SHORTENER' => [ - 'HOST' => '%APP_URL_SHORTENER_HOST%', - 'USER' => '%APP_URL_SHORTENER_USER%', - 'PASS' => '%APP_URL_SHORTENER_PASS%', - ] - ]; diff --git a/models/Setting.php b/models/Setting.php index 2473e60..f2e6d43 100644 --- a/models/Setting.php +++ b/models/Setting.php @@ -27,18 +27,6 @@ namespace models; return $this->_update($this->get_table_name(), ['value' => $value], ['id_user' => $id_user, 'name' => $name]); } - /** - * Get a user setting by his name for a user. - * - * @param int $id_user : user id - * - * @return array - */ - public function get_by_name_for_user(int $id_user, string $name) - { - return $this->_select_one($this->get_table_name(), ['name' => $name, 'id_user' => $id_user]); - } - /** * Return table name. */ diff --git a/templates/setting/show.php b/templates/setting/show.php index 5b9a0d8..bc64c83 100644 --- a/templates/setting/show.php +++ b/templates/setting/show.php @@ -112,30 +112,6 @@ - - -
-
-
-

Support du raccourcisseur d'URL

-
-
-
-
- - -
-
- -
-
-
-
-
-