getGUID(); $alt_text = get_input('alt_text'); $url = get_input('logo_url'); if (empty($placeid) || empty($pageid) || !is_uploaded_file($_FILES['logo_file']['tmp_name'])) { /*translation:Logo could not be saved. Please fill all required fields.*/ register_error(elgg_echo("koolielu:error_not_all_needed_information_profided")); forward($_SERVER['HTTP_REFERER']); } if ((isset($_FILES['logo_file'])) && (substr_count($_FILES['logo_file']['type'],'image/'))) { $exif = exif_imagetype($_FILES['logo_file']['tmp_name']); $extension = ""; switch ($exif) { case IMAGETYPE_GIF: $extension = ".gif"; break; case IMAGETYPE_JPEG: $extension = ".jpeg"; break; case IMAGETYPE_PNG: $extension = ".png"; break; } // If none of allowed extensions detected, file upload is not allowed if ($extension == "") { /*translation:Uploaded file type is not supported.*/ register_error(elgg_echo("koolielu:error_uploaded_filetype_not_supported")); forward($_SERVER['HTTP_REFERER']); } // Add the extension to the filename // We are resizing any file turning it into .jpg, thus it is the only sane extension $address .= ".jpeg"; // Save image into the FS $resized_logo = get_resized_image_from_uploaded_file('logo_file', 150, 150, false); $saved = saveImageFile($address, $resized_logo, $userid); // Save image data into the database $datas = koolielu_add_logo($address, $placeid, $pageid, $userid, $url, $alt_text); if (!($saved || $datas)) { /*translation:Logo could not be saved.*/ register_error(elgg_echo('koolielu:error_logo_could_not_be_saved')); } else { /*translation:Logo saved.*/ system_message(elgg_echo('koolielu:message_logo_saved')); } } forward($_SERVER['HTTP_REFERER']); ?>