Permalink
Browse files

Added hook for more flexible authentication to external url - backwar…

…ds compatible with existing file resources
  • Loading branch information...
1 parent e341bb8 commit d0cc843ed3b12dba68e6c89990ec5b20c73b149b fiedorow committed Feb 19, 2005
Showing with 17 additions and 2 deletions.
  1. +17 −2 mod/resource/type/file/resource.class.php
@@ -108,11 +108,13 @@ function set_parameters() {
'value' => current_language()),
'sitename' => array('langstr' => get_string('fullsitename'),
'value' => $site->fullname),
+ 'serverurl' => array('langstr' => get_string('serverurl'),
+ 'value' => $CFG->wwwroot),
'currenttime' => array('langstr' => get_string('time'),
'value' => time()),
'encryptedcode' => array('langstr' => get_string('encryptedcode'),
- 'value' => md5($_SERVER['REMOTE_ADDR'].$CFG->resource_secretphrase)),
-
+ 'value' => $this->set_encrypted_parameter()),
+
'label6' => array('langstr' => "",
'value' =>'/optgroup')
);
@@ -541,6 +543,19 @@ function setup($form) {
parent::setup_end();
}
+//backwards compatible with existing resources
+function set_encrypted_parameter() {
+ global $CFG;
+
+ if (!empty($this->resource->reference) && file_exists($CFG->dirroot ."/mod/resource//type/file/externserverfile.php")) {
+ include $CFG->dirroot ."/mod/resource/type/file/externserverfile.php";
+ if (function_exists(extern_server_file)) {
+ return extern_server_file($this->resource->reference);
+ }
+ }
+ return md5($_SERVER['REMOTE_ADDR'].$CFG->resource_secretphrase);
+}
+
}
?>

0 comments on commit d0cc843

Please sign in to comment.