From bff38dadde1e94ed29252143dbe52446c92009a2 Mon Sep 17 00:00:00 2001 From: e107steved Date: Sun, 7 Dec 2008 13:08:54 +0000 Subject: [PATCH] Add admin logging to news --- e107_admin/newspost.php | 178 +++++++++++------- e107_admin/update_routines.php | 6 +- e107_files/def_e107_prefs.php | 5 +- e107_handlers/news_class.php | 53 ++++-- .../English/admin/lan_log_messages.php | 15 +- e107_languages/English/admin/lan_newspost.php | 10 +- e107_plugins/alt_news/alt_news.php | 16 +- 7 files changed, 181 insertions(+), 102 deletions(-) diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 87769e52d..73abd4354 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -9,19 +9,21 @@ * News Administration * * $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $ - * $Revision: 1.17 $ - * $Date: 2008-12-02 16:50:16 $ - * $Author: secretr $ + * $Revision: 1.18 $ + * $Date: 2008-12-07 13:08:41 $ + * $Author: e107steved $ */ require_once("../class2.php"); -if (!getperms("H")) { +if (!getperms("H")) +{ header("location:".e_BASE."index.php"); exit; } require_once(e_HANDLER."calendar/calendar_class.php"); $cal = new DHTML_Calendar(true); -function headerjs(){ +function headerjs() +{ global $cal; $js = $cal->load_files(); @@ -71,14 +73,22 @@ $amount = 10; if(isset($_POST['news_userclass'])) { - $_POST['news_class'] = implode(",", array_keys($_POST['news_userclass'])); + unset($temp); + foreach ($_POST['news_userclass'] as $k => $v) + { + $temp[] = intval($k); + } + $_POST['news_class'] = implode(",", $temp); + unset($temp); + unset($_POST['news_userclass']); } if(isset($_POST['delete'])) { - $tmp = array_keys($_POST['delete']); - list($delete, $del_id) = explode("_", $tmp[0]); + $tmp = array_keys($_POST['delete']); + list($delete, $del_id) = explode("_", $tmp[0]); + $del_id = intval($del_id); } @@ -87,8 +97,9 @@ if ($delete == "main" && $del_id) if ($sql->db_Count('news','(*)',"WHERE news_id = '{$del_id}'")) { $e_event->trigger("newsdel", $del_id); - if($sql->db_Delete("news", "news_id='$del_id' ")) + if($sql->db_Delete("news", "news_id='{$del_id}' ")) { + $admin_log->log_event('NEWS_01',$del_id,E_LOG_INFORMATIVE,''); $newspost->show_message(NWSLAN_31." #".$del_id." ".NWSLAN_32); $e107cache->clear("news.php"); $e107cache->clear("othernews"); @@ -101,8 +112,11 @@ if ($delete == "main" && $del_id) } -if ($delete == "category" && $del_id) { - if ($sql->db_Delete("news_category", "category_id='$del_id' ")) { +if ($delete == "category" && $del_id) +{ + if ($sql->db_Delete("news_category", "category_id='{$del_id}' ")) + { + $admin_log->log_event('NEWS_02',$del_id,E_LOG_INFORMATIVE,''); $newspost->show_message(NWSLAN_33." #".$del_id." ".NWSLAN_32); unset($delete, $del_id); } @@ -111,8 +125,9 @@ if ($delete == "category" && $del_id) { if($delete == "sn" && $del_id) { - if ($sql->db_Delete("submitnews", "submitnews_id='$del_id' ")) + if ($sql->db_Delete("submitnews", "submitnews_id='{$del_id}' ")) { + $admin_log->log_event('NEWS_03',$del_id,E_LOG_INFORMATIVE,''); $newspost->show_message(NWSLAN_34." #".$del_id." ".NWSLAN_32); $e107cache->clear("news.php"); $e107cache->clear("othernews"); @@ -129,16 +144,20 @@ if (isset($_POST['submitupload'])) $uploaded = file_upload(e_IMAGE."newspost_images/"); - foreach($_POST['uploadtype'] as $key=>$uploadtype){ - if($uploadtype == "thumb"){ + foreach($_POST['uploadtype'] as $key=>$uploadtype) + { + if($uploadtype == "thumb") + { rename(e_IMAGE."newspost_images/".$uploaded[$key]['name'],e_IMAGE."newspost_images/thumb_".$uploaded[$key]['name']); } - if($uploadtype == "file"){ + if($uploadtype == "file") + { rename(e_IMAGE."newspost_images/".$uploaded[$key]['name'],e_FILE."downloads/".$uploaded[$key]['name']); } - if ($uploadtype == "resize" && $_POST['resize_value']) { + if ($uploadtype == "resize" && $_POST['resize_value']) + { require_once(e_HANDLER."resize_handler.php"); resize_image(e_IMAGE."newspost_images/".$uploaded[$key]['name'], e_IMAGE."newspost_images/".$uploaded[$key]['name'], $_POST['resize_value'], "copy"); } @@ -165,11 +184,16 @@ if (isset($_POST['submit_news'])) unset($sub_action, $id); } -if (isset($_POST['create_category'])) { - if ($_POST['category_name']) { - if (empty($_POST['category_button'])) { + +if (isset($_POST['create_category'])) +{ + if ($_POST['category_name']) + { + if (empty($_POST['category_button'])) + { $handle = opendir(e_IMAGE."icons"); - while ($file = readdir($handle)) { + while ($file = readdir($handle)) + { if ($file != "." && $file != ".." && $file != "/" && $file != "null.txt" && $file != "CVS") { $iconlist[] = $file; } @@ -177,17 +201,26 @@ if (isset($_POST['create_category'])) { closedir($handle); $_POST['category_button'] = $iconlist[0]; } + else + { + $_POST['category_button'] = $tp->toDB($_POST['category_button']); + } $_POST['category_name'] = $tp->toDB($_POST['category_name']); - $sql->db_Insert("news_category", "'0', '".$_POST['category_name']."', '".$_POST['category_button']."'"); + $sql->db_Insert('news_category', "'0', '".$_POST['category_name']."', '".$_POST['category_button']."'"); + $admin_log->log_event('NEWS_04',$_POST['category_name'].', '.$_POST['category_button'],E_LOG_INFORMATIVE,''); $newspost->show_message(NWSLAN_35); } } -if (isset($_POST['update_category'])) { - if ($_POST['category_name']) { - $category_button = ($_POST['category_button'] ? $_POST['category_button'] : ""); + +if (isset($_POST['update_category'])) +{ + if ($_POST['category_name']) + { + $category_button = $tp->toDB(($_POST['category_button'] ? $_POST['category_button'] : "")); $_POST['category_name'] = $tp->toDB($_POST['category_name']); - $sql->db_Update("news_category", "category_name='".$_POST['category_name']."', category_icon='".$category_button."' WHERE category_id='".$_POST['category_id']."'"); + $sql->db_Update("news_category", "category_name='".$_POST['category_name']."', category_icon='".$category_button."' WHERE category_id='".intval($_POST['category_id'])."'"); + $admin_log->log_event('NEWS_05',intval($_POST['category_id']).':'.$_POST['category_name'].', '.$category_button,E_LOG_INFORMATIVE,''); $newspost->show_message(NWSLAN_36); } $e107cache->clear("news.php"); @@ -195,42 +228,52 @@ if (isset($_POST['update_category'])) { $e107cache->clear("othernews2"); } + if (isset($_POST['save_prefs'])) { - $pref['newsposts'] = $_POST['newsposts']; - $pref['newsposts_archive'] = $_POST['newsposts_archive']; - $pref['newsposts_archive_title'] = $tp->toDB($_POST['newsposts_archive_title']); - $pref['news_cats'] = $_POST['news_cats']; - $pref['nbr_cols'] = $_POST['nbr_cols']; - $pref['subnews_attach'] = $_POST['subnews_attach']; - $pref['subnews_resize'] = $_POST['subnews_resize']; - $pref['subnews_class'] = $_POST['subnews_class']; - $pref['subnews_htmlarea'] = $_POST['subnews_htmlarea']; - $pref['subnews_hide_news'] = $_POST['subnews_hide_news']; - $pref['news_subheader'] = $tp->toDB($_POST['news_subheader']); - $pref['news_newdateheader'] = $_POST['news_newdateheader']; - $pref['news_unstemplate'] = $_POST['news_unstemplate']; - $pref['news_editauthor'] = $_POST['news_editauthor']; + unset($temp); + $temp['newsposts'] = intval($_POST['newsposts']); + $temp['newsposts_archive'] = intval($_POST['newsposts_archive']); + $temp['newsposts_archive_title'] = $tp->toDB($_POST['newsposts_archive_title']); + $temp['news_cats'] = intval($_POST['news_cats']); + $temp['nbr_cols'] = intval($_POST['nbr_cols']); + $temp['subnews_attach'] = intval($_POST['subnews_attach']); + $temp['subnews_resize'] = intval($_POST['subnews_resize']); + $temp['subnews_class'] = intval($_POST['subnews_class']); + $temp['subnews_htmlarea'] = intval($_POST['subnews_htmlarea']); + $temp['news_subheader'] = $tp->toDB($_POST['news_subheader']); + $temp['news_newdateheader'] = intval($_POST['news_newdateheader']); + $temp['news_unstemplate'] = intval($_POST['news_unstemplate']); + $temp['news_editauthor'] = intval($_POST['news_editauthor']); - save_prefs(); - $e107cache->clear("news.php"); - $e107cache->clear("othernews"); - $e107cache->clear("othernews2"); - $newspost->show_message(NWSLAN_119); + if ($admin_log->logArrayDiffs($temp, $pref, 'NEWS_06')) + { + save_prefs(); // Only save if changes + $e107cache->clear("news.php"); + $e107cache->clear("othernews"); + $e107cache->clear("othernews2"); + $newspost->show_message(NWSLAN_119); + } + else + { + $newspost->show_message(LAN_NEWS_47); + } } + if (!e_QUERY || $action == "main") { $newspost->show_existing_items($action, $sub_action, $sort_order, $from, $amount); } + if ($action == "create") { $preset = $pst->read_preset("admin_newspost"); //only works here because $_POST is used. if ($sub_action == "edit" && !$_POST['preview'] && !$_POST['submit_news']) { - if ($sql->db_Select("news", "*", "news_id='$id' ")) + if ($sql->db_Select("news", "*", "news_id='{$id}' ")) { $row = $sql->db_Fetch(); extract($row); @@ -297,7 +340,7 @@ class newspost function show_existing_items($action, $sub_action, $sort_order, $from, $amount) { - // ##### Display scrolling list of existing news items --------------------------------------------------------------------------------------------------------- + // ##### Display scrolling list of existing news items global $sql, $ns, $tp, $imode; $text = "
"; @@ -379,7 +422,8 @@ class newspost } - function show_options($action) { + function show_options($action) + { global $sql; if ($action == "") { @@ -813,7 +857,8 @@ class newspost } - function preview_item($id) { + function preview_item($id) + { // ##### Display news preview --------------------------------------------------------------------------------------------------------- global $tp, $sql, $ix, $IMAGES_DIRECTORY; @@ -873,9 +918,11 @@ class newspost echo $tp -> parseTemplate('{NEWSINFO}', FALSE, $news_shortcodes); } - function submit_item($sub_action, $id) { - // ##### Format and submit item --------------------------------------------------------------------------------------------------------- - global $tp, $ix, $sql; + + function submit_item($sub_action, $id) + { + // ##### Format and submit item to DB + global $tp, $ix, $sql, $admin_log; if($_POST['news_start']) { $tmp = explode("/", $_POST['news_start']); @@ -917,8 +964,10 @@ class newspost else { $sql->db_Update("submitnews", "submitnews_auth='1' WHERE submitnews_id ='".$id."' "); + $admin_log->log_event('NEWS_07',$id,E_LOG_INFORMATIVE,''); } - if (!$_POST['cat_id']) { + if (!$_POST['cat_id']) + { $_POST['cat_id'] = 1; } @@ -928,13 +977,17 @@ class newspost unset($_POST['news_title'], $_POST['cat_id'], $_POST['data'], $_POST['news_extended'], $_POST['news_allow_comments'], $_POST['startday'], $_POST['startmonth'], $_POST['startyear'], $_POST['endday'], $_POST['endmonth'], $_POST['endyear'], $_POST['news_id'], $_POST['news_class']); } - function show_message($message) { + + function show_message($message) + { // ##### Display comfort --------------------------------------------------------------------------------------------------------- global $ns; $ns->tablerender("", "
".$message."
"); } - function show_categories($sub_action, $id) { + + function show_categories($sub_action, $id) + { global $sql, $rs, $ns, $tp; $handle = opendir(e_IMAGE."icons"); while ($file = readdir($handle)) { @@ -1023,7 +1076,9 @@ class newspost $ns->tablerender(NWSLAN_51, $text); } - function show_news_prefs() { + + function show_news_prefs() + { global $sql, $rs, $ns, $pref; $text = "
@@ -1057,16 +1112,6 @@ class newspost "; - // - // ".NWSLAN_108."
".NWSLAN_109." - // - // - // - // "; - - - - // ##### ADDED FOR NEWS ARCHIVE -------------------------------------------------------------------- // the possible archive values are from "0" to "< $pref['newsposts']" @@ -1212,7 +1257,8 @@ class newspost } -function newspost_adminmenu() { +function newspost_adminmenu() +{ global $newspost; global $action; $newspost->show_options($action); diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 6ef70571e..868e5df84 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ -| $Revision: 1.32 $ -| $Date: 2008-12-06 15:48:16 $ +| $Revision: 1.33 $ +| $Date: 2008-12-07 13:08:41 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -220,7 +220,7 @@ function update_706_to_800($type='') // List of unwanted $pref values which can go $obs_prefs = array('frontpage_type','rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle', 'utf-compatmode','frontpage_method','standards_mode','image_owner','im_quality', 'signup_option_timezone', - 'modules', 'plug_sc', 'plug_bb', 'plug_status', 'plug_latest' + 'modules', 'plug_sc', 'plug_bb', 'plug_status', 'plug_latest', 'subnews_hide_news' ); // List of DB tables not required (includes a few from 0.6xx) diff --git a/e107_files/def_e107_prefs.php b/e107_files/def_e107_prefs.php index 072a388c1..c54052017 100644 --- a/e107_files/def_e107_prefs.php +++ b/e107_files/def_e107_prefs.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_files/def_e107_prefs.php,v $ -| $Revision: 1.17 $ -| $Date: 2008-11-23 22:49:42 $ +| $Revision: 1.18 $ +| $Date: 2008-12-07 13:08:41 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -118,7 +118,6 @@ City, State, Country 'subnews_resize' => '', 'subnews_class' => '0', 'subnews_htmlarea' => '0', - 'subnews_hide_news' => '', 'news_newdateheader' => '0', 'email_text' => '', 'useGeshi' => '0', diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php index 741fe2585..5b890196f 100644 --- a/e107_handlers/news_class.php +++ b/e107_handlers/news_class.php @@ -9,17 +9,18 @@ * News handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/news_class.php,v $ - * $Revision: 1.6 $ - * $Date: 2008-12-02 16:50:15 $ - * $Author: secretr $ + * $Revision: 1.7 $ + * $Date: 2008-12-07 13:08:41 $ + * $Author: e107steved $ */ if (!defined('e107_INIT')) { exit; } class news { - function submit_item($news) { - global $sql, $tp, $e107cache, $e_event, $pref; + function submit_item($news) + { + global $sql, $tp, $e107cache, $e_event, $pref, $admin_log; if (!is_object($tp)) $tp = new e_parse; if (!is_object($sql)) $sql = new db; @@ -32,21 +33,32 @@ class news { $author_insert = ($news['news_author'] == 0) ? "news_author = '".USERID."'," : "news_author = '".intval($news['news_author'])."', "; $news['news_author'] = ($news['news_author']) ? $news['news_author'] : USERID; - if ($news['news_id']) { + if ($news['news_id']) + { // Updating existing item $vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' "; - if ($sql -> db_Update('news', $vals)) { + if ($sql -> db_Update('news', $vals)) + { + $admin_log->logArrayAll('NEWS_09', $news); $e_event -> trigger('newsupd', $news); $message = LAN_NEWS_21; $e107cache -> clear('news.php'); - } else { + } + else + { $message = "".(!mysql_errno() ? LAN_NEWS_46 : LAN_NEWS_5).""; } - } else { - if ($news['news_id'] = $sql ->db_Insert('news', "0, '".$news['news_title']."', '".$news['news_body']."', '".$news['news_extended']."', ".intval($news['news_datestamp']).", ".intval($news['news_author']).", '".intval($news['cat_id'])."', '".intval($news['news_allow_comments'])."', '".intval($news['news_start'])."', '".intval($news['news_end'])."', '".$tp->toDB($news['news_class'])."', '".intval($news['news_rendertype'])."', '0' , '".$news['news_summary']."', '".$tp->toDB($news['news_thumbnail'])."', '".intval($news['news_sticky'])."' ")) { + } + else + { // Adding item + if ($news['news_id'] = $sql ->db_Insert('news', "0, '".$news['news_title']."', '".$news['news_body']."', '".$news['news_extended']."', ".intval($news['news_datestamp']).", ".intval($news['news_author']).", '".intval($news['cat_id'])."', '".intval($news['news_allow_comments'])."', '".intval($news['news_start'])."', '".intval($news['news_end'])."', '".$tp->toDB($news['news_class'])."', '".intval($news['news_rendertype'])."', '0' , '".$news['news_summary']."', '".$tp->toDB($news['news_thumbnail'])."', '".intval($news['news_sticky'])."' ")) + { + $admin_log->logArrayAll('NEWS_08', $news); $e_event -> trigger('newspost', $news); $message = LAN_NEWS_6; $e107cache -> clear('news.php'); - } else { + } + else + { $message = "".LAN_NEWS_7.""; } } @@ -103,17 +115,20 @@ class news { return $message; } - function render_newsitem($news, $mode = 'default', $n_restrict = '', $NEWS_TEMPLATE = '', $param='') { + function render_newsitem($news, $mode = 'default', $n_restrict = '', $NEWS_TEMPLATE = '', $param='') + { global $e107, $tp, $sql, $override, $pref, $ns, $NEWSSTYLE, $NEWSLISTSTYLE, $news_shortcodes, $loop_uid, $imode; if ($override_newsitem = $override -> override_check('render_newsitem')) { $result = call_user_func($override_newsitem, $news, $mode, $n_restrict, $NEWS_TEMPLATE, $param); - if ($result == 'return') { + if ($result == 'return') + { return; } } if (!is_object($e107->tp)) $e107->tp = new e_parse; - if ($n_restrict == 'userclass') { + if ($n_restrict == 'userclass') + { $news['news_id'] = 0; $news['news_title'] = LAN_NEWS_1; $news['data'] = LAN_NEWS_2; @@ -194,15 +209,19 @@ class news { require_once(e_FILE.'shortcode/batch/news_shortcodes.php'); $text = $e107->tp -> parseTemplate($NEWS_PARSE, TRUE, $news_shortcodes); - if ($mode == 'return') { + if ($mode == 'return') + { return $text; - } else { + } + else + { echo $text; return TRUE; } } - function make_xml_compatible($original) { + function make_xml_compatible($original) + { global $e107; if (!is_object($e107->tp)) $e107->tp = new e_parse; $original = $e107->tp->toHTML($original, TRUE); diff --git a/e107_languages/English/admin/lan_log_messages.php b/e107_languages/English/admin/lan_log_messages.php index 3f48bf70f..c0e3ae645 100644 --- a/e107_languages/English/admin/lan_log_messages.php +++ b/e107_languages/English/admin/lan_log_messages.php @@ -1,6 +1,6 @@ diff --git a/e107_languages/English/admin/lan_newspost.php b/e107_languages/English/admin/lan_newspost.php index f15de396d..e8cc6e71e 100644 --- a/e107_languages/English/admin/lan_newspost.php +++ b/e107_languages/English/admin/lan_newspost.php @@ -4,9 +4,9 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_newspost.php,v $ -| $Revision: 1.2 $ -| $Date: 2008-05-18 16:34:28 $ -| $Author: e107coders $ +| $Revision: 1.3 $ +| $Date: 2008-12-07 13:08:48 $ +| $Author: e107steved $ +----------------------------------------------------------------------------+ */ define("NWSLAN_1", "News story deleted."); @@ -161,11 +161,9 @@ define("LAN_NEWS_40", "Insert download links"); define("LAN_NEWS_42", "Files"); // define("LAN_NEWS_43", "(no images in /e107_images/newspost_images)"); // deprecated see lan_admin.php define("LAN_NEWS_44", "Trackback not enabled."); - define("LAN_NEWS_45", "ID"); - define("LAN_NEWS_46", "News item not updated as no changes were made."); -// define("LAN_NEWS_47", "Image"); // already defined above. +define('LAN_NEWS_47', 'Nothing changed - not updated'); define("LAN_NEWS_48", "No Image"); define("LAN_NEWS_49", "Render-type"); diff --git a/e107_plugins/alt_news/alt_news.php b/e107_plugins/alt_news/alt_news.php index b9ac02639..5ca69cda8 100644 --- a/e107_plugins/alt_news/alt_news.php +++ b/e107_plugins/alt_news/alt_news.php @@ -9,9 +9,9 @@ * Alternate News * * $Source: /cvs_backup/e107_0.8/e107_plugins/alt_news/alt_news.php,v $ - * $Revision: 1.2 $ - * $Date: 2008-12-03 12:38:08 $ - * $Author: secretr $ + * $Revision: 1.3 $ + * $Date: 2008-12-07 13:08:54 $ + * $Author: e107steved $ */ if (!defined('e107_INIT')) { exit; } @@ -91,8 +91,12 @@ function alt_news($news_category) { list($news['category_id'], $news['category_name'], $news['category_icon']) = $sql2->db_Fetch(); $news['comment_total'] = $sql2->db_Count("comments", "(*)", "WHERE comment_item_id='".intval($news['news_id'])."' AND comment_type='0' "); $ix->render_newsitem($news); - } else { - if ($pref['subnews_hide_news'] == 1) { + } + /* + else + { + if ($pref['subnews_hide_news'] == 1) This $pref no longer available + { if ($news['admin_id'] == 1 && $pref['siteadmin']) { $news['admin_name'] = $pref['siteadmin']; } @@ -107,7 +111,7 @@ function alt_news($news_category) { list($news['category_id'], $news['category_name'], $news['category_icon']) = $sql2->db_Fetch(); $ix->render_newsitem($news, "", "userclass"); } - } + } */ } } }