コード例 #1
0
ファイル: edit.php プロジェクト: scyrma/moodle-local_hub
<?php

require '../../../../config.php';
require_once $CFG->dirroot . '/local/hub/top/sites/siteslib.php';
require_login();
if (!ismoodlesiteadmin()) {
    print_error('erroradminonly', 'local_hub');
}
$cool = optional_param('cool', '', PARAM_INT);
$uncool = optional_param('uncool', '', PARAM_INT);
$edit = optional_param('edit', '', PARAM_INT);
$delete = optional_param('delete', '', PARAM_INT);
if (!empty($cool) and confirm_sesskey()) {
    if ($site = $DB->get_record("hub_site_directory", array("id" => $cool))) {
        $site->cool = MAXVOTES;
        $site->cooldate = time();
        $DB->update_record("hub_site_directory", $site);
        add_to_log($SITE->id, "resource", "cool", "view.php?id=380", "COOL: {$site->url}, {$site->sitename}", 380, $USER->id);
        redirect("index.php?country={$site->country}", "{$site->sitename} marked as COOL!", 1);
    }
}
if (!empty($uncool) and confirm_sesskey()) {
    if ($site = $DB->get_record("hub_site_directory", array("id" => $uncool))) {
        $site->cool = 0;
        $site->cooldate = 0;
        $DB->update_record("hub_site_directory", $site);
        add_to_log($SITE->id, "resource", "uncool", "view.php?id=380", "UNCOOL: {$site->url}, {$site->sitename}", 380, $USER->id);
        redirect("index.php?country={$site->country}", "{$site->sitename} suddenly seems NOT SO COOL! ", 1);
    }
}
if (!empty($delete) and confirm_sesskey()) {
コード例 #2
0
<?php

require '../../../../config.php';
require_once "siteslib.php";
$country = optional_param('country', '', PARAM_ALPHA);
$cool = optional_param('cool', 0, PARAM_INT);
$uncool = optional_param('uncool', 0, PARAM_INT);
$sitevoting = optional_param('voting', 0, PARAM_INT);
$edit = optional_param('edit', '', PARAM_ALPHA);
$isadmin = ismoodlesiteadmin();
$USER->siteediting = $isadmin && $edit == "on";
/// Try to get the country, from USER, IP or request
$usercountry = "";
if (!empty($USER->country)) {
    $usercountry = $USER->country;
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
    if ($countryinfo = $DB->get_record_sql("SELECT * FROM {countries} WHERE ipfrom <= inet_aton('{$ip}') AND inet_aton('{$ip}') <= ipto ")) {
        $usercountry = $countryinfo->code2;
    }
}
if (empty($country) and $usercountry) {
    $country = $usercountry;
}
$hide_all_links = false;
$mostrecent = 0;
$strresources = get_string("modulenameplural", "resource");
$PAGE->set_context(context_system::instance());
$PAGE->set_url(new moodle_url('/sites/index_norecordset.php'));
$PAGE->set_title('Moodle: Moodle sites');
$PAGE->set_heading('Moodle sites');