]> git.mjollnir.org Git - moodle.git/commitdiff
OK a number of small changes here.
authormoodler <moodler>
Sun, 5 Jan 2003 06:45:20 +0000 (06:45 +0000)
committermoodler <moodler>
Sun, 5 Jan 2003 06:45:20 +0000 (06:45 +0000)
Firstly, I'm replacing all use of old-style global variables like
$HTTY_REFERER with their new-style equivalent $_SERVER["HTTP_REFERER"]
Also using $_POST instead $HTTP_POST_VARS  etc

Secondly, if gdversion == 0 (ie GD is not installed) then:

 - users are not even allowed to upload new images
 - graphs now just print a message instead of failing.

this allows Moodle to still be used even if GD is not present

25 files changed:
admin/lang.php
course/lib.php
course/loginas.php
course/mod.php
files/index.php
lang/en/forum.php
lang/en/moodle.php
lib/moodlelib.php
lib/weblib.php
login/index.php
mod/forum/lib.php
mod/forum/post.php
mod/forum/rate.php
mod/forum/subscribe.php
mod/journal/edit.php
mod/quiz/edit.php
mod/resource/details.php
mod/survey/details.php
mod/survey/lib.php
mod/survey/report.php
mod/survey/save.php
mod/survey/view.php
user/edit.html
user/edit.php
user/lib.php

index 6fe4da5f2b32ee84fd6c96ef4ef68412b358333f..2c3b5c66c2a933b09af0593183c947945fdd42f1 100644 (file)
 
     } 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)) {
index 9233040195b5269022a78647694dd2af0fbe7339..7b447c4fc58c9a591a0dbdc80fb41995ca2b7d17 100644 (file)
@@ -756,7 +756,11 @@ function print_course_categories($categories, $selected="none", $width=180) {
 
 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\">";
+    }
 }
 
 
index 311c04dd4e04753e598146ad06f773b284c15574..134bafa852436dbb0da0e49ece7c6d878a6bc935 100644 (file)
@@ -19,7 +19,7 @@
         $USER->loggedin = true;
         $USER->site = $CFG->wwwroot;
         save_session("USER");
-        redirect($HTTP_REFERER);
+        redirect($_SERVER["HTTP_REFERER"]);
         exit;
     }
 
index 04456185c1435c604c0455d0a3b7383700a8aef4..3263ecb6da56f8a44a45d686f23f9c68b29df9ce 100644 (file)
     } 
 
 
-    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;
         }
 
index 9c2ddd973586c902b15634be1f42b1b9e00be089..11fc1d8af67439f61539220a16d3c0f97f78ffcf 100644 (file)
 
             } 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);
index 3337193aedc1cfe7c1463f8fb2dcec2d87b99e7e..9109b6bd9e02e650057174c1896a9a88fc71e7bf 100644 (file)
@@ -81,6 +81,7 @@ $string['postupdated'] = "Your post was updated";
 $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";
index 34312d1b753b2f7504a54c58d3a06ebfbfae5e03..8ae84f7f981d6e46447d534745d8bb285dd588d0 100644 (file)
@@ -192,6 +192,7 @@ $string['fullname'] = "Full name";
 $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)
 
index 20636f5f95d3ece4cd7324fa79ba605504c12152..69290538c053fad60588daa97489c54ac6269586 100644 (file)
@@ -254,12 +254,12 @@ function require_login($courseid=0) {
 /// 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");
@@ -458,9 +458,7 @@ function get_moodle_cookie() {
 
     $cookiename = "MOODLEID{$CFG->prefix}"; 
 
-    global $$cookiename;
-
-    return rc4decrypt($$cookiename);
+    return rc4decrypt($_COOKIE[$cookiename]);
 }
 
 
@@ -1124,12 +1122,11 @@ function check_php_version($version="4.1.0") {
 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;
     }
index 69f1dfaac320cb0a306b3cbb8ee1fbcb617931d7..8d9c91b9566b258fe33dfd2bbc648d5cae31ac7c 100644 (file)
@@ -120,9 +120,7 @@ function strip_querystring($url) {
 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"]));
 }
 
 
@@ -132,16 +130,14 @@ function me() {
 /// 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");
@@ -152,14 +148,12 @@ function me() {
 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();
 }
 
@@ -182,18 +176,19 @@ function match_referer($good_referer = "") {
 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().")");
@@ -306,15 +301,17 @@ function choose_from_menu ($options, $name, $selected="", $nothing="choose", $sc
         }
         $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";
@@ -674,10 +671,9 @@ function print_heading_with_help($text, $helppage, $module="moodle") {
 }
     
 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>");
@@ -1080,10 +1076,10 @@ function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=
 }
 
 function notice ($message, $link="") {
-    global $THEME, $HTTP_REFERER;
+    global $THEME;
 
     if (!$link) {
-        $link = $HTTP_REFERER;
+        $link = $_SERVER["HTTP_REFERER"];
     }
 
     echo "<BR>";
index 5bb1b83826f60903e2f160a22b18e0c20d4941e0..0455c7c677d1e3c84052bcfaa6bdbf4df8993b05 100644 (file)
@@ -79,7 +79,7 @@
     }
 
     if (empty($SESSION->wantsurl)) {
-           $SESSION->wantsurl = $HTTP_REFERER;
+           $SESSION->wantsurl = $_SERVER["HTTP_REFERER"];
         save_session("SESSION");
     }
     
index 3006bc383f15e7fa092ded6ac55d58c6ce437d6c..3dd9dda1b5bc2dfeda012d55fe4bb3136834acb8 100644 (file)
@@ -1061,12 +1061,12 @@ function forum_print_search_form($course, $search="", $return=false, $type="") {
 
 
 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");
         }
     }
index cb108a63cb0f8a08b3d05e3d5824fbcc911214a7..fa38ce0c355f97b73f5b0f715dd2edd569f2c651 100644 (file)
@@ -7,7 +7,7 @@
     require("lib.php");
 
     if (isguest()) {
-        error(get_string("noguestpost", "forum"), $HTTP_REFERER);
+        error(get_string("noguestpost", "forum"), $_SERVER["HTTP_REFERER"]);
     }
 
     if ($post = data_submitted()) {
@@ -73,7 +73,7 @@
 
     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);
index 8f51c22aaa9491403e55bedd1141b83b54ecbb37..940708c63dbca29f5505e11eda5d4792ae27e836 100644 (file)
@@ -7,7 +7,7 @@
     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
@@ -18,9 +18,9 @@
 
     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;
             }
@@ -40,7 +40,7 @@
                 }
             }
         }
-        redirect($HTTP_REFERER, "Ratings saved");
+        redirect($_SERVER["HTTP_REFERER"], get_string("ratingssaved", "forum"));
 
     } else {
         error("This page was not accessed correctly");
index b7209eb01d809d3497461ba874c348e12e0f4458..45b389459e67677b9a190464fb8c45c9eddf0d5d 100644 (file)
@@ -10,7 +10,7 @@
     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)) {
@@ -68,7 +68,7 @@
             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
@@ -76,7 +76,7 @@
             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"]);
         }
     }
 
index 63900492f3eb01563b524bbbcd42c93e6cfd6538..f27a5986390bfd9713b28471e0e88d5919c4f379 100644 (file)
@@ -15,7 +15,7 @@
     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)) {
index 65fce5a20ec93a097432e8669963723a3c95ba24..2b979fe3834876ee2ed1fdf59295ecd4b0d856a2 100644 (file)
@@ -14,7 +14,7 @@
     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
@@ -77,7 +77,7 @@
     }
 
     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") {
index d1cd83ead155a4f02f28e2585a2cffe4fe25b6b2..a974d1ad3bf721629e53d602ee45b15c8aa553f3 100644 (file)
@@ -26,7 +26,7 @@
                       "<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;
         }
 
index aab504a9870f5aac03ec8a22eed61350241ff44e..e805c0f9cbff72f3e31a5a6a8b7e0f67583738c7 100644 (file)
@@ -21,7 +21,7 @@
                        -> $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");
index 2aeafbc43aa5bd8fd93b88e53d1c3dd5fa32b521..bf0e6f2216b274e3fb37d7c5e6e3e4aeb1f79752 100644 (file)
@@ -94,7 +94,7 @@ function survey_user_complete($course, $user, $mod, $survey) {
     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");
     }
@@ -379,4 +379,16 @@ function survey_question_color($qnum) {
     }
 }
 
+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\">";
+    }
+}
+
 ?>
index 0a8c6b4d96b324e4db6dec60d77b0d811b9cb62f..c397b587e2b53b8e07d7ca999608bf4180df7c7d 100644 (file)
@@ -92,7 +92,9 @@
         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>";
              } 
          }
index 62ef15979ce7da312db1128b677103c668999c89..63536bb5da85172d82fd5e15fbfb6f1e11bdc71c 100644 (file)
@@ -6,12 +6,12 @@
 
 // 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
@@ -33,7 +33,7 @@
     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;
     }
 
@@ -44,7 +44,7 @@
 
     $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'
index df13ce0263385ba7eeff1521584bfa36215141b3..d3c7436c2676ff23bb16810c4629b93d852abf32 100644 (file)
@@ -45,7 +45,7 @@
         $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;
index 34fc4ec8cab68c337586e598eeee3b18fa951956..0a4e31b5b27387b263df08c065f068fc4d1a744d 100644 (file)
@@ -142,6 +142,9 @@ if (isadmin()) {
 <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>
@@ -153,6 +156,8 @@ if (isadmin()) {
     ?>
     </td>
 </tr>
+<? }  ?>
+
 <tr valign=top>
     <td><P><? print_string("webpage") ?>:</td>
     <td><input type="text" name="url" size=50 value="<? p($user->url) ?>">
index 8ff2dc1e40520eca6c524790e50e95eb2a5740a6..bf29f04ab2ccf95c52455090ffccad2d132db399 100644 (file)
@@ -48,7 +48,7 @@
         $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);
             }
 
@@ -57,7 +57,7 @@
         } 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;
index 27a08073228795fc8dff2208e7913d2621bce983..e329366499923f6517e0291b299d7818a2577d25 100644 (file)
@@ -56,16 +56,44 @@ function save_user_image($userid, $filename) {
 
     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);