本文整理汇总了PHP中get_site_identifier函数的典型用法代码示例。如果您正苦于以下问题:PHP get_site_identifier函数的具体用法?PHP get_site_identifier怎么用?PHP get_site_identifier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_site_identifier函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: backup_is_same_site
/**
* Are we restoring a backup that was made on the same site that we are restoring to?
* This relies on some information that was only added to backup files in January 2009.
* For older backup files, fall back to guessing based on wwwroot. MDL-16614 explains
* when this guess could give the wrong answer.
* @return boolean true if the backup was made on the same site we are restoring to.
*/
function backup_is_same_site(&$restore)
{
global $CFG;
static $hashedsiteid = null;
if (is_null($hashedsiteid)) {
$hashedsiteid = md5(get_site_identifier());
}
if (!empty($restore->original_siteidentifier)) {
return $restore->original_siteidentifier == $hashedsiteid;
} else {
return $restore->original_wwwroot == $CFG->wwwroot;
}
}
示例2: define_structure
protected function define_structure()
{
global $CFG;
$info = array();
$info['name'] = $this->get_setting_value('filename');
$info['moodle_version'] = $CFG->version;
$info['moodle_release'] = $CFG->release;
$info['backup_version'] = $CFG->backup_version;
$info['backup_release'] = $CFG->backup_release;
$info['backup_date'] = time();
$info['backup_uniqueid'] = $this->get_backupid();
$info['mnet_remoteusers'] = backup_controller_dbops::backup_includes_mnet_remote_users($this->get_backupid());
$info['original_wwwroot'] = $CFG->wwwroot;
$info['original_site_identifier_hash'] = md5(get_site_identifier());
$info['original_course_id'] = $this->get_courseid();
$originalcourseinfo = backup_controller_dbops::backup_get_original_course_info($this->get_courseid());
$info['original_course_fullname'] = $originalcourseinfo->fullname;
$info['original_course_shortname'] = $originalcourseinfo->shortname;
$info['original_course_startdate'] = $originalcourseinfo->startdate;
$info['original_course_contextid'] = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
$info['original_system_contextid'] = get_context_instance(CONTEXT_SYSTEM)->id;
// Get more information from controller
list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information($this->get_backupid());
// Define elements
$moodle_backup = new backup_nested_element('moodle_backup');
$information = new backup_nested_element('information', null, array('name', 'moodle_version', 'moodle_release', 'backup_version', 'backup_release', 'backup_date', 'mnet_remoteusers', 'original_wwwroot', 'original_site_identifier_hash', 'original_course_id', 'original_course_fullname', 'original_course_shortname', 'original_course_startdate', 'original_course_contextid', 'original_system_contextid'));
$details = new backup_nested_element('details');
$detail = new backup_nested_element('detail', array('backup_id'), array('type', 'format', 'interactive', 'mode', 'execution', 'executiontime'));
$contents = new backup_nested_element('contents');
$activities = new backup_nested_element('activities');
$activity = new backup_nested_element('activity', null, array('moduleid', 'sectionid', 'modulename', 'title', 'directory'));
$sections = new backup_nested_element('sections');
$section = new backup_nested_element('section', null, array('sectionid', 'title', 'directory'));
$course = new backup_nested_element('course', null, array('courseid', 'title', 'directory'));
$settings = new backup_nested_element('settings');
$setting = new backup_nested_element('setting', null, array('level', 'section', 'activity', 'name', 'value'));
// Build the tree
$moodle_backup->add_child($information);
$information->add_child($details);
$details->add_child($detail);
$information->add_child($contents);
if (!empty($cinfo['activities'])) {
$contents->add_child($activities);
$activities->add_child($activity);
}
if (!empty($cinfo['sections'])) {
$contents->add_child($sections);
$sections->add_child($section);
}
if (!empty($cinfo['course'])) {
$contents->add_child($course);
}
$information->add_child($settings);
$settings->add_child($setting);
// Set the sources
$information->set_source_array(array((object) $info));
$detail->set_source_array($dinfo);
$activity->set_source_array($cinfo['activities']);
$section->set_source_array($cinfo['sections']);
$course->set_source_array($cinfo['course']);
$setting->set_source_array($sinfo);
// Prepare some information to be sent to main moodle_backup.xml file
return $moodle_backup;
}
示例3: backup_general_info
function backup_general_info($bf, $preferences)
{
global $CFG;
fwrite($bf, start_tag("INFO", 1, true));
//The name of the backup
fwrite($bf, full_tag("NAME", 2, false, $preferences->backup_name));
//The moodle_version
fwrite($bf, full_tag("MOODLE_VERSION", 2, false, $preferences->moodle_version));
fwrite($bf, full_tag("MOODLE_RELEASE", 2, false, $preferences->moodle_release));
//The backup_version
fwrite($bf, full_tag("BACKUP_VERSION", 2, false, $preferences->backup_version));
fwrite($bf, full_tag("BACKUP_RELEASE", 2, false, $preferences->backup_release));
//The date
fwrite($bf, full_tag("DATE", 2, false, $preferences->backup_unique_code));
//The original site wwwroot
fwrite($bf, full_tag("ORIGINAL_WWWROOT", 2, false, $CFG->wwwroot));
//The original site identifier. MD5 hashed for security.
fwrite($bf, full_tag("ORIGINAL_SITE_IDENTIFIER_HASH", 2, false, md5(get_site_identifier())));
//The zip method used
if (!empty($CFG->zip)) {
$zipmethod = 'external';
} else {
$zipmethod = 'internal';
}
//Indicate if it includes external MNET users
$sql = "SELECT b.old_id\n FROM {$CFG->prefix}backup_ids b\n JOIN {$CFG->prefix}user u ON b.old_id=u.id\n WHERE b.backup_code = '{$preferences->backup_unique_code}'\n AND b.table_name = 'user' AND u.mnethostid != '{$CFG->mnet_localhost_id}'";
if (record_exists_sql($sql)) {
fwrite($bf, full_tag("MNET_REMOTEUSERS", 2, false, 'true'));
}
fwrite($bf, full_tag("ZIP_METHOD", 2, false, $zipmethod));
//Te includes tag
fwrite($bf, start_tag("DETAILS", 2, true));
//Now, go to mod element of preferences to print its status
foreach ($preferences->mods as $element) {
//Calculate info
$included = "false";
$userinfo = "false";
if ($element->backup) {
$included = "true";
if ($element->userinfo) {
$userinfo = "true";
}
}
//Prints the mod start
fwrite($bf, start_tag("MOD", 3, true));
fwrite($bf, full_tag("NAME", 4, false, $element->name));
fwrite($bf, full_tag("INCLUDED", 4, false, $included));
fwrite($bf, full_tag("USERINFO", 4, false, $userinfo));
if (isset($preferences->mods[$element->name]->instances) && is_array($preferences->mods[$element->name]->instances) && count($preferences->mods[$element->name]->instances)) {
fwrite($bf, start_tag("INSTANCES", 4, true));
foreach ($preferences->mods[$element->name]->instances as $id => $object) {
if (!empty($object->backup)) {
//Calculate info
$included = "false";
$userinfo = "false";
if ($object->backup) {
$included = "true";
if ($object->userinfo) {
$userinfo = "true";
}
}
fwrite($bf, start_tag("INSTANCE", 5, true));
fwrite($bf, full_tag("ID", 5, false, $id));
fwrite($bf, full_tag("NAME", 5, false, $object->name));
fwrite($bf, full_tag("INCLUDED", 5, false, $included));
fwrite($bf, full_tag("USERINFO", 5, false, $userinfo));
fwrite($bf, end_tag("INSTANCE", 5, true));
}
}
fwrite($bf, end_tag("INSTANCES", 4, true));
}
//Print the end
fwrite($bf, end_tag("MOD", 3, true));
}
//The metacourse in backup
if ($preferences->backup_metacourse == 1) {
fwrite($bf, full_tag("METACOURSE", 3, false, "true"));
} else {
fwrite($bf, full_tag("METACOURSE", 3, false, "false"));
}
//The user in backup
if ($preferences->backup_users == 1) {
fwrite($bf, full_tag("USERS", 3, false, "course"));
} else {
if ($preferences->backup_users == 0) {
fwrite($bf, full_tag("USERS", 3, false, "all"));
} else {
fwrite($bf, full_tag("USERS", 3, false, "none"));
}
}
//The logs in backup
if ($preferences->backup_logs == 1) {
fwrite($bf, full_tag("LOGS", 3, false, "true"));
} else {
fwrite($bf, full_tag("LOGS", 3, false, "false"));
}
//The user files
if ($preferences->backup_user_files == 1) {
fwrite($bf, full_tag("USERFILES", 3, false, "true"));
} else {
//.........这里部分代码省略.........
示例4: rc4decrypt
/**
* rc4decrypt
*
* @param string $data Data to decrypt.
* @return string The now decrypted data.
*/
function rc4decrypt($data)
{
return endecrypt(get_site_identifier(), $data, 'de');
}
示例5: array
$navlinks = array();
$navlinks[] = array('name' => $stradministration, 'link' => "../{$CFG->admin}/index.php", 'type' => 'misc');
$navlinks[] = array('name' => $strregistration, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("{$site->shortname}: {$strregistration}", $site->fullname, $navigation);
print_heading($strregistration);
print_simple_box($strregistrationinfo, "center", "70%");
/// Print the form
echo "<form id=\"mform1\" class=\"mform\" action=\"http://moodle.org/register/\" method=\"post\">\n";
echo '<fieldset id="registration">';
echo '<legend>Registration Information</legend>';
echo "<!-- The following hidden variables are to help prevent fake entries being sent. -->\n";
echo "<!-- Together they form a key. If any of these change between updates then the entry -->\n";
echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
echo "<input type=\"hidden\" name=\"url\" value=\"{$CFG->wwwroot}\" />\n";
echo "<input type=\"hidden\" name=\"secret\" value=\"" . get_site_identifier() . "\" />\n";
echo "<input type=\"hidden\" name=\"host\" value=\"" . $_SERVER["HTTP_HOST"] . "\" />\n";
echo "<input type=\"hidden\" name=\"lang\" value=\"" . current_language() . "\" />\n";
echo "<input type=\"hidden\" name=\"version\" value=\"{$CFG->version}\" />\n";
echo "<input type=\"hidden\" name=\"release\" value=\"{$CFG->release}\" />\n";
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label>URL</label></div>';
echo '<div class="felement ftext">' . $CFG->wwwroot . '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label>' . get_string("currentversion") . '</label></div>';
echo '<div class="felement ftext">' . "{$CFG->release} ({$CFG->version})" . '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="sitename">' . get_string("fullsitename") . '</label></div>';
echo '<div class="felement ftext">';
示例6: backup_is_samesite
/**
* Given the information fetched from moodle_backup.xml file
* decide if we are restoring in the same site the backup was
* generated or no. Behavior of various parts of restore are
* dependent of this.
*
* Backups created natively in 2.0 and later declare the hashed
* site identifier. Backups created by conversion from a 1.9
* backup do not declare such identifier, so there is a fallback
* to wwwroot comparison. See MDL-16614.
*/
public static function backup_is_samesite($info)
{
global $CFG;
$hashedsiteid = md5(get_site_identifier());
if (isset($info->original_site_identifier_hash) && !empty($info->original_site_identifier_hash)) {
return $info->original_site_identifier_hash == $hashedsiteid;
} else {
return $info->original_wwwroot == $CFG->wwwroot;
}
}
示例7: rc4decrypt
/**
* rc4decrypt
*
* Please note that in this version of moodle that the default for rc4encryption is
* using the slightly more secure password key. There may be an issue when upgrading
* from an older version of moodle.
*
* @todo MDL-31836 Remove the old password key in version 2.4
* Code also needs to be changed in sessionlib.php
* @see get_moodle_cookie()
* @see set_moodle_cookie()
*
* @param string $data Data to decrypt.
* @param bool $usesecurekey Lets us know if we are using the old or new secure password key.
* @return string The now decrypted data.
*/
function rc4decrypt($data, $usesecurekey = true)
{
if (!$usesecurekey) {
$passwordkey = 'nfgjeingjk';
} else {
$passwordkey = get_site_identifier();
}
return endecrypt($passwordkey, $data, 'de');
}
示例8: generate_email_processing_address
function generate_email_processing_address($modid, $modargs)
{
global $CFG;
$header = $CFG->mailprefix . substr(base64_encode(pack('C', $modid)), 0, 2) . $modargs;
return $header . substr(md5($header . get_site_identifier()), 0, 16) . '@' . $CFG->maildomain;
}
示例9: get_site_secret_for_hub
/**
* Return the site secret for a given hub
* site identifier is assigned to Mooch
* each hub has a unique and personal site secret.
* @param string $huburl
* @return string site secret
*/
public function get_site_secret_for_hub($huburl)
{
global $DB;
$existingregistration = $DB->get_record('registration_hubs', array('huburl' => $huburl));
if (!empty($existingregistration)) {
return $existingregistration->secret;
}
if ($huburl == HUB_MOODLEORGHUBURL) {
$siteidentifier = get_site_identifier();
} else {
$siteidentifier = random_string(32) . $_SERVER['HTTP_HOST'];
}
return $siteidentifier;
}
示例10: blocks_repopulate_page
blocks_repopulate_page($page);
//add admin_tree block to site if not already present
if ($admintree = get_record('block', 'name', 'admin_tree')) {
$page = page_create_object(PAGE_COURSE_VIEW, SITEID);
$pageblocks = blocks_get_by_page($page);
blocks_execute_action($page, $pageblocks, 'add', (int) $admintree->id, false, false);
if ($admintreeinstance = get_record('block_instance', 'pagetype', $page->type, 'pageid', SITEID, 'blockid', $admintree->id)) {
$pageblocks = blocks_get_by_page($page);
// Needs to be re-got, since has just changed
blocks_execute_action($page, $pageblocks, 'moveleft', $admintreeinstance, false, false);
}
}
set_config('adminblocks_initialised', 1);
}
/// Define the unique site ID code if it isn't already set. This getter does that as a side-effect.
get_site_identifier();
/// Check if the guest user exists. If not, create one.
if (!record_exists("user", "username", "guest")) {
if (!($guest = create_guest_record())) {
notify("Could not create guest user record !!!");
}
}
/// Set up the admin user
if (empty($CFG->rolesactive)) {
build_context_path();
// just in case - should not be needed
create_admin_user();
}
/// Check for valid admin user - no guest autologin
require_login(0, false);
$context = get_context_instance(CONTEXT_SYSTEM);
示例11: generate_tool_token
/**
* Returns a unique hash for this site and this enrolment instance.
*
* Used to verify that the link to the cartridge has not just been guessed.
*
* @param int $toolid The id of the shared tool
* @return string MD5 hash of combined site ID and enrolment instance ID.
* @since Moodle 3.2
*/
public static function generate_tool_token($toolid)
{
$siteidentifier = get_site_identifier();
$checkhash = md5($siteidentifier . '_enrol_lti_' . $toolid);
return $checkhash;
}
示例12: rc4decrypt
/**
* rc4decrypt
*
* @todo Finish documenting this function
*
* @param string $data Data to decrypt
* @return string The now decrypted data
*/
function rc4decrypt($data)
{
$password = get_site_identifier();
return endecrypt($password, $data, 'de');
}
示例13: memory_xml_output
$xml_output = new memory_xml_output();
$xml = new xml_writer($xml_output);
// Start the XML construction process
$xml->start();
// Open the top level XML element
$xml->begin_tag('MOODLE_ROLES_MIGRATION');
// General site and migration data
$xml->begin_tag('INFO');
$xml->full_tag('NAME', 'rolesmigration');
$xml->full_tag('MOODLE_VERSION', $CFG->version);
$xml->full_tag('MOODLE_RELEASE', $CFG->release);
$xml->full_tag('BACKUP_VERSION', $CFG->backup_version);
$xml->full_tag('BACKUP_RELEASE', $CFG->backup_release);
$xml->full_tag('DATE', time());
$xml->full_tag('ORIGINAL_WWWROOT', $CFG->wwwroot);
$xml->full_tag('ORIGINAL_SITE_IDENTIFIER_HASH', md5(get_site_identifier()));
$xml->end_tag('INFO');
// The roles tag contains all data for selected Roles on export screen
$xml->begin_tag('ROLES');
// Loop through provided role IDs
foreach ($data->export as $role) {
// Grab role from DB
if ($role = $DB->get_record('role', array('shortname' => $role))) {
$role_array = (array) $role;
// Loop through columns and create tag for each one
$xml->begin_tag('ROLE');
foreach ($role_array as $field => $value) {
$xml->full_tag(strtoupper($field), $value);
// Lets make an array of Role IDs to use later while we're here
if ('id' == $field) {
$role_ids[] = $value;
示例14: old_urkund_get_url
function old_urkund_get_url($baseurl, $plagiarismfile)
{
// Get url of api.
global $DB;
$receiver = $DB->get_field('plagiarism_urkund_config', 'value', array('cm' => $plagiarismfile->cm, 'name' => 'urkund_receiver'));
if (empty($receiver)) {
return '';
}
return $baseurl . '/' . $receiver . '/' . md5(get_site_identifier()) . '_' . $plagiarismfile->cm . '_' . $plagiarismfile->id;
}
示例15: catch
$result = $xmlrpcclient->call($function, $params);
} catch (Exception $e) {
$error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage()));
}
}
/////// FORM REGISTRATION ACTION //////
if (!empty($fromform) and empty($update) and confirm_sesskey()) {
if (!empty($fromform) and confirm_sesskey()) {
// if the register button has been clicked
$params = (array) $fromform;
//we are using the form input as the redirection parameters (token, url and name)
$unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);
if (empty($unconfirmedhub)) {
//we save the token into the communication table in order to have a reference
$unconfirmedhub = new stdClass();
$unconfirmedhub->token = get_site_identifier();
$unconfirmedhub->huburl = $huburl;
$unconfirmedhub->hubname = $hubname;
$unconfirmedhub->confirmed = 0;
$unconfirmedhub->id = $registrationmanager->add_registeredhub($unconfirmedhub);
}
$params['token'] = $unconfirmedhub->token;
$params['url'] = $CFG->wwwroot;
redirect(new moodle_url($huburl . '/local/hub/siteregistration.php', $params));
}
}
/////// OUTPUT SECTION /////////////
echo $OUTPUT->header();
//Display update notification result
if (!empty($registeredhub->confirmed)) {
if (!empty($result)) {