} elseif ($imagesize['2'] == 3) { $ext = 'png'; } if ($ext == '') { $errors[] = 'Invalid image format uploaded. Allowed formats: jpg, gif and png!'; } } if (!$errors) { $src = $_FILES['avatar']['tmp_name']; $dst_tmp = $config['BASE_DIR'] . '/tmp/avatars/' . $UID . '.' . $ext; if (move_uploaded_file($src, $dst_tmp)) { require $config['BASE_DIR'] . '/classes/image.class.php'; $dst = $config['BASE_DIR'] . '/media/users/orig/' . $UID . '.jpg'; $image = new VImageConv(); $image->process($dst_tmp, $dst, 'MAX_HEIGHT', 240, 200); $image->resize(true); $src = $dst; $dst = $config['BASE_DIR'] . '/media/users/' . $UID . '.jpg'; $image->process($src, $dst, 'EXACT', 100, 120); $image->resize(true); $photo_new = TRUE; } else { $errors[] = 'Failed to move uploaded file (invalid permissions?)!'; } } } if (!$errors) { $sql_add = NULL; if ($password != '') { $passwd = md5($password); $sql_add = " ,pwd = '" . $passwd . "'";
$image = new VImageConv(); foreach ($_FILES as $key => $values) { if ($values['tmp_name'] != '') { if (is_uploaded_file($values['tmp_name'])) { $filename = substr($values['name'], strrpos($values['name'], DIRECTORY_SEPARATOR) + 1); $extension = strtolower(substr($values['name'], strrpos($values['name'], '.') + 1)); $extensions_allowed = explode(',', trim($config['image_allowed_extensions'])); if (in_array($extension, $extensions_allowed)) { $sql = "INSERT INTO notice_images (addtime, extension) VALUES (" . time() . ", '" . $extension . "')"; $conn->execute($sql); $image_id = mysql_insert_id(); $dst_orig = $config['BASE_DIR'] . '/images/notice_images/' . $image_id . '.' . $extension; if (move_uploaded_file($values['tmp_name'], $dst_orig)) { $src = $dst_orig; $dst = $config['BASE_DIR'] . '/images/notice_images/thumbs/' . $image_id . '.jpg'; $image->process($src, $dst, 'MAX_WIDTH', 150, 0); $image->resize(true, true); ++$images; } else { $sql = "DELETE FROM notice_images WHERE image_id = " . $image_id . " LIMIT 1"; $conn->execute($sql); } } } } } } if ($images > 0) { $_SESSION['message'] = 'Successfully added ' . $images . ' images!'; VRedirect::go($config['BASE_URL'] . '/siteadmin/notices.php?m=list_images'); }