Removing "&" in function calls by reference (support of PHP 5.6+)

This commit is contained in:
Eric van der Vlist 2020-05-02 16:43:41 +02:00
parent 21807536ca
commit 885867e065
1 changed files with 16 additions and 15 deletions

View File

@ -1,8 +1,8 @@
<?php
/* Copyright 2011 Eric van der Vlist (vdv@dyomedea.com)
/* Copyright 2011-2020 Eric van der Vlist (vdv@dyomedea.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
@ -19,7 +19,7 @@
Plugin Name: owark
Plugin URI: http://owark.org
Description: Tired of broken links? Archive yours with owark, the Open Web Archive!
Version: 0.1
Version: 0.2
Author: Eric van der Vlist
Author URI: http://eric.van-der-vlist.com
License: GLP2
@ -34,7 +34,7 @@ if (!class_exists("Owark")) {
private $post_type = "";
private $version = '0.2';
private $notices = "";
/**
* Class constructor
*
@ -67,7 +67,7 @@ if (!class_exists("Owark")) {
add_filter ( 'comment_text', array($this, 'comment_filter'));
add_filter ( 'get_comment_author_link', array($this, 'comment_filter'));
add_action('owark_schedule_event', array(Owark, 'schedule'));
add_action('owark_schedule_event', array('Owark', 'schedule'));
if ( !wp_next_scheduled( 'owark_schedule_event', array('occurrences' => 30) ) ) {
wp_schedule_event(time(), 'hourly', 'owark_schedule_event', array('occurrences' => 30));
}
@ -133,7 +133,7 @@ if (!class_exists("Owark")) {
if (!is_dir(dirname(__FILE__) . '/archives')) {
@mkdir(dirname(__FILE__) . '/archives');
if (!is_dir(dirname(__FILE__) . '/archives')) {
$this->notices = $this->notices . "<div class=\"error fade\"><p><strong>The Open Web Archive has not been able to create the folder /archives in its installation directory. Please create it by hand and make it writable for the web server.</strong></p></div>";
$this->notices = $this->notices . "<div class=\"error fade\"><p><strong>The Open Web Archive has not been able to create the folder /archives in its installation directory. Please create it by hand and make it writable for the web server.</strong></p></div>";
}
}
@ -149,17 +149,18 @@ if (!class_exists("Owark")) {
// Check that wget is installed
$output = array();
exec('/usr/bin/wget -V', &$output);
exec('/usr/bin/wget -V', $output);
if ( empty($output) ) {
$this->notices = $this->notices . "<div class=\"error fade\"><p><strong>The Open Web Archives is not able to run wget and retrieve the pages to archive. Please check that wget is installed and on the default path.</strong></p></div>";
$this->notices = $this->notices .
"<div class=\"error fade\"><p><strong>The Open Web Archives is not able to run GNU wget and retrieve the pages to archive. Please check that wget is installed and on the default path.</strong></p></div>";
}
// We need as least version 1.11 or higher
$helper = preg_match('/GNU Wget ([0-9\.]+) /', $output[0], $wget_version);
if ( $wget_version[1] < '1.11' ) {
$this->notices = $this->notices . "<div class=\"error fade\"><p><strong>The Open Web Archives needs wget version 1.11 or higher.</strong><br />Version read: {$wget_version[0]}</p></div>";
if ( $wget_version[0] < '1.11' ) {
$this->notices = $this->notices . "<div class=\"error fade\"><p><strong>The Open Web Archives needs GNU wget version 1.11 or higher.</strong><br />Version read: {$wget_version[0]}</p></div>";
}
if ($this->notices != '') {
@ -439,7 +440,7 @@ if (!class_exists("Owark")) {
$loc = '/wp-content/plugins/owark' . substr($link->arc_location, $pos);
$arc_loc = home_url() . $loc;
// The file name is either index.html or guessed from the URL
// The file name is either index.html or guessed from the URL
if ($home_url[strlen($home_url)] == '/') {
$file_location = '.'. $loc .'/index.html';
} else {
@ -480,7 +481,7 @@ if (!class_exists("Owark")) {
$matches = NULL;
// <meta http-equiv="Content-Type" content="text/xml; charset=iso-8859-1"/>
if (preg_match('/<meta\s*http-equiv\s*=\s*["\']Content-Type["\']\s+content\s*=\s*["\'][^"\'>]*charset\s*=\s*([^"\'>]+)\s*["\']/si',
$content, &$matches) > 0) {
$content, $matches) > 0) {
$encoding = $matches[1];
} else {
$encoding = mb_detect_encoding($content);
@ -543,12 +544,12 @@ if (!class_exists("Owark")) {
$date = date('c');
$relpath = '/archives/'. str_replace('%2F', '/', urlencode(preg_replace('/https?:\/\//', '', $url->final_url))) . '/' . $date;
$path = dirname(__FILE__).$relpath;
//mkdir($path, $recursive=true);
//mkdir($path, $recursive=true);
$output = array();
$status = 0;
exec("wget -t3 -E -H -k -K -p -nd -nv --timeout=60 --user-agent=\"Mozilla/5.0 (compatible; owark/0.1; http://owark.org/)\" -P $path {$url->final_url}",
&$output, &$status);
$output, $status);
$q = $wpdb->insert("{$wpdb->prefix}owark", array(
'url' => $url->final_url,
@ -557,7 +558,7 @@ if (!class_exists("Owark")) {
'arc_location' => $relpath));
if ($occurrences > 0) {
wp_schedule_single_event(time() + 90, 'owark_schedule_event', array('occurrences' => $occurrences - 1));
wp_schedule_single_event(time() + 90, 'owark_schedule_event', array('occurrences' => $occurrences - 1));
}
}