// init page var $listings_page = "contacts.php"; // make sure that an action is set if ($action == "") { $action = "add"; } // check news_id format, if not numeric then send to listing page if ($action != "add" && !is_numeric($item_id)) { header("Location: " . $listings_page); exit; } // if action isn't add, load data for edit/delete if ($action != "add") { // load the item's details $item_result = fetchContactsDetail($item_id, ""); $images_result = fetchContactsPhotos($item_id); if (count($item_result) < 1) { // send to listings page if no result header("Location: " . $listings_page); exit; } // proceed with deleting the item, if requested if ($action == "delete") { // delete row from database $sql = "DELETE FROM contacts WHERE id = '" . intval($item_id) . "' "; $sqlConn->Execute($sql); if ($images_result[0]["image"] != "" && @is_file(FILES_PATH . FILES_CONTACTS_LARGE . $images_result[0]["image"])) { @unlink(FILES_PATH . FILES_CONTACTS_LARGE . $images_result[0]["image"]); } if ($images_result[0]["image"] != "" && @is_file(FILES_PATH . FILES_CONTACTS_MEDIUM . $images_result[0]["image"])) { @unlink(FILES_PATH . FILES_CONTACTS_MEDIUM . $images_result[0]["image"]);
if ($action == "") { $action = "add"; } // check image_id format, if not numeric then send to listing page if ($action != "add" && !is_numeric($image_id)) { header("Location: " . $listings_page); exit; } // check artist_id format, if not numeric then send to listing page if ($action == "add" && !is_numeric($item_id)) { header("Location: " . $listings_page); exit; } if ($action != "add") { // load the item's details $image_row = fetchContactsPhotos($image_id); if (count($image_row) < 1) { // send to listings page if no result header("Location: " . $listings_page); exit; } // proceed with deleting the item, if requested if ($action == "delete") { // delete large if ($image_row["image"] != "" && @is_file(FILES_PATH . FILES_ACTIVITIES_LARGE . $image_row["image"])) { @unlink(FILES_PATH . FILES_ACTIVITIES_LARGE . $image_row["image"]); } // delete medium if ($image_row["image"] != "" && @is_file(FILES_PATH . FILES_ACTIVITIES_MEDIUM . $image_row["image"])) { @unlink(FILES_PATH . FILES_ACTIVITIES_MEDIUM . $image_row["image"]); }