static php5 fix

This commit is contained in:
Garvin Hicking 2013-05-10 10:52:05 +02:00
parent d93811a96b
commit 98378026a6
2 changed files with 21 additions and 9 deletions

View file

@ -1,3 +1,8 @@
1.1:
----
static php5 function fixes
1.0:
----
do not show in Dashboard (POC)

View file

@ -26,7 +26,7 @@ class serendipity_event_linktrimmer extends serendipity_event {
'php' => '4.1.0'
));
$propbag->add('version', '1.0');
$propbag->add('version', '1.1');
$propbag->add('author', 'Garvin Hicking');
$propbag->add('stackable', false);
$propbag->add('configuration', array('prefix', 'domain'));
@ -103,7 +103,7 @@ class serendipity_event_linktrimmer extends serendipity_event {
$title = PLUGIN_LINKTRIMMER_NAME;
}
function base62($var) {
static function base62($var) {
static $base_characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$stack = array();
@ -117,14 +117,21 @@ class serendipity_event_linktrimmer extends serendipity_event {
return implode('', array_reverse($stack));
}
function lookup($url, $custom_hash = '') {
static function lookup($url, $custom_hash = '', $is_static = true) {
global $serendipity;
$pref = $this->get_config('domain') . $this->get_config('prefix') . '/';
if ($this->get_config('domain') == $serendipity['baseURL']) {
$pref = $this->get_config('domain') . $this->get_config('prefix') . '/';
// When called statically (like from the twitter plugin), $this is not available.
// Static calls like in that plugin put the $pref config values in front of the return
// by their own.
if ($is_static) {
$pref = '';
} else {
$pref = $this->get_config('domain');
$pref = $this->get_config('domain') . $this->get_config('prefix') . '/';
if ($this->get_config('domain') == $serendipity['baseURL']) {
$pref = $this->get_config('domain') . $this->get_config('prefix') . '/';
} else {
$pref = $this->get_config('domain');
}
}
$custom_hash = trim($custom_hash);
@ -155,7 +162,7 @@ class serendipity_event_linktrimmer extends serendipity_event {
return $pref . $res['hash'];
}
function create($url, $hash = '') {
static function create($url, $hash = '') {
global $serendipity;
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}linktrimmer (url) VALUES ('" . serendipity_db_escape_string($url) . "')");
@ -188,7 +195,7 @@ class serendipity_event_linktrimmer extends serendipity_event {
$this->setupDB();
if (isset($_REQUEST['submit']) && !empty($_REQUEST['linktrimmer_url'])) {
$url = $this->lookup($_REQUEST['linktrimmer_url'], $_REQUEST['linktrimmer_hash']);
$url = $this->lookup($_REQUEST['linktrimmer_url'], $_REQUEST['linktrimmer_hash'], false);
if ($url == false) {
$error = PLUGIN_LINKTRIMMER_ERROR;
}