예제 #1
0
 public static function static_constructor()
 {
     self::$allowed_request_headers = array('Host', 'Referer', 'Range', 'Cookie');
     self::$custom_request_headers = array('User-Agent' => 'YouTube Cache', 'X-Cache-Admin' => $GLOBALS['admin_email']);
     self::$cached_headers = array('Content-Type', 'Content-Length', 'Last-Modified', 'Server');
 }
예제 #2
0
                if (rename($this->temp_cache_filename, $this->cache_filename) === FALSE) {
                    $this->log(2, __FUNCTION__, "Cannot rename temporary cache file: [{$this->temp_cache_filename}] to [{$this->cache_filename}]");
                } else {
                    $this->add_video($sz);
                    // Add video to the db
                    $this->add_to_stats();
                    // Calc stats
                    $this->cache_fp = null;
                    $this->log(1, __FUNCTION__, "Close cached file: " . $this->cache_filename);
                }
            }
        }
        $this->close_temporary_transfer($this->cache_request);
        // Delete from temporary
        $this->stop_caching();
    }
}
function char_to_hex($ch)
{
    return sprintf('%2X', ord($ch));
}
function safe_filename($fn)
{
    return preg_replace_callback('/[^a-zA-Z0-9_-]/', 'char_to_hex', $fn);
}
if (!$db || !$set) {
    fatal_error("No DB instance or settings!");
}
// Instance cacher and run it
$cr = new YouTubeCacher();
$cr->run($db, $set);