update php headers to phpdoc style (and some fixes)
parent
c4972a4a8e
commit
a92e6ec8af
|
@ -2,7 +2,7 @@ xxx.xx.xx
|
|||
- [ ] Add public page of the list of know urls and in/visible status
|
||||
- [ ] Add passworded links
|
||||
- [ ] fix deprecated external service
|
||||
- [ ] update php header to phpdoc style
|
||||
- [x] update php header to phpdoc style
|
||||
- [x] fix post page options display
|
||||
|
||||
2021.08.28 - pre release
|
||||
|
|
32
_admin.php
32
_admin.php
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
|
@ -72,14 +72,14 @@ class adminKutrl
|
|||
{
|
||||
global $core;
|
||||
$s = $core->blog->settings->kUtRL;
|
||||
|
||||
|
||||
if (!$s->kutrl_active || !$s->kutrl_admin_service) {
|
||||
return null;
|
||||
}
|
||||
if (null === ($kut = kutrl::quickPlace('admin'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if ($post) {
|
||||
$post_url = $post->getURL();
|
||||
$rs = $kut->isKnowUrl($post_url);
|
||||
|
@ -136,7 +136,7 @@ class adminKutrl
|
|||
{
|
||||
global $core;
|
||||
$s = $core->blog->settings->kUtRL;
|
||||
|
||||
|
||||
# Create: see adminAfterPostCreate
|
||||
if (!empty($_POST['kutrl_create']) || !$s->kutrl_active) {
|
||||
return null;
|
||||
|
@ -160,7 +160,7 @@ class adminKutrl
|
|||
}
|
||||
$title = html::escapeHTML($rs->post_title);
|
||||
$new_post_url = $rs->getURL();
|
||||
|
||||
|
||||
# Delete
|
||||
if (!empty($_POST['kutrl_delete'])) {
|
||||
$kut->remove($old_post_url);
|
||||
|
@ -216,7 +216,7 @@ class adminKutrl
|
|||
{
|
||||
global $core;
|
||||
$s = $core->blog->settings->kUtRL;
|
||||
|
||||
|
||||
if (!$s->kutrl_active) {
|
||||
return null;
|
||||
}
|
||||
|
|
22
_define.php
22
_define.php
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
|
22
_install.php
22
_install.php
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return;
|
||||
|
|
22
_prepend.php
22
_prepend.php
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
|
|
30
_public.php
30
_public.php
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -109,7 +109,7 @@ class urlKutrl extends dcUrlHandlers
|
|||
{
|
||||
global $core, $_ctx;
|
||||
$s = $core->blog->settings->kUtRL;
|
||||
|
||||
|
||||
# Not active, go to default 404
|
||||
if (!$s->kutrl_active) {
|
||||
self::p404();
|
||||
|
@ -215,7 +215,7 @@ class urlKutrl extends dcUrlHandlers
|
|||
protected static function kutrl404()
|
||||
{
|
||||
global $core;
|
||||
|
||||
|
||||
if (!$core->blog->settings->kUtRL->kutrl_srv_local_404_active) {
|
||||
self::p404();
|
||||
return null;
|
||||
|
@ -348,7 +348,7 @@ class tplKutrl
|
|||
public static function pageIf($attr, $content)
|
||||
{
|
||||
$operator = isset($attr['operator']) ? self::getOperator($attr['operator']) : '&&';
|
||||
|
||||
|
||||
if (isset($attr['is_active'])) {
|
||||
$sign = (boolean) $attr['is_active'] ? '' : '!';
|
||||
$if[] = $sign . '$core->blog->settings->kUtRL->kutrl_srv_local_public';
|
||||
|
@ -511,7 +511,7 @@ class tplKutrl
|
|||
" if (!empty(\$kutrl_rs)) { " .
|
||||
" \$core->callBehavior('publicAfterKutrlCreate',\$core,\$kutrl_rs,__('New public short URL')); " .
|
||||
" } \n" .
|
||||
|
||||
|
||||
" } \n" .
|
||||
" unset(\$kutrl_rs); \n" .
|
||||
"} \n" .
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return;
|
||||
|
@ -43,7 +43,6 @@ $this->addUserAction(
|
|||
/* description */ __('delete the version number')
|
||||
);
|
||||
|
||||
|
||||
# Delete only dc version and plugin files from pluginsBeforeDelete
|
||||
# Keep table
|
||||
|
||||
|
|
30
_widgets.php
30
_widgets.php
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -116,7 +116,7 @@ class widgetKutrl
|
|||
{
|
||||
global $core;
|
||||
$s = $core->blog->settings->kUtRL;
|
||||
|
||||
|
||||
if (!$s->kutrl_active
|
||||
|| !$s->kutrl_srv_local_public
|
||||
|| ($w->homeonly == 1 && !$core->url->isHome($core->url->type)) || ($w->homeonly == 2 && $core->url->isHome($core->url->type))
|
||||
|
@ -177,7 +177,7 @@ class widgetKutrl
|
|||
$order .= $w->sort == 'desc' ? ' DESC' : ' ASC';
|
||||
|
||||
$limit = $core->con->limit(abs((integer) $w->limit));
|
||||
|
||||
|
||||
$rs = $core->con->select(
|
||||
'SELECT kut_counter, kut_hash ' .
|
||||
"FROM " . $core->prefix . "kutrl " .
|
||||
|
@ -195,7 +195,7 @@ class widgetKutrl
|
|||
while($rs->fetch()) {
|
||||
$i++;
|
||||
$rank = '<span class="rankkutrl-rank">' . $i . '</span>';
|
||||
|
||||
|
||||
$hash = $rs->kut_hash;
|
||||
$url = $core->blog->url . $core->url->getBase('kutrl') . '/' . $hash;
|
||||
$cut_len = - abs((integer) $w->urllen);
|
||||
|
@ -227,7 +227,7 @@ class widgetKutrl
|
|||
) .
|
||||
'</a></li>';
|
||||
}
|
||||
|
||||
|
||||
if (empty($content)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
<author>Jean-Christian Denis and contributors</author>
|
||||
<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>
|
||||
<da:dcmin>2.19</da:dcmin>
|
||||
<da:details>http://plugins.dotaddict.org/dc2/details/kUtRL</da:details>
|
||||
<da:section></da:section>
|
||||
<da:support>https://github.com/JcDenis/kUtRL</da:support>
|
||||
</module>
|
||||
</modules>
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -77,7 +77,7 @@ class kUtRL
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
# Silently try to reduce url (using 'plugin' place)
|
||||
# return long url on error else short url on success
|
||||
public static function quickReduce($url, $custom = null, $place = 'plugin')
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
# This file is used with plugin activityReport
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
# This file contents class to acces local short links records
|
||||
|
||||
|
@ -112,7 +112,7 @@ class kutrlLog
|
|||
$cur->kut_url = '';
|
||||
$cur->kut_dt = date('Y-m-d H:i:s');
|
||||
$cur->kut_counter = 0;
|
||||
|
||||
|
||||
$cur->update(
|
||||
"WHERE blog_id='" . $this->blog . "' " .
|
||||
"AND kut_id='" . $id . "' "
|
||||
|
@ -180,7 +180,7 @@ class kutrlLog
|
|||
$r = 'SELECT count(S.kut_id) ';
|
||||
} else {
|
||||
$content_req = '';
|
||||
|
||||
|
||||
if (!empty($p['columns']) && is_array($p['columns'])) {
|
||||
$content_req .= implode(', ', $p['columns']) . ', ';
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
class kutrlLinkslist
|
||||
{
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
# Generic class for shorten link service
|
||||
# A service class must extends this one
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
# This file contents class to shorten url pass through wiki
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
# This file takes records from plugin dcMiniUrl
|
||||
# and inserts them into plugin kUtRL.
|
||||
|
@ -19,118 +19,117 @@ if (!defined('DC_CONTEXT_ADMIN')){return;}
|
|||
$miniurl_patch = new dcMiniUrl2kUtRL($core);
|
||||
if ($miniurl_patch->parseRecords())
|
||||
{
|
||||
try
|
||||
{
|
||||
$core->plugins->deactivateModule('dcMiniUrl');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
//$core->error->add($e->getMessage());
|
||||
}
|
||||
try
|
||||
{
|
||||
$core->plugins->deactivateModule('dcMiniUrl');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
//$core->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class dcMiniUrl2kUtRL
|
||||
{
|
||||
public $core;
|
||||
|
||||
public $k_tb;
|
||||
public $m_tb;
|
||||
public $core;
|
||||
|
||||
public function __construct($core)
|
||||
{
|
||||
$this->core = $core;
|
||||
$this->con = $core->con;
|
||||
$this->k_tb = $core->prefix.'kutrl';
|
||||
$this->m_tb = $core->prefix.'miniurl';
|
||||
}
|
||||
|
||||
public function parseRecords()
|
||||
{
|
||||
$rs = $this->con->select(
|
||||
'SELECT * FROM '.$this->m_tb.' '
|
||||
);
|
||||
public $k_tb;
|
||||
public $m_tb;
|
||||
|
||||
while ($rs->fetch())
|
||||
{
|
||||
if ($rs->miniurl_type == 'customurl' || $rs->miniurl_type == 'miniurl')
|
||||
{
|
||||
if ($this->exists($rs)) continue;
|
||||
public function __construct($core)
|
||||
{
|
||||
$this->core = $core;
|
||||
$this->con = $core->con;
|
||||
$this->k_tb = $core->prefix.'kutrl';
|
||||
$this->m_tb = $core->prefix.'miniurl';
|
||||
}
|
||||
|
||||
$this->insertKutrl($rs);
|
||||
$this->insertLocal($rs);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->insertOther($rs);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function parseRecords()
|
||||
{
|
||||
$rs = $this->con->select(
|
||||
'SELECT * FROM '.$this->m_tb.' '
|
||||
);
|
||||
|
||||
private function insertKutrl($rs)
|
||||
{
|
||||
$cur = $this->common($rs);
|
||||
$cur->kut_service = 'kutrl';
|
||||
$cur->kut_type = 'local';
|
||||
$cur->kut_counter = 0;
|
||||
$cur->kut_password = null;
|
||||
while ($rs->fetch())
|
||||
{
|
||||
if ($rs->miniurl_type == 'customurl' || $rs->miniurl_type == 'miniurl')
|
||||
{
|
||||
if ($this->exists($rs)) continue;
|
||||
|
||||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
}
|
||||
$this->insertKutrl($rs);
|
||||
$this->insertLocal($rs);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->insertOther($rs);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function insertLocal($rs)
|
||||
{
|
||||
$cur = $this->common($rs);
|
||||
$cur->kut_service = 'local';
|
||||
$cur->kut_type = $rs->miniurl_type == 'customurl' ?
|
||||
'localcustom' : 'localnormal';
|
||||
private function insertKutrl($rs)
|
||||
{
|
||||
$cur = $this->common($rs);
|
||||
$cur->kut_service = 'kutrl';
|
||||
$cur->kut_type = 'local';
|
||||
$cur->kut_counter = 0;
|
||||
$cur->kut_password = null;
|
||||
|
||||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
}
|
||||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
}
|
||||
|
||||
private function insertOther($rs)
|
||||
{
|
||||
$cur = $this->common($rs);
|
||||
private function insertLocal($rs)
|
||||
{
|
||||
$cur = $this->common($rs);
|
||||
$cur->kut_service = 'local';
|
||||
$cur->kut_type = $rs->miniurl_type == 'customurl' ?
|
||||
'localcustom' : 'localnormal';
|
||||
|
||||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
}
|
||||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
}
|
||||
|
||||
private function common($rs)
|
||||
{
|
||||
$cur = $this->con->openCursor($this->k_tb);
|
||||
$this->con->writeLock($this->k_tb);
|
||||
$cur->kut_id = $this->nextId();
|
||||
$cur->blog_id = $rs->blog_id;
|
||||
$cur->kut_service = 'unknow';
|
||||
$cur->kut_type = $rs->miniurl_type;
|
||||
$cur->kut_hash = $rs->miniurl_id;
|
||||
$cur->kut_url = $rs->miniurl_str;
|
||||
$cur->kut_dt = $rs->miniurl_dt;
|
||||
$cur->kut_counter = $rs->miniurl_counter;
|
||||
$cur->kut_password = $rs->miniurl_password;
|
||||
|
||||
return $cur;
|
||||
}
|
||||
private function insertOther($rs)
|
||||
{
|
||||
$cur = $this->common($rs);
|
||||
|
||||
private function exists($rs)
|
||||
{
|
||||
$chk = $this->con->select(
|
||||
'SELECT kut_hash FROM '.$this->k_tb.' '.
|
||||
"WHERE blog_id = '".$rs->blog_id."' ".
|
||||
"AND kut_service = 'local' ".
|
||||
"AND kut_hash = '".$rs->miniurl_id."' "
|
||||
);
|
||||
return !$chk->isEmpty();
|
||||
}
|
||||
|
||||
private function nextId()
|
||||
{
|
||||
return $this->con->select(
|
||||
'SELECT MAX(kut_id) FROM '.$this->k_tb.' '
|
||||
)->f(0) + 1;
|
||||
}
|
||||
}
|
||||
?>
|
||||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
}
|
||||
|
||||
private function common($rs)
|
||||
{
|
||||
$cur = $this->con->openCursor($this->k_tb);
|
||||
$this->con->writeLock($this->k_tb);
|
||||
$cur->kut_id = $this->nextId();
|
||||
$cur->blog_id = $rs->blog_id;
|
||||
$cur->kut_service = 'unknow';
|
||||
$cur->kut_type = $rs->miniurl_type;
|
||||
$cur->kut_hash = $rs->miniurl_id;
|
||||
$cur->kut_url = $rs->miniurl_str;
|
||||
$cur->kut_dt = $rs->miniurl_dt;
|
||||
$cur->kut_counter = $rs->miniurl_counter;
|
||||
$cur->kut_password = $rs->miniurl_password;
|
||||
|
||||
return $cur;
|
||||
}
|
||||
|
||||
private function exists($rs)
|
||||
{
|
||||
$chk = $this->con->select(
|
||||
'SELECT kut_hash FROM '.$this->k_tb.' '.
|
||||
"WHERE blog_id = '".$rs->blog_id."' ".
|
||||
"AND kut_service = 'local' ".
|
||||
"AND kut_hash = '".$rs->miniurl_id."' "
|
||||
);
|
||||
return !$chk->isEmpty();
|
||||
}
|
||||
|
||||
private function nextId()
|
||||
{
|
||||
return $this->con->select(
|
||||
'SELECT MAX(kut_id) FROM '.$this->k_tb.' '
|
||||
)->f(0) + 1;
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -21,7 +21,7 @@ class bitlyKutrlService extends kutrlService
|
|||
'id' => 'bitly',
|
||||
'name' => 'bit.ly',
|
||||
'home' => 'http://bit.ly',
|
||||
|
||||
|
||||
'url_api' => 'http://api.bit.ly/v3/',
|
||||
'url_base' => 'http://bit.ly/',
|
||||
'url_min_len' => 25
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -21,7 +21,7 @@ class customKutrlService extends kutrlService
|
|||
'id' => 'custom',
|
||||
'name' => 'Custom'
|
||||
];
|
||||
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$config = unserialize(base64_decode($this->settings->kutrl_srv_custom));
|
||||
|
@ -29,12 +29,12 @@ class customKutrlService extends kutrlService
|
|||
{
|
||||
$config = [];
|
||||
}
|
||||
|
||||
|
||||
$this->config['url_api'] = !empty($config['url_api']) ? $config['url_api'] : '';
|
||||
$this->config['url_base'] = !empty($config['url_base']) ? $config['url_base'] : '';
|
||||
$this->config['url_param'] = !empty($config['url_param']) ? $config['url_param'] : '';
|
||||
$this->config['url_encode'] = !empty($config['url_api']);
|
||||
|
||||
|
||||
$this->config['url_min_length'] = strlen($this->url_base) + 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -37,7 +37,7 @@ class defaultKutrlService extends kutrlService
|
|||
'url_encode' => SHORTEN_SERVICE_ENCODE
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function settingsForm()
|
||||
{
|
||||
echo
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -27,7 +27,7 @@ class googlKutrlService extends kutrlService
|
|||
'key' => ''
|
||||
];
|
||||
private $headers = array('Content-Type: application/json');
|
||||
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->url_base = 'http://goo.gl/';
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
|
@ -19,12 +19,12 @@ class isgdKutrlService extends kutrlService
|
|||
'id' => 'isgd',
|
||||
'name' => 'is.gd',
|
||||
'home' => 'http://is.gd/',
|
||||
|
||||
|
||||
'url_api' => 'http://is.gd/api.php',
|
||||
'url_base' => 'http://is.gd/',
|
||||
'url_min_length' => 25
|
||||
];
|
||||
|
||||
|
||||
public function testService()
|
||||
{
|
||||
$arg = ['longurl' => urlencode($this->url_test)];
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -21,10 +21,10 @@ class localKutrlService extends kutrlService
|
|||
'id' => 'local',
|
||||
'name' => 'kUtRL',
|
||||
'home' => 'http://kutrl.fr',
|
||||
|
||||
|
||||
'allow_custom_hash' => true
|
||||
];
|
||||
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$protocols = (string) $this->settings->kutrl_srv_local_protocols;
|
||||
|
@ -32,9 +32,9 @@ class localKutrlService extends kutrlService
|
|||
|
||||
$this->config['url_base'] = $this->core->blog->url . $this->core->url->getBase('kutrl') . '/';
|
||||
$this->config['url_min_len'] = strlen($this->url_base) + 2;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function saveSettings()
|
||||
{
|
||||
$this->settings->put('kutrl_srv_local_protocols', $_POST['kutrl_srv_local_protocols'], 'string');
|
||||
|
@ -47,7 +47,7 @@ class localKutrlService extends kutrlService
|
|||
{
|
||||
echo
|
||||
'<div class="two-cols"><div class="col">' .
|
||||
|
||||
|
||||
'<p><strong>' . __('Settings:') . '</strong></p>' .
|
||||
'<p><label class="classic">' .
|
||||
__('Allowed protocols:') . '<br />' .
|
||||
|
@ -75,7 +75,7 @@ class localKutrlService extends kutrlService
|
|||
'<p class="form-note">' . __('If this is not activated, the default 404 page of the theme will be display.') . '</p>' .
|
||||
|
||||
'</div><div class="col">' .
|
||||
|
||||
|
||||
'<p><strong>' . __('Note:') . '</strong></p>' .
|
||||
'<p>' .
|
||||
__('This service use your own Blog to shorten and serve URL.') . '<br />' .
|
||||
|
@ -96,7 +96,7 @@ class localKutrlService extends kutrlService
|
|||
'</p>' .
|
||||
'<p>' . __('There are two templates delivered with kUtRL, if you do not use default theme, you may adapt them to yours.') . '<br />' .
|
||||
__('Files are in plugin directory /default-templates, just copy them into your theme and edit them.') . '</p>' .
|
||||
|
||||
|
||||
'</div></div><br class="clear"/>';
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ class localKutrlService extends kutrlService
|
|||
false === $this->log->select(null,$prefix . $next_id, null, 'local') ?
|
||||
$next_id : $this->next($next_id, $prefix);
|
||||
}
|
||||
|
||||
|
||||
protected function append($id)
|
||||
{
|
||||
$id = str_split($id);
|
||||
|
@ -210,7 +210,7 @@ class localKutrlService extends kutrlService
|
|||
}
|
||||
return implode($id);
|
||||
}
|
||||
|
||||
|
||||
public function getUrl($hash)
|
||||
{
|
||||
if (false === ($rs = $this->log->select(null, $hash, null, 'local'))) {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
|
|
@ -1,121 +1,120 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
class suprKutrlService extends kutrlService
|
||||
{
|
||||
protected $config = array(
|
||||
'id' => 'supr',
|
||||
'name' => 'su.pr StumbleUpon',
|
||||
'home' => 'http://su.pr',
|
||||
|
||||
'url_api' => 'http://su.pr/api/',
|
||||
'url_base' => 'http://su.pr/',
|
||||
'url_min_len' => 23
|
||||
);
|
||||
|
||||
private $args = array(
|
||||
'version' => '1.0',
|
||||
'format' => 'xml',
|
||||
'login' => '',
|
||||
'apiKey' => ''
|
||||
);
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->args['login'] = $this->settings->kutrl_srv_supr_login;
|
||||
$this->args['apiKey'] = $this->settings->kutrl_srv_supr_apikey;
|
||||
}
|
||||
|
||||
public function saveSettings()
|
||||
{
|
||||
$this->settings->put('kutrl_srv_supr_login',$_POST['kutrl_srv_supr_login']);
|
||||
$this->settings->put('kutrl_srv_supr_apikey',$_POST['kutrl_srv_supr_apikey']);
|
||||
}
|
||||
|
||||
public function settingsForm()
|
||||
{
|
||||
echo
|
||||
'<p><label class="classic">'.__('Login:').'<br />'.
|
||||
form::field(array('kutrl_srv_supr_login'),50,255,$this->settings->kutrl_srv_supr_login).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
sprintf(__('This is your login to sign up to %s'),$this->config['name']).
|
||||
'</p>'.
|
||||
'<p><label class="classic">'.__('API Key:').'<br />'.
|
||||
form::field(array('kutrl_srv_supr_apikey'),50,255,$this->settings->kutrl_srv_supr_apikey).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
sprintf(__('This is your personnal %s API key. You can find it on your account page.'),$this->config['name']).
|
||||
'</p>';
|
||||
}
|
||||
|
||||
public function testService()
|
||||
{
|
||||
if (empty($this->args['login']) || empty($this->args['apiKey']))
|
||||
{
|
||||
$this->error->add(__('Service is not well configured.'));
|
||||
return false;
|
||||
}
|
||||
protected $config = array(
|
||||
'id' => 'supr',
|
||||
'name' => 'su.pr StumbleUpon',
|
||||
'home' => 'http://su.pr',
|
||||
|
||||
$args = $this->args;
|
||||
$arg['longUrl'] = $this->url_test;
|
||||
if (!($response = self::post($this->url_api.'shorten',$args,true)))
|
||||
{
|
||||
$this->error->add(__('Failed to call service.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$rsp = simplexml_load_string($response);
|
||||
|
||||
$status = (string) $rsp->statusCode;
|
||||
if ($status != 'OK') {
|
||||
$err_no = (integer) $rsp->errorCode;
|
||||
$err_msg = (integer) $rsp->errorMessage;
|
||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createHash($url,$hash=null)
|
||||
{
|
||||
$args = $this->args;
|
||||
$args['longUrl'] = $url;
|
||||
|
||||
if (!($response = self::post($this->url_api.'shorten',$args,true)))
|
||||
{
|
||||
$this->error->add(__('Failed to call service.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$rsp = simplexml_load_string($response);
|
||||
|
||||
$status = (string) $rsp->statusCode;
|
||||
if ($status != 'OK') {
|
||||
$err_no = (integer) $rsp->errorCode;
|
||||
$err_msg = (integer) $rsp->errorMessage;
|
||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
||||
return false;
|
||||
}
|
||||
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = (string) $rsp->results[0]->nodeKeyVal->hash;
|
||||
$rs->url = (string) $rsp->results[0]->nodeKeyVal->nodeKey;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
?>
|
||||
'url_api' => 'http://su.pr/api/',
|
||||
'url_base' => 'http://su.pr/',
|
||||
'url_min_len' => 23
|
||||
);
|
||||
|
||||
private $args = array(
|
||||
'version' => '1.0',
|
||||
'format' => 'xml',
|
||||
'login' => '',
|
||||
'apiKey' => ''
|
||||
);
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->args['login'] = $this->settings->kutrl_srv_supr_login;
|
||||
$this->args['apiKey'] = $this->settings->kutrl_srv_supr_apikey;
|
||||
}
|
||||
|
||||
public function saveSettings()
|
||||
{
|
||||
$this->settings->put('kutrl_srv_supr_login',$_POST['kutrl_srv_supr_login']);
|
||||
$this->settings->put('kutrl_srv_supr_apikey',$_POST['kutrl_srv_supr_apikey']);
|
||||
}
|
||||
|
||||
public function settingsForm()
|
||||
{
|
||||
echo
|
||||
'<p><label class="classic">'.__('Login:').'<br />'.
|
||||
form::field(array('kutrl_srv_supr_login'),50,255,$this->settings->kutrl_srv_supr_login).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
sprintf(__('This is your login to sign up to %s'),$this->config['name']).
|
||||
'</p>'.
|
||||
'<p><label class="classic">'.__('API Key:').'<br />'.
|
||||
form::field(array('kutrl_srv_supr_apikey'),50,255,$this->settings->kutrl_srv_supr_apikey).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
sprintf(__('This is your personnal %s API key. You can find it on your account page.'),$this->config['name']).
|
||||
'</p>';
|
||||
}
|
||||
|
||||
public function testService()
|
||||
{
|
||||
if (empty($this->args['login']) || empty($this->args['apiKey']))
|
||||
{
|
||||
$this->error->add(__('Service is not well configured.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$args = $this->args;
|
||||
$arg['longUrl'] = $this->url_test;
|
||||
if (!($response = self::post($this->url_api.'shorten',$args,true)))
|
||||
{
|
||||
$this->error->add(__('Failed to call service.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$rsp = simplexml_load_string($response);
|
||||
|
||||
$status = (string) $rsp->statusCode;
|
||||
if ($status != 'OK') {
|
||||
$err_no = (integer) $rsp->errorCode;
|
||||
$err_msg = (integer) $rsp->errorMessage;
|
||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createHash($url,$hash=null)
|
||||
{
|
||||
$args = $this->args;
|
||||
$args['longUrl'] = $url;
|
||||
|
||||
if (!($response = self::post($this->url_api.'shorten',$args,true)))
|
||||
{
|
||||
$this->error->add(__('Failed to call service.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$rsp = simplexml_load_string($response);
|
||||
|
||||
$status = (string) $rsp->statusCode;
|
||||
if ($status != 'OK') {
|
||||
$err_no = (integer) $rsp->errorCode;
|
||||
$err_msg = (integer) $rsp->errorMessage;
|
||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
||||
return false;
|
||||
}
|
||||
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = (string) $rsp->results[0]->nodeKeyVal->hash;
|
||||
$rs->url = (string) $rsp->results[0]->nodeKeyVal->nodeKey;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
}
|
|
@ -1,127 +1,126 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')){return;}
|
||||
|
||||
class trimKutrlService extends kutrlService
|
||||
{
|
||||
protected $config = array(
|
||||
'id' => 'trim',
|
||||
'name' => 'tr.im',
|
||||
'home' => 'http://tr.im',
|
||||
|
||||
'url_api' => 'http://api.tr.im/v1/',
|
||||
'url_base' => 'http://tr.im/',
|
||||
'url_min_len' => 25
|
||||
);
|
||||
|
||||
private $args = array(
|
||||
'username' => '',
|
||||
'password' => ''
|
||||
);
|
||||
|
||||
private $api_rate_time = 0;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->args['username'] = $this->settings->kutrl_srv_trim_username;
|
||||
$this->args['password'] = $this->settings->kutrl_srv_trim_password;
|
||||
|
||||
$this->api_rate_time = (integer) $this->settings->kutrl_srv_trim_apiratetime;
|
||||
}
|
||||
|
||||
public function saveSettings()
|
||||
{
|
||||
$this->settings->put('kutrl_srv_trim_username',$_POST['kutrl_srv_trim_username']);
|
||||
$this->settings->put('kutrl_srv_trim_password',$_POST['kutrl_srv_trim_password']);
|
||||
}
|
||||
|
||||
public function settingsForm()
|
||||
{
|
||||
echo
|
||||
'<p><label class="classic">'.__('Login:').'<br />'.
|
||||
form::field(array('kutrl_srv_trim_username'),50,255,$this->settings->kutrl_srv_trim_username).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
__('This is your login to sign up to tr.im.').
|
||||
'</p>'.
|
||||
'<p><label class="classic">'.__('Password:').'<br />'.
|
||||
form::field(array('kutrl_srv_trim_password'),50,255,$this->settings->kutrl_srv_trim_password).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
__('This is your password to sign up to tr.im.').
|
||||
'</p>';
|
||||
}
|
||||
|
||||
public function testService()
|
||||
{
|
||||
if (empty($this->args['username']) || empty($this->args['password']))
|
||||
{
|
||||
$this->error->add(__('Service is not well configured.'));
|
||||
return false;
|
||||
}
|
||||
if (time() < $this->api_rate_time + 300) // bloc service within 5min on API rate limit
|
||||
{
|
||||
$this->error->add(__('Prevent service rate limit.'));
|
||||
return false;
|
||||
}
|
||||
if (!($rsp = self::post($this->url_api.'verify.xml',$this->args,true,true)))
|
||||
{
|
||||
$this->error->add(__('Service is unavailable.'));
|
||||
return false;
|
||||
}
|
||||
$r = simplexml_load_string($rsp);
|
||||
|
||||
if ($r['code'] == 200)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$this->error->add(__('Authentication to service failed.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createHash($url,$hash=null)
|
||||
{
|
||||
$arg = $this->args;
|
||||
$arg['url'] = $url;
|
||||
|
||||
if (!($rsp = self::post($this->url_api.'trim_url.xml',$arg,true,true)))
|
||||
{
|
||||
$this->error->add(__('Service is unavailable.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$r = simplexml_load_string($rsp);
|
||||
|
||||
# API rate limit
|
||||
if ($r['code'] == 425)
|
||||
{
|
||||
$this->settings->put('kutrl_srv_trim_apiratetime',time());
|
||||
protected $config = array(
|
||||
'id' => 'trim',
|
||||
'name' => 'tr.im',
|
||||
'home' => 'http://tr.im',
|
||||
|
||||
$this->error->add(__('Service rate limit exceeded.'));
|
||||
return false;
|
||||
}
|
||||
if (isset($r->trimpath))
|
||||
{
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = $r->trimpath;
|
||||
$rs->url = $url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
$this->error->add(__('Unreadable service response.'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
'url_api' => 'http://api.tr.im/v1/',
|
||||
'url_base' => 'http://tr.im/',
|
||||
'url_min_len' => 25
|
||||
);
|
||||
|
||||
private $args = array(
|
||||
'username' => '',
|
||||
'password' => ''
|
||||
);
|
||||
|
||||
private $api_rate_time = 0;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->args['username'] = $this->settings->kutrl_srv_trim_username;
|
||||
$this->args['password'] = $this->settings->kutrl_srv_trim_password;
|
||||
|
||||
$this->api_rate_time = (integer) $this->settings->kutrl_srv_trim_apiratetime;
|
||||
}
|
||||
|
||||
public function saveSettings()
|
||||
{
|
||||
$this->settings->put('kutrl_srv_trim_username',$_POST['kutrl_srv_trim_username']);
|
||||
$this->settings->put('kutrl_srv_trim_password',$_POST['kutrl_srv_trim_password']);
|
||||
}
|
||||
|
||||
public function settingsForm()
|
||||
{
|
||||
echo
|
||||
'<p><label class="classic">'.__('Login:').'<br />'.
|
||||
form::field(array('kutrl_srv_trim_username'),50,255,$this->settings->kutrl_srv_trim_username).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
__('This is your login to sign up to tr.im.').
|
||||
'</p>'.
|
||||
'<p><label class="classic">'.__('Password:').'<br />'.
|
||||
form::field(array('kutrl_srv_trim_password'),50,255,$this->settings->kutrl_srv_trim_password).
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
__('This is your password to sign up to tr.im.').
|
||||
'</p>';
|
||||
}
|
||||
|
||||
public function testService()
|
||||
{
|
||||
if (empty($this->args['username']) || empty($this->args['password']))
|
||||
{
|
||||
$this->error->add(__('Service is not well configured.'));
|
||||
return false;
|
||||
}
|
||||
if (time() < $this->api_rate_time + 300) // bloc service within 5min on API rate limit
|
||||
{
|
||||
$this->error->add(__('Prevent service rate limit.'));
|
||||
return false;
|
||||
}
|
||||
if (!($rsp = self::post($this->url_api.'verify.xml',$this->args,true,true)))
|
||||
{
|
||||
$this->error->add(__('Service is unavailable.'));
|
||||
return false;
|
||||
}
|
||||
$r = simplexml_load_string($rsp);
|
||||
|
||||
if ($r['code'] == 200)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$this->error->add(__('Authentication to service failed.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createHash($url,$hash=null)
|
||||
{
|
||||
$arg = $this->args;
|
||||
$arg['url'] = $url;
|
||||
|
||||
if (!($rsp = self::post($this->url_api.'trim_url.xml',$arg,true,true)))
|
||||
{
|
||||
$this->error->add(__('Service is unavailable.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$r = simplexml_load_string($rsp);
|
||||
|
||||
# API rate limit
|
||||
if ($r['code'] == 425)
|
||||
{
|
||||
$this->settings->put('kutrl_srv_trim_apiratetime',time());
|
||||
|
||||
$this->error->add(__('Service rate limit exceeded.'));
|
||||
return false;
|
||||
}
|
||||
if (isset($r->trimpath))
|
||||
{
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = $r->trimpath;
|
||||
$rs->url = $url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
$this->error->add(__('Unreadable service response.'));
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
@ -34,10 +34,10 @@ class yourlsKutrlService extends kutrlService
|
|||
{
|
||||
$this->args['username'] = $this->settings->kutrl_srv_yourls_username;
|
||||
$this->args['password'] = $this->settings->kutrl_srv_yourls_password;
|
||||
|
||||
|
||||
$base = (string) $this->settings->kutrl_srv_yourls_base;
|
||||
//if (!empty($base) && substr($base,-1,1) != '/') $base .= '/';
|
||||
|
||||
|
||||
$this->config['url_api'] = $base;
|
||||
$this->config['url_base'] = $base;
|
||||
$this->config['url_min_len'] = strlen($base)+3;
|
||||
|
@ -80,16 +80,16 @@ class yourlsKutrlService extends kutrlService
|
|||
$this->error->add(__('Service is not well configured.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$args = $this->args;
|
||||
$args['url'] = $this->url_test;
|
||||
|
||||
|
||||
if (!($response = self::post($this->url_api, $this->args, true))) {
|
||||
$this->error->add(__('Service is unavailable.'));
|
||||
return false;
|
||||
}
|
||||
$rsp = @simplexml_load_string($response);
|
||||
|
||||
|
||||
if ($rsp && $rsp->status == 'success') {
|
||||
return true;
|
||||
}
|
||||
|
|
30
index.php
30
index.php
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of kUtRL, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return;
|
||||
|
@ -121,7 +121,7 @@ if ($part == 'link') {
|
|||
}
|
||||
$url = trim($core->con->escape($_POST['str']));
|
||||
$hash = empty($_POST['custom']) ? null : $_POST['custom'];
|
||||
|
||||
|
||||
if (empty($url)) {
|
||||
throw new Exception(__('There is nothing to shorten.'));
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ if ($part == 'links') {
|
|||
}
|
||||
$o->remove($rs->kut_url);
|
||||
}
|
||||
|
||||
|
||||
$core->blog->triggerBlog();
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
|
@ -408,7 +408,7 @@ if ($part == 'service') {
|
|||
|
||||
foreach(kutrl::getServices($core) as $service_id => $service) {
|
||||
$o = new $service($core);
|
||||
|
||||
|
||||
echo '<div class="fieldset" id="setting-' . $service_id . '"><h4>' . $o->name . '</h4>';
|
||||
|
||||
if (!empty($_POST['save'])) {
|
||||
|
@ -458,7 +458,7 @@ if ($part == 'link') {
|
|||
<div class="fieldset">
|
||||
<h4>' . sprintf(__('Shorten link using service "%s"'), $kut->name) . '</h4>
|
||||
<form id="create-link" method="post" action="' . $p_url . '">
|
||||
|
||||
|
||||
<p><label for="str">' . __('Long link:') . '</label>' .
|
||||
form::field('str', 100, 255, '') . '</p>';
|
||||
|
||||
|
|
|
@ -13,5 +13,4 @@
|
|||
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html';
|
||||
?>
|
||||
$__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html';
|
|
@ -518,5 +518,4 @@ $GLOBALS['__l10n']['You can use "bob!!" if you want a semi-custom link, it start
|
|||
$GLOBALS['__l10n']['Service:'] = 'Service :';
|
||||
|
||||
#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';
|
|
@ -13,5 +13,4 @@
|
|||
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html';
|
||||
?>
|
||||
$__resources['help']['kUtRL'] = dirname(__FILE__).'/help/help.html';
|
Loading…
Reference in New Issue