function nv_del_content_module($id) { global $db, $module_name, $module_data, $title; $content_del = "NO_" . $id; $title = ""; list($id, $listcatid, $title, $homeimgfile, $homeimgthumb) = $db->sql_fetchrow($db->sql_query("SELECT `id`, `listcatid`, `title`, `homeimgfile`, `homeimgthumb` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `id`=" . intval($id) . "")); if ($id > 0) { nv_save_log_content($id); if ($homeimgfile != "" or $homeimgthumb != "") { $homeimgfile .= "|" . $homeimgthumb; $homeimgfile_arr = explode("|", $homeimgfile); foreach ($homeimgfile_arr as $homeimgfile_i) { if (!empty($homeimgfile_i) and is_file(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $homeimgfile_i)) { @nv_deletefile(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $homeimgfile_i); } } } $number_no_del = 0; $array_catid = explode(",", $listcatid); foreach ($array_catid as $catid_i) { $catid_i = intval($catid_i); if ($catid_i > 0) { $query = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid_i . "` WHERE `id`=" . $id . ""; $db->sql_query($query); if (!$db->sql_affectedrows()) { $number_no_del++; } $db->sql_freeresult(); } } if ($number_no_del == 0) { $query = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `id`=" . $id; $db->sql_query($query); if (!$db->sql_affectedrows()) { $number_no_del++; $db->sql_freeresult(); } } $number_no_del = 0; if ($number_no_del == 0) { $db->sql_query("DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_comments` WHERE `id` = " . $id); $db->sql_query("DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_block` WHERE `id` = " . $id); $content_del = "OK_" . $id; } else { $content_del = "ERR_" . $lang_module['error_del_content']; } } return $content_del; }
$id_array = array_map("intval", explode(",", $listid)); $sql = "SELECT `id`, `listcatid`, `status`, `publtime`, `exptime` FROM " . NV_PREFIXLANG . "_" . $module_data . "_rows WHERE `id` in (" . implode(",", $id_array) . ")"; $result = $db->sql_query($sql); while (list($id, $listcatid, $status, $publtime, $exptime) = $db->sql_fetchrow($result)) { $data_save = array(); if ($exptime > 0 and $exptime < NV_CURRENTTIME) { $data_save['exptime'] = 0; } if ($publtime > NV_CURRENTTIME) { $data_save['publtime'] = NV_CURRENTTIME; } if ($status == 0) { $data_save['status'] = 1; } if (!empty($data_save)) { nv_save_log_content($id); $arr_catid = array_map("intval", explode(",", $listcatid)); $s_ud = ""; foreach ($data_save as $key => $value) { $s_ud .= "`" . $key . "` = '" . $value . "', "; } $s_ud .= "`edittime` = '" . NV_CURRENTTIME . "'"; $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_rows` SET " . $s_ud . " WHERE `id` =" . $id . ""); foreach ($arr_catid as $catid_i) { $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid_i . "` SET " . $s_ud . " WHERE `id` =" . $id . ""); } } } nv_del_moduleCache($module_name); } Header("Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "");
} if ($rowcontent['id'] == 0) { $rowcontent['publtime'] = $rowcontent['publtime'] > NV_CURRENTTIME ? $rowcontent['publtime'] : NV_CURRENTTIME; $query = "INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "_rows` (`id`, `listcatid`, `topicid`, `admin_id`, `author`, `sourceid`, `addtime`, `edittime`, `status`, `publtime`, `exptime`, `archive`, `title`, `alias`, `hometext`, `homeimgfile`, `homeimgalt`, `homeimgthumb`, `imgposition`, `bodytext`, `copyright`, `inhome`,`is_notice`, `allowed_comm`, `allowed_rating`, `ratingdetail`, `allowed_send`, `allowed_print`, `allowed_save`, `hitstotal`, `hitscm`, `hitslm`, `keywords`) VALUES\r\n (NULL, " . $db->dbescape_string($rowcontent['listcatid']) . ",\r\n " . intval($rowcontent['topicid']) . ",\r\n " . intval($rowcontent['admin_id']) . ",\r\n " . $db->dbescape_string($rowcontent['author']) . ",\r\n " . intval($rowcontent['sourceid']) . ",\r\n " . intval($rowcontent['addtime']) . ",\r\n " . intval($rowcontent['edittime']) . ",\r\n " . intval($rowcontent['status']) . ",\r\n " . intval($rowcontent['publtime']) . ",\r\n " . intval($rowcontent['exptime']) . ", \r\n " . intval($rowcontent['archive']) . ",\r\n " . $db->dbescape_string($rowcontent['title']) . ",\r\n " . $db->dbescape_string($rowcontent['alias']) . ",\r\n " . $db->dbescape_string($rowcontent['hometext']) . ",\r\n " . $db->dbescape_string($rowcontent['homeimgfile']) . ",\r\n " . $db->dbescape_string($rowcontent['homeimgalt']) . ",\r\n " . $db->dbescape_string($rowcontent['homeimgthumb']) . ",\r\n " . intval($rowcontent['imgposition']) . ",\r\n " . $db->dbescape_string($rowcontent['bodytext']) . ",\r\n " . intval($rowcontent['copyright']) . ", \r\n " . intval($rowcontent['inhome']) . ",\r\n " . intval($rowcontent['is_notice']) . ",\r\n " . intval($rowcontent['allowed_comm']) . ", \r\n " . intval($rowcontent['allowed_rating']) . ", \r\n " . $db->dbescape_string($rowcontent['ratingdetail']) . ", \r\n " . intval($rowcontent['allowed_send']) . ", \r\n " . intval($rowcontent['allowed_print']) . ", \r\n " . intval($rowcontent['allowed_save']) . ", \r\n " . intval($rowcontent['hitstotal']) . ", \r\n " . intval($rowcontent['hitscm']) . ", \r\n " . intval($rowcontent['hitslm']) . ", \r\n " . $db->dbescape_string($rowcontent['keywords']) . ")"; $rowcontent['id'] = $db->sql_query_insert_id($query); if ($rowcontent['id'] > 0) { nv_insert_logs(NV_LANG_DATA, $module_name, 'log_add_content', "id " . $rowcontent['id'], $admin_info['userid']); foreach ($catids as $catid) { $db->sql_query("INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid . "` SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `id`=" . $rowcontent['id'] . ""); } } else { $error = $lang_module['errorsave']; } $db->sql_freeresult(); } else { nv_save_log_content($rowcontent['id']); $rowcontent_old = $db->sql_fetchrow($db->sql_query("SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` where `id`=" . $rowcontent['id'] . "")); if ($rowcontent_old['status'] == 1) { $rowcontent['status'] = 1; } $query = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_rows` SET \r\n `listcatid`=" . $db->dbescape_string($rowcontent['listcatid']) . ", \r\n `topicid`=" . intval($rowcontent['topicid']) . ", \r\n `author`=" . $db->dbescape_string($rowcontent['author']) . ", \r\n `sourceid`=" . intval($rowcontent['sourceid']) . ", \r\n `status`=" . intval($rowcontent['status']) . ", \r\n `publtime`=" . intval($rowcontent['publtime']) . ", \r\n `exptime`=" . intval($rowcontent['exptime']) . ", \r\n `archive`=" . intval($rowcontent['archive']) . ", \r\n `title`=" . $db->dbescape_string($rowcontent['title']) . ", \r\n `alias`=" . $db->dbescape_string($rowcontent['alias']) . ", \r\n `hometext`=" . $db->dbescape_string($rowcontent['hometext']) . ", \r\n `homeimgfile`=" . $db->dbescape_string($rowcontent['homeimgfile']) . ",\r\n `homeimgalt`=" . $db->dbescape_string($rowcontent['homeimgalt']) . ",\r\n `homeimgthumb`=" . $db->dbescape_string($rowcontent['homeimgthumb']) . ",\r\n `imgposition`=" . intval($rowcontent['imgposition']) . ",\r\n `bodytext`=" . $db->dbescape_string($rowcontent['bodytext']) . ", \r\n `copyright`=" . intval($rowcontent['copyright']) . ", \r\n `inhome`=" . intval($rowcontent['inhome']) . ",\r\n `is_notice`=" . intval($rowcontent['is_notice']) . ",\r\n `allowed_comm`=" . intval($rowcontent['allowed_comm']) . ", \r\n `allowed_rating`=" . intval($rowcontent['allowed_rating']) . ", \r\n `allowed_send`=" . intval($rowcontent['allowed_send']) . ", \r\n `allowed_print`=" . intval($rowcontent['allowed_print']) . ", \r\n `allowed_save`=" . intval($rowcontent['allowed_save']) . ", \r\n `keywords`=" . $db->dbescape_string($rowcontent['keywords']) . ", \r\n `edittime`=UNIX_TIMESTAMP( ) \r\n WHERE `id` =" . $rowcontent['id'] . ""; $db->sql_query($query); if ($db->sql_affectedrows() > 0) { //nv_insert_logs( NV_LANG_DATA, $module_name, 'log_edit_content', "id ".$rowcontent['id'], $admin_info['userid'] ); $array_cat_old = explode(",", $rowcontent_old['listcatid']); foreach ($array_cat_old as $catid) { $db->sql_query("DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid . "` WHERE `id` = " . $rowcontent['id'] . ""); } $array_cat_new = explode(",", $rowcontent['listcatid']); foreach ($array_cat_new as $catid) { $db->sql_query("INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid . "` SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `id`=" . $rowcontent['id'] . "");