Exemplo n.º 1
0
 function process_autoblog()
 {
     global $wpdb;
     // Our starting time
     $timestart = current_time('timestamp');
     //Or processing limit
     $timelimit = AUTOBLOG_PROCESSING_TIMELIMIT;
     // max seconds for processing
     $lastprocessing = get_autoblog_option('autoblog_processing', strtotime('-1 week', current_time('timestamp')));
     if ($lastprocessing < strtotime('-' . AUTOBLOG_PROCESSING_CHECKLIMIT . ' minutes', current_time('timestamp'))) {
         update_autoblog_option('autoblog_processing', current_time('timestamp'));
         // grab the feeds
         $autoblogs = $this->get_autoblogentries(current_time('timestamp'));
         foreach ((array) $autoblogs as $key => $ablog) {
             if (current_time('timestamp') > $timestart + $timelimit) {
                 // time out
                 $this->msgs[] = __('<strong>Notice:</strong> Processing stopped due to ' . $timelimit . ' second timeout.', 'autoblogtext');
                 break;
             }
             $details = unserialize($ablog->feed_meta);
             $process = false;
             if (isset($details['processfeed']) && $details['processfeed'] > 0) {
                 $process = true;
             } else {
                 $process = false;
             }
             if ($process) {
                 do_action('autoblog_pre_process_feed', $ablog->feed_id, $details);
                 $this->process_feed($ablog->feed_id, $details);
                 do_action('autoblog_post_process_feed', $ablog->feed_id, $details);
             }
         }
     } else {
     }
     if (!empty($this->msgs)) {
         $this->record_msg();
     }
 }
Exemplo n.º 2
0
    function handle_admin_page()
    {
        global $action, $page;
        // Handle the editing and adding pages
        if (isset($_GET['action']) && $_GET['action'] == 'add') {
            // We are adding a new feed
            $this->handle_addnew_page();
            return;
        }
        $showlist = true;
        $current_offset = get_option('gmt_offset');
        $timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
        $messages = array();
        $messages[1] = __('Your feed has been added.', 'autoblogtext');
        $messages[2] = __('Your feed has been updated.', 'autoblogtext');
        $messages[3] = __('Your feed(s) have been deleted.', 'autoblogtext');
        $messages[4] = __('Your feed(s) has been processed.', 'autoblogtext');
        $messages[7] = __('Your feed has been tested.', 'autoblogtext');
        $messages[8] = __('Your feed(s) has been processed.', 'autoblogtext');
        $errors = array();
        $errors[1] = __('Your feed could not be added.', 'autoblogtext');
        $errors[2] = __('Your feed could not be updated.', 'autoblogtext');
        $errors[3] = __('Your feed(s) could not be deleted.', 'autoblogtext');
        $errors[4] = __('Your feed(s) could not be processed.', 'autoblogtext');
        $errors[5] = __('Please select a feed to delete.', 'autoblogtext');
        $errors[6] = __('Please select a feed to process.', 'autoblogtext');
        $errors[7] = __('Your feed could not be tested.', 'autoblogtext');
        $errors[8] = __('No new entries in your feed(s).', 'autoblogtext');
        if (isset($_GET['edit']) && is_numeric(addslashes($_GET['edit']))) {
            $this->handle_edit_page(addslashes($_GET['edit']));
            return;
        }
        // If we are still here then we are wanting to view the list
        echo "<div class='wrap'>";
        // Show the heading
        echo '<div class="icon32" id="icon-edit"><br/></div>';
        echo "<h2>" . __('Auto Blog Feeds', 'autoblogtext') . '<a class="add-new-h2" href="admin.php?page=' . $page . '&action=add">' . __('Add New', 'membership') . '</a></h2>';
        echo "<br/>";
        if (isset($_GET['msg'])) {
            echo '<div id="message" class="updated fade"><p>' . $messages[(int) $_GET['msg']] . '</p></div>';
            $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
        }
        if (isset($_GET['err'])) {
            echo '<div id="message" class="error fade"><p>' . $errors[(int) $_GET['err']] . '</p></div>';
            $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
        }
        $testlog = get_autoblog_option('autoblog_last_test_log', false);
        if (!empty($testlog) && $testlog !== false && isset($_GET['msg']) && (int) $_GET['msg'] == 7) {
            echo '<div id="testmessage" class="updated fade"><p>';
            echo implode('<br/>', $testlog['log']);
            echo '</p></div>';
        }
        echo "<form action='' method='post'>";
        echo "<input type='hidden' name='action' value='autoblog' />";
        wp_nonce_field('autoblog');
        echo '<div class="tablenav">';
        echo '<div class="alignleft actions">';
        ?>
			<select name="bulkaction">
			<option selected="selected" value=""><?php 
        _e('Bulk Actions', 'popover');
        ?>
</option>
			<option value="process"><?php 
        _e('Process', 'autoblogtext');
        ?>
</option>
			<option value="delete"><?php 
        _e('Delete', 'autoblogtext');
        ?>
</option>
			</select>
			<input type="submit" class="button-secondary action" id="doaction" name="doaction" value="<?php 
        _e('Apply', 'popover');
        ?>
">
		<?php 
        echo '</div>';
        echo '<div class="alignright actions">';
        echo '</div>';
        echo '</div>';
        // New table based layout
        echo '<table width="100%" cellpadding="3" cellspacing="3" class="widefat" style="width: 100%;">';
        echo '<thead>';
        echo '<tr>';
        echo '<th scope="col" class="manage-column column-cb check-column">';
        echo "<input type='checkbox' />";
        echo '</th>';
        echo '<th scope="col">';
        echo __('Feed title', 'autoblogtext');
        echo '</th>';
        echo '<th scope="col">';
        echo __('Feed post type', 'autoblogtext');
        echo '</th>';
        if (function_exists('is_network_admin') && is_network_admin()) {
            echo '<th scope="col">';
            echo __('Feed target', 'autoblogtext');
            echo '</th>';
            echo '<th scope="col" style="text-align: right;">';
            echo __('Last processed *', 'autoblogtext');
            echo '</th>';
            echo '<th scope="col" style="text-align: right;">';
            echo __('Next check *', 'autoblogtext');
            echo '</th>';
        } else {
            echo '<th scope="col" style="text-align: right;">';
            echo __('Last processed', 'autoblogtext');
            echo '</th>';
            echo '<th scope="col" style="text-align: right;">';
            echo __('Next check', 'autoblogtext');
            echo '</th>';
        }
        do_action('autoblog_admin_columns');
        echo '</tr>';
        echo '</thead>';
        echo '<tfoot>';
        echo '<tr>';
        echo '<th scope="col" class="manage-column column-cb check-column">';
        echo "<input type='checkbox'/>";
        echo '</th>';
        echo '<th scope="col">';
        echo __('Feed title', 'autoblogtext');
        echo '</th>';
        echo '<th scope="col">';
        echo __('Feed post type', 'autoblogtext');
        echo '</th>';
        if (function_exists('is_network_admin') && is_network_admin()) {
            echo '<th scope="col">';
            echo __('Feed target', 'autoblogtext');
            echo '</th>';
            echo '<th scope="col" style="text-align: right;">';
            echo __('Last processed *', 'autoblogtext');
            echo '</th>';
            echo '<th scope="col" style="text-align: right;">';
            echo __('Next check *', 'autoblogtext');
            echo '</th>';
        } else {
            echo '<th scope="col" style="text-align: right;">';
            echo __('Last processed', 'autoblogtext');
            echo '</th>';
            echo '<th scope="col" style="text-align: right;">';
            echo __('Next check', 'autoblogtext');
            echo '</th>';
        }
        do_action('autoblog_admin_columns');
        echo '</tr>';
        echo '</tfoot>';
        echo '<tbody id="the-list">';
        $autoblogs = $this->get_autoblogentries();
        if (!empty($autoblogs)) {
            foreach ($autoblogs as $key => $table) {
                $details = maybe_unserialize($table->feed_meta);
                //$this->show_table($key, $table);
                echo '<tr>';
                ?>
				<td class="check-column" scope="row"><input type="checkbox" value="<?php 
                echo $table->feed_id;
                ?>
" name="select[]"></td>
				<?php 
                echo '<td>';
                if (function_exists('is_network_admin') && is_network_admin()) {
                    echo '<a href="' . network_admin_url("admin.php?page=autoblog_admin&amp;edit=" . $table->feed_id) . '">';
                } else {
                    echo '<a href="' . admin_url("admin.php?page=autoblog_admin&amp;edit=" . $table->feed_id) . '">';
                }
                if (!empty($details)) {
                    echo esc_html(stripslashes($details['title']));
                } else {
                    echo __('No title set', 'autoblogtext');
                }
                echo '</a>';
                //network_admin_url
                echo '<div class="row-actions">';
                $actions = array();
                if (function_exists('is_network_admin') && is_network_admin()) {
                    $actions[] = "<a href='" . network_admin_url("admin.php?page=autoblog_admin&amp;edit=" . $table->feed_id) . "' class='editfeed'>" . __('Edit', 'autoblogtext') . "</a>";
                    $actions[] = "<a href='" . wp_nonce_url(network_admin_url("admin.php?page=autoblog_admin&amp;delete=" . $table->feed_id), 'autoblogdelete') . "' class='deletefeed'>" . __('Delete', 'autoblogtext') . "</a>";
                    $actions[] = "<a href='" . wp_nonce_url(network_admin_url("admin.php?page=autoblog_admin&amp;process=" . $table->feed_id), 'autoblogprocess') . "' class='processfeed'>" . __('Process', 'autoblogtext') . "</a>";
                    $actions[] = "<a href='" . wp_nonce_url(network_admin_url("admin.php?page=autoblog_admin&amp;test=" . $table->feed_id), 'autoblogtest') . "' class='testfeed'>" . __('Test', 'autoblogtext') . "</a>";
                    $actions = apply_filters('autoblog_networkadmin_actions', $actions, $table->feed_id);
                } else {
                    $actions[] = "<a href='" . admin_url("admin.php?page=autoblog_admin&amp;edit=" . $table->feed_id) . "' class='editfeed'>" . __('Edit', 'autoblogtext') . "</a>";
                    $actions[] = "<a href='" . wp_nonce_url(admin_url("admin.php?page=autoblog_admin&amp;delete=" . $table->feed_id), 'autoblogdelete') . "' class='deletefeed'>" . __('Delete', 'autoblogtext') . "</a>";
                    $actions[] = "<a href='" . wp_nonce_url(admin_url("admin.php?page=autoblog_admin&amp;process=" . $table->feed_id), 'autoblogprocess') . "' class='processfeed'>" . __('Process', 'autoblogtext') . "</a>";
                    $actions[] = "<a href='" . wp_nonce_url(admin_url("admin.php?page=autoblog_admin&amp;test=" . $table->feed_id), 'autoblogtest') . "' class='testfeed'>" . __('Test', 'autoblogtext') . "</a>";
                    $actions = apply_filters('autoblog_networkadmin_actions', $actions, $table->feed_id);
                }
                echo implode(' | ', $actions);
                echo '</div>';
                echo '</td>';
                echo "<td>";
                echo $details['posttype'];
                echo "</td>";
                if (function_exists('is_network_admin') && is_network_admin()) {
                    echo "<td>";
                    echo esc_html(get_blog_option($table->blog_id, 'blogname'));
                    echo "</td>";
                }
                echo '<td style="text-align: right;">';
                if ($table->lastupdated != 0) {
                    echo "<abbr title='" . date_i18n($timezone_format, $table->lastupdated) . "'>";
                    echo autoblog_time2str($table->lastupdated);
                    echo "</abbr>";
                    //echo date_i18n($timezone_format, $table->lastupdated);
                    //echo date("j M Y : H:i", $table->lastupdated);
                } else {
                    echo __('Never', 'autoblogtext');
                }
                echo '</td>';
                echo '<td style="text-align: right;">';
                if ($table->nextcheck != 0) {
                    echo "<abbr title='" . date_i18n($timezone_format, $table->nextcheck) . "'>";
                    echo autoblog_time2str($table->nextcheck);
                    echo "</abbr>";
                } else {
                    echo __('Never', 'autoblogtext');
                }
                echo '</td>';
                do_action('autoblog_admin_columns_data', $table);
                echo '</tr>';
            }
        } else {
            echo '<tr>';
            echo '<td>';
            echo '</td>';
            echo '<td colspan="5">';
            echo __('You do not have any feeds setup - please click Add New to get started', 'autoblogtext');
            echo '</td>';
            echo '</tr>';
        }
        echo '</tbody>';
        echo '</table>';
        echo '<div class="tablenav">';
        echo '<div class="alignleft actions">';
        ?>
			<select name="bulkaction2">
			<option selected="selected" value=""><?php 
        _e('Bulk Actions', 'popover');
        ?>
</option>
			<option value="process"><?php 
        _e('Process', 'autoblogtext');
        ?>
</option>
			<option value="delete"><?php 
        _e('Delete', 'autoblogtext');
        ?>
</option>
			</select>
			<input type="submit" class="button-secondary action" id="doaction2" name="doaction2" value="<?php 
        _e('Apply', 'popover');
        ?>
">
		<?php 
        echo '</div>';
        echo '<div class="alignright actions">';
        echo '</div>';
        echo '</div>';
        echo "</form>";
        if (function_exists('is_network_admin') && is_network_admin()) {
            echo "<p>" . __('* Times and dates are local to each site.', 'autoblogtext') . "</p>";
        }
        echo "</div>";
        // wrap
    }