Check that the archive directory is writable
This commit is contained in:
parent
4d62124a03
commit
460c77f116
29
owark.php
29
owark.php
|
@ -25,6 +25,18 @@ Author URI: http://eric.van-der-vlist.com
|
||||||
License: GLP2
|
License: GLP2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Log
|
||||||
|
*/
|
||||||
|
if ( ! function_exists('print_r_log')) {
|
||||||
|
function print_r_log ( $log ) {
|
||||||
|
if ( is_array( $log ) || is_object( $log ) ) {
|
||||||
|
error_log( print_r( $log, true ) );
|
||||||
|
} else {
|
||||||
|
error_log( $log );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!class_exists("Owark")) {
|
if (!class_exists("Owark")) {
|
||||||
class Owark {
|
class Owark {
|
||||||
|
@ -93,6 +105,8 @@ if (!class_exists("Owark")) {
|
||||||
*/
|
*/
|
||||||
function sanity_checks(){
|
function sanity_checks(){
|
||||||
|
|
||||||
|
// print_r_log("Sanity checks");
|
||||||
|
|
||||||
// Install or upgrade tables if needed
|
// Install or upgrade tables if needed
|
||||||
|
|
||||||
$installed_ver = get_option( "owark_db_version" );
|
$installed_ver = get_option( "owark_db_version" );
|
||||||
|
@ -137,13 +151,15 @@ if (!class_exists("Owark")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have an archive subdirectory
|
// Check if we have an archive subdirectory
|
||||||
|
$archives_dir = dirname(__FILE__) . '/archives';
|
||||||
if (!is_dir(dirname(__FILE__) . '/archives')) {
|
if (!is_dir($archives_dir)) {
|
||||||
@mkdir(dirname(__FILE__) . '/archives');
|
@mkdir($archives_dir);
|
||||||
if (!is_dir(dirname(__FILE__) . '/archives')) {
|
if (!is_dir($archives_dir)) {
|
||||||
$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>";
|
||||||
}
|
}
|
||||||
}
|
} elseif (! is_writable($archives_dir)) {
|
||||||
|
$this->notices = $this->notices . "<div class=\"error fade\"><p><strong>The Open Web Archive needs a writable folder /archives in its installation directory. Please make it writable for the web server.</strong></p></div>";
|
||||||
|
}
|
||||||
|
|
||||||
// Check that we can execute commands
|
// Check that we can execute commands
|
||||||
|
|
||||||
|
@ -546,6 +562,7 @@ if (!class_exists("Owark")) {
|
||||||
AND broken=0
|
AND broken=0
|
||||||
AND final_url!=''";
|
AND final_url!=''";
|
||||||
$url = $wpdb->get_row($query);
|
$url = $wpdb->get_row($query);
|
||||||
|
print_r_log($url);
|
||||||
$wpdb->flush();
|
$wpdb->flush();
|
||||||
|
|
||||||
if ($url != NULL) {
|
if ($url != NULL) {
|
||||||
|
@ -558,7 +575,7 @@ if (!class_exists("Owark")) {
|
||||||
$status = 0;
|
$status = 0;
|
||||||
exec("wget -t3 -E -H -k -K -p -nd -nv --timeout=60 --user-agent=\"Mozilla/5.0 (compatible; owark/0.2; http://owark.org/)\" -P $path {$url->final_url}",
|
exec("wget -t3 -E -H -k -K -p -nd -nv --timeout=60 --user-agent=\"Mozilla/5.0 (compatible; owark/0.2; http://owark.org/)\" -P $path {$url->final_url}",
|
||||||
$output, $status);
|
$output, $status);
|
||||||
|
print_r_log("wget status: $status");
|
||||||
$q = $wpdb->insert("{$wpdb->prefix}owark", array(
|
$q = $wpdb->insert("{$wpdb->prefix}owark", array(
|
||||||
'url' => $url->final_url,
|
'url' => $url->final_url,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
|
|
Loading…
Reference in New Issue