} else if ($mode == "compare") {
- if (isset($HTTP_POST_VARS['file'])){ // Save a file
- $newstrings = $HTTP_POST_VARS;
+ if (isset($_POST['file'])){ // Save a file
+ $newstrings = $_POST;
$file = $newstrings['file'];
unset($newstrings['file']);
if (lang_save_file($langdir, $file, $newstrings)) {
function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
global $CFG;
- echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">";
+ if (empty($CFG->gdversion)) {
+ echo "(".get_string("gdneed").")";
+ } else {
+ echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">";
+ }
}
$USER->loggedin = true;
$USER->site = $CFG->wwwroot;
save_session("USER");
- redirect($HTTP_REFERER);
+ redirect($_SERVER["HTTP_REFERER"]);
exit;
}
}
- if (isset($course) && isset($HTTP_POST_VARS)) { // add or update form submitted
+ if (isset($_POST["course"])) { // add or update form submitted
if (isset($SESSION->modform)) { // Variables are stored in the session
$mod = $SESSION->modform;
unset($SESSION->modform);
save_session("SESSION");
} else {
- $mod = (object)$HTTP_POST_VARS;
+ $mod = (object)$_POST;
}
require_login($mod->course);
error("Could not cache module information!");
}
- redirect($HTTP_REFERER);
+ redirect($_SERVER["HTTP_REFERER"]);
exit;
} else if (isset($delete)) { // value = course module
} else if (isset($add)) {
if (!$add) {
- redirect($HTTP_REFERER);
+ redirect($_SERVER["HTTP_REFERER"]);
die;
}
} else {
html_header($course, $wdir);
- if (setfilelist($HTTP_POST_VARS)) {
+ if (setfilelist($_POST)) {
echo "<P ALIGN=CENTER>You are about to delete:</P>";
print_simple_box_start("center");
printfilelist($USER->filelist);
case "move":
html_header($course, $wdir);
- if ($count = setfilelist($HTTP_POST_VARS)) {
+ if ($count = setfilelist($_POST)) {
$USER->fileop = $action;
$USER->filesource = $wdir;
save_session("USER");
} else {
html_header($course, $wdir, "form.name");
- if (setfilelist($HTTP_POST_VARS)) {
+ if (setfilelist($_POST)) {
echo "<P ALIGN=CENTER>You are about create a zip file containing:</P>";
print_simple_box_start("center");
printfilelist($USER->filelist);
$string['processingpost'] = "Processing post \$a";
$string['rate'] = "Rate";
$string['ratings'] = "Ratings";
+$string['ratingssaved'] = "Ratings saved";
$string['readtherest'] = "Read the rest of this topic";
$string['re'] = "Re:"; // Put in front of subjects that are replies to another post
$string['repliesmany'] = "\$a replies so far";
$string['fullsitename'] = "Full site name";
$string['gd1'] = "GD 1.x is installed";
$string['gd2'] = "GD 2.x is installed";
+$string['gdneed'] = "GD must be installed to see this graph";
$string['gdnot'] = "GD is not installed";
$string['gpl'] = "Copyright (C) 2001-2002 Martin Dougiamas (http://dougiamas.com)
/// whether they are "logged in" or allowed to be in a particular course.
/// If not, then it redirects them to the site login or course enrolment.
- global $CFG, $SESSION, $USER, $FULLME, $HTTP_REFERER, $PHPSESSID;
+ global $CFG, $SESSION, $USER, $FULLME, $PHPSESSID;
// First check that the user is logged in to the site.
if (! (isset($USER->loggedin) and $USER->confirmed and ($USER->site == $CFG->wwwroot)) ) { // They're not
$SESSION->wantsurl = $FULLME;
- $SESSION->fromurl = $HTTP_REFERER;
+ $SESSION->fromurl = $_SERVER["HTTP_REFERER"];
save_session("SESSION");
$USER = NULL;
save_session("USER");
$cookiename = "MOODLEID{$CFG->prefix}";
- global $$cookiename;
-
- return rc4decrypt($$cookiename);
+ return rc4decrypt($_COOKIE[$cookiename]);
}
function check_browser_version($brand="MSIE", $version=5.5) {
/// Checks to see if is a browser matches the specified
/// brand and is equal or better version.
- global $HTTP_USER_AGENT;
- if (!$HTTP_USER_AGENT) {
+ if (empty($_SERVER["HTTP_USER_AGENT"])) {
return false;
}
- $string = explode(";", $HTTP_USER_AGENT);
+ $string = explode(";", $_SERVER["HTTP_USER_AGENT"]);
if (!isset($string[1])) {
return false;
}
function get_referer() {
/// returns the URL of the HTTP_REFERER, less the querystring portion
- global $HTTP_REFERER;
-
- return strip_querystring(nvl($HTTP_REFERER));
+ return strip_querystring(nvl($_SERVER["HTTP_REFERER"]));
}
/// return different things depending on a lot of things like your OS, Web
/// server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.)
- global $REQUEST_URI, $PATH_INFO, $PHP_SELF;
-
- if ($REQUEST_URI) {
- return $REQUEST_URI;
+ if (!empty($_SERVER["REQUEST_URI"])) {
+ return $_SERVER["REQUEST_URI"];
- } else if ($PATH_INFO) {
- return $PATH_INFO;
+ } else if (!empty($_SERVER["PATH_INFO"])) {
+ return $_SERVER["PATH_INFO"];
- } else if ($PHP_SELF) {
- return $PHP_SELF;
+ } else if (!empty($_SERVER["PHP_SELF"])) {
+ return $_SERVER["PHP_SELF"];
} else {
notify("Error: Could not find any of these web server variables: \$REQUEST_URI, \$PATH_INFO or \$PHP_SELF");
function qualified_me() {
/// like me() but returns a full URL
- global $HTTPS, $HTTP_HOST;
-
- if (!$HTTP_HOST) {
+ if (empty($_SERVER["HTTP_HOST"])) {
notify("Error: could not find web server variable: \$HTTP_HOST");
}
- $protocol = (isset($HTTPS) && $HTTPS == "on") ? "https://" : "http://";
- $url_prefix = "$protocol$HTTP_HOST";
+ $protocol = (isset($_SERVER["HTTPS"]) and $_SERVER["HTTPS"] == "on") ? "https://" : "http://";
+ $url_prefix = "$protocol".$_SERVER["HTTP_HOST"];
return $url_prefix . me();
}
function data_submitted($url="") {
/// Used on most forms in Moodle to check for data
/// Returns the data as an object, if it's found.
+/// This object can be used in foreach loops without
+/// casting because it's cast to (array) automatically
///
/// Checks that submitted POST data exists, and also
/// checks the referer against the given url (it uses
/// the current page if none was specified.
- global $HTTP_POST_VARS, $CFG;
-
- if (empty($HTTP_POST_VARS)) {
+ if (empty($_POST)) {
return false;
+
} else {
if (match_referer($url)) {
- return (object)$HTTP_POST_VARS;
+ return (object)$_POST;
} else {
if ($CFG->debug > 10) {
notice("The form did not come from this page! (referer = ".get_referer().")");
}
$output .= ">$nothing</OPTION>\n";
}
- foreach ($options as $value => $label) {
- $output .= " <OPTION VALUE=\"$value\"";
- if ($value == $selected) {
- $output .= " SELECTED";
- }
- if ($label) {
- $output .= ">$label</OPTION>\n";
- } else {
- $output .= ">$value</OPTION>\n";
+ if (!empty($options)) {
+ foreach ($options as $value => $label) {
+ $output .= " <OPTION VALUE=\"$value\"";
+ if ($value == $selected) {
+ $output .= " SELECTED";
+ }
+ if ($label) {
+ $output .= ">$label</OPTION>\n";
+ } else {
+ $output .= ">$value</OPTION>\n";
+ }
}
}
$output .= "</SELECT>\n";
}
function print_continue($link) {
- global $HTTP_REFERER;
if (!$link) {
- $link = $HTTP_REFERER;
+ $link = $_SERVER["HTTP_REFERER"];
}
print_heading("<A HREF=\"$link\">".get_string("continue")."</A>");
}
function notice ($message, $link="") {
- global $THEME, $HTTP_REFERER;
+ global $THEME;
if (!$link) {
- $link = $HTTP_REFERER;
+ $link = $_SERVER["HTTP_REFERER"];
}
echo "<BR>";
}
if (empty($SESSION->wantsurl)) {
- $SESSION->wantsurl = $HTTP_REFERER;
+ $SESSION->wantsurl = $_SERVER["HTTP_REFERER"];
save_session("SESSION");
}
function forum_set_return() {
- global $CFG, $SESSION, $HTTP_REFERER;
+ global $CFG, $SESSION;
if (! isset($SESSION->fromdiscussion)) {
// If the referer is NOT a login screen then save it.
- if (! strncasecmp("$CFG->wwwroot/login", $HTTP_REFERER, 300)) {
- $SESSION->fromdiscussion = $HTTP_REFERER;
+ if (! strncasecmp("$CFG->wwwroot/login", $_SERVER["HTTP_REFERER"], 300)) {
+ $SESSION->fromdiscussion = $_SERVER["HTTP_REFERER"];
save_session("SESSION");
}
}
require("lib.php");
if (isguest()) {
- error(get_string("noguestpost", "forum"), $HTTP_REFERER);
+ error(get_string("noguestpost", "forum"), $_SERVER["HTTP_REFERER"]);
}
if ($post = data_submitted()) {
if (isset($forum)) { // User is starting a new discussion in a forum
- $SESSION->fromurl = $HTTP_REFERER;
+ $SESSION->fromurl = $_SERVER["HTTP_REFERER"];
save_session("SESSION");
if (! $forum = get_record("forum", "id", $forum)) {
print_header();
notice_yesno(get_string("deletesure", "forum"),
"post.php?delete=$delete&confirm=$delete",
- $HTTP_REFERER);
+ $_SERVER["HTTP_REFERER"]);
echo "<CENTER><HR>";
forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
require("lib.php");
if (isguest()) {
- error("Guests are not allowed to rate posts.", $HTTP_REFERER);
+ error("Guests are not allowed to rate posts.", $_SERVER["HTTP_REFERER"]);
}
require_variable($id); // The course these ratings are part of
require_login($course->id);
- if (isset($HTTP_POST_VARS)) { // form submitted
+ if ($data = data_submitted("$CFG->wwwroot/mod/forum/discuss.php")) { // form submitted
- foreach ($HTTP_POST_VARS as $post => $rating) {
+ foreach ($data as $post => $rating) {
if ($post == "id") {
continue;
}
}
}
}
- redirect($HTTP_REFERER, "Ratings saved");
+ redirect($_SERVER["HTTP_REFERER"], get_string("ratingssaved", "forum"));
} else {
error("This page was not accessed correctly");
optional_variable($user); // Force everyone to be subscribed to this forum?
if (isguest()) {
- error("Guests are not allowed to subscribe to posts.", $HTTP_REFERER);
+ error("Guests are not allowed to subscribe to posts.", $_SERVER["HTTP_REFERER"]);
}
if (! $forum = get_record("forum", "id", $id)) {
add_to_log($course->id, "forum", "unsubscribe", "view.php?f=$forum->id", "$forum->id");
redirect($returnto, get_string("nownotsubscribed", "forum", $info), 1);
} else {
- error("Could not unsubscribe you from that forum", "$HTTP_REFERER");
+ error("Could not unsubscribe you from that forum", $_SERVER["HTTP_REFERER"]);
}
} else { // subscribe
add_to_log($course->id, "forum", "subscribe", "view.php?f=$forum->id", "$forum->id");
redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
} else {
- error("Could not subscribe you to that forum", "$HTTP_REFERER");
+ error("Could not subscribe you to that forum", $_SERVER["HTTP_REFERER"]);
}
}
require_login($course->id);
if (isguest()) {
- error("Guests are not allowed to edit journals", $HTTP_REFERER);
+ error("Guests are not allowed to edit journals", $_SERVER["HTTP_REFERER"]);
}
if (! $journal = get_record("journal", "id", $cm->instance)) {
if ($modform and !empty($modform->course)) { // form submitted from mod.html
if (empty($modform->name) or empty($modform->intro)) {
- error(get_string("filloutallfields"), $HTTP_REFERER);
+ error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
}
$SESSION->modform = $modform; // Save the form in the current session
}
if (!empty($add)) { /// Add a question to the current quiz
- $rawquestions = $HTTP_POST_VARS;
+ $rawquestions = $_POST;
if (!empty($modform->questions)) {
$questions = explode(",", $modform->questions);
}
}
if (!empty($setgrades)) { /// The grades have been updated, so update our internal list
- $rawgrades = $HTTP_POST_VARS;
+ $rawgrades = $_POST;
unset($modform->grades);
foreach ($rawgrades as $key => $value) { // Parse input for question -> grades
if (substr($key, 0, 1) == "q") {
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> $strediting");
if (!$form->name or !$form->type or !$form->summary) {
- error(get_string("filloutallfields"), $HTTP_REFERER);
+ error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
}
print_simple_box_start("center", "", "$THEME->cellheading");
break;
default:
- error(get_string("notypechosen", "resource"), $HTTP_REFERER);
+ error(get_string("notypechosen", "resource"), $_SERVER["HTTP_REFERER"]);
break;
}
-> $streditingasurvey");
if (!$form->name or !$form->template) {
- error(get_string("filloutallfields"), $HTTP_REFERER);
+ error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
}
print_simple_box_start("center", "", "$THEME->cellheading");
global $CFG;
if (survey_already_done($survey->id, $user->id)) {
- echo "<IMG SRC=\"$CFG->wwwroot/mod/survey/graph.php?id=$mod->id&sid=$user->id&type=student.png\">";
+ survey_print_graph("id=$mod->id&sid=$user->id&type=student.png");
} else {
print_string("notdone", "survey");
}
}
}
+function survey_print_graph($url) {
+ global $CFG, $SURVEY_GHEIGHT, $SURVEY_GWIDTH;
+
+ if (empty($CFG->gdversion)) {
+ echo "(".get_string("gdneed").")";
+
+ } else {
+ echo "<IMG HEIGHT=\"$SURVEY_GHEIGHT\" WIDTH=\"$SURVEY_GWIDTH\" BORDER=1".
+ " SRC=\"$CFG->wwwroot/mod/survey/graph.php?$url\">";
+ }
+}
+
?>
print_header("$survey->name: $strsummary", "$strsummary - $strallscales");
if (survey_count_responses($survey->id)) {
- echo "<P ALIGN=CENTER><A HREF=\"report.php?action=scales&id=$id\"><IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH tail\" BORDER=1 SRC=\"graph.php?id=$id&type=overall.png\"></A>";
+ echo "<P ALIGN=CENTER><A HREF=\"report.php?action=scales&id=$id\">";
+ survey_print_graph("id=$id&type=overall.png");
+ echo "</A>";
} else {
echo "<P ALIGN=CENTER>".get_string("nobodyyet","survey")."</P>";
}
continue;
}
echo "<P ALIGN=center><A TITLE=\"$strseemoredetail\" HREF=report.php?action=questions&id=$id&qid=$question->multi>";
- echo "<IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH BORDER=1
- SRC=\"graph.php?id=$id&qid=$question->id&type=multiquestion.png\">";
+ survey_print_graph("id=$id&qid=$question->id&type=multiquestion.png");
echo "</A></P><BR>";
}
}
foreach ($subquestionorder as $key => $val) {
$subquestion = $subquestions[$val];
if ($subquestion->type > 0) {
- echo "<P ALIGN=CENTER><A TITLE=\"$strseemoredetail\" HREF=\"report.php?action=question&id=$id&qid=$subquestion->id\">
- <IMG HEIGHT=\"$SURVEY_GHEIGHT\" WIDTH=\"$SURVEY_GWIDTH\" BORDER=1 SRC=\"graph.php?id=$id&qid=$subquestion->id&type=question.png\"></A></P>";
+ echo "<P ALIGN=CENTER>";
+ echo "<A TITLE=\"$strseemoredetail\" HREF=\"report.php?action=question&id=$id&qid=$subquestion->id\">";
+ survey_print_graph("id=$id&qid=$subquestion->id&type=question.png");
+ echo "</A></P>";
}
}
} else if ($question->type > 0 ) {
- echo "<P ALIGN=CENTER><A TITLE=\"$strseemoredetail\" HREF=\"report.php?action=question&id=$id&qid=$question->id\">
- <IMG HEIGHT=\"$SURVEY_GHEIGHT\" WIDTH=\"$SURVEY_GWIDTH\" BORDER=1 SRC=\"graph.php?id=$id&qid=$question->id&type=question.png\"></A></P>";
+ echo "<P ALIGN=CENTER>";
+ echo "<A TITLE=\"$strseemoredetail\" HREF=\"report.php?action=question&id=$id&qid=$question->id\">";
+ survey_print_graph("id=$id&qid=$question->id&type=question.png");
+ echo "</A></P>";
+
} else {
echo "<H3>$question->text:</H3>";
if ($aaa = survey_get_user_answers($survey->id, $question->id)) {
echo "</P>";
// Print overall summary
- echo "<P ALIGN=CENTER><IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH ALIGN=CENTER SRC=\"graph.php?id=$id&sid=$student&type=student.png\"></P>";
+ echo "<P ALIGN=CENTER>";
+ survey_print_graph("id=$id&sid=$student&type=student.png");
+ echo "</P>";
// Print scales
$questions = get_records_list("survey_questions", "id", $survey->questions);
if ($virtualscales && $question->type > 0) { // Don't show non-virtual scales if virtual
continue;
}
- echo "<P ALIGN=center><A TITLE=\"$strseemoredetail\" HREF=report.php?action=questions&id=$id&qid=$question->multi>";
- echo "<IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH BORDER=1
- SRC=\"graph.php?id=$id&qid=$question->id&sid=$student&type=studentmultiquestion.png\">";
+ echo "<P ALIGN=center>";
+ echo "<A TITLE=\"$strseemoredetail\" HREF=report.php?action=questions&id=$id&qid=$question->multi>";
+ survey_print_graph("id=$id&qid=$question->id&sid=$student&type=studentmultiquestion.png");
echo "</A></P><BR>";
}
}
// Make sure this is a legitimate posting
- if (!isset($HTTP_POST_VARS)) {
+ if (!$formdata = data_submitted("$CFG->wwwroot/mod/survey/view.php")) {
error("You are not supposed to use this script like that.");
}
if (isguest()) {
- error("Guests are not allowed to answer surveys", $HTTP_REFERER);
+ error("Guests are not allowed to answer surveys", $_SERVER["HTTP_REFERER"]);
}
require_variable($id); // Course Module ID
add_to_log($course->id, "survey", "submit", "view.php?id=$cm->id", "$survey->id");
if (survey_already_done($survey->id, $USER->id)) {
- notice(get_string("alreadysubmitted", "survey"), $HTTP_REFERER);
+ notice(get_string("alreadysubmitted", "survey"), $_SERVER["HTTP_REFERER"]);
exit;
}
$answers = array();
- foreach ($HTTP_POST_VARS as $key => $val) {
+ foreach ($formdata as $key => $val) {
if ($key <> "userid" && $key <> "id") {
if ( substr($key,0,1) == "q") {
$key = substr($key,1); // keep everything but the 'q'
$numusers = survey_count_responses($survey->id);
print_heading(get_string("peoplecompleted", "survey", $numusers));
echo "<CENTER>";
- echo "<IMG HEIGHT=\"$SURVEY_GHEIGHT\" WIDTH=\"$SURVEY_GWIDTH\" SRC=\"$CFG->wwwroot/mod/survey/graph.php?id=$cm->id&sid=$USER->id&type=student.png\">";
+ survey_print_graph("id=$cm->id&sid=$USER->id&type=student.png");
echo "</CENTER>";
print_footer($course);
exit;
<tr>
<td colspan=2><BR><B><? print_string("followingoptional") ?>:</B></td>
</tr>
+
+
+<? if (!empty($CFG->gdversion)) { ?>
<tr valign=top>
<td><P><? print_string("newpicture") ?>:</td>
<td>
?>
</td>
</tr>
+<? } ?>
+
<tr valign=top>
<td><P><? print_string("webpage") ?>:</td>
<td><input type="text" name="url" size=50 value="<? p($user->url) ?>">
$usernew->lastname = strip_tags($usernew->lastname);
if (find_form_errors($user, $usernew, $err)) {
- if ($filename = valid_uploaded_file($imagefile)) {
+ if ($filename = valid_uploaded_file($_FILES['imagefile'])) {
$usernew->picture = save_user_image($user->id, $filename);
}
} else {
$timenow = time();
- if ($filename = valid_uploaded_file($imagefile)) {
+ if ($filename = valid_uploaded_file($_FILES['imagefile'])) {
$usernew->picture = save_user_image($user->id, $filename);
} else {
$usernew->picture = $user->picture;
global $CFG;
+ if (empty($CFG->gdversion)) {
+ return false;
+ }
+
$imageinfo = GetImageSize($filename);
$image->width = $imageinfo[0];
$image->height = $imageinfo[1];
$image->type = $imageinfo[2];
switch ($image->type) {
- case 2: $im = ImageCreateFromJPEG($filename); break;
- case 3: $im = ImageCreateFromPNG($filename); break;
- default: return 0;
+ case 1:
+ if (function_exists("ImageCreateFromGIF")) {
+ $im = ImageCreateFromGIF($filename);
+ } else {
+ notice("GIF not supported on this server");
+ return false;
+ }
+ break;
+ case 2:
+ if (function_exists("ImageCreateFromJPEG")) {
+ $im = ImageCreateFromJPEG($filename);
+ } else {
+ notice("JPEG not supported on this server");
+ return false;
+ }
+ break;
+ case 3:
+ if (function_exists("ImageCreateFromPNG")) {
+ $im = ImageCreateFromPNG($filename);
+ } else {
+ notice("PNG not supported on this server");
+ return false;
+ }
+ break;
+ default:
+ return false;
}
+
if (function_exists("ImageCreateTrueColor") and $CFG->gdversion >= 2) {
$im1 = ImageCreateTrueColor(100,100);
$im2 = ImageCreateTrueColor(35,35);