Dotclear

Changeset 4001:a2dd2cb6fd33 for plugins


Ignore:
Timestamp:
07/01/19 11:23:37 (6 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add settings (in maintenance plugin) for CSP system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/maintenance/index.php

    r3994 r4001  
    9999} 
    100100 
     101// Save system settings 
     102 
     103if (!empty($_POST['save_system'])) { 
     104 
     105    try { 
     106        // Default (global) settings 
     107        $core->blog->settings->system->put('csp_admin_on', !empty($_POST['system_csp_global']), null, null, true, true); 
     108        $core->blog->settings->system->put('csp_admin_report_only', !empty($_POST['system_csp_global_report_only']), null, null, true, true); 
     109        // Current blog settings 
     110        $core->blog->settings->system->put('csp_admin_on', !empty($_POST['system_csp'])); 
     111        $core->blog->settings->system->put('csp_admin_report_only', !empty($_POST['system_csp_report_only'])); 
     112 
     113        dcPage::addSuccessNotice(__('System settings have been saved.')); 
     114 
     115        if (!empty($_POST['system_csp_reset'])) { 
     116            $core->blog->settings->system->dropEvery('csp_admin_on'); 
     117            $core->blog->settings->system->dropEvery('csp_admin_report_only'); 
     118            dcPage::addSuccessNotice(__('All blog\'s Content-Security-Policy settings have been reset to default.')); 
     119        } 
     120 
     121        http::redirect($p_url . '&tab=' . $tab . '#' . $tab); 
     122    } catch (Exception $e) { 
     123        $core->error->add($e->getMessage()); 
     124    } 
     125} 
     126 
    101127// Combos 
    102128 
     
    127153<body>'; 
    128154 
    129 // Check if there is somthing to display according to user permissions 
     155// Check if there is something to display according to user permissions 
    130156if (empty($tasks)) { 
    131157    echo dcPage::breadcrumb( 
     
    324350        '</form>' . 
    325351        '</div>'; 
     352 
     353    // System tab 
     354    if ($core->auth->isSuperAdmin()) { 
     355        echo 
     356        '<div id="system" class="multi-part" title="' . __('System') . '">' . 
     357        '<h3>' . __('System settings') . '</h3>' . 
     358            '<form action="' . $p_url . '" method="post">'; 
     359 
     360        echo 
     361        '<div class="fieldset two-cols clearfix">' . 
     362        '<h4 class="pretty-title">' . __('Content-Security-Policy') . '</h4>' . 
     363 
     364        '<div class="col">' . 
     365        '<p><label for="system_csp" class="classic">' . 
     366        form::checkbox('system_csp', '1', $core->blog->settings->system->csp_admin_on) . 
     367        __('Enable Content-Security-Policy system') . '</label></p>' . 
     368        '<p><label for="system_csp_report_only" class="classic">' . 
     369        form::checkbox('system_csp_report_only', '1', $core->blog->settings->system->csp_admin_report_only) . 
     370        __('Enable Content-Security-Policy report only') . '</label></p>' . 
     371        '</div>' . 
     372 
     373        '<div class="col">' . 
     374        '<p><label for="system_csp_global" class="classic">' . 
     375        form::checkbox('system_csp_global', '1', $core->blog->settings->system->getGlobal('csp_admin_on')) . 
     376        __('Enable Content-Security-Policy system by default') . '</label></p>' . 
     377        '<p><label for="system_csp_global_report_only" class="classic">' . 
     378        form::checkbox('system_csp_global_report_only', '1', $core->blog->settings->system->getGlobal('csp_admin_report_only')) . 
     379        __('Enable Content-Security-Policy report only by default') . '</label></p>' . 
     380        '<p><label for="system_csp_reset" class="classic">' . 
     381        form::checkbox('system_csp_reset', '1', 0) . 
     382        __('Also reset all Content-Security-Policy blogs\'s settings to default') . '</label></p>' . 
     383        '</div>' . 
     384        '</div>'; 
     385 
     386        echo 
     387        '<p class="field wide"><input type="submit" value="' . __('Save') . '" /> ' . 
     388        form::hidden(['tab'], 'system') . 
     389        form::hidden(['save_system'], 1) . 
     390        $core->formNonce() . '</p>' . 
     391            '</form>' . 
     392            '</div>'; 
     393    } 
     394 
    326395} 
    327396 
Note: See TracChangeset for help on using the changeset viewer.

Sites map