#3: supporting other filenames than index.html

This commit is contained in:
Eric van der Vlist 2011-06-04 16:33:57 +02:00
parent dad0250e5a
commit 136dad5a15
1 changed files with 25 additions and 10 deletions

View File

@ -430,8 +430,8 @@ if (!class_exists("Owark")) {
$home_url = home_url(); $home_url = home_url();
$loc = ""; $loc = "";
if( ($pos = strpos($link->arc_location, '/wp-content/plugins/owark/')) !== FALSE ) if( ($pos = strpos($link->arc_location, '/archives')) !== FALSE )
$loc = substr($link->arc_location, $pos); $loc = '/wp-content/plugins/owark' . substr($link->arc_location, $pos);
$arc_loc = home_url() . $loc; $arc_loc = home_url() . $loc;
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@ -444,12 +444,26 @@ if (!class_exists("Owark")) {
echo "This is an <a href='http://owark.org'>Open Web Archive</a> archive of <a href=\"{$link->url}\">{$link->url}</a>."; echo "This is an <a href='http://owark.org'>Open Web Archive</a> archive of <a href=\"{$link->url}\">{$link->url}</a>.";
echo "<br />This snapshot has been taken on {$link->arc_date} for the website <a href=\"{$home_url}\">{$blog_title}</a> which contains a link to this page and has saved a copy to be displayed in the page ever disappears."; echo "<br />This snapshot has been taken on {$link->arc_date} for the website <a href=\"{$home_url}\">{$blog_title}</a> which contains a link to this page and has saved a copy to be displayed in the page ever disappears.";
echo '</div></div><div style="position:relative">'; echo '</div></div><div style="position:relative">';
$file_location = '.'.$loc.'/index.html';
$f = fopen($file_location, "r"); $dir = opendir('.'.$loc);
echo fread($f, filesize($file_location)); $filename = false;
fclose($f); while (false !== ($file = readdir($dir))) {
echo '</div>'; if ('.html' === substr($file, strlen($file) - 5)) {
} $filename = $file;
break;
}
}
closedir($dir);
if ($filename) {
$file_location = '.'.$loc.'/' . $filename;
$f = fopen($file_location, "r");
echo fread($f, filesize($file_location));
fclose($f);
echo '</div>';
}
}
/** /**
* Check if we've got something to archive * Check if we've got something to archive
@ -478,7 +492,8 @@ if (!class_exists("Owark")) {
if ($url != NULL) { if ($url != NULL) {
$date = date('c'); $date = date('c');
$path = dirname(__FILE__).'/archives/'. str_replace('%2F', '/', urlencode(preg_replace('/https?:\/\//', '', $url->final_url))) . '/' . $date; $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(); $output = array();
@ -490,7 +505,7 @@ if (!class_exists("Owark")) {
'url' => $url->final_url, 'url' => $url->final_url,
'status' => $status, 'status' => $status,
'arc_date' => $date, 'arc_date' => $date,
'arc_location' => $path)); 'arc_location' => $relpath));
if ($occurrences > 0) { 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));