update php headers to phpdoc style (and some fixes)

This commit is contained in:
Jean-Christian Denis 2021-09-02 14:32:26 +02:00
parent c4972a4a8e
commit a92e6ec8af
31 changed files with 641 additions and 650 deletions

View file

@ -2,7 +2,7 @@ xxx.xx.xx
- [ ] Add public page of the list of know urls and in/visible status - [ ] Add public page of the list of know urls and in/visible status
- [ ] Add passworded links - [ ] Add passworded links
- [ ] fix deprecated external service - [ ] fix deprecated external service
- [ ] update php header to phpdoc style - [x] update php header to phpdoc style
- [x] fix post page options display - [x] fix post page options display
2021.08.28 - pre release 2021.08.28 - pre release

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return; return;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return; return;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return; return;
@ -43,7 +43,6 @@ $this->addUserAction(
/* description */ __('delete the version number') /* description */ __('delete the version number')
); );
# Delete only dc version and plugin files from pluginsBeforeDelete # Delete only dc version and plugin files from pluginsBeforeDelete
# Keep table # Keep table

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -5,9 +5,7 @@
<author>Jean-Christian Denis and contributors</author> <author>Jean-Christian Denis and contributors</author>
<desc>Use, create and serve short url on your blog</desc> <desc>Use, create and serve short url on your blog</desc>
<file>https://github.com/JcDenis/kUtRL/releases/download/v2021.08.28/plugin-kUtRL.zip</file> <file>https://github.com/JcDenis/kUtRL/releases/download/v2021.08.28/plugin-kUtRL.zip</file>
<da:dcmin>2.19</da:dcmin>
<da:details>http://plugins.dotaddict.org/dc2/details/kUtRL</da:details> <da:details>http://plugins.dotaddict.org/dc2/details/kUtRL</da:details>
<da:section></da:section>
<da:support>https://github.com/JcDenis/kUtRL</da:support> <da:support>https://github.com/JcDenis/kUtRL</da:support>
</module> </module>
</modules> </modules>

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
# This file is used with plugin activityReport # This file is used with plugin activityReport

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
# This file contents class to acces local short links records # This file contents class to acces local short links records

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
class kutrlLinkslist class kutrlLinkslist
{ {

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
# Generic class for shorten link service # Generic class for shorten link service
# A service class must extends this one # A service class must extends this one

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
# This file contents class to shorten url pass through wiki # This file contents class to shorten url pass through wiki

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
# This file takes records from plugin dcMiniUrl # This file takes records from plugin dcMiniUrl
# and inserts them into plugin kUtRL. # and inserts them into plugin kUtRL.
@ -19,118 +19,117 @@ if (!defined('DC_CONTEXT_ADMIN')){return;}
$miniurl_patch = new dcMiniUrl2kUtRL($core); $miniurl_patch = new dcMiniUrl2kUtRL($core);
if ($miniurl_patch->parseRecords()) if ($miniurl_patch->parseRecords())
{ {
try try
{ {
$core->plugins->deactivateModule('dcMiniUrl'); $core->plugins->deactivateModule('dcMiniUrl');
} }
catch (Exception $e) catch (Exception $e)
{ {
//$core->error->add($e->getMessage()); //$core->error->add($e->getMessage());
} }
} }
class dcMiniUrl2kUtRL class dcMiniUrl2kUtRL
{ {
public $core; public $core;
public $k_tb; public $k_tb;
public $m_tb; public $m_tb;
public function __construct($core) public function __construct($core)
{ {
$this->core = $core; $this->core = $core;
$this->con = $core->con; $this->con = $core->con;
$this->k_tb = $core->prefix.'kutrl'; $this->k_tb = $core->prefix.'kutrl';
$this->m_tb = $core->prefix.'miniurl'; $this->m_tb = $core->prefix.'miniurl';
} }
public function parseRecords() public function parseRecords()
{ {
$rs = $this->con->select( $rs = $this->con->select(
'SELECT * FROM '.$this->m_tb.' ' 'SELECT * FROM '.$this->m_tb.' '
); );
while ($rs->fetch()) while ($rs->fetch())
{ {
if ($rs->miniurl_type == 'customurl' || $rs->miniurl_type == 'miniurl') if ($rs->miniurl_type == 'customurl' || $rs->miniurl_type == 'miniurl')
{ {
if ($this->exists($rs)) continue; if ($this->exists($rs)) continue;
$this->insertKutrl($rs); $this->insertKutrl($rs);
$this->insertLocal($rs); $this->insertLocal($rs);
} }
else else
{ {
$this->insertOther($rs); $this->insertOther($rs);
} }
} }
return true; return true;
} }
private function insertKutrl($rs) private function insertKutrl($rs)
{ {
$cur = $this->common($rs); $cur = $this->common($rs);
$cur->kut_service = 'kutrl'; $cur->kut_service = 'kutrl';
$cur->kut_type = 'local'; $cur->kut_type = 'local';
$cur->kut_counter = 0; $cur->kut_counter = 0;
$cur->kut_password = null; $cur->kut_password = null;
$cur->insert(); $cur->insert();
$this->con->unlock(); $this->con->unlock();
} }
private function insertLocal($rs) private function insertLocal($rs)
{ {
$cur = $this->common($rs); $cur = $this->common($rs);
$cur->kut_service = 'local'; $cur->kut_service = 'local';
$cur->kut_type = $rs->miniurl_type == 'customurl' ? $cur->kut_type = $rs->miniurl_type == 'customurl' ?
'localcustom' : 'localnormal'; 'localcustom' : 'localnormal';
$cur->insert(); $cur->insert();
$this->con->unlock(); $this->con->unlock();
} }
private function insertOther($rs) private function insertOther($rs)
{ {
$cur = $this->common($rs); $cur = $this->common($rs);
$cur->insert(); $cur->insert();
$this->con->unlock(); $this->con->unlock();
} }
private function common($rs) private function common($rs)
{ {
$cur = $this->con->openCursor($this->k_tb); $cur = $this->con->openCursor($this->k_tb);
$this->con->writeLock($this->k_tb); $this->con->writeLock($this->k_tb);
$cur->kut_id = $this->nextId(); $cur->kut_id = $this->nextId();
$cur->blog_id = $rs->blog_id; $cur->blog_id = $rs->blog_id;
$cur->kut_service = 'unknow'; $cur->kut_service = 'unknow';
$cur->kut_type = $rs->miniurl_type; $cur->kut_type = $rs->miniurl_type;
$cur->kut_hash = $rs->miniurl_id; $cur->kut_hash = $rs->miniurl_id;
$cur->kut_url = $rs->miniurl_str; $cur->kut_url = $rs->miniurl_str;
$cur->kut_dt = $rs->miniurl_dt; $cur->kut_dt = $rs->miniurl_dt;
$cur->kut_counter = $rs->miniurl_counter; $cur->kut_counter = $rs->miniurl_counter;
$cur->kut_password = $rs->miniurl_password; $cur->kut_password = $rs->miniurl_password;
return $cur; return $cur;
} }
private function exists($rs) private function exists($rs)
{ {
$chk = $this->con->select( $chk = $this->con->select(
'SELECT kut_hash FROM '.$this->k_tb.' '. 'SELECT kut_hash FROM '.$this->k_tb.' '.
"WHERE blog_id = '".$rs->blog_id."' ". "WHERE blog_id = '".$rs->blog_id."' ".
"AND kut_service = 'local' ". "AND kut_service = 'local' ".
"AND kut_hash = '".$rs->miniurl_id."' " "AND kut_hash = '".$rs->miniurl_id."' "
); );
return !$chk->isEmpty(); return !$chk->isEmpty();
} }
private function nextId() private function nextId()
{ {
return $this->con->select( return $this->con->select(
'SELECT MAX(kut_id) FROM '.$this->k_tb.' ' 'SELECT MAX(kut_id) FROM '.$this->k_tb.' '
)->f(0) + 1; )->f(0) + 1;
} }
} }
?>

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){return;}

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,121 +1,120 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){return;}
class suprKutrlService extends kutrlService class suprKutrlService extends kutrlService
{ {
protected $config = array( protected $config = array(
'id' => 'supr', 'id' => 'supr',
'name' => 'su.pr StumbleUpon', 'name' => 'su.pr StumbleUpon',
'home' => 'http://su.pr', 'home' => 'http://su.pr',
'url_api' => 'http://su.pr/api/', 'url_api' => 'http://su.pr/api/',
'url_base' => 'http://su.pr/', 'url_base' => 'http://su.pr/',
'url_min_len' => 23 'url_min_len' => 23
); );
private $args = array( private $args = array(
'version' => '1.0', 'version' => '1.0',
'format' => 'xml', 'format' => 'xml',
'login' => '', 'login' => '',
'apiKey' => '' 'apiKey' => ''
); );
protected function init() protected function init()
{ {
$this->args['login'] = $this->settings->kutrl_srv_supr_login; $this->args['login'] = $this->settings->kutrl_srv_supr_login;
$this->args['apiKey'] = $this->settings->kutrl_srv_supr_apikey; $this->args['apiKey'] = $this->settings->kutrl_srv_supr_apikey;
} }
public function saveSettings() public function saveSettings()
{ {
$this->settings->put('kutrl_srv_supr_login',$_POST['kutrl_srv_supr_login']); $this->settings->put('kutrl_srv_supr_login',$_POST['kutrl_srv_supr_login']);
$this->settings->put('kutrl_srv_supr_apikey',$_POST['kutrl_srv_supr_apikey']); $this->settings->put('kutrl_srv_supr_apikey',$_POST['kutrl_srv_supr_apikey']);
} }
public function settingsForm() public function settingsForm()
{ {
echo echo
'<p><label class="classic">'.__('Login:').'<br />'. '<p><label class="classic">'.__('Login:').'<br />'.
form::field(array('kutrl_srv_supr_login'),50,255,$this->settings->kutrl_srv_supr_login). form::field(array('kutrl_srv_supr_login'),50,255,$this->settings->kutrl_srv_supr_login).
'</label></p>'. '</label></p>'.
'<p class="form-note">'. '<p class="form-note">'.
sprintf(__('This is your login to sign up to %s'),$this->config['name']). sprintf(__('This is your login to sign up to %s'),$this->config['name']).
'</p>'. '</p>'.
'<p><label class="classic">'.__('API Key:').'<br />'. '<p><label class="classic">'.__('API Key:').'<br />'.
form::field(array('kutrl_srv_supr_apikey'),50,255,$this->settings->kutrl_srv_supr_apikey). form::field(array('kutrl_srv_supr_apikey'),50,255,$this->settings->kutrl_srv_supr_apikey).
'</label></p>'. '</label></p>'.
'<p class="form-note">'. '<p class="form-note">'.
sprintf(__('This is your personnal %s API key. You can find it on your account page.'),$this->config['name']). sprintf(__('This is your personnal %s API key. You can find it on your account page.'),$this->config['name']).
'</p>'; '</p>';
} }
public function testService() public function testService()
{ {
if (empty($this->args['login']) || empty($this->args['apiKey'])) if (empty($this->args['login']) || empty($this->args['apiKey']))
{ {
$this->error->add(__('Service is not well configured.')); $this->error->add(__('Service is not well configured.'));
return false; return false;
} }
$args = $this->args; $args = $this->args;
$arg['longUrl'] = $this->url_test; $arg['longUrl'] = $this->url_test;
if (!($response = self::post($this->url_api.'shorten',$args,true))) if (!($response = self::post($this->url_api.'shorten',$args,true)))
{ {
$this->error->add(__('Failed to call service.')); $this->error->add(__('Failed to call service.'));
return false; return false;
} }
$rsp = simplexml_load_string($response); $rsp = simplexml_load_string($response);
$status = (string) $rsp->statusCode; $status = (string) $rsp->statusCode;
if ($status != 'OK') { if ($status != 'OK') {
$err_no = (integer) $rsp->errorCode; $err_no = (integer) $rsp->errorCode;
$err_msg = (integer) $rsp->errorMessage; $err_msg = (integer) $rsp->errorMessage;
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg)); $this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
return false; return false;
} }
return true; return true;
} }
public function createHash($url,$hash=null) public function createHash($url,$hash=null)
{ {
$args = $this->args; $args = $this->args;
$args['longUrl'] = $url; $args['longUrl'] = $url;
if (!($response = self::post($this->url_api.'shorten',$args,true))) if (!($response = self::post($this->url_api.'shorten',$args,true)))
{ {
$this->error->add(__('Failed to call service.')); $this->error->add(__('Failed to call service.'));
return false; return false;
} }
$rsp = simplexml_load_string($response); $rsp = simplexml_load_string($response);
$status = (string) $rsp->statusCode; $status = (string) $rsp->statusCode;
if ($status != 'OK') { if ($status != 'OK') {
$err_no = (integer) $rsp->errorCode; $err_no = (integer) $rsp->errorCode;
$err_msg = (integer) $rsp->errorMessage; $err_msg = (integer) $rsp->errorMessage;
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg)); $this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
return false; return false;
} }
$rs = new ArrayObject(); $rs = new ArrayObject();
$rs->hash = (string) $rsp->results[0]->nodeKeyVal->hash; $rs->hash = (string) $rsp->results[0]->nodeKeyVal->hash;
$rs->url = (string) $rsp->results[0]->nodeKeyVal->nodeKey; $rs->url = (string) $rsp->results[0]->nodeKeyVal->nodeKey;
$rs->type = $this->id; $rs->type = $this->id;
return $rs; return $rs;
} }
} }
?>

View file

@ -1,127 +1,126 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){return;}
class trimKutrlService extends kutrlService class trimKutrlService extends kutrlService
{ {
protected $config = array( protected $config = array(
'id' => 'trim', 'id' => 'trim',
'name' => 'tr.im', 'name' => 'tr.im',
'home' => 'http://tr.im', 'home' => 'http://tr.im',
'url_api' => 'http://api.tr.im/v1/', 'url_api' => 'http://api.tr.im/v1/',
'url_base' => 'http://tr.im/', 'url_base' => 'http://tr.im/',
'url_min_len' => 25 'url_min_len' => 25
); );
private $args = array( private $args = array(
'username' => '', 'username' => '',
'password' => '' 'password' => ''
); );
private $api_rate_time = 0; private $api_rate_time = 0;
protected function init() protected function init()
{ {
$this->args['username'] = $this->settings->kutrl_srv_trim_username; $this->args['username'] = $this->settings->kutrl_srv_trim_username;
$this->args['password'] = $this->settings->kutrl_srv_trim_password; $this->args['password'] = $this->settings->kutrl_srv_trim_password;
$this->api_rate_time = (integer) $this->settings->kutrl_srv_trim_apiratetime; $this->api_rate_time = (integer) $this->settings->kutrl_srv_trim_apiratetime;
} }
public function saveSettings() public function saveSettings()
{ {
$this->settings->put('kutrl_srv_trim_username',$_POST['kutrl_srv_trim_username']); $this->settings->put('kutrl_srv_trim_username',$_POST['kutrl_srv_trim_username']);
$this->settings->put('kutrl_srv_trim_password',$_POST['kutrl_srv_trim_password']); $this->settings->put('kutrl_srv_trim_password',$_POST['kutrl_srv_trim_password']);
} }
public function settingsForm() public function settingsForm()
{ {
echo echo
'<p><label class="classic">'.__('Login:').'<br />'. '<p><label class="classic">'.__('Login:').'<br />'.
form::field(array('kutrl_srv_trim_username'),50,255,$this->settings->kutrl_srv_trim_username). form::field(array('kutrl_srv_trim_username'),50,255,$this->settings->kutrl_srv_trim_username).
'</label></p>'. '</label></p>'.
'<p class="form-note">'. '<p class="form-note">'.
__('This is your login to sign up to tr.im.'). __('This is your login to sign up to tr.im.').
'</p>'. '</p>'.
'<p><label class="classic">'.__('Password:').'<br />'. '<p><label class="classic">'.__('Password:').'<br />'.
form::field(array('kutrl_srv_trim_password'),50,255,$this->settings->kutrl_srv_trim_password). form::field(array('kutrl_srv_trim_password'),50,255,$this->settings->kutrl_srv_trim_password).
'</label></p>'. '</label></p>'.
'<p class="form-note">'. '<p class="form-note">'.
__('This is your password to sign up to tr.im.'). __('This is your password to sign up to tr.im.').
'</p>'; '</p>';
} }
public function testService() public function testService()
{ {
if (empty($this->args['username']) || empty($this->args['password'])) if (empty($this->args['username']) || empty($this->args['password']))
{ {
$this->error->add(__('Service is not well configured.')); $this->error->add(__('Service is not well configured.'));
return false; return false;
} }
if (time() < $this->api_rate_time + 300) // bloc service within 5min on API rate limit if (time() < $this->api_rate_time + 300) // bloc service within 5min on API rate limit
{ {
$this->error->add(__('Prevent service rate limit.')); $this->error->add(__('Prevent service rate limit.'));
return false; return false;
} }
if (!($rsp = self::post($this->url_api.'verify.xml',$this->args,true,true))) if (!($rsp = self::post($this->url_api.'verify.xml',$this->args,true,true)))
{ {
$this->error->add(__('Service is unavailable.')); $this->error->add(__('Service is unavailable.'));
return false; return false;
} }
$r = simplexml_load_string($rsp); $r = simplexml_load_string($rsp);
if ($r['code'] == 200) if ($r['code'] == 200)
{ {
return true; return true;
} }
$this->error->add(__('Authentication to service failed.')); $this->error->add(__('Authentication to service failed.'));
return false; return false;
} }
public function createHash($url,$hash=null) public function createHash($url,$hash=null)
{ {
$arg = $this->args; $arg = $this->args;
$arg['url'] = $url; $arg['url'] = $url;
if (!($rsp = self::post($this->url_api.'trim_url.xml',$arg,true,true))) if (!($rsp = self::post($this->url_api.'trim_url.xml',$arg,true,true)))
{ {
$this->error->add(__('Service is unavailable.')); $this->error->add(__('Service is unavailable.'));
return false; return false;
} }
$r = simplexml_load_string($rsp); $r = simplexml_load_string($rsp);
# API rate limit # API rate limit
if ($r['code'] == 425) if ($r['code'] == 425)
{ {
$this->settings->put('kutrl_srv_trim_apiratetime',time()); $this->settings->put('kutrl_srv_trim_apiratetime',time());
$this->error->add(__('Service rate limit exceeded.')); $this->error->add(__('Service rate limit exceeded.'));
return false; return false;
} }
if (isset($r->trimpath)) if (isset($r->trimpath))
{ {
$rs = new ArrayObject(); $rs = new ArrayObject();
$rs->hash = $r->trimpath; $rs->hash = $r->trimpath;
$rs->url = $url; $rs->url = $url;
$rs->type = $this->id; $rs->type = $this->id;
return $rs; return $rs;
} }
$this->error->add(__('Unreadable service response.')); $this->error->add(__('Unreadable service response.'));
return false; return false;
} }
} }
?>

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief kUtRL, a plugin for Dotclear 2
# This file is part of kUtRL, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return; return;

View file

@ -14,4 +14,3 @@
if (!defined('DC_RC_PATH')) { return; } if (!defined('DC_RC_PATH')) { return; }
$__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html'; $__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html';
?>

View file

@ -519,4 +519,3 @@ $GLOBALS['__l10n']['Service:'] = 'Service :';
#index.php:539 #index.php:539
$GLOBALS['__l10n']['Delete selected short links'] = 'Effacer les liens sélectionnés'; $GLOBALS['__l10n']['Delete selected short links'] = 'Effacer les liens sélectionnés';

View file

@ -14,4 +14,3 @@
if (!defined('DC_RC_PATH')) { return; } if (!defined('DC_RC_PATH')) { return; }
$__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html'; $__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html';
?>