示例#1
0
 function save($parent = '')
 {
     $this->get();
     $this->data['parent'] = $parent;
     if ($this->data['content/type'] == 'text/html') {
         if (empty($parent)) {
             $html = str_get_html($this->content, false, true, DEFAULT_TARGET_CHARSET, false);
             $options = array('link[href]' => 'href', 'script[src]' => 'src', 'img[src]' => 'src');
             foreach ($options as $tag => $option) {
                 foreach ($html->find($tag) as &$link) {
                     $path = $link->{$option};
                     $u = getUrl($path, $this->url);
                     if ($u !== null) {
                         $this->data['children'][] = $u;
                         $p = new ArchivePage($u, $this->url);
                         if (DEBUG) {
                             echo '<br/>[' . date('H:i:s') . '] <span style="color:grey">' . $u . '</span>...';
                             flush();
                         }
                         $f = $p->refresh();
                         if (DEBUG) {
                             echo ' <span style="color:green">[success]</span>';
                             flush();
                         }
                         $link->{$option} = '{/}' . $u;
                     }
                 }
             }
             $this->content = $html->__toString();
         }
     } else {
         if ($this->data['content/type'] == 'text/css') {
             preg_match_all('/url\\(["\']?(.+?)["\']?\\)/i', $this->content, $matches);
             foreach ($matches[1] as $i => $match) {
                 $path = trim($match, '"\'');
                 $u = getUrl($path, $this->url);
                 if ($u !== null) {
                     $this->data['children'][] = $u;
                     $p = new ArchivePage($u, $this->url);
                     if (DEBUG) {
                         echo '<br/>[' . date('H:i:s') . '] <span style="color:grey">' . $u . '</span>...';
                         flush();
                     }
                     $f = $p->refresh();
                     if (DEBUG) {
                         echo ' <span style="color:green">[success]</span>';
                         flush();
                     }
                     $this->content = str_replace($matches[0][$i], str_replace($path, '{/}' . $u, $matches[0][$i]), $this->content);
                 }
             }
         }
     }
     file_put_contents($this->file . '.data' . $this->data['ext'], $this->content);
     file_put_contents($this->file . '.info', serialize($this->data));
 }
示例#2
0
<?php

define('DEBUG', !empty($_GET['debug']) && $_GET['debug'] == '1');
require_once 'library/classes.php';
if (isset($_GET['refresh'])) {
    $page = new ArchivePage(urldecode($_GET['refresh']));
    $page->refresh(!empty($_GET['force']) && $_GET['force'] == '1');
    if (DEBUG) {
        exit('<br/><br/>Success');
    }
    header('Location: ./');
    exit;
}
if (isset($_GET['view'])) {
    $url = urldecode($_GET['view']);
    $page = new ArchivePage($url);
    $file = isset($_GET['md5']) ? $page->getMd5($_GET['md5']) : $page->getLastVersion();
    header('Content-type: ' . $file->contentType());
    exit(str_replace('{/}', '/archive/?view=', $file->get()));
}
$pages = array();
$domains = glob('archive/*');
foreach ($domains as $domain) {
    $dirs = glob($domain . '/*');
    foreach ($dirs as $dir) {
        $url = 'http://' . substr($domain, strlen('archive/')) . base64_decode(basename($dir));
        $pages[$url] = new ArchivePage($url);
    }
}
?>
<html>