getGUID(); if (get_input("cancel_button")) { forward($_SERVER['HTTP_REFERER']); } if (empty($title)) { register_error("title missing"); forward($_SERVER['HTTP_REFERER']); } // if editing existing quality mark if ($id) { update_data("UPDATE {$CONFIG->dbprefix}koolielu_quality_marks SET title = '$title' WHERE ID = $id;"); } if ((isset($_FILES['quality_mark_image'])) && (substr_count($_FILES['quality_mark_image']['type'],'image/'))) { $quality_mark_image = get_uploaded_file("quality_mark_image"); $exif = exif_imagetype($_FILES['quality_mark_image']['tmp_name']); switch ($exif) { case IMAGETYPE_GIF: $extension = ".gif"; break; case IMAGETYPE_JPEG: $extension = ".jpeg"; break; case IMAGETYPE_PNG: $extension = ".png"; break; } // Add the extension to the filename $address .= $extension; // Save image into the FS $saved = saveImageFile($address, $quality_mark_image, $user_guid); if ($id) { $previous_data = get_data_row("SELECT * FROM {$CONFIG->dbprefix}koolielu_quality_marks WHERE ID = $id"); $old_image_file = $previous_data->image; $old_user_guid = $previous_data->user_guid; deleteImageFile($old_image_file, $user_guid); update_data("UPDATE {$CONFIG->dbprefix}koolielu_quality_marks SET image = '$address', user_guid = $user_guid WHERE ID = $id;"); } else { // Save new quality mark into the database $datas = insert_data("INSERT INTO {$CONFIG->dbprefix}koolielu_quality_marks (title, image, user_guid) VALUES ('$title', '$address', $user_guid)"); if (!($saved || $datas)) { /*translation:Could not be added.*/ register_error(elgg_echo('koolielu:error_could_not_be_added')); } else { /*translation:New quality mark added.*/ system_message(elgg_echo('koolielu:message_new_quality_mark_added')); } } } forward($_SERVER['HTTP_REFERER']); ?>