Skip to content

Commit

Permalink
Checks for bad permissions and defaults to default picture
Browse files Browse the repository at this point in the history
  • Loading branch information
martin committed May 18, 2002
1 parent c1e88d4 commit 54bdcdb
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,39 @@
}

if (!file_exists("$CFG->dataroot/users")) {
mkdir("$CFG->dataroot/users", 0777);
if (! mkdir("$CFG->dataroot/users", 0777)) {
$badpermissions = true;
}
}
if (!file_exists("$CFG->dataroot/users/$USER->id")) {
mkdir("$CFG->dataroot/users/$USER->id", 0777);
if (! mkdir("$CFG->dataroot/users/$USER->id", 0777)) {
$badpermissions = true;
}
}

ImageCopyBicubic($im1, $im, 0, 0, $cx-$half, $cy-$half, 100, 100, $half*2, $half*2);
ImageCopyBicubic($im2, $im, 0, 0, $cx-$half, $cy-$half, 35, 35, $half*2, $half*2);
if ($badpermissions) {
$usernew->picture = "0";

} else {
ImageCopyBicubic($im1, $im, 0, 0, $cx-$half, $cy-$half, 100, 100, $half*2, $half*2);
ImageCopyBicubic($im2, $im, 0, 0, $cx-$half, $cy-$half, 35, 35, $half*2, $half*2);

// Draw borders over the top.
$black1 = ImageColorAllocate ($im1, 0, 0, 0);
$black2 = ImageColorAllocate ($im2, 0, 0, 0);
ImageLine ($im1, 0, 0, 0, 99, $black1);
ImageLine ($im1, 0, 99, 99, 99, $black1);
ImageLine ($im1, 99, 99, 99, 0, $black1);
ImageLine ($im1, 99, 0, 0, 0, $black1);
ImageLine ($im2, 0, 0, 0, 34, $black2);
ImageLine ($im2, 0, 34, 34, 34, $black2);
ImageLine ($im2, 34, 34, 34, 0, $black2);
ImageLine ($im2, 34, 0, 0, 0, $black2);

ImageJpeg($im1, "$CFG->dataroot/users/$USER->id/f1.jpg", 90);
ImageJpeg($im2, "$CFG->dataroot/users/$USER->id/f2.jpg", 95);
$usernew->picture = "1";
// Draw borders over the top.
$black1 = ImageColorAllocate ($im1, 0, 0, 0);
$black2 = ImageColorAllocate ($im2, 0, 0, 0);
ImageLine ($im1, 0, 0, 0, 99, $black1);
ImageLine ($im1, 0, 99, 99, 99, $black1);
ImageLine ($im1, 99, 99, 99, 0, $black1);
ImageLine ($im1, 99, 0, 0, 0, $black1);
ImageLine ($im2, 0, 0, 0, 34, $black2);
ImageLine ($im2, 0, 34, 34, 34, $black2);
ImageLine ($im2, 34, 34, 34, 0, $black2);
ImageLine ($im2, 34, 0, 0, 0, $black2);

ImageJpeg($im1, "$CFG->dataroot/users/$USER->id/f1.jpg", 90);
ImageJpeg($im2, "$CFG->dataroot/users/$USER->id/f2.jpg", 95);
$usernew->picture = "1";
}
} else {
$usernew->picture = $user->picture;
}
Expand Down

0 comments on commit 54bdcdb

Please sign in to comment.