'; function MemberPrintNews() { global $site; global $short_date_format; $bNewsFriendly = getParam('permalinks_news') == 'on' ? true : false; $res = getNewsList(); if ( !$res ) return; echo "\n"; if ( !mysql_num_rows($res) ) { echo "\n"; } while ( $news_arr = mysql_fetch_array($res) ) { $news_header = process_line_output( $news_arr['Header'] ); $sNewsUrl = getNewsUrl($news_arr['newsID'], $news_arr['NewsUri'], $bNewsFriendly); echo " \n"; } echo "
No news available.
Edit | Delete ".date( str_replace('%','',$short_date_format), $news_arr['Date'] )."  {$news_header}
\n"; } function MemberDeleteNews() { $res = db_res( "DELETE FROM `News` WHERE `ID` = ". (int)$_GET['delete_id'] ); return $res; } function MemberAddNews() { global $max_l; global $max_h; $news_text = strlen( $_POST['text'] ) > $max_l ? "LEFT ( '". process_db_input( $_POST['text'] ) ."', $max_l )" : "'". process_db_input( $_POST['text'] ) ."'"; $news_header = strlen( $_POST['header'] ) > $max_h ? "LEFT ( '". process_db_input( $_POST['header'] ) ."', $max_h )" : "'". process_db_input( $_POST['header'] ). "'"; $news_snippet = "'".process_db_input( $_POST['snippet'] )."'"; $sNewsUri = uriGenerate($news_header, 'News', 'NewsUri', 50); $res = db_res( "INSERT INTO `News` ( `Date`, `Header`, `Text`, `Snippet`, `NewsUri` ) VALUES ( NOW(), $news_header, $news_text, $news_snippet, '$sNewsUri')" ); return $res; } function MemberEditNews() { global $max_l; global $max_h; $news_id = (int)$_POST['edit_id']; $news_text = strlen( $_POST['text'] ) > $max_l ? "LEFT ( '". process_db_input( $_POST['text'] ) ."', $max_l )" : "'". process_db_input( $_POST['text'] ) ."'"; $news_header = strlen( $_POST['header'] ) > $max_h ? "LEFT ( '". process_db_input( $_POST['header'] ) ."', $max_h )" : "'". process_db_input( $_POST['header'] ). "'"; $news_snippet = "'".process_db_input( $_POST['snippet'] )."'"; $res = db_res( "UPDATE `News` SET `Date`=NOW(), `Header`=$news_header, `Text`=$news_text, `Snippet`=$news_snippet WHERE `ID` = $news_id" ); return $res; } $max_l = getParam( "max_news_text" ); $max_p = getParam( "max_news_preview" ); $max_h = getParam( "max_news_header" ); if ( !$max_l ) $max_l = 4096; if ( !$max_h ) $max_h = 32; $action_result = ""; if ( !$demo_mode && $_POST['action'] == 'new' ) { if ( MemberAddNews() ) $action_result .= "News was added"; else $action_result .= "News adding failed"; } if ( !$demo_mode && $_POST['action'] == 'edit' && ((int)$_POST['edit_id'] != 0) ) { if ( MemberEditNews() ) $action_result .= "News was updated"; else $action_result .= "News updating failed"; } if ( !$demo_mode && (int)$_GET['delete_id'] != 0 && $_GET['action'] == "delete" ) { if ( MemberDeleteNews() ) $action_result .= "News was deleted"; else $action_result .= "News deleting failed"; } $_page['header'] = "News"; $_page['header_text'] = "News compose"; TopCodeAdmin(); ContentBlockHead("News"); if ( strlen($action_result) ) echo "
$action_result

\n"; MemberPrintNews(); if ( (int)$_GET['edit_id'] != 0 ) { $news_arr = db_arr( "SELECT `ID`, DATE_FORMAT(`Date`, '$short_date_format' ) AS 'Date', `Header`, `Snippet`, `Text` FROM `News` WHERE `ID` = ". (int)$_GET['edit_id'] ); } { ContentBlockFoot(); ContentBlockHead("News compose"); ?>
Header:
Snippet:
Text:
'; echo ''; } else { echo ''; echo ''; echo ''; } ?>