OK a number of small changes here.

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
This commit is contained in:
moodler 2003-01-05 06:45:20 +00:00
parent 3b7c1de95e
commit 607809b3ba
25 changed files with 147 additions and 95 deletions

View File

@ -130,8 +130,8 @@
} 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)) {

View 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\">";
}
}

View File

@ -19,7 +19,7 @@
$USER->loggedin = true;
$USER->site = $CFG->wwwroot;
save_session("USER");
redirect($HTTP_REFERER);
redirect($_SERVER["HTTP_REFERER"]);
exit;
}

View File

@ -17,14 +17,14 @@
}
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);
@ -118,7 +118,7 @@
error("Could not cache module information!");
}
redirect($HTTP_REFERER);
redirect($_SERVER["HTTP_REFERER"]);
exit;
} else if (isset($delete)) { // value = course module
@ -218,7 +218,7 @@
} else if (isset($add)) {
if (!$add) {
redirect($HTTP_REFERER);
redirect($_SERVER["HTTP_REFERER"]);
die;
}

View File

@ -163,7 +163,7 @@
} 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);
@ -181,7 +181,7 @@
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");
@ -348,7 +348,7 @@
} 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);

View 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";

View 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)

View 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;
}

View 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 (!empty($_SERVER["REQUEST_URI"])) {
return $_SERVER["REQUEST_URI"];
if ($REQUEST_URI) {
return $REQUEST_URI;
} else if (!empty($_SERVER["PATH_INFO"])) {
return $_SERVER["PATH_INFO"];
} else if ($PATH_INFO) {
return $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>";

View File

@ -79,7 +79,7 @@
}
if (empty($SESSION->wantsurl)) {
$SESSION->wantsurl = $HTTP_REFERER;
$SESSION->wantsurl = $_SERVER["HTTP_REFERER"];
save_session("SESSION");
}

View 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");
}
}

View 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)) {
@ -227,7 +227,7 @@
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);

View 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");

View 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"]);
}
}

View 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)) {

View 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);
}
@ -114,7 +114,7 @@
}
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") {

View 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");
@ -167,7 +167,7 @@
break;
default:
error(get_string("notypechosen", "resource"), $HTTP_REFERER);
error(get_string("notypechosen", "resource"), $_SERVER["HTTP_REFERER"]);
break;
}

View 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");

View 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\">";
}
}
?>

View 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>";
}
@ -120,8 +122,7 @@
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>";
}
}
@ -173,13 +174,18 @@
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)) {
@ -287,7 +293,9 @@
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);
@ -307,9 +315,9 @@
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>";
}
}

View 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'

View 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;

View 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) ?>">

View 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;

View 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);