The PHP cURL extension must be installed for Amber to work properly. Ask your web host to install it, or follow the instructions here.
';
}
}
public static function ajax_log_cache_view() {
if ( isset( $_GET['cache'] ) ) {
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
$status = Amber::get_status();
if ( $status->save_view_for_external_cache_location ($_GET['cache'] ) ) {
status_header( 200 );
} else {
status_header( 404 );
}
} else {
status_header( 400 );
}
die();
}
/* Handle Ajax request and query NetClerk to get availability information for a URL */
public static function ajax_get_url_status() {
if (isset($_REQUEST['url']) && isset($_REQUEST['country'])) {
header("Content-Type: application/json");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
$lookup = Amber::get_availability();
$lookup_result = $lookup->get_status( $_REQUEST['url'], $_REQUEST['country'] );
if ($lookup_result === FALSE || !isset($lookup_result['data'])) {
status_header( 500 );
die();
}
foreach ( $lookup_result['data'] as $key => $value ) {
$lookup_result['data'][$key]['behavior'] = Amber::get_behavior($lookup_result['data'][$key]['available']);
}
print(json_encode($lookup_result, JSON_UNESCAPED_SLASHES));
status_header( 200 );
} else {
status_header( 400 );
}
die();
}
/* Handle Ajax request and query a Timegate server to find Mementos for a URL */
public static function ajax_get_memento() {
if (isset($_REQUEST['url'], $_REQUEST['date'])) {
header("Content-Type: application/json");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
$date = str_replace(" ", "+", $_REQUEST['date']);
$memento_service = Amber::get_memento_service();
$lookup_result = $memento_service->getMemento( $_REQUEST['url'], $date );
print(json_encode($lookup_result, JSON_UNESCAPED_SLASHES));
status_header( 200 );
} else {
status_header( 400 );
}
die();
}
/* Ensure that the directory on the local file system that contains cached content
has an htaccess file to prevent the content from being loaded directly (to
protect against XSS attacks from malicious saved javascript) */
public static function secure_local_storage($dir) {
$filename = join(DIRECTORY_SEPARATOR,array($dir,'.htaccess'));
if (!file_exists($filename)) {
$htaccess = <<