From 54bdcdbecc91d387f20b24277071b262e22f32d1 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 18 May 2002 03:13:44 +0000 Subject: [PATCH] Checks for bad permissions and defaults to default picture --- user/edit.php | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/user/edit.php b/user/edit.php index 12aac784a0..8080252a32 100644 --- a/user/edit.php +++ b/user/edit.php @@ -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; } -- 2.39.5