getGUID(); $alt_text = get_input('alt_text'); $url = get_input('logo_url'); // Only placeid, pageid and file itself are required 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 (is_uploaded_file($_FILES['logo_file']['tmp_name'])) { $logo = get_uploaded_file('logo_file'); $exif = exif_imagetype($_FILES['logo_file']['tmp_name']); // Default filetpe is .swf, not that good - but nothing to do with it $extension = ""; switch ($exif) { case IMAGETYPE_GIF: $extension = ".gif"; break; case IMAGETYPE_JPEG: $extension = ".jpeg"; break; case IMAGETYPE_PNG: $extension = ".png"; break; case IMAGETYPE_SWF: $extension = ".swf"; break; case IMAGETYPE_SWC: $extension = ".swf"; 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 $address .= $extension; // Object into fs $saved = saveImageFile($address, $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']); ?>