Esempio n. 1
1
 function &sysDb()
 {
     $amber =& Amber::getInstance($this->_globalConfig);
     if (!is_object($amber)) {
         return false;
     }
     return $amber->sysDb();
 }
 function test_filter_cached_one_link_country_specific_behavior_same_as_default()
 {
     update_option('amber_options', array('amber_available_action' => AMBER_ACTION_HOVER, 'amber_country_available_action' => AMBER_ACTION_HOVER, 'amber_country_id' => 'IR'));
     $this->status_stub->method('get_summary')->willReturn(array('default' => array('date' => '1395590225', 'location' => 'Amber/cache/0a137b375cc3881a70e186ce2172c8d1', 'status' => 1, 'size' => 3453)));
     $result = Amber::filter('The quick brown <a href="http://fox.com">fox</a> jumped over the lazy dog');
     $this->assertEquals('The quick brown <a href="http://fox.com" data-versionurl="http://example.org/Amber/cache/0a137b375cc3881a70e186ce2172c8d1" data-versiondate="2014-03-23T15:57:05+00:00" data-amber-behavior="up hover:2">fox</a> jumped over the lazy dog', $result);
 }
Esempio n. 3
0
/**
 * @ignore
 */
function doImport(&$config)
{
    $installerPath = __AMBER_BASE__ . '/install/';
    $amber =& Amber::getInstance($config);
    // Create tx_amber_sys_objects
    $sysDb =& Amber::sysDb();
    $sql = file_get_contents($installerPath . '/tx_amber_sys_objects.sql');
    if ($sql == false) {
        echo formatMessage('Unable to open tx_amber_sys_objects.sql');
        return false;
    }
    $sysDb->Execute($sql);
    if ($sysDb->ErrorNo() != 0) {
        echo formatMessage('Importing tx_amber_sys_objects.sql failed:<p />' . $sysDb->ErrorMsg());
    }
    // Create table which hold sample data
    $db =& Amber::currentDb();
    $sql = @file_get_contents($installerPath . '/sample_data.sql');
    if ($sql == false) {
        echo formatMessage('Unable to open sample_data.sql');
        return false;
    }
    $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        echo formatMessage('Importing sample_data.sql failed:<p />' . $db->ErrorMsg());
    }
}
Esempio n. 4
0
 function setControlExporter(&$ctrl)
 {
     // set the exporter of Control $ctrl
     // do something like $ctrl->_exporter =& new ControlExporter;
     Amber::showError('Error', 'Abstract function called: Exporter::setControlExporter, type: ' . $this->type);
     die;
 }
 /**
  *
  * @access public
  * @param  integer handle of object to return
  * @return mixed
  *
  */
 function &getObject($handle)
 {
     $me =& ObjectHandler::getInstance();
     if (!isset($me->_list[$handle])) {
         Amber::showError('ObjectHandler::getObject()', 'Invalid handle: [' . $handle . ']');
         return null;
     }
     return $me->_list[$handle];
 }
 /**
  * Create association between an exporter type string and the class which
  * will be responsible to handle output.
  *
  * @static
  * @access public
  * @param string Exporter type string
  * @param string Name of the class which must be instantiated for this type of exporter
  */
 function register($type, $className)
 {
     $instance =& ExporterFactory::getInstance();
     if (array_key_exists($type, $instance->_classList)) {
         Amber::showError('Error', 'Duplicate exporter type: "' . $type . '"');
         die;
     }
     $instance->_classList[$type] = $className;
 }
 /**
  * @access public
  * @param string
  * @param string
  */
 function register($type, $className)
 {
     $instance =& AggregateFactory::getInstance();
     if (!class_exists($className)) {
         Amber::showError('Warning', 'Missing declaration for class "' . $className . '", aggregate type = ' . $type);
         return false;
     }
     $instance->_classList[$type] = $className;
 }
 /**
  * @access public
  * @param string
  * @param string
  * @param AmberObjectRaw
  */
 function saveObject($type, $name, &$obj)
 {
     $types = array_keys($this->objectTypes);
     if (!in_array($type, $types)) {
         Amber::showError('ObjectManager', 'Requested saving of unsupported object type: "' . $type . '"');
         die;
     }
     $this->objectLoader->save($type, $name, $obj);
 }
 function &setAmberConfig()
 {
     $cfgFileName = '../conf/localconf.xml';
     if (!file_exists($cfgFileName)) {
         Amber::showError('Error: localconf.xml does not exist', 'Amber needs to be configured before you can use it. <br>Use the <a href="../Amber/install/index.php" target="_blank">install tool</a> to set up the database connection.');
     }
     $cfg = new AmberConfig();
     $cfg->fromXML($cfgFileName);
     setlocale(LC_CTYPE, 'de_DE', 'de_DE@euro');
     setlocale(LC_TIME, 'de_DE', 'de_DE@euro');
     // needed for date, time
     setlocale(LC_MONETARY, 'de_DE', 'de_DE@euro');
     // needed for numbers
     return Amber::getInstance($cfg);
 }
Esempio n. 10
0
 /**
  * Register and add settings
  */
 public function page_init()
 {
     add_settings_section('amber_cache_section', 'Storage Settings', array($this, 'print_cache_section_info'), 'amber-settings-admin');
     add_settings_field('amber_max_file', 'Maximum file size (kB)', array($this, 'amber_max_file_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_max_disk', 'Maximum disk usage (MB)', array($this, 'amber_max_disk_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_storage_location', 'Storage location', array($this, 'amber_storage_location_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_update_strategy', 'Update strategy for captures', array($this, 'amber_update_strategy_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_excluded_sites', 'Excluded URL Patterns', array($this, 'amber_excluded_sites_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_excluded_formats', 'Excluded file formats', array($this, 'amber_excluded_formats_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_section('amber_delivery_section', 'Amber Delivery', array($this, 'print_delivery_section_info'), 'amber-settings-admin');
     add_settings_field('amber_available_action', 'Available links', array($this, 'amber_available_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_available_action_hover', 'Hover delay (seconds)', array($this, 'amber_available_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_unavailable_action', 'Unavailable links', array($this, 'amber_unavailable_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_unavailable_action_hover', 'Hover delay (seconds)', array($this, 'amber_unavailable_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_id', 'Country', array($this, 'amber_country_id_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_available_action', 'Available links', array($this, 'amber_country_available_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_available_action_hover', 'Hover delay (seconds)', array($this, 'amber_country_available_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_unavailable_action', 'Unavailable links', array($this, 'amber_country_unavailable_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_unavailable_action_hover', 'Hover delay (seconds)', array($this, 'amber_country_unavailable_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     register_setting('amber_option_group', 'amber_options', array($this, 'sanitize'));
     Amber::disk_space_purge();
 }
Esempio n. 11
0
 function get($str)
 {
     $path = split('/', $str);
     if ($path[0] == 'db') {
         $conf =& $this->database;
     } else {
         if ($path[0] == 'sys') {
             $conf =& $this->sys_objects;
         } else {
             Amber::showError('AmberConfig::get()', 'Invalid root: "' . $path[0] . '"');
         }
     }
     unset($path[0]);
     foreach ($path as $p) {
         if (!isset($conf[$p])) {
             //Amber::showError('AmberConfig::get()', 'No such element: "' . $p . '"');
             return '';
         }
         $conf =& $conf[$p];
     }
     return $conf;
 }
Esempio n. 12
0
 function pageLayout(&$report)
 {
     $this->noAutoPage = $report->noAutoPage;
     $this->noMargins = $report->noMargins;
     $this->noHeadFoot = $report->noHeadFoot;
     $this->unit = 1 / 20;
     $this->reportWidth = $report->Width;
     if ($report->Orientation == 'portrait') {
         $this->paperWidth = $report->PaperWidth;
         $this->paperHeight = $report->PaperHeight;
     } else {
         $this->paperWidth = $report->PaperHeight;
         $this->paperHeight = $report->PaperWidth;
     }
     if ($this->noMargins) {
         $this->rightMargin = 0;
         $this->leftMargin = 0;
         $this->topMargin = 0;
         $this->bottomMargin = 0;
         $this->paperWidth = $this->paperWidth - $report->LeftMargin - $report->RightMargin;
         $this->paperHeight = $this->paperHeight - $report->TopMargin - $report->BottomMargin;
     } else {
         $this->rightMargin = $report->RightMargin;
         $this->leftMargin = $report->LeftMargin;
         $this->topMargin = $report->TopMargin;
         $this->bottomMargin = $report->BottomMargin;
     }
     if ($this->noHeadFoot) {
         $this->pageHeaderHeight = 0;
         $this->pageFooterHeight = 0;
     } else {
         $this->pageHeaderHeight = $report->PageHeader->Height;
         $this->pageFooterHeight = $report->PageFooter->Height;
     }
     if ($this->noAutoPage) {
         $this->printWidth = $this->reportWidth;
         $this->pagesHorizontal = 1;
     } else {
         $this->printWidth = $this->paperWidth - $this->leftMargin - $this->rightMargin;
         //width of printable area of page (w/o morgins)
         if ($this->printWidth <= 0) {
             $msg = 'paper width: ' . (int) $this->paperWidth . '; left margin:' . (int) $this->leftMargin . '; right margin: ' . (int) $this->rightMargin . ';';
             die(Amber::showError('Error: Width of printable area too small', $msg, true));
         }
         $this->pagesHorizontal = floor($this->reportWidth / $this->printWidth) + 1;
         // No of pages needed to print report
         $this->printHeight = $this->paperHeight - $this->topMargin - $this->bottomMargin - $this->pageHeaderHeight - $this->pageFooterHeight;
         //height of printable area of page (w/o margins)
     }
     $this->pageNo = -1;
 }
Esempio n. 13
0
 /**
  *
  * @access public
  * @param Report
  * @param array XML data
  *
  */
 function load(&$parent, $data)
 {
     $this->_parent =& $parent;
     $this->Name = $data['Name'];
     $this->Height = empty($data['Height']) ? 0 : $data['Height'];
     $this->ForceNewPage = empty($data['ForceNewPage']) ? 0 : $data['ForceNewPage'];
     if (isset($data['Visible'])) {
         $this->Visible = $data['Visible'];
     }
     if (isset($data['BackColor'])) {
         $this->BackColor = MSColor($data['BackColor']);
     }
     if (isset($data['CanGrow'])) {
         $this->CanGrow = $data['CanGrow'];
     }
     if (isset($data['CanShrink'])) {
         $this->CanShrink = $data['CanShrink'];
     }
     if (isset($data['KeepTogether'])) {
         $this->KeepTogether = $data['KeepTogether'];
     }
     if (isset($data['EventProcPrefix'])) {
         $this->EventProcPrefix = $data['EventProcPrefix'];
     } else {
         $this->EventProcPrefix = $data['Name'];
     }
     $s = $data['EventProcPrefix'] . '_Format';
     if (method_exists($this->_parent->_Code, $s)) {
         $this->_OnFormatFunc = $s;
     } else {
         $this->_OnFormatFunc = 'allSections_Format';
         // null-OnFormat
     }
     $s = $data['EventProcPrefix'] . '_Print';
     if (method_exists($this->_parent->_Code, $s)) {
         $this->_OnPrintFunc = $s;
     } else {
         $this->_OnPrintFunc = 'allSections_Print';
         // null-OnPrint
     }
     if (!empty($data['Controls'])) {
         foreach ($data['Controls'] as $c) {
             $ctl =& ControlFactory::create($c['ControlType'], $c, $parent->hReport);
             if ($ctl == false) {
                 Amber::showError('Warning', 'Skipping unsupported control type: ' . htmlentities($c['ControlType']));
             } else {
                 $this->Controls[] =& $ctl;
                 $parent->Controls[$ctl->Name] =& $ctl;
                 $parent->ControlValues[$ctl->Name] =& $ctl->Value;
                 $ctl->_SectionSlip =& $parent->SectionSlip;
             }
         }
     }
 }
Esempio n. 14
0
 /**
  * Register and add settings
  */
 public function page_init()
 {
     add_settings_section('amber_cache_section', 'Storage Settings', array($this, 'print_cache_section_info'), 'amber-settings-admin');
     add_settings_field('amber_backend', 'Backend to use for storing snapshots', array($this, 'amber_backend_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_alternate_backends', 'Alternate backend(s) to use for storing snapshots', array($this, 'amber_alternate_backends_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_max_file', 'Maximum file size (kB)', array($this, 'amber_max_file_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_max_disk', 'Maximum disk usage (MB)', array($this, 'amber_max_disk_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_storage_location', 'Storage location', array($this, 'amber_storage_location_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_perma_api_key', 'Perma API key', array($this, 'amber_perma_api_key_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_perma_server_url', 'Perma URL', array($this, 'amber_perma_server_url_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_perma_api_server_url', 'Perma API URL', array($this, 'amber_perma_api_server_url_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_aws_access_key', 'AWS Access Key', array($this, 'amber_aws_access_key_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_aws_secret_key', 'AWS Secret Access Key', array($this, 'amber_aws_secret_key_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_aws_bucket', 'S3 Bucket', array($this, 'amber_aws_bucket_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_aws_region', 'S3 Region', array($this, 'amber_aws_region_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_post_types', 'Included post types', array($this, 'amber_post_types_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_update_strategy', 'Update strategy for snapshots', array($this, 'amber_update_strategy_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_excluded_sites', 'Excluded URL Patterns', array($this, 'amber_excluded_sites_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_field('amber_excluded_formats', 'Excluded file formats', array($this, 'amber_excluded_formats_callback'), 'amber-settings-admin', 'amber_cache_section');
     add_settings_section('amber_delivery_section', 'Amber Delivery', array($this, 'print_delivery_section_info'), 'amber-settings-admin');
     add_settings_field('amber_available_action', 'Available links', array($this, 'amber_available_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_available_action_hover', 'Hover delay (seconds)', array($this, 'amber_available_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_unavailable_action', 'Unavailable links', array($this, 'amber_unavailable_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_unavailable_action_hover', 'Hover delay (seconds)', array($this, 'amber_unavailable_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_id', 'Country', array($this, 'amber_country_id_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_available_action', 'Available links', array($this, 'amber_country_available_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_available_action_hover', 'Hover delay (seconds)', array($this, 'amber_country_available_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_unavailable_action', 'Unavailable links', array($this, 'amber_country_unavailable_action_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_field('amber_country_unavailable_action_hover', 'Hover delay (seconds)', array($this, 'amber_country_unavailable_action_hover_callback'), 'amber-settings-admin', 'amber_delivery_section');
     add_settings_section('amber_services_section', 'Optional Functionality', array($this, 'print_services_section_info'), 'amber-settings-admin');
     if (isset($this->options['amber_enable_netclerk']) && $this->options['amber_enable_netclerk']) {
         add_settings_field('amber_external_availability', 'Use a third-party database to check site availability', array($this, 'amber_external_availability_callback'), 'amber-settings-admin', 'amber_services_section');
         add_settings_field('amber_report_availability', 'Inform a third-party database of site availability', array($this, 'amber_report_availability_callback'), 'amber-settings-admin', 'amber_services_section');
     }
     add_settings_field('amber_timegate', 'Check a TimeGate server for additional snapshots', array($this, 'amber_timegate_callback'), 'amber-settings-admin', 'amber_services_section');
     register_setting('amber_option_group', 'amber_options', array($this, 'sanitize'));
     Amber::disk_space_purge();
 }
Esempio n. 15
0
 function run()
 {
     Amber::evaluate('module "' . $this->name . '"', $this->code);
 }
Esempio n. 16
0
 /**
  * @access public
  * @abstract
  * @param string
  */
 function run($type)
 {
     Amber::showError('Error', 'Virtual method AmberObject::run() not overridden');
 }
 function test_extract_excluded_site_bad_regexp()
 {
     update_option('amber_options', array('amber_excluded_sites' => "*yahoo.com"));
     $this->checker_stub->method('check')->willReturn(array('status' => 1));
     $post_id = $this->factory->post->create(array('post_content' => 'The quick brown <a href="http://yahoo.com/">fox</a> jumped over the lazy <a href="http://dog.com/yahoo.com">dog</a>'));
     /* This will emit warning messages, but they can be ignored */
     $result = Amber::extract_links($post_id, true);
     $this->assertEquals(2, count($result));
     $this->assertEquals(1, $result["http://yahoo.com/"]);
     $this->assertEquals(1, $result["http://dog.com/yahoo.com"]);
 }
 function test_get_behavior_country_down_hover()
 {
     update_option('amber_options', array('amber_unavailable_action' => AMBER_ACTION_NONE, 'amber_unavailable_action_hover' => 1, 'amber_country_unavailable_action' => AMBER_ACTION_HOVER, 'amber_country_unavailable_action_hover' => 5));
     $this->assertEquals("down hover:5", Amber::get_behavior(false, true));
 }
Esempio n. 19
0
 /**
  * @access public
  * @param string type name (sum, avg, count etc.)
  * @param string section name 
  * @return Object 
  */
 function &createAggregate($type, $sectionName)
 {
     if (isset($this->Sections[$sectionName])) {
         return $this->Sections[$sectionName]->createAggregate($type);
     } else {
         Amber::showError('Error', 'Section "' . $sectionName . "\" not found. Valid section names are:\n" . implode(', ', array_keys($this->Sections)));
     }
 }
Esempio n. 20
0
 function _doQuery()
 {
     $db =& Amber::currentDb();
     if ($this->RowSourceType == 'Table/Query') {
         $db->SetFetchMode(ADODB_FETCH_BOTH);
         $data =& $db->GetAll($this->RowSource);
     }
     if (isset($this->BoundColumn)) {
         // Indexes in Access start with 1
         $bound = $this->BoundColumn - 1;
     } else {
         $bound = 0;
     }
     // FIXME: Determine first visible row -> option value
     $this->_data = array();
     if (is_array($data)) {
         foreach ($data as $idx => $row) {
             $this->_data[$row[$bound]] = $row[1];
         }
     }
 }
Esempio n. 21
0
 public static function ajax_scan()
 {
     /* Maximum number of pages and posts to process in each 
        request. This is used for both pages AND posts, so the
        maximum per request is actually twice this, depending
        on the mix of content on the site */
     check_ajax_referer('amber_dashboard');
     $batch_size = 10;
     $number_remaining = 0;
     $transients = array('amber_scan_pages', 'amber_scan_posts');
     foreach ($transients as $t) {
         $ids = get_transient($t);
         if ($ids !== FALSE && is_array($ids)) {
             $i = $batch_size;
             while (count($ids) > 0 && $i-- > 0) {
                 $id = array_shift($ids);
                 Amber::extract_links($id);
             }
             set_transient($t, $ids, 24 * 60 * 60);
             $number_remaining += count($ids);
         }
     }
     print $number_remaining;
     die;
 }
Esempio n. 22
0
    function render_dashboard_page()
    {
        $this->list_table = new Amber_List_Table();
        $this->list_table->prepare_items();
        ?>
        <div class="wrap">
            <form id="amber_dashboard" method="get">
                <?php 
        wp_nonce_field('amber_dashboard');
        ?>

                <div id="icon-users" class="icon32"><br/></div>
                <h2>Amber Dashboard</h2>           

                <div id="amber-stats">  
                    <h3>Global Statistics</h3>
                    <table>
                        <tbody>
                            <tr><td>Snapshots preserved</td><td><?php 
        print $this->cache_size();
        ?>
</td></tr>
                            <tr><td>Links to snapshot</td><td><?php 
        print $this->queue_size();
        ?>
</td></tr>
                            <tr><td>Last check</td><td><?php 
        print $this->last_check();
        ?>
</td></tr>
                            <tr><td>Disk space used</td><td><?php 
        print $this->disk_usage() . " of " . Amber::get_option('amber_max_disk');
        ?>
 MB</td></tr>
                        </tbody>
                    </table>

                    <?php 
        submit_button("Delete all snapshots", "small", "delete_all");
        ?>
                    <?php 
        submit_button("Scan content for links to preserve", "small", "scan");
        ?>
                    <?php 
        submit_button("Snapshot all new links", "small", "cache_now");
        ?>
                    <?php 
        submit_button("Export list of snapshots", "small", "export");
        ?>
                    
                </div>            
            </form>
            <form  id="amber_dashboard-2">
                <input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" />
                <?php 
        $this->list_table->display();
        ?>

                <div id="amber-lightbox">
                    <div id="amber-lightbox-content">
                        <div id="batch_status"></div>
                        <input type="submit" name="stop" id="stop" class="button button-small" value="Stop">
                    </div>
                </div>
            </form>
        </div>

<style>
    div#amber-stats {
         float: left;
         background:#ECECEC;
         border:1px solid #CCC;
         padding:0 10px;
         margin-top:5px;
         border-radius:5px;
    }

    p.submit {
        float: left;
        padding-right: 20px;
    }

    th.views, td.views
    {
        text-align: center;
    }

    div#amber-lightbox {
        width: 100%;
        height: 75%;
        z-index: 200;
        position: absolute;
        background-color: rgba(0,0,0,.7);
        left: -10px;
        top: 0;
        padding-top: 25%;
        display: none;
    }
    div#amber-lightbox-content {
        float: left;
        width: 50%;
        margin-left: 25%;
        top: 25%;
        postion: absolute;
        background:#ECECEC;
        border:1px solid #CCC;
        padding:30px;
        margin-top:5px;
        border-radius:5px;
    }
    div#batch_status {
        width: 80%;
        overflow: hidden;
        float: left;
    }

    div#amber-lightbox input {
        float: right;
        position: relative;
    }

</style>
<script type="text/javascript" >

jQuery(document).ready(function($) {

    $("input#cache_now").click(function() { cache_all(); return false;});
    $("input#scan").click(function() {  scan_all(); return false;});

    function show_status(s) {
        $("div#amber-lightbox").show();
        $("#batch_status").html(s);
    }

    function show_status_done(s) {
        $("#batch_status").html(s);
        $("#amber-lightbox input").val("Close");
    }

    function cache_one() {
        var data = { 'action': 'amber_cache', '_wpnonce': $("#_wpnonce").val() };
        $.post(ajaxurl, data, function(response) {
            if (response) {
                // Cached a page, check to see if there's another
                show_status("Preserving..." + response);
                setTimeout(cache_one, 100);     
            } else {
                show_status_done("Done preserving links");
            }
        });
    }

    function cache_all () {
        show_status("Preserving links...");
        cache_one();
    }

    function scan_one() {
        var data = { 'action': 'amber_scan', '_wpnonce': $("#_wpnonce").val()};
        $.post(ajaxurl, data, function(response) {
            if (response && response != 0) {
                show_status("Scanning content. " + response + " items remaining.");
                setTimeout(scan_one, 100);      
            } else {
                show_status_done("Done scanning content");
            }
        });
    }

    function scan_all () {
        show_status("Scanning content for links...");
        var data = { 'action': 'amber_scan_start', '_wpnonce': $("#_wpnonce").val() };
        $.post(ajaxurl, data, function(response) {
            if (response) {
                show_status(response + " items left to scan");
                setTimeout(scan_one, 100);
            } else {
                show_status_done("No items to scan");
            }
        });     
    }
});
</script>

        <?php 
    }
Esempio n. 23
0
 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;
 }
Esempio n. 24
0
} else {
    $type = 'html';
    // for a list of possible values see ExporterFactory.php and corresponding include files
}
$mode = 'normal';
if (isset($_GET['mode'])) {
    $mode = $_GET['mode'];
    // 'design' or 'normal'
}
$cfgFileName = '../Amber/conf/localconf.xml';
if (!file_exists($cfgFileName)) {
    Amber::showError('Error: localconf.xml does not exist', 'Amber needs to be configured before you can use it. <br>Use the <a href="../Amber/install/index.php" target="_blank">install tool</a> to set up the database connection.');
    die;
}
$cfg = new AmberConfig();
$cfg->fromXML($cfgFileName);
setlocale(LC_CTYPE, 'de_DE', 'de_DE@euro');
setlocale(LC_TIME, 'de_DE', 'de_DE@euro');
// needed for date, time
setlocale(LC_MONETARY, 'de_DE', 'de_DE@euro');
// needed for numbers
//setlocale (LC_ALL, 'de_DE', 'de_DE@euro');
if (isset($_GET['filter'])) {
    $filter = $_GET['filter'];
}
$amber =& Amber::getInstance($cfg);
if ($mode == 'normal') {
    $amber->OpenReport($repName, AC_NORMAL, $filter, $type);
} else {
    $amber->OpenReport($repName, AC_DESIGN, $filter, $type);
}
Esempio n. 25
0
 /**
  *
  * @access private
  * @param string name of XML file to load
  * @return array parsed XML data
  *
  */
 function &getArray($fileName)
 {
     if (empty($this->_cacheDir)) {
         // This should never happen!
         $this->_cacheDir = '.';
     }
     $cacheFileName = $this->_cacheDir . '/' . md5($fileName);
     //$cacheFileName = $this->_cacheDir . '/' . basename($fileName);
     if (!file_exists($fileName)) {
         Amber::showError('Error', 'XML file not found: ' . htmlspecialchars($fileName));
         die;
     }
     if ($this->_cacheEnabled == true) {
         if (filemtime($fileName) > @filemtime($cacheFileName)) {
             $res =& $this->_makeXMLTree(file_get_contents($fileName));
             $fp = @fopen($cacheFileName, 'w');
             if ($fp != false) {
                 fwrite($fp, serialize($res));
                 fclose($fp);
             }
         } else {
             $res =& unserialize(file_get_contents($cacheFileName));
         }
     } else {
         $res =& $this->_makeXMLTree(file_get_contents($fileName));
     }
     return $res;
 }
Esempio n. 26
0
 /**
  * @static
  * @access public
  * @param string
  */
 function evaluate($name, &$code)
 {
     ob_start();
     $result = eval(' ?' . '>' . $code . '<' . '?php ');
     $message = ob_get_contents();
     ob_end_clean();
     if ($result === false) {
         Amber::showError('Unable to evaluate ' . $name, $message);
         die;
     }
 }
Esempio n. 27
0
 /**
  * @access protected
  * @param string
  * @param AmberObjectRaw
  */
 function saveModule($name, &$obj)
 {
     $modPath = $this->_basePath . '/modules/';
     if (!is_dir($modPath)) {
         Amber::showError('ObjectLoaderFile::saveModule()', 'Directory does not exist: ' . $modPath);
         die;
     }
     $fileNameCode = $modPath . $name . '.php';
     $fp = fopen($fileNameCode, 'w');
     fwrite($fp, $obj->code);
 }