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();
}
}
include_once dirname( __FILE__ ) . '/amber-install.php';
include_once dirname( __FILE__ ) . '/amber-settings.php';
include_once dirname( __FILE__ ) . '/amber-dashboard.php';
include_once dirname( __FILE__ ) . '/libraries/AmberStatus.php';
include_once dirname( __FILE__ ) . '/libraries/AmberInterfaces.php';
include_once dirname( __FILE__ ) . '/libraries/AmberNetworkUtils.php';
include_once dirname( __FILE__ ) . '/libraries/AmberMementoService.php';
include_once dirname( __FILE__ ) . '/libraries/backends/amber/AmberStorage.php';
include_once dirname( __FILE__ ) . '/libraries/backends/amber/AmberFetcher.php';
include_once dirname( __FILE__ ) . '/libraries/backends/internetarchive/InternetArchiveStorage.php';
include_once dirname( __FILE__ ) . '/libraries/backends/internetarchive/InternetArchiveFetcher.php';
include_once dirname( __FILE__ ) . '/libraries/backends/perma/PermaStorage.php';
include_once dirname( __FILE__ ) . '/libraries/backends/perma/PermaFetcher.php';
include_once dirname( __FILE__ ) . '/libraries/backends/aws/AmazonS3Storage.php';
include_once dirname( __FILE__ ) . '/libraries/AmberChecker.php';
include_once dirname( __FILE__ ) . '/libraries/AmberAvailability.php';
include_once dirname( __FILE__ ) . '/libraries/AmberDB.php';
/* The filter to lookup and rewrite links with amber data- attributes */
add_filter ( 'the_content', array('Amber', 'filter'));
/* Activate, deactivate, and uninstall hooks */
register_activation_hook( __FILE__, array('AmberInstall','activate'));
register_deactivation_hook( __FILE__, array('AmberInstall','deactivate'));
register_uninstall_hook( __FILE__, array('AmberInstall','uninstall'));
/* Check to see if the plugin has been updated */
add_action( 'plugins_loaded', array('AmberInstall', 'upgrade') );
/* Warn if permalinks are not enabled */
add_action( 'admin_notices', array('Amber', 'admin_notices') );
/* Add CSS and Javascript to all pages */
add_action( 'wp_enqueue_scripts', array('Amber', 'register_plugin_assets') );
/* Scan content for links whenever it's saved */
add_action( 'save_post', array('Amber', 'extract_links') );
/* Add actions and filters for loading cache content */
add_action( 'init', array('Amber', 'add_rewrite_rules') );
add_filter( 'query_vars', array('Amber', 'custom_query_vars') );
add_action( 'parse_query', array('Amber', 'display_cached_content') );
add_filter( 'wp_headers', array('Amber', 'filter_cached_content_headers') );
/* Add "Cache Now" link to edit pages */
add_action( 'add_meta_boxes', array('Amber', 'add_meta_boxes') );
/* Setup cron */
add_action( 'amber_cron_event_hook', array('Amber', 'cron_event_hook') );
add_filter( 'cron_schedules', array('Amber', 'cron_add_schedule') );
if ( ! wp_next_scheduled( 'amber_cron_event_hook' ) ) {
wp_schedule_event( time(), 'fiveminutes', 'amber_cron_event_hook' );
}
/* Setup ajax methods for batch caching and scanning */
add_action( 'wp_ajax_amber_cache', array('Amber', 'ajax_cache') );
add_action( 'wp_ajax_amber_cache_now', array('Amber', 'ajax_cache_now') );
add_action( 'wp_ajax_amber_scan_start', array('Amber', 'ajax_scan_start') );
add_action( 'wp_ajax_amber_scan', array('Amber', 'ajax_scan') );
add_action( 'wp_ajax_nopriv_amber_logcacheview', array('Amber', 'ajax_log_cache_view') );
add_action( 'wp_ajax_nopriv_amber_status', array('Amber', 'ajax_get_url_status') );
add_action( 'wp_ajax_amber_status', array('Amber', 'ajax_get_url_status') );
add_action( 'wp_ajax_nopriv_amber_memento', array('Amber', 'ajax_get_memento') );
add_action( 'wp_ajax_amber_memento', array('Amber', 'ajax_get_memento') );
?>