⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php  //$Id: lib.php,v 1.3.2.14 2009/03/26 20:59:31 skodak Exp $/////////////////////////////////////////////////////////////////////////////                                                                       //// NOTICE OF COPYRIGHT                                                   ////                                                                       //// Moodle - Modular Object-Oriented Dynamic Learning Environment         ////          http://moodle.org                                            ////                                                                       //// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     ////                                                                       //// This program is free software; you can redistribute it and/or modify  //// it under the terms of the GNU General Public License as published by  //// the Free Software Foundation; either version 2 of the License, or     //// (at your option) any later version.                                   ////                                                                       //// This program is distributed in the hope that it will be useful,       //// but WITHOUT ANY WARRANTY; without even the implied warranty of        //// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //// GNU General Public License for more details:                          ////                                                                       ////          http://www.gnu.org/copyleft/gpl.html                         ////                                                                       /////////////////////////////////////////////////////////////////////////////require_once("$CFG->libdir/adminlib.php");define('REPORT_SECURITY_OK', 'ok');define('REPORT_SECURITY_INFO', 'info');define('REPORT_SECURITY_WARNING', 'warning');define('REPORT_SECURITY_SERIOUS', 'serious');define('REPORT_SECURITY_CRITICAL', 'critical');function report_security_hide_timearning() {     echo '<script type="text/javascript">//<![CDATA[    var el = document.getElementById("timewarning");    el.setAttribute("class", "timewarninghidden");//]]></script>';}function report_security_get_issue_list() {    return array(        'report_security_check_globals',        'report_security_check_unsecuredataroot',        'report_security_check_displayerrors',        'report_security_check_noauth',        'report_security_check_embed',        'report_security_check_mediafilterswf',        'report_security_check_openprofiles',        'report_security_check_google',        'report_security_check_passwordpolicy',        'report_security_check_emailchangeconfirmation',        'report_security_check_cookiesecure',        'report_security_check_configrw',        'report_security_check_riskxss',        'report_security_check_riskadmin',        'report_security_check_defaultuserrole',        'report_security_check_guestrole',        'report_security_check_frontpagerole',        'report_security_check_defaultcourserole',        'report_security_check_courserole',    );}function report_security_doc_link($issue, $name) {    global $CFG;    if (empty($CFG->docroot)) {        return $name;    }    $lang = str_replace('_utf8', '', current_language());    $str = "<a onclick=\"this.target='docspopup'\" href=\"$CFG->docroot/$lang/report/security/$issue\">";    $str .= "<img class=\"iconhelp\" src=\"$CFG->httpswwwroot/pix/docs.gif\" alt=\"\" />$name</a>";    return $str;}///=============================================///               Issue checks///=============================================/** * Verifies register globals PHP setting. * @param bool $detailed * @return object result */function report_security_check_globals($detailed=false) {    $result = new object();    $result->issue   = 'report_security_check_globals';    $result->name    = get_string('check_globals_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = null;    if (ini_get_bool('register_globals')) {        $result->status = REPORT_SECURITY_CRITICAL;        $result->info   = get_string('check_globals_error', 'report_security');    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_globals_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_globals_details', 'report_security');    }    return $result;}/** * Verifies unsupported noauth setting * @param bool $detailed * @return object result */function report_security_check_noauth($detailed=false) {    global $CFG;    $result = new object();    $result->issue   = 'report_security_check_noauth';    $result->name    = get_string('check_noauth_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = null;    $result->link    = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths\">".get_string('authsettings', 'admin').'</a>';    if (is_enabled_auth('none')) {        $result->status = REPORT_SECURITY_CRITICAL;        $result->info   = get_string('check_noauth_error', 'report_security');    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_noauth_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_noauth_details', 'report_security');    }    return $result;}/** * Verifies if password policy set * @param bool $detailed * @return object result */function report_security_check_passwordpolicy($detailed=false) {    global $CFG;    $result = new object();    $result->issue   = 'report_security_check_passwordpolicy';    $result->name    = get_string('check_passwordpolicy_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=sitepolicies\">".get_string('sitepolicies', 'admin').'</a>';    if (empty($CFG->passwordpolicy)) {        $result->status = REPORT_SECURITY_WARNING;        $result->info   = get_string('check_passwordpolicy_error', 'report_security');    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_passwordpolicy_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_passwordpolicy_details', 'report_security');    }    return $result;}/** * Verifies sloppy embedding - this should have been removed long ago!! * @param bool $detailed * @return object result */function report_security_check_embed($detailed=false) {    global $CFG;    $result = new object();    $result->issue   = 'report_security_check_embed';    $result->name    = get_string('check_embed_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=sitepolicies\">".get_string('sitepolicies', 'admin').'</a>';    if (!empty($CFG->allowobjectembed)) {        $result->status = REPORT_SECURITY_CRITICAL;        $result->info   = get_string('check_embed_error', 'report_security');    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_embed_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_embed_details', 'report_security');    }    return $result;}/** * Verifies sloppy swf embedding - this should have been removed long ago!! * @param bool $detailed * @return object result */function report_security_check_mediafilterswf($detailed=false) {    global $CFG;    $result = new object();    $result->issue   = 'report_security_check_mediafilterswf';    $result->name    = get_string('check_mediafilterswf_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=filtersettingfiltermediaplugin\">".get_string('filtersettings', 'admin').'</a>';    if (!empty($CFG->textfilters)) {        $activefilters = explode(',', $CFG->textfilters);    } else {        $activefilters = array();    }    if (array_search('filter/mediaplugin', $activefilters) !== false and !empty($CFG->filter_mediaplugin_enable_swf)) {        $result->status = REPORT_SECURITY_CRITICAL;        $result->info   = get_string('check_mediafilterswf_error', 'report_security');    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_mediafilterswf_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_mediafilterswf_details', 'report_security');    }    return $result;}/** * Verifies fatal misconfiguration of dataroot * @param bool $detailed * @return object result */function report_security_check_unsecuredataroot($detailed=false) {    global $CFG;    $result = new object();    $result->issue   = 'report_security_check_unsecuredataroot';    $result->name    = get_string('check_unsecuredataroot_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = null;    $insecuredataroot = is_dataroot_insecure(true);    if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {        $result->status = REPORT_SECURITY_SERIOUS;        $result->info   = get_string('check_unsecuredataroot_warning', 'report_security', $CFG->dataroot);    } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {        $result->status = REPORT_SECURITY_CRITICAL;        $result->info   = get_string('check_unsecuredataroot_error', 'report_security', $CFG->dataroot);    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_unsecuredataroot_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_unsecuredataroot_details', 'report_security');    }    return $result;}/** * Verifies disaplying of errors - problem for lib files and 3rd party code * because we can not disable debugging in these scripts (they do not include config.php) * @param bool $detailed * @return object result */function report_security_check_displayerrors($detailed=false) {    $result = new object();    $result->issue   = 'report_security_check_displayerrors';    $result->name    = get_string('check_displayerrors_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = null;    if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {        $result->status = REPORT_SECURITY_WARNING;        $result->info   = get_string('check_displayerrors_error', 'report_security');    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_displayerrors_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_displayerrors_details', 'report_security');    }    return $result;}/** * Verifies open profiles - originaly open by default, not anymore because spammer abused it a lot * @param bool $detailed * @return object result */function report_security_check_openprofiles($detailed=false) {    global $CFG;    $result = new object();    $result->issue   = 'report_security_check_openprofiles';    $result->name    = get_string('check_openprofiles_name', 'report_security');    $result->info    = null;    $result->details = null;    $result->status  = null;    $result->link    = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=sitepolicies\">".get_string('sitepolicies', 'admin').'</a>';    if (empty($CFG->forcelogin) and empty($CFG->forceloginforprofiles)) {        $result->status = REPORT_SECURITY_WARNING;        $result->info   = get_string('check_openprofiles_error', 'report_security');    } else {        $result->status = REPORT_SECURITY_OK;        $result->info   = get_string('check_openprofiles_ok', 'report_security');    }    if ($detailed) {        $result->details = get_string('check_openprofiles_details', 'report_security');    }    return $result;}/** * Verifies google access not combined with disabled guest access * because attackers might gain guest access by modifying browser signature. * @param bool $detailed * @return object result */function report_security_check_google($detailed=false) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -