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 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
|
||||||
|
|
32
_admin.php
32
_admin.php
|
@ -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;
|
||||||
|
@ -72,14 +72,14 @@ class adminKutrl
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
$s = $core->blog->settings->kUtRL;
|
$s = $core->blog->settings->kUtRL;
|
||||||
|
|
||||||
if (!$s->kutrl_active || !$s->kutrl_admin_service) {
|
if (!$s->kutrl_active || !$s->kutrl_admin_service) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (null === ($kut = kutrl::quickPlace('admin'))) {
|
if (null === ($kut = kutrl::quickPlace('admin'))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($post) {
|
if ($post) {
|
||||||
$post_url = $post->getURL();
|
$post_url = $post->getURL();
|
||||||
$rs = $kut->isKnowUrl($post_url);
|
$rs = $kut->isKnowUrl($post_url);
|
||||||
|
@ -136,7 +136,7 @@ class adminKutrl
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
$s = $core->blog->settings->kUtRL;
|
$s = $core->blog->settings->kUtRL;
|
||||||
|
|
||||||
# Create: see adminAfterPostCreate
|
# Create: see adminAfterPostCreate
|
||||||
if (!empty($_POST['kutrl_create']) || !$s->kutrl_active) {
|
if (!empty($_POST['kutrl_create']) || !$s->kutrl_active) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -160,7 +160,7 @@ class adminKutrl
|
||||||
}
|
}
|
||||||
$title = html::escapeHTML($rs->post_title);
|
$title = html::escapeHTML($rs->post_title);
|
||||||
$new_post_url = $rs->getURL();
|
$new_post_url = $rs->getURL();
|
||||||
|
|
||||||
# Delete
|
# Delete
|
||||||
if (!empty($_POST['kutrl_delete'])) {
|
if (!empty($_POST['kutrl_delete'])) {
|
||||||
$kut->remove($old_post_url);
|
$kut->remove($old_post_url);
|
||||||
|
@ -216,7 +216,7 @@ class adminKutrl
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
$s = $core->blog->settings->kUtRL;
|
$s = $core->blog->settings->kUtRL;
|
||||||
|
|
||||||
if (!$s->kutrl_active) {
|
if (!$s->kutrl_active) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
22
_define.php
22
_define.php
|
@ -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;
|
||||||
|
|
22
_install.php
22
_install.php
|
@ -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;
|
||||||
|
|
22
_prepend.php
22
_prepend.php
|
@ -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;
|
||||||
|
|
30
_public.php
30
_public.php
|
@ -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;
|
||||||
|
@ -109,7 +109,7 @@ class urlKutrl extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
global $core, $_ctx;
|
global $core, $_ctx;
|
||||||
$s = $core->blog->settings->kUtRL;
|
$s = $core->blog->settings->kUtRL;
|
||||||
|
|
||||||
# Not active, go to default 404
|
# Not active, go to default 404
|
||||||
if (!$s->kutrl_active) {
|
if (!$s->kutrl_active) {
|
||||||
self::p404();
|
self::p404();
|
||||||
|
@ -215,7 +215,7 @@ class urlKutrl extends dcUrlHandlers
|
||||||
protected static function kutrl404()
|
protected static function kutrl404()
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
if (!$core->blog->settings->kUtRL->kutrl_srv_local_404_active) {
|
if (!$core->blog->settings->kUtRL->kutrl_srv_local_404_active) {
|
||||||
self::p404();
|
self::p404();
|
||||||
return null;
|
return null;
|
||||||
|
@ -348,7 +348,7 @@ class tplKutrl
|
||||||
public static function pageIf($attr, $content)
|
public static function pageIf($attr, $content)
|
||||||
{
|
{
|
||||||
$operator = isset($attr['operator']) ? self::getOperator($attr['operator']) : '&&';
|
$operator = isset($attr['operator']) ? self::getOperator($attr['operator']) : '&&';
|
||||||
|
|
||||||
if (isset($attr['is_active'])) {
|
if (isset($attr['is_active'])) {
|
||||||
$sign = (boolean) $attr['is_active'] ? '' : '!';
|
$sign = (boolean) $attr['is_active'] ? '' : '!';
|
||||||
$if[] = $sign . '$core->blog->settings->kUtRL->kutrl_srv_local_public';
|
$if[] = $sign . '$core->blog->settings->kUtRL->kutrl_srv_local_public';
|
||||||
|
@ -511,7 +511,7 @@ class tplKutrl
|
||||||
" if (!empty(\$kutrl_rs)) { " .
|
" if (!empty(\$kutrl_rs)) { " .
|
||||||
" \$core->callBehavior('publicAfterKutrlCreate',\$core,\$kutrl_rs,__('New public short URL')); " .
|
" \$core->callBehavior('publicAfterKutrlCreate',\$core,\$kutrl_rs,__('New public short URL')); " .
|
||||||
" } \n" .
|
" } \n" .
|
||||||
|
|
||||||
" } \n" .
|
" } \n" .
|
||||||
" unset(\$kutrl_rs); \n" .
|
" unset(\$kutrl_rs); \n" .
|
||||||
"} \n" .
|
"} \n" .
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
30
_widgets.php
30
_widgets.php
|
@ -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;
|
||||||
|
@ -116,7 +116,7 @@ class widgetKutrl
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
$s = $core->blog->settings->kUtRL;
|
$s = $core->blog->settings->kUtRL;
|
||||||
|
|
||||||
if (!$s->kutrl_active
|
if (!$s->kutrl_active
|
||||||
|| !$s->kutrl_srv_local_public
|
|| !$s->kutrl_srv_local_public
|
||||||
|| ($w->homeonly == 1 && !$core->url->isHome($core->url->type)) || ($w->homeonly == 2 && $core->url->isHome($core->url->type))
|
|| ($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';
|
$order .= $w->sort == 'desc' ? ' DESC' : ' ASC';
|
||||||
|
|
||||||
$limit = $core->con->limit(abs((integer) $w->limit));
|
$limit = $core->con->limit(abs((integer) $w->limit));
|
||||||
|
|
||||||
$rs = $core->con->select(
|
$rs = $core->con->select(
|
||||||
'SELECT kut_counter, kut_hash ' .
|
'SELECT kut_counter, kut_hash ' .
|
||||||
"FROM " . $core->prefix . "kutrl " .
|
"FROM " . $core->prefix . "kutrl " .
|
||||||
|
@ -195,7 +195,7 @@ class widgetKutrl
|
||||||
while($rs->fetch()) {
|
while($rs->fetch()) {
|
||||||
$i++;
|
$i++;
|
||||||
$rank = '<span class="rankkutrl-rank">' . $i . '</span>';
|
$rank = '<span class="rankkutrl-rank">' . $i . '</span>';
|
||||||
|
|
||||||
$hash = $rs->kut_hash;
|
$hash = $rs->kut_hash;
|
||||||
$url = $core->blog->url . $core->url->getBase('kutrl') . '/' . $hash;
|
$url = $core->blog->url . $core->url->getBase('kutrl') . '/' . $hash;
|
||||||
$cut_len = - abs((integer) $w->urllen);
|
$cut_len = - abs((integer) $w->urllen);
|
||||||
|
@ -227,7 +227,7 @@ class widgetKutrl
|
||||||
) .
|
) .
|
||||||
'</a></li>';
|
'</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
|
@ -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;
|
||||||
|
@ -77,7 +77,7 @@ class kUtRL
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Silently try to reduce url (using 'plugin' place)
|
# Silently try to reduce url (using 'plugin' place)
|
||||||
# return long url on error else short url on success
|
# return long url on error else short url on success
|
||||||
public static function quickReduce($url, $custom = null, $place = 'plugin')
|
public static function quickReduce($url, $custom = null, $place = 'plugin')
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class kutrlLog
|
||||||
$cur->kut_url = '';
|
$cur->kut_url = '';
|
||||||
$cur->kut_dt = date('Y-m-d H:i:s');
|
$cur->kut_dt = date('Y-m-d H:i:s');
|
||||||
$cur->kut_counter = 0;
|
$cur->kut_counter = 0;
|
||||||
|
|
||||||
$cur->update(
|
$cur->update(
|
||||||
"WHERE blog_id='" . $this->blog . "' " .
|
"WHERE blog_id='" . $this->blog . "' " .
|
||||||
"AND kut_id='" . $id . "' "
|
"AND kut_id='" . $id . "' "
|
||||||
|
@ -180,7 +180,7 @@ class kutrlLog
|
||||||
$r = 'SELECT count(S.kut_id) ';
|
$r = 'SELECT count(S.kut_id) ';
|
||||||
} else {
|
} else {
|
||||||
$content_req = '';
|
$content_req = '';
|
||||||
|
|
||||||
if (!empty($p['columns']) && is_array($p['columns'])) {
|
if (!empty($p['columns']) && is_array($p['columns'])) {
|
||||||
$content_req .= implode(', ', $p['columns']) . ', ';
|
$content_req .= implode(', ', $p['columns']) . ', ';
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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 $m_tb;
|
|
||||||
|
|
||||||
public function __construct($core)
|
public $k_tb;
|
||||||
{
|
public $m_tb;
|
||||||
$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.' '
|
|
||||||
);
|
|
||||||
|
|
||||||
while ($rs->fetch())
|
public function __construct($core)
|
||||||
{
|
{
|
||||||
if ($rs->miniurl_type == 'customurl' || $rs->miniurl_type == 'miniurl')
|
$this->core = $core;
|
||||||
{
|
$this->con = $core->con;
|
||||||
if ($this->exists($rs)) continue;
|
$this->k_tb = $core->prefix.'kutrl';
|
||||||
|
$this->m_tb = $core->prefix.'miniurl';
|
||||||
|
}
|
||||||
|
|
||||||
$this->insertKutrl($rs);
|
public function parseRecords()
|
||||||
$this->insertLocal($rs);
|
{
|
||||||
}
|
$rs = $this->con->select(
|
||||||
else
|
'SELECT * FROM '.$this->m_tb.' '
|
||||||
{
|
);
|
||||||
$this->insertOther($rs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function insertKutrl($rs)
|
while ($rs->fetch())
|
||||||
{
|
{
|
||||||
$cur = $this->common($rs);
|
if ($rs->miniurl_type == 'customurl' || $rs->miniurl_type == 'miniurl')
|
||||||
$cur->kut_service = 'kutrl';
|
{
|
||||||
$cur->kut_type = 'local';
|
if ($this->exists($rs)) continue;
|
||||||
$cur->kut_counter = 0;
|
|
||||||
$cur->kut_password = null;
|
|
||||||
|
|
||||||
$cur->insert();
|
$this->insertKutrl($rs);
|
||||||
$this->con->unlock();
|
$this->insertLocal($rs);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->insertOther($rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private function insertLocal($rs)
|
private function insertKutrl($rs)
|
||||||
{
|
{
|
||||||
$cur = $this->common($rs);
|
$cur = $this->common($rs);
|
||||||
$cur->kut_service = 'local';
|
$cur->kut_service = 'kutrl';
|
||||||
$cur->kut_type = $rs->miniurl_type == 'customurl' ?
|
$cur->kut_type = 'local';
|
||||||
'localcustom' : 'localnormal';
|
$cur->kut_counter = 0;
|
||||||
|
$cur->kut_password = null;
|
||||||
|
|
||||||
$cur->insert();
|
$cur->insert();
|
||||||
$this->con->unlock();
|
$this->con->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function insertOther($rs)
|
private function insertLocal($rs)
|
||||||
{
|
{
|
||||||
$cur = $this->common($rs);
|
$cur = $this->common($rs);
|
||||||
|
$cur->kut_service = 'local';
|
||||||
|
$cur->kut_type = $rs->miniurl_type == 'customurl' ?
|
||||||
|
'localcustom' : 'localnormal';
|
||||||
|
|
||||||
$cur->insert();
|
$cur->insert();
|
||||||
$this->con->unlock();
|
$this->con->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function common($rs)
|
private function insertOther($rs)
|
||||||
{
|
{
|
||||||
$cur = $this->con->openCursor($this->k_tb);
|
$cur = $this->common($rs);
|
||||||
$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)
|
$cur->insert();
|
||||||
{
|
$this->con->unlock();
|
||||||
$chk = $this->con->select(
|
}
|
||||||
'SELECT kut_hash FROM '.$this->k_tb.' '.
|
|
||||||
"WHERE blog_id = '".$rs->blog_id."' ".
|
private function common($rs)
|
||||||
"AND kut_service = 'local' ".
|
{
|
||||||
"AND kut_hash = '".$rs->miniurl_id."' "
|
$cur = $this->con->openCursor($this->k_tb);
|
||||||
);
|
$this->con->writeLock($this->k_tb);
|
||||||
return !$chk->isEmpty();
|
$cur->kut_id = $this->nextId();
|
||||||
}
|
$cur->blog_id = $rs->blog_id;
|
||||||
|
$cur->kut_service = 'unknow';
|
||||||
private function nextId()
|
$cur->kut_type = $rs->miniurl_type;
|
||||||
{
|
$cur->kut_hash = $rs->miniurl_id;
|
||||||
return $this->con->select(
|
$cur->kut_url = $rs->miniurl_str;
|
||||||
'SELECT MAX(kut_id) FROM '.$this->k_tb.' '
|
$cur->kut_dt = $rs->miniurl_dt;
|
||||||
)->f(0) + 1;
|
$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
|
<?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;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -21,7 +21,7 @@ class bitlyKutrlService extends kutrlService
|
||||||
'id' => 'bitly',
|
'id' => 'bitly',
|
||||||
'name' => 'bit.ly',
|
'name' => 'bit.ly',
|
||||||
'home' => 'http://bit.ly',
|
'home' => 'http://bit.ly',
|
||||||
|
|
||||||
'url_api' => 'http://api.bit.ly/v3/',
|
'url_api' => 'http://api.bit.ly/v3/',
|
||||||
'url_base' => 'http://bit.ly/',
|
'url_base' => 'http://bit.ly/',
|
||||||
'url_min_len' => 25
|
'url_min_len' => 25
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -21,7 +21,7 @@ class customKutrlService extends kutrlService
|
||||||
'id' => 'custom',
|
'id' => 'custom',
|
||||||
'name' => 'Custom'
|
'name' => 'Custom'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$config = unserialize(base64_decode($this->settings->kutrl_srv_custom));
|
$config = unserialize(base64_decode($this->settings->kutrl_srv_custom));
|
||||||
|
@ -29,12 +29,12 @@ class customKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
$config = [];
|
$config = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config['url_api'] = !empty($config['url_api']) ? $config['url_api'] : '';
|
$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_base'] = !empty($config['url_base']) ? $config['url_base'] : '';
|
||||||
$this->config['url_param'] = !empty($config['url_param']) ? $config['url_param'] : '';
|
$this->config['url_param'] = !empty($config['url_param']) ? $config['url_param'] : '';
|
||||||
$this->config['url_encode'] = !empty($config['url_api']);
|
$this->config['url_encode'] = !empty($config['url_api']);
|
||||||
|
|
||||||
$this->config['url_min_length'] = strlen($this->url_base) + 2;
|
$this->config['url_min_length'] = strlen($this->url_base) + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -37,7 +37,7 @@ class defaultKutrlService extends kutrlService
|
||||||
'url_encode' => SHORTEN_SERVICE_ENCODE
|
'url_encode' => SHORTEN_SERVICE_ENCODE
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingsForm()
|
public function settingsForm()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -27,7 +27,7 @@ class googlKutrlService extends kutrlService
|
||||||
'key' => ''
|
'key' => ''
|
||||||
];
|
];
|
||||||
private $headers = array('Content-Type: application/json');
|
private $headers = array('Content-Type: application/json');
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->url_base = 'http://goo.gl/';
|
$this->url_base = 'http://goo.gl/';
|
||||||
|
|
|
@ -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;}
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ class isgdKutrlService extends kutrlService
|
||||||
'id' => 'isgd',
|
'id' => 'isgd',
|
||||||
'name' => 'is.gd',
|
'name' => 'is.gd',
|
||||||
'home' => 'http://is.gd/',
|
'home' => 'http://is.gd/',
|
||||||
|
|
||||||
'url_api' => 'http://is.gd/api.php',
|
'url_api' => 'http://is.gd/api.php',
|
||||||
'url_base' => 'http://is.gd/',
|
'url_base' => 'http://is.gd/',
|
||||||
'url_min_length' => 25
|
'url_min_length' => 25
|
||||||
];
|
];
|
||||||
|
|
||||||
public function testService()
|
public function testService()
|
||||||
{
|
{
|
||||||
$arg = ['longurl' => urlencode($this->url_test)];
|
$arg = ['longurl' => urlencode($this->url_test)];
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -21,10 +21,10 @@ class localKutrlService extends kutrlService
|
||||||
'id' => 'local',
|
'id' => 'local',
|
||||||
'name' => 'kUtRL',
|
'name' => 'kUtRL',
|
||||||
'home' => 'http://kutrl.fr',
|
'home' => 'http://kutrl.fr',
|
||||||
|
|
||||||
'allow_custom_hash' => true
|
'allow_custom_hash' => true
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$protocols = (string) $this->settings->kutrl_srv_local_protocols;
|
$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_base'] = $this->core->blog->url . $this->core->url->getBase('kutrl') . '/';
|
||||||
$this->config['url_min_len'] = strlen($this->url_base) + 2;
|
$this->config['url_min_len'] = strlen($this->url_base) + 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveSettings()
|
public function saveSettings()
|
||||||
{
|
{
|
||||||
$this->settings->put('kutrl_srv_local_protocols', $_POST['kutrl_srv_local_protocols'], 'string');
|
$this->settings->put('kutrl_srv_local_protocols', $_POST['kutrl_srv_local_protocols'], 'string');
|
||||||
|
@ -47,7 +47,7 @@ class localKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<div class="two-cols"><div class="col">' .
|
'<div class="two-cols"><div class="col">' .
|
||||||
|
|
||||||
'<p><strong>' . __('Settings:') . '</strong></p>' .
|
'<p><strong>' . __('Settings:') . '</strong></p>' .
|
||||||
'<p><label class="classic">' .
|
'<p><label class="classic">' .
|
||||||
__('Allowed protocols:') . '<br />' .
|
__('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>' .
|
'<p class="form-note">' . __('If this is not activated, the default 404 page of the theme will be display.') . '</p>' .
|
||||||
|
|
||||||
'</div><div class="col">' .
|
'</div><div class="col">' .
|
||||||
|
|
||||||
'<p><strong>' . __('Note:') . '</strong></p>' .
|
'<p><strong>' . __('Note:') . '</strong></p>' .
|
||||||
'<p>' .
|
'<p>' .
|
||||||
__('This service use your own Blog to shorten and serve URL.') . '<br />' .
|
__('This service use your own Blog to shorten and serve URL.') . '<br />' .
|
||||||
|
@ -96,7 +96,7 @@ class localKutrlService extends kutrlService
|
||||||
'</p>' .
|
'</p>' .
|
||||||
'<p>' . __('There are two templates delivered with kUtRL, if you do not use default theme, you may adapt them to yours.') . '<br />' .
|
'<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>' .
|
__('Files are in plugin directory /default-templates, just copy them into your theme and edit them.') . '</p>' .
|
||||||
|
|
||||||
'</div></div><br class="clear"/>';
|
'</div></div><br class="clear"/>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class localKutrlService extends kutrlService
|
||||||
false === $this->log->select(null,$prefix . $next_id, null, 'local') ?
|
false === $this->log->select(null,$prefix . $next_id, null, 'local') ?
|
||||||
$next_id : $this->next($next_id, $prefix);
|
$next_id : $this->next($next_id, $prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function append($id)
|
protected function append($id)
|
||||||
{
|
{
|
||||||
$id = str_split($id);
|
$id = str_split($id);
|
||||||
|
@ -210,7 +210,7 @@ class localKutrlService extends kutrlService
|
||||||
}
|
}
|
||||||
return implode($id);
|
return implode($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUrl($hash)
|
public function getUrl($hash)
|
||||||
{
|
{
|
||||||
if (false === ($rs = $this->log->select(null, $hash, null, 'local'))) {
|
if (false === ($rs = $this->log->select(null, $hash, null, 'local'))) {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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_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;
|
'url_api' => 'http://su.pr/api/',
|
||||||
$arg['longUrl'] = $this->url_test;
|
'url_base' => 'http://su.pr/',
|
||||||
if (!($response = self::post($this->url_api.'shorten',$args,true)))
|
'url_min_len' => 23
|
||||||
{
|
);
|
||||||
$this->error->add(__('Failed to call service.'));
|
|
||||||
return false;
|
private $args = array(
|
||||||
}
|
'version' => '1.0',
|
||||||
|
'format' => 'xml',
|
||||||
$rsp = simplexml_load_string($response);
|
'login' => '',
|
||||||
|
'apiKey' => ''
|
||||||
$status = (string) $rsp->statusCode;
|
);
|
||||||
if ($status != 'OK') {
|
|
||||||
$err_no = (integer) $rsp->errorCode;
|
protected function init()
|
||||||
$err_msg = (integer) $rsp->errorMessage;
|
{
|
||||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
$this->args['login'] = $this->settings->kutrl_srv_supr_login;
|
||||||
return false;
|
$this->args['apiKey'] = $this->settings->kutrl_srv_supr_apikey;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
public function saveSettings()
|
||||||
|
{
|
||||||
public function createHash($url,$hash=null)
|
$this->settings->put('kutrl_srv_supr_login',$_POST['kutrl_srv_supr_login']);
|
||||||
{
|
$this->settings->put('kutrl_srv_supr_apikey',$_POST['kutrl_srv_supr_apikey']);
|
||||||
$args = $this->args;
|
}
|
||||||
$args['longUrl'] = $url;
|
|
||||||
|
public function settingsForm()
|
||||||
if (!($response = self::post($this->url_api.'shorten',$args,true)))
|
{
|
||||||
{
|
echo
|
||||||
$this->error->add(__('Failed to call service.'));
|
'<p><label class="classic">'.__('Login:').'<br />'.
|
||||||
return false;
|
form::field(array('kutrl_srv_supr_login'),50,255,$this->settings->kutrl_srv_supr_login).
|
||||||
}
|
'</label></p>'.
|
||||||
|
'<p class="form-note">'.
|
||||||
$rsp = simplexml_load_string($response);
|
sprintf(__('This is your login to sign up to %s'),$this->config['name']).
|
||||||
|
'</p>'.
|
||||||
$status = (string) $rsp->statusCode;
|
'<p><label class="classic">'.__('API Key:').'<br />'.
|
||||||
if ($status != 'OK') {
|
form::field(array('kutrl_srv_supr_apikey'),50,255,$this->settings->kutrl_srv_supr_apikey).
|
||||||
$err_no = (integer) $rsp->errorCode;
|
'</label></p>'.
|
||||||
$err_msg = (integer) $rsp->errorMessage;
|
'<p class="form-note">'.
|
||||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
sprintf(__('This is your personnal %s API key. You can find it on your account page.'),$this->config['name']).
|
||||||
return false;
|
'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$rs = new ArrayObject();
|
public function testService()
|
||||||
$rs->hash = (string) $rsp->results[0]->nodeKeyVal->hash;
|
{
|
||||||
$rs->url = (string) $rsp->results[0]->nodeKeyVal->nodeKey;
|
if (empty($this->args['login']) || empty($this->args['apiKey']))
|
||||||
$rs->type = $this->id;
|
{
|
||||||
|
$this->error->add(__('Service is not well configured.'));
|
||||||
return $rs;
|
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
|
<?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_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.'));
|
'url_api' => 'http://api.tr.im/v1/',
|
||||||
return false;
|
'url_base' => 'http://tr.im/',
|
||||||
}
|
'url_min_len' => 25
|
||||||
if (isset($r->trimpath))
|
);
|
||||||
{
|
|
||||||
$rs = new ArrayObject();
|
private $args = array(
|
||||||
$rs->hash = $r->trimpath;
|
'username' => '',
|
||||||
$rs->url = $url;
|
'password' => ''
|
||||||
$rs->type = $this->id;
|
);
|
||||||
|
|
||||||
return $rs;
|
private $api_rate_time = 0;
|
||||||
}
|
|
||||||
$this->error->add(__('Unreadable service response.'));
|
protected function init()
|
||||||
return false;
|
{
|
||||||
}
|
$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
|
<?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;
|
||||||
|
@ -34,10 +34,10 @@ class yourlsKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
$this->args['username'] = $this->settings->kutrl_srv_yourls_username;
|
$this->args['username'] = $this->settings->kutrl_srv_yourls_username;
|
||||||
$this->args['password'] = $this->settings->kutrl_srv_yourls_password;
|
$this->args['password'] = $this->settings->kutrl_srv_yourls_password;
|
||||||
|
|
||||||
$base = (string) $this->settings->kutrl_srv_yourls_base;
|
$base = (string) $this->settings->kutrl_srv_yourls_base;
|
||||||
//if (!empty($base) && substr($base,-1,1) != '/') $base .= '/';
|
//if (!empty($base) && substr($base,-1,1) != '/') $base .= '/';
|
||||||
|
|
||||||
$this->config['url_api'] = $base;
|
$this->config['url_api'] = $base;
|
||||||
$this->config['url_base'] = $base;
|
$this->config['url_base'] = $base;
|
||||||
$this->config['url_min_len'] = strlen($base)+3;
|
$this->config['url_min_len'] = strlen($base)+3;
|
||||||
|
@ -80,16 +80,16 @@ class yourlsKutrlService extends kutrlService
|
||||||
$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;
|
||||||
$args['url'] = $this->url_test;
|
$args['url'] = $this->url_test;
|
||||||
|
|
||||||
if (!($response = self::post($this->url_api, $this->args, true))) {
|
if (!($response = self::post($this->url_api, $this->args, true))) {
|
||||||
$this->error->add(__('Service is unavailable.'));
|
$this->error->add(__('Service is unavailable.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$rsp = @simplexml_load_string($response);
|
$rsp = @simplexml_load_string($response);
|
||||||
|
|
||||||
if ($rsp && $rsp->status == 'success') {
|
if ($rsp && $rsp->status == 'success') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
30
index.php
30
index.php
|
@ -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;
|
||||||
|
@ -121,7 +121,7 @@ if ($part == 'link') {
|
||||||
}
|
}
|
||||||
$url = trim($core->con->escape($_POST['str']));
|
$url = trim($core->con->escape($_POST['str']));
|
||||||
$hash = empty($_POST['custom']) ? null : $_POST['custom'];
|
$hash = empty($_POST['custom']) ? null : $_POST['custom'];
|
||||||
|
|
||||||
if (empty($url)) {
|
if (empty($url)) {
|
||||||
throw new Exception(__('There is nothing to shorten.'));
|
throw new Exception(__('There is nothing to shorten.'));
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ if ($part == 'links') {
|
||||||
}
|
}
|
||||||
$o->remove($rs->kut_url);
|
$o->remove($rs->kut_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
|
@ -408,7 +408,7 @@ if ($part == 'service') {
|
||||||
|
|
||||||
foreach(kutrl::getServices($core) as $service_id => $service) {
|
foreach(kutrl::getServices($core) as $service_id => $service) {
|
||||||
$o = new $service($core);
|
$o = new $service($core);
|
||||||
|
|
||||||
echo '<div class="fieldset" id="setting-' . $service_id . '"><h4>' . $o->name . '</h4>';
|
echo '<div class="fieldset" id="setting-' . $service_id . '"><h4>' . $o->name . '</h4>';
|
||||||
|
|
||||||
if (!empty($_POST['save'])) {
|
if (!empty($_POST['save'])) {
|
||||||
|
@ -458,7 +458,7 @@ if ($part == 'link') {
|
||||||
<div class="fieldset">
|
<div class="fieldset">
|
||||||
<h4>' . sprintf(__('Shorten link using service "%s"'), $kut->name) . '</h4>
|
<h4>' . sprintf(__('Shorten link using service "%s"'), $kut->name) . '</h4>
|
||||||
<form id="create-link" method="post" action="' . $p_url . '">
|
<form id="create-link" method="post" action="' . $p_url . '">
|
||||||
|
|
||||||
<p><label for="str">' . __('Long link:') . '</label>' .
|
<p><label for="str">' . __('Long link:') . '</label>' .
|
||||||
form::field('str', 100, 255, '') . '</p>';
|
form::field('str', 100, 255, '') . '</p>';
|
||||||
|
|
||||||
|
|
|
@ -13,5 +13,4 @@
|
||||||
|
|
||||||
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';
|
||||||
?>
|
|
|
@ -518,5 +518,4 @@ $GLOBALS['__l10n']['You can use "bob!!" if you want a semi-custom link, it start
|
||||||
$GLOBALS['__l10n']['Service:'] = 'Service :';
|
$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';
|
||||||
|
|
|
@ -13,5 +13,4 @@
|
||||||
|
|
||||||
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';
|
||||||
?>
|
|
Loading…
Reference in New Issue