コード例 #1
0
ファイル: security.php プロジェクト: alexpagnoni/ampoliros
function main_settings($eventData)
{
    global $gEnv, $gXml_def, $gLocale, $gPage_title;
    $amp_security = new SecurityLayer();
    $session_lifetime = $amp_security->GetSessionLifetime();
    $max_wrong_logins = $amp_security->GetMaxWrongLogins();
    $wrong_login_delay = $amp_security->GetWrongLoginDelay();
    $lock_unsecure_webservices = $amp_security->GetUnsecureWebServicesLock();
    $only_https_root = $amp_security->GetOnlyHttpsRootAccess();
    $only_https_site = $amp_security->GetOnlyHttpsSiteAccess();
    $alerts_on = $amp_security->GetAlertEvents();
    $wrong_local_root_login = $alerts_on['wronglocalrootlogin'] ? 'true' : 'false';
    $wrong_local_user_login = $alerts_on['wronglocaluserlogin'] ? 'true' : 'false';
    $wrong_remote_login = $alerts_on['wrongremotelogin'] ? 'true' : 'false';
    $module_operation = $alerts_on['moduleoperation'] ? 'true' : 'false';
    $sitemodule_operation = $alerts_on['modulesiteoperation'] ? 'true' : 'false';
    $site_operation = $alerts_on['siteoperation'] ? 'true' : 'false';
    $reports_interval = $amp_security->GetReportsInterval();
    $reports_enabled = $reports_interval ? 'true' : 'false';
    $report_destination_email = $amp_security->GetReportsEmail();
    $alert_destination_email = $amp_security->GetAlertsEmail();
    $tabs[0]['label'] = $gLocale->GetStr('security_presets.tab');
    $tabs[1]['label'] = $gLocale->GetStr('access_settings.tab');
    $tabs[2]['label'] = $gLocale->GetStr('alerts_settings.tab');
    $tabs[3]['label'] = $gLocale->GetStr('reports_settings.tab');
    $gXml_def = '<tab><name>security</name>
      <args>
        <tabs type="array">' . huixml_encode($tabs) . '</tabs>
        <tabactionfunction>settings_tab_builder</tabactionfunction>
        <activetab>' . (isset($eventData['tab']) ? $eventData['tab'] : '') . '</activetab>
      </args>
      <children>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>presets</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('security_presets.label')))) . '</headers>
              </args>
              <children>
    
              <button row="0" col="0"><name>preset</name>
                <args>
                  <themeimage>decrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_low.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_LOW))))) . '</action>
                </args>
              </button>
    
              <label row="0" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_low.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              <button row="1" col="0"><name>preset</name>
                <args>
                  <themeimage>encrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_normal.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_NORMAL))))) . '</action>
                </args>
              </button>
    
              <label row="1" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_normal.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              <button row="2" col="0"><name>preset</name>
                <args>
                  <themeimage>encrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_high.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_HIGH))))) . '</action>
                </args>
              </button>
    
              <label row="2" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_high.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              <button row="3" col="0"><name>preset</name>
                <args>
                  <themeimage>encrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_paranoid.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_PARANOID))))) . '</action>
                </args>
              </button>
    
              <label row="3" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_paranoid.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              </children>
            </table>
    
          </children>
        </vertgroup>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>access</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('access_settings.label')))) . '</headers>
              </args>
              <children>
    
                <form row="0" col="0"><name>access</name>
                  <args>
                    <method>post</method>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_access_prefs', '')))) . '</action>
                  </args>
                  <children>
                    <grid>
                      <children>
    
                        <label row="0" col="0"><name>sessionlifetime</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('session_lifetime.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="0" col="1"><name>sessionlifetime</name>
                          <args>
                            <value>' . $session_lifetime . '</value>
                            <disp>action</disp>
                            <size>10</size>
                          </args>
                        </string>
    
                        <label row="1" col="0"><name>maxwronglogins</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('max_wrong_logins.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="1" col="1"><name>maxwronglogins</name>
                          <args>
                            <value>' . $max_wrong_logins . '</value>
                            <disp>action</disp>
                            <size>4</size>
                          </args>
                        </string>
    
                        <label row="2" col="0"><name>wronglogindelay</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_login_delay.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="2" col="1"><name>wronglogindelay</name>
                          <args>
                            <value>' . $wrong_login_delay . '</value>
                            <disp>action</disp>
                            <size>3</size>
                          </args>
                        </string>
    
                        <label row="3" col="0"><name>lockunsecurewebservices</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('block_unsecure_webservices.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="3" col="1"><name>lockunsecurewebservices</name>
                          <args>
                            <checked>' . ($lock_unsecure_webservices ? 'true' : 'false') . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="4" col="0"><name>onlyhttpsroot</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('only_https_root.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="4" col="1"><name>onlyhttpsroot</name>
                          <args>
                            <checked>' . ($only_https_root ? 'true' : 'false') . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="5" col="0"><name>onlyhttpssite</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('only_https_site.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="5" col="1"><name>onlyhttpssite</name>
                          <args>
                            <checked>' . ($only_https_site ? 'true' : 'false') . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                      </children>
                    </grid>
                  </children>
                </form>
    
                <button row="1" col="0"><name>apply</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <label type="encoded">' . urlencode($gLocale->GetStr('apply.submit')) . '</label>
                    <themeimage>button_ok</themeimage>
                    <formsubmit>access</formsubmit>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_access_prefs', '')))) . '</action>
                  </args>
                </button>
              </children>
            </table>
    
          </children>
        </vertgroup>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>alerts</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('alerts_settings.label')))) . '</headers>
              </args>
              <children>
    
                <form row="0" col="0"><name>alerts</name>
                  <args>
                    <method>post</method>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_alerts_prefs', '')))) . '</action>
                  </args>
                  <children>
                    <grid>
                      <children>
    
                        <label row="0" col="0"><name>alertonevents</name>
                          <args>
                            <bold>true</bold>
                            <label type="encoded">' . urlencode($gLocale->GetStr('alert_on_events.label')) . '</label>
                          </args>
                        </label>
    
                        <label row="1" col="0"><name>wronglocalrootlogin</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_local_root_login.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="1" col="1"><name>wronglocalrootlogin</name>
                          <args>
                            <checked>' . $wrong_local_root_login . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="2" col="0"><name>wronglocaluserlogin</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_local_user_login.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="2" col="1"><name>wronglocaluserlogin</name>
                          <args>
                            <checked>' . $wrong_local_user_login . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="3" col="0"><name>wrongremotelogin</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_remote_login.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="3" col="1"><name>wrongremotelogin</name>
                          <args>
                            <checked>' . $wrong_remote_login . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="4" col="0"><name>moduleoperation</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('module_operation.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="4" col="1"><name>moduleoperation</name>
                          <args>
                            <checked>' . $module_operation . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="5" col="0"><name>sitemoduleoperation</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('sitemodule_operation.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="5" col="1"><name>sitemoduleoperation</name>
                          <args>
                            <checked>' . $sitemodule_operation . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="6" col="0"><name>siteoperation</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('site_operation.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="6" col="1"><name>siteoperation</name>
                          <args>
                            <checked>' . $site_operation . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="7" col="0"><name>alertdestinationemail</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('alert_destination_email.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="7" col="1"><name>alertdestinationemail</name>
                          <args>
                            <value type="encoded">' . urlencode($alert_destination_email) . '</value>
                            <disp>action</disp>
                            <size>25</size>
                          </args>
                        </string>
    
                      </children>
                    </grid>
                  </children>
                </form>
    
                <button row="1" col="0"><name>apply</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <label type="encoded">' . urlencode($gLocale->GetStr('apply.submit')) . '</label>
                    <themeimage>button_ok</themeimage>
                    <formsubmit>alerts</formsubmit>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_alerts_prefs', '')))) . '</action>
                  </args>
                </button>
              </children>
            </table>
    
          </children>
        </vertgroup>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>alerts</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('reports_settings.label')))) . '</headers>
              </args>
              <children>
    
                <form row="0" col="0"><name>alerts</name>
                  <args>
                    <method>post</method>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_reports_prefs', '')))) . '</action>
                  </args>
                  <children>
                    <grid>
                      <children>
    
                        <label row="0" col="0"><name>enablereports</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('enable_reports.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="0" col="1"><name>enablereports</name>
                          <args>
                            <checked>' . $reports_enabled . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="1" col="0"><name>reportsinterval</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('reports_interval.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="1" col="1"><name>reportsinterval</name>
                          <args>
                            <value>' . $reports_interval . '</value>
                            <disp>action</disp>
                            <size>3</size>
                          </args>
                        </string>
    
                        <label row="2" col="0"><name>reportdestinationemail</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('report_destination_email.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="2" col="1"><name>reportdestinationemail</name>
                          <args>
                            <value type="encoded">' . urlencode($report_destination_email) . '</value>
                            <disp>action</disp>
                            <size>25</size>
                          </args>
                        </string>
    
                      </children>
                    </grid>
                  </children>
                </form>
    
                <button row="1" col="0"><name>apply</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <label type="encoded">' . urlencode($gLocale->GetStr('apply.submit')) . '</label>
                    <themeimage>button_ok</themeimage>
                    <formsubmit>alerts</formsubmit>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_reports_prefs', '')))) . '</action>
                  </args>
                </button>
              </children>
            </table>
    
          </children>
        </vertgroup>
    
      </children>
    </tab>';
    $gPage_title .= ' - ' . $gLocale->GetStr('settings.title');
}