Example #1
0
// Highlight the requested tab (if valid):
$AdminUI->set_path('options', 'misc', !empty($tab) ? $tab : $tab3);
if (empty($tab)) {
    // "Main tab" actions:
    if (param('action', 'string', '')) {
        // Check that this action request is not a CSRF hacked request:
        $Session->assert_received_crumb('tools');
        // fp> TODO: have an option to only PRUNE files older than for example 30 days
        $current_User->check_perm('options', 'edit', true);
    }
    set_max_execution_time(0);
    $Plugins->trigger_event('AdminToolAction');
    switch ($action) {
        case 'del_itemprecache':
            // Clear pre-rendered item cache (DB)
            dbm_delete_itemprecache();
            break;
        case 'del_commentprecache':
            // Clear pre-rendered comment cache (DB)
            dbm_delete_commentprecache();
            break;
        case 'del_messageprecache':
            // Clear pre-rendered message cache (DB)
            dbm_delete_messageprecache();
            break;
        case 'del_pagecache':
            // Delete the page cache /blogs/cache
            dbm_delete_pagecache();
            break;
        case 'del_filecache':
            // delete the thumbnail cahces .evocache
/**
 * Convert item content separators to new format
 */
function dbm_convert_item_content_separators()
{
    global $DB;
    // Display process status
    // TRANS: "more", "teaserbreak", "nextpage" and "pagebreak" must NOT be translated.
    echo T_('Convert item content separators from <!--more--> to [teaserbreak] and <!--nextpage--> to [pagebreak]...');
    evo_flush();
    $DB->query('UPDATE T_items__item
		SET post_content = REPLACE( REPLACE( REPLACE( REPLACE( post_content,
			"<!--more-->",     "[teaserbreak]" ),
			"<!--more-->",           "[teaserbreak]" ),
			"&lt;!--nextpage--&gt;", "[pagebreak]" ),
			"<!--nextpage-->",       "[pagebreak]" )');
    /* test code to return to old separators to see how it works with old separators
    	$DB->query( 'UPDATE T_items__item
    		SET post_content = REPLACE( REPLACE( post_content,
    			"[teaserbreak]", "<!--more-->" ),
    			"[pagebreak]",   "<!--nextpage-->" )' );
    	*/
    $item_updated_count = intval($DB->rows_affected);
    if ($item_updated_count > 0) {
        // Some separators were updated
        echo ' ' . sprintf(T_('%d items have been updated.'), $item_updated_count);
        // To see the changes we should update the pre-rendered item contents
        echo '<br />' . T_('Clear pre-rendered item cache (DB)') . '...';
        dbm_delete_itemprecache();
        echo ' OK.';
    } else {
        // No old separators in DB
        echo ' ' . T_('No old separators were found.');
    }
    echo "<br />\n";
}