2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-02 16:50:16 +00:00
* e107 website system
*
* Copyright ( C ) 2001 - 2008 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* News Administration
*
* $Source : / cvs_backup / e107_0 . 8 / e107_admin / newspost . php , v $
2008-12-07 13:08:54 +00:00
* $Revision : 1.18 $
* $Date : 2008 - 12 - 07 13 : 08 : 41 $
* $Author : e107steved $
2006-12-02 04:36:16 +00:00
*/
require_once ( " ../class2.php " );
2008-12-07 13:08:54 +00:00
if ( ! getperms ( " H " ))
{
2006-12-02 04:36:16 +00:00
header ( " location: " . e_BASE . " index.php " );
exit ;
}
require_once ( e_HANDLER . " calendar/calendar_class.php " );
$cal = new DHTML_Calendar ( true );
2008-12-07 13:08:54 +00:00
function headerjs ()
{
2006-12-02 04:36:16 +00:00
global $cal ;
$js = $cal -> load_files ();
return $js ;
}
$e_sub_cat = 'news' ;
$e_wysiwyg = " data,news_extended " ;
// -------- Presets. ------------ // always load before auth.php
require_once ( e_HANDLER . " preset_class.php " );
$pst = new e_preset ;
$pst -> form = " dataform " ; // form id of the form that will have it's values saved.
$pst -> page = " newspost.php?create " ; // display preset options on which page(s).
$pst -> id = " admin_newspost " ;
// ------------------------------
$newspost = new newspost ;
require_once ( " auth.php " );
2007-02-07 21:22:19 +00:00
$pst -> save_preset ( 'news_datestamp' ); // save and render result using unique name. Don't save item datestamp
2006-12-02 04:36:16 +00:00
require_once ( e_HANDLER . " userclass_class.php " );
require_once ( e_HANDLER . " news_class.php " );
require_once ( e_HANDLER . " ren_help.php " );
require_once ( e_HANDLER . " form_handler.php " );
require_once ( e_HANDLER . " file_class.php " );
$fl = new e_file ;
$rs = new form ;
$ix = new news ;
2008-12-02 16:50:16 +00:00
if ( e_QUERY )
2007-10-26 21:51:05 +00:00
{
$tmp = explode ( " . " , e_QUERY );
$action = $tmp [ 0 ];
$sub_action = varset ( $tmp [ 1 ], '' );
$id = intval ( varset ( $tmp [ 2 ], 0 ));
$sort_order = varset ( $tmp [ 2 ], 'desc' );
$from = intval ( varset ( $tmp [ 3 ], 0 ));
unset ( $tmp );
2006-12-02 04:36:16 +00:00
}
$from = ( $from ? $from : 0 );
$amount = 10 ;
// ##### Main loop -----------------------------------------------------------------------------------------------------------------------
if ( isset ( $_POST [ 'news_userclass' ]))
{
2008-12-07 13:08:54 +00:00
unset ( $temp );
foreach ( $_POST [ 'news_userclass' ] as $k => $v )
{
$temp [] = intval ( $k );
}
$_POST [ 'news_class' ] = implode ( " , " , $temp );
unset ( $temp );
unset ( $_POST [ 'news_userclass' ]);
2006-12-02 04:36:16 +00:00
}
if ( isset ( $_POST [ 'delete' ]))
{
2008-12-07 13:08:54 +00:00
$tmp = array_keys ( $_POST [ 'delete' ]);
list ( $delete , $del_id ) = explode ( " _ " , $tmp [ 0 ]);
$del_id = intval ( $del_id );
2006-12-02 04:36:16 +00:00
}
2008-06-15 20:20:28 +00:00
2006-12-02 04:36:16 +00:00
if ( $delete == " main " && $del_id )
{
if ( $sql -> db_Count ( 'news' , '(*)' , " WHERE news_id = ' { $del_id } ' " ))
{
$e_event -> trigger ( " newsdel " , $del_id );
2008-12-07 13:08:54 +00:00
if ( $sql -> db_Delete ( " news " , " news_id=' { $del_id } ' " ))
2006-12-02 04:36:16 +00:00
{
2008-12-07 13:08:54 +00:00
$admin_log -> log_event ( 'NEWS_01' , $del_id , E_LOG_INFORMATIVE , '' );
2006-12-02 04:36:16 +00:00
$newspost -> show_message ( NWSLAN_31 . " # " . $del_id . " " . NWSLAN_32 );
$e107cache -> clear ( " news.php " );
$e107cache -> clear ( " othernews " );
$e107cache -> clear ( " othernews2 " );
admin_purge_related ( " news " , $del_id );
}
}
unset ( $delete , $del );
}
2008-06-15 20:20:28 +00:00
2008-12-07 13:08:54 +00:00
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 , '' );
2006-12-02 04:36:16 +00:00
$newspost -> show_message ( NWSLAN_33 . " # " . $del_id . " " . NWSLAN_32 );
unset ( $delete , $del_id );
}
}
2008-06-15 20:20:28 +00:00
2006-12-02 04:36:16 +00:00
if ( $delete == " sn " && $del_id )
{
2008-12-07 13:08:54 +00:00
if ( $sql -> db_Delete ( " submitnews " , " submitnews_id=' { $del_id } ' " ))
2006-12-02 04:36:16 +00:00
{
2008-12-07 13:08:54 +00:00
$admin_log -> log_event ( 'NEWS_03' , $del_id , E_LOG_INFORMATIVE , '' );
2006-12-02 04:36:16 +00:00
$newspost -> show_message ( NWSLAN_34 . " # " . $del_id . " " . NWSLAN_32 );
$e107cache -> clear ( " news.php " );
$e107cache -> clear ( " othernews " );
$e107cache -> clear ( " othernews2 " );
unset ( $delete , $del_id );
}
}
2008-06-15 20:20:28 +00:00
2008-12-02 16:50:16 +00:00
if ( isset ( $_POST [ 'submitupload' ]))
2008-06-15 20:20:28 +00:00
{
2006-12-02 04:36:16 +00:00
$pref [ 'upload_storagetype' ] = " 1 " ;
require_once ( e_HANDLER . " upload_handler.php " );
$uploaded = file_upload ( e_IMAGE . " newspost_images/ " );
2008-12-07 13:08:54 +00:00
foreach ( $_POST [ 'uploadtype' ] as $key => $uploadtype )
{
if ( $uploadtype == " thumb " )
{
2006-12-02 04:36:16 +00:00
rename ( e_IMAGE . " newspost_images/ " . $uploaded [ $key ][ 'name' ], e_IMAGE . " newspost_images/thumb_ " . $uploaded [ $key ][ 'name' ]);
}
2008-12-07 13:08:54 +00:00
if ( $uploadtype == " file " )
{
2006-12-02 04:36:16 +00:00
rename ( e_IMAGE . " newspost_images/ " . $uploaded [ $key ][ 'name' ], e_FILE . " downloads/ " . $uploaded [ $key ][ 'name' ]);
}
2008-12-07 13:08:54 +00:00
if ( $uploadtype == " resize " && $_POST [ 'resize_value' ])
{
2006-12-02 04:36:16 +00:00
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 " );
}
}
}
2008-06-15 20:20:28 +00:00
2006-12-02 04:36:16 +00:00
// required.
2008-12-02 16:50:16 +00:00
if ( isset ( $_POST [ 'preview' ]))
2008-06-15 20:20:28 +00:00
{
2006-12-02 04:36:16 +00:00
$_POST [ 'news_title' ] = $tp -> toDB ( $_POST [ 'news_title' ]);
$_POST [ 'news_summary' ] = $tp -> toDB ( $_POST [ 'news_summary' ]);
$newspost -> preview_item ( $id );
}
2008-12-02 16:50:16 +00:00
if ( isset ( $_POST [ 'submit_news' ]))
2008-06-15 20:20:28 +00:00
{
2006-12-02 04:36:16 +00:00
$newspost -> submit_item ( $sub_action , $id );
2007-06-07 20:43:33 +00:00
$e107cache -> clear ( " news.php " );
2006-12-02 04:36:16 +00:00
$e107cache -> clear ( " othernews " );
$e107cache -> clear ( " othernews2 " );
$action = " main " ;
unset ( $sub_action , $id );
}
2008-12-07 13:08:54 +00:00
if ( isset ( $_POST [ 'create_category' ]))
{
if ( $_POST [ 'category_name' ])
{
if ( empty ( $_POST [ 'category_button' ]))
{
2006-12-02 04:36:16 +00:00
$handle = opendir ( e_IMAGE . " icons " );
2008-12-07 13:08:54 +00:00
while ( $file = readdir ( $handle ))
{
2006-12-02 04:36:16 +00:00
if ( $file != " . " && $file != " .. " && $file != " / " && $file != " null.txt " && $file != " CVS " ) {
$iconlist [] = $file ;
}
}
closedir ( $handle );
$_POST [ 'category_button' ] = $iconlist [ 0 ];
}
2008-12-07 13:08:54 +00:00
else
{
$_POST [ 'category_button' ] = $tp -> toDB ( $_POST [ 'category_button' ]);
}
2006-12-02 04:36:16 +00:00
$_POST [ 'category_name' ] = $tp -> toDB ( $_POST [ 'category_name' ]);
2008-12-07 13:08:54 +00:00
$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 , '' );
2006-12-02 04:36:16 +00:00
$newspost -> show_message ( NWSLAN_35 );
}
}
2008-12-07 13:08:54 +00:00
if ( isset ( $_POST [ 'update_category' ]))
{
if ( $_POST [ 'category_name' ])
{
$category_button = $tp -> toDB (( $_POST [ 'category_button' ] ? $_POST [ 'category_button' ] : " " ));
2006-12-02 04:36:16 +00:00
$_POST [ 'category_name' ] = $tp -> toDB ( $_POST [ 'category_name' ]);
2008-12-07 13:08:54 +00:00
$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 , '' );
2006-12-02 04:36:16 +00:00
$newspost -> show_message ( NWSLAN_36 );
}
$e107cache -> clear ( " news.php " );
$e107cache -> clear ( " othernews " );
$e107cache -> clear ( " othernews2 " );
}
2008-12-07 13:08:54 +00:00
2008-12-02 16:50:16 +00:00
if ( isset ( $_POST [ 'save_prefs' ]))
2008-06-15 20:20:28 +00:00
{
2008-12-07 13:08:54 +00:00
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' ]);
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 );
}
2006-12-02 04:36:16 +00:00
}
2008-12-07 13:08:54 +00:00
2008-12-02 16:50:16 +00:00
if ( ! e_QUERY || $action == " main " )
2007-10-26 21:51:05 +00:00
{
$newspost -> show_existing_items ( $action , $sub_action , $sort_order , $from , $amount );
2006-12-02 04:36:16 +00:00
}
2008-12-07 13:08:54 +00:00
2008-12-02 16:50:16 +00:00
if ( $action == " create " )
2008-06-15 20:20:28 +00:00
{
$preset = $pst -> read_preset ( " admin_newspost " ); //only works here because $_POST is used.
2006-12-02 04:36:16 +00:00
2008-12-02 16:50:16 +00:00
if ( $sub_action == " edit " && ! $_POST [ 'preview' ] && ! $_POST [ 'submit_news' ])
2008-06-15 20:20:28 +00:00
{
2008-12-07 13:08:54 +00:00
if ( $sql -> db_Select ( " news " , " * " , " news_id=' { $id } ' " ))
2008-06-15 20:20:28 +00:00
{
$row = $sql -> db_Fetch ();
extract ( $row );
$_POST [ 'news_title' ] = $news_title ;
$_POST [ 'data' ] = $news_body ;
$_POST [ 'news_author' ] = $row [ 'news_author' ];
$_POST [ 'news_extended' ] = $news_extended ;
$_POST [ 'news_allow_comments' ] = $news_allow_comments ;
$_POST [ 'news_class' ] = $news_class ;
$_POST [ 'news_summary' ] = $news_summary ;
$_POST [ 'news_sticky' ] = $news_sticky ;
$_POST [ 'news_datestamp' ] = ( $_POST [ 'news_datestamp' ]) ? $_POST [ 'news_datestamp' ] : $news_datestamp ;
$_POST [ 'cat_id' ] = $news_category ;
$_POST [ 'news_start' ] = $news_start ;
$_POST [ 'news_end' ] = $news_end ;
$_POST [ 'comment_total' ] = $sql -> db_Count ( " comments " , " (*) " , " WHERE comment_item_id=' $news_id ' AND comment_type='0' " );
$_POST [ 'news_rendertype' ] = $news_render_type ;
$_POST [ 'news_thumbnail' ] = $news_thumbnail ;
2006-12-02 04:36:16 +00:00
}
2008-06-15 20:20:28 +00:00
}
$newspost -> create_item ( $sub_action , $id );
2006-12-02 04:36:16 +00:00
}
2008-06-15 20:20:28 +00:00
2008-12-02 16:50:16 +00:00
if ( $action == " cat " )
2008-06-15 20:20:28 +00:00
{
$newspost -> show_categories ( $sub_action , $id );
2006-12-02 04:36:16 +00:00
}
2008-06-15 20:20:28 +00:00
2008-12-02 16:50:16 +00:00
if ( $action == " sn " )
2008-06-15 20:20:28 +00:00
{
$newspost -> submitted_news ( $sub_action , $id );
2006-12-02 04:36:16 +00:00
}
2008-06-15 20:20:28 +00:00
2008-12-02 16:50:16 +00:00
if ( $action == " pref " )
2008-06-15 20:20:28 +00:00
{
$newspost -> show_news_prefs ( $sub_action , $id );
2006-12-02 04:36:16 +00:00
}
2008-06-15 20:20:28 +00:00
2006-12-02 04:36:16 +00:00
echo "
< script type = \ " text/javascript \" >
function fclear () {
document . getElementById ( 'dataform' ) . data . value = \ " \" ;
document . getElementById ( 'dataform' ) . news_extended . value = \ " \" ;
}
</ script > \n " ;
require_once ( " footer.php " );
exit ;
2008-06-15 20:20:28 +00:00
2008-12-02 16:50:16 +00:00
class newspost
2007-10-26 21:51:05 +00:00
{
2006-12-02 04:36:16 +00:00
2008-05-18 16:34:28 +00:00
function show_existing_items ( $action , $sub_action , $sort_order , $from , $amount )
2007-10-26 21:51:05 +00:00
{
2008-12-07 13:08:54 +00:00
// ##### Display scrolling list of existing news items
2007-10-26 21:51:05 +00:00
global $sql , $ns , $tp , $imode ;
$text = " <div style='text-align:center'> " ;
if ( ! $sort_order ) $sort_order = 'desc' ;
if ( $sort_order != 'asc' ) $sort_order = 'desc' ;
$sort_link = $sort_order == 'asc' ? 'desc' : 'asc' ; // Effectively toggle setting for headings
2008-12-02 16:50:16 +00:00
2008-05-18 16:34:28 +00:00
if ( isset ( $_POST [ 'searchquery' ]))
2007-10-26 21:51:05 +00:00
{
$query = " news_title REGEXP(' " . $_POST [ 'searchquery' ] . " ') OR news_body REGEXP(' " . $_POST [ 'searchquery' ] . " ') OR news_extended REGEXP(' " . $_POST [ 'searchquery' ] . " ') ORDER BY news_datestamp DESC " ;
2008-05-18 16:34:28 +00:00
}
else
2007-10-26 21:51:05 +00:00
{
$query = " ORDER BY " . ( $sub_action ? $sub_action : " news_datestamp " ) . " " . strtoupper ( $sort_order ) . " LIMIT { $from } , { $amount } " ;
}
if ( $sql -> db_Select ( " news " , " * " , $query , ( $_POST [ 'searchquery' ] ? 0 : " nowhere " )))
{
$newsarray = $sql -> db_getList ();
$text .= "
2006-12-02 04:36:16 +00:00
< form action = '".e_SELF."' id = 'newsform' method = 'post' >
2008-11-11 13:26:49 +00:00
< table class = 'fborder e-list' style = '".ADMIN_WIDTH."' >
< thead >
2006-12-02 04:36:16 +00:00
< tr >
2007-10-26 21:51:05 +00:00
< td style = 'width:5%' class = 'fcaption' >< a href = '".e_SELF."?main.news_id.{$sort_link}.{$from}' > " .LAN_NEWS_45. " </ a ></ td >
< td style = 'width:55%' class = 'fcaption' >< a href = '".e_SELF."?main.news_title.{$sort_link}.{$from}' > " .NWSLAN_40. " </ a ></ td >
2006-12-02 04:36:16 +00:00
< td style = 'width:15%' class = 'fcaption' > " .LAN_NEWS_49. " </ td >
< td style = 'width:15%' class = 'fcaption' > " .LAN_OPTIONS. " </ td >
2008-11-11 13:26:49 +00:00
</ tr >
</ thead >
< tbody > " ;
2007-10-26 21:51:05 +00:00
$ren_type = array ( " default " , " title " , " other-news " , " other-news 2 " );
foreach ( $newsarray as $row )
{
extract ( $row );
2006-12-02 04:36:16 +00:00
// Note: To fix the alignment bug. Put both buttons inside the Form.
// But make EDIT a 'button' and DELETE 'submit'
2007-10-26 21:51:05 +00:00
$text .= " <tr>
< td style = 'width:5%' class = 'forumheader3' > { $news_id } </ td >
< td style = 'width:55%' class = 'forumheader3' >< a href = '".e_BASE."news.php?item.{$news_id}.{$news_category}' > " .( $news_title ? $tp->toHTML ( $news_title , " " , " no_hook , emotes_off , no_make_clickable " ) : " [ " .NWSLAN_42. " ] " ). " </ a ></ td >
2006-12-02 04:36:16 +00:00
< td style = '20%' class = 'forumheader3' > " ;
2007-10-26 21:51:05 +00:00
$text .= $ren_type [ $news_render_type ];
if ( $news_sticky )
{
$sicon = ( file_exists ( THEME . " images/sticky.png " ) ? THEME . " images/sticky.png " : e_IMAGE . " packs/ " . $imode . " /generic/sticky.png " );
$text .= " <img src=' " . $sicon . " ' alt='' /> " ;
}
$text .= "
2006-12-02 04:36:16 +00:00
</ td >
< td style = 'width:15%; text-align:center' class = 'forumheader3' >
< a href = '".e_SELF."?create.edit.{$news_id}' > " .ADMIN_EDIT_ICON. " </ a >
< input type = 'image' title = '".LAN_DELETE."' name = 'delete[main_{$news_id}]' src = '".ADMIN_DELETE_ICON_PATH."' onclick = \ " return jsconfirm(' " . NWSLAN_39 . " [ID: $news_id ]') \" />
</ td >
</ tr > " ;
}
2008-11-11 13:26:49 +00:00
$text .= " </tbody></table></form> " ;
2008-05-18 16:34:28 +00:00
}
else
2007-10-26 21:51:05 +00:00
{
$text .= " <div style='text-align:center'> " . NWSLAN_43 . " </div> " ;
}
2006-12-02 04:36:16 +00:00
2007-10-26 21:51:05 +00:00
$newsposts = $sql -> db_Count ( " news " );
2006-12-02 04:36:16 +00:00
2008-05-18 16:34:28 +00:00
if ( ! $_POST [ 'searchquery' ])
2007-10-26 21:51:05 +00:00
{
$parms = $newsposts . " , " . $amount . " , " . $from . " , " . e_SELF . " ? " . ( e_QUERY ? " $action . $sub_action . $sort_order . " : " main.news_datestamp.desc. " ) . " [FROM] " ;
$text .= " <br /> " . $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
2006-12-02 04:36:16 +00:00
2007-10-26 21:51:05 +00:00
}
2006-12-02 04:36:16 +00:00
2007-10-26 21:51:05 +00:00
$text .= " <br /><form method='post' action=' " . e_SELF . " '> \n <p> \n <input class='tbox' type='text' name='searchquery' size='20' value='' maxlength='50' /> \n <input class='button' type='submit' name='searchsubmit' value=' " . NWSLAN_63 . " ' /> \n </p> \n </form> \n </div> " ;
2006-12-02 04:36:16 +00:00
2007-10-26 21:51:05 +00:00
$ns -> tablerender ( NWSLAN_4 , $text );
2006-12-02 04:36:16 +00:00
}
2007-10-26 21:51:05 +00:00
2008-12-07 13:08:54 +00:00
function show_options ( $action )
{
2006-12-02 04:36:16 +00:00
global $sql ;
if ( $action == " " ) {
$action = " main " ;
}
$var [ 'main' ][ 'text' ] = NWSLAN_44 ;
$var [ 'main' ][ 'link' ] = e_SELF ;
$var [ 'create' ][ 'text' ] = NWSLAN_45 ;
$var [ 'create' ][ 'link' ] = e_SELF . " ?create " ;
$var [ 'cat' ][ 'text' ] = NWSLAN_46 ;
$var [ 'cat' ][ 'link' ] = e_SELF . " ?cat " ;
$var [ 'cat' ][ 'perm' ] = " 7 " ;
$var [ 'pref' ][ 'text' ] = NWSLAN_90 ;
$var [ 'pref' ][ 'link' ] = e_SELF . " ?pref " ;
$var [ 'pref' ][ 'perm' ] = " N " ;
if ( $sql -> db_Select ( " submitnews " , " * " , " submitnews_auth ='0' " )) {
$var [ 'sn' ][ 'text' ] = NWSLAN_47 ;
$var [ 'sn' ][ 'link' ] = e_SELF . " ?sn " ;
$var [ 'sn' ][ 'perm' ] = " N " ;
}
show_admin_menu ( NWSLAN_48 , $action , $var );
}
function create_item ( $sub_action , $id )
{
2008-06-15 20:20:28 +00:00
global $cal ;
2008-12-02 16:50:16 +00:00
// ##### Display creation form
2008-06-15 20:20:28 +00:00
global $sql , $rs , $ns , $pref , $tp , $pst , $e107 ;
2006-12-02 04:36:16 +00:00
2008-12-02 16:50:16 +00:00
if ( $sub_action == " sn " && ! $_POST [ 'preview' ])
2008-06-15 20:20:28 +00:00
{
2008-12-02 16:50:16 +00:00
if ( $sql -> db_Select ( " submitnews " , " * " , " submitnews_id= $id " , TRUE ))
2008-06-15 20:20:28 +00:00
{
2006-12-02 04:36:16 +00:00
list ( $id , $submitnews_name , $submitnews_email , $_POST [ 'news_title' ], $submitnews_category , $_POST [ 'data' ], $submitnews_datestamp , $submitnews_ip , $submitnews_auth , $submitnews_file ) = $sql -> db_Fetch ();
if ( e_WYSIWYG )
{
2008-05-31 17:55:31 +00:00
if ( substr ( $_POST [ 'data' ], - 7 , 7 ) == '[/html]' ) $_POST [ 'data' ] = substr ( $_POST [ 'data' ], 0 , - 7 );
if ( substr ( $_POST [ 'data' ], 0 , 6 ) == '[html]' ) $_POST [ 'data' ] = substr ( $_POST [ 'data' ], 6 );
2006-12-02 04:36:16 +00:00
$_POST [ 'data' ] .= " <br /><b> " . NWSLAN_49 . " " . $submitnews_name . " </b> " ;
$_POST [ 'data' ] .= ( $submitnews_file ) ? " <br /><br /><img src=' { e_IMAGE}newspost_images/ " . $submitnews_file . " ' style='float:right; margin-left:5px;margin-right:5px;margin-top:5px;margin-bottom:5px; border:1px solid' /> " : " " ;
}
else
{
$_POST [ 'data' ] .= " \n [[b] " . NWSLAN_49 . " " . $submitnews_name . " [/b]] " ;
$_POST [ 'data' ] .= ( $submitnews_file ) ? " \n \n [img] { e_IMAGE}newspost_images/ " . $submitnews_file . " [/img] " : " " ;
}
$_POST [ 'cat_id' ] = $submitnews_category ;
}
2008-06-15 20:20:28 +00:00
}
2006-12-02 04:36:16 +00:00
2008-12-02 16:50:16 +00:00
if ( $sub_action == " upload " && ! $_POST [ 'preview' ])
2008-06-15 20:20:28 +00:00
{
2006-12-02 04:36:16 +00:00
if ( $sql -> db_Select ( " upload " , " * " , " upload_id= $id " )) {
$row = $sql -> db_Fetch ();
extract ( $row );
$post_author_id = substr ( $upload_poster , 0 , strpos ( $upload_poster , " . " ));
$post_author_name = substr ( $upload_poster , ( strpos ( $upload_poster , " . " ) + 1 ));
$upload_file = " pub_ " . ( preg_match ( " #Binary \ s(.*?) \ /# " , $upload_file , $match ) ? $match [ 1 ] : $upload_file );
$_POST [ 'news_title' ] = LAN_UPLOAD . " : " . $upload_name ;
$_POST [ 'data' ] = $upload_description . " \n [b] " . NWSLAN_49 . " <a href='user.php?id. " . $post_author_id . " '> " . $post_author_name . " </a>[/b] \n \n [file=request.php? " . $upload_file . " ] " . $upload_name . " [/file] \n " ;
}
2008-06-15 20:20:28 +00:00
}
2006-12-02 04:36:16 +00:00
$text = " <div style='text-align:center'>
< form method = 'post' action = '".e_SELF."?".e_QUERY."' id = 'dataform' " .(FILE_UPLOADS ? " enctype = 'multipart/form-data' " : " " ). " >
< table style = '".ADMIN_WIDTH."' class = 'fborder' >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_6. " : </ td >
< td style = 'width:80%' class = 'forumheader3' > " ;
2007-02-07 18:48:27 +00:00
if ( ! $sql -> db_Select ( " news_category " ))
{
2006-12-02 04:36:16 +00:00
$text .= NWSLAN_10 ;
2007-02-07 18:48:27 +00:00
}
else
{
$text .= " \t <select name='cat_id' class='tbox'> \n " ;
2006-12-02 04:36:16 +00:00
2007-02-07 18:48:27 +00:00
while ( list ( $cat_id , $cat_name , $cat_icon ) = $sql -> db_Fetch ())
{
$sel = ( $_POST [ 'cat_id' ] == $cat_id ) ? " selected='selected' " : " " ;
$text .= " <option value=' $cat_id ' { $sel } > " . $tp -> toHTML ( $cat_name , FALSE , " defs " ) . " </option> \n " ;
2006-12-02 04:36:16 +00:00
}
$text .= " </select> " ;
}
$text .= " </td>
</ tr >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_12. " :</ td >
< td style = 'width:80%' class = 'forumheader3' >
2008-06-15 20:20:28 +00:00
< input class = 'tbox' type = 'text' name = 'news_title' size = '80' value = '".$tp->post_toForm($_POST[' news_title '])."' maxlength = '200' style = 'width:95%' />
2006-12-02 04:36:16 +00:00
</ td >
</ tr >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .LAN_NEWS_27. " :</ td >
< td style = 'width:80%' class = 'forumheader3' >
2008-06-15 20:20:28 +00:00
< input class = 'tbox' type = 'text' name = 'news_summary' size = '80' value = '".$tp->post_toForm($_POST[' news_summary '])."' maxlength = '250' style = 'width:95%' />
2006-12-02 04:36:16 +00:00
</ td >
2008-05-18 16:34:28 +00:00
</ tr > " ;
2008-06-15 20:20:28 +00:00
// -------- News Author ---------------------
2008-05-18 16:34:28 +00:00
$text .= " <tr>
< td class = 'forumheader3' >
" .LAN_NEWS_50. " :
</ td >
< td class = 'forumheader3' > " ;
if ( ! getperms ( '0' ) && ! check_class ( $pref [ 'news_editauthor' ]))
{
$auth = ( $_POST [ 'news_author' ]) ? $_POST [ 'news_author' ] : USERID ;
$sql -> db_Select ( " user " , " user_name " , " user_id = ' " . $auth . " ' LIMIT 1 " );
$row = $sql -> db_Fetch ( MYSQL_ASSOC );
$text .= " <input type='hidden' name='news_author' value=' " . $auth . chr ( 1 ) . $row [ 'user_name' ] . " ' /> " ;
$text .= " <a href=' " . e_BASE . " user.php?id. " . $_POST [ 'news_author' ] . " '> " . $row [ 'user_name' ] . " </a> " ;
}
else // allow master admin to
{
$text .= "
< select class = 'tbox' name = 'news_author' > " ;
$qry = " SELECT user_id,user_name FROM #user WHERE user_perms = '0' OR FIND_IN_SET('H',user_perms) " ;
if ( $pref [ 'subnews_class' ] && $pref [ 'subnews_class' ] != e_UC_GUEST && $pref [ 'subnews_class' ] != e_UC_NOBODY )
{
if ( $pref [ 'subnews_class' ] == e_UC_MEMBER )
{
$qry .= " OR user_ban != 1 " ;
}
elseif ( $pref [ 'subnews_class' ] == e_UC_ADMIN )
{
$qry .= " OR user_admin = 1 " ;
}
else
{
$qry .= " OR FIND_IN_SET( " . intval ( $pref [ 'subnews_class' ]) . " ,user_class) " ;
}
}
$sql -> db_Select_gen ( $qry );
while ( $row = $sql -> db_Fetch ())
{
if ( $_POST [ 'news_author' ])
{
$sel = ( $_POST [ 'news_author' ] == $row [ 'user_id' ]) ? " selected='selected' " : " " ;
}
else
{
$sel = ( USERID == $row [ 'user_id' ]) ? " selected='selected' " : " " ;
}
$text .= " <option value= \" " . $row [ 'user_id' ] . chr ( 1 ) . $row [ 'user_name' ] . " \" { $sel } > " . $row [ 'user_name' ] . " </option> \n " ;;
}
$text .= " </select>
" ;
}
2008-06-15 20:20:28 +00:00
2008-05-18 16:34:28 +00:00
$text .= "
</ td >
2006-12-02 04:36:16 +00:00
</ tr >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_13. " :< br /></ td >
< td style = 'width:80%;margin-left:auto' class = 'forumheader3' > " ;
$insertjs = ( ! e_WYSIWYG ) ? " rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);' " : " rows='25' " ;
$_POST [ 'data' ] = $tp -> toForm ( $_POST [ 'data' ]);
$text .= " <textarea class='tbox' id='data' name='data' cols='80' style='width:100%' $insertjs > " . ( strstr ( $tp -> post_toForm ( $_POST [ 'data' ]), " [img]http " ) ? $_POST [ 'data' ] : str_replace ( " [img]../ " , " [img] " , $tp -> post_toForm ( $_POST [ 'data' ]))) . " </textarea>
" ;
$text .= display_help ( " helpb " , 'news' );
//Extended news form textarea
if ( e_WYSIWYG ){ $ff_expand = " tinyMCE.execCommand('mceResetDesignMode') " ; } // Fixes Firefox issue with hidden wysiwyg textarea.
$text .= "
</ td >
</ tr >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_14. " :</ td >
< td style = 'width:80%' class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = \ " expandit(this); $ff_expand\ " > " .NWSLAN_83. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display:none' >
< textarea class = 'tbox' id = 'news_extended' name = 'news_extended' cols = '80' style = 'width:95%' $insertjs > " .(strstr( $tp->post_toForm ( $_POST['news_extended'] ), " [ img ] http " ) ? $tp->post_toForm ( $_POST['news_extended'] ) : str_replace( " [ img ] ../ " , " [ img ] " , $tp->post_toForm ( $_POST['news_extended'] ))). " </ textarea >
" . display_help( " helpc " , 'extended'). "
</ div >
</ td >
</ tr >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_66. " :</ td >
< td style = 'width:80%' class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .NWSLAN_69. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' > " ;
if ( ! FILE_UPLOADS )
{
$text .= " <b> " . LAN_UPLOAD_SERVEROFF . " </b> " ;
}
else
{
if ( ! is_writable ( e_FILE . " downloads " ))
{
$text .= LAN_UPLOAD_777 . " <b> " . str_replace ( " ../ " , " " , e_FILE . " downloads/ " ) . " </b><br /><br /> " ;
}
if ( ! is_writable ( e_IMAGE . " newspost_images " ))
{
$text .= LAN_UPLOAD_777 . " <b> " . str_replace ( " ../ " , " " , e_IMAGE . " newspost_images/ " ) . " </b><br /><br /> " ;
}
$up_name = array ( LAN_NEWS_24 , NWSLAN_67 , LAN_NEWS_22 , NWSLAN_68 );
$up_value = array ( " resize " , " image " , " thumb " , " file " );
$text .= " <div id='up_container' >
< span id = 'upline' style = 'white-space:nowrap' >
< input class = 'tbox' type = 'file' name = 'file_userfile[]' size = '40' />
< select class = 'tbox' name = 'uploadtype[]' > " ;
for ( $i = 0 ; $i < count ( $up_value ); $i ++ )
{
$selected = ( $_POST [ 'uploadtype' ] == $up_value [ $i ]) ? " selected='selected' " : " " ;
$text .= " <option value=' " . $up_value [ $i ] . " ' $selected > " . $up_name [ $i ] . " </option> \n " ;
};
$text .= " </select> </span>
</ div >
< table style = 'width:100%' >
< tr >< td >< input type = 'button' class = 'button' value = '".LAN_NEWS_26."' onclick = \ " duplicateHTML('upline','up_container'); \" /></td>
< td >< span class = 'smalltext' > " .LAN_NEWS_25. " </ span >& nbsp ; < input class = 'tbox' type = 'text' name = 'resize_value' value = '".($_POST[' resize_value '] ? $_POST[' resize_value '] : ' 100 ')."' size = '3' />& nbsp ; px </ td >
< td >< input class = 'button' type = 'submit' name = 'submitupload' value = '".NWSLAN_66."' /></ td >
</ tr ></ table > " ;
}
$text .= " </div>
</ td >
</ tr >
< tr >
< td class = 'forumheader3' > " .NWSLAN_67. " :</ td >
< td class = 'forumheader3' >
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .LAN_NEWS_23. " </ a >
< div style = 'display: none' >< br /> " ;
2008-02-19 19:33:45 +00:00
$parms = " name=news_thumbnail " ;
2006-12-02 04:36:16 +00:00
$parms .= " &path= " . e_IMAGE . " newspost_images/ " ;
$parms .= " &default= " . $_POST [ 'news_thumbnail' ];
$parms .= " &width=100px " ;
$parms .= " &height=100px " ;
$parms .= " &multiple=TRUE " ;
$parms .= " &label=-- " . LAN_NEWS_48 . " -- " ;
2008-02-19 19:33:45 +00:00
$parms .= " &click_target=data " ;
$parms .= " &click_prefix=[img][[e_IMAGE]]newspost_images/ " ;
$parms .= " &click_postfix=[/img] " ;
2006-12-02 04:36:16 +00:00
2008-03-18 00:39:02 +00:00
2008-02-19 19:33:45 +00:00
$text .= $tp -> parseTemplate ( " { IMAGESELECTOR= { $parms } } " );
2006-12-02 04:36:16 +00:00
$text .= " </div>
</ td >
</ tr >
" ;
$text .= " <tr>
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_15. " :</ td >
< td style = 'width:80%' class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .NWSLAN_18. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' >
" . ( $_POST['news_allow_comments'] ? " < input name = 'news_allow_comments' type = 'radio' value = '0' /> " .LAN_ENABLED. " & nbsp ; & nbsp ; < input name = 'news_allow_comments' type = 'radio' value = '1' checked = 'checked' /> " .LAN_DISABLED : " < input name = 'news_allow_comments' type = 'radio' value = '0' checked = 'checked' /> " .LAN_ENABLED. " & nbsp ; & nbsp ; < input name = 'news_allow_comments' type = 'radio' value = '1' /> " .LAN_DISABLED). "
</ div >
</ td >
</ tr >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_73. " :</ td >
< td style = 'width:80%' class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .NWSLAN_74. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' > " ;
$ren_type = array ( NWSLAN_75 , NWSLAN_76 , NWSLAN_77 , NWSLAN_77 . " 2 " );
foreach ( $ren_type as $key => $value ) {
$checked = ( $_POST [ 'news_rendertype' ] == $key ) ? " checked='checked' " : " " ;
$text .= " <input name='news_rendertype' type='radio' value=' $key ' $checked /> " ;
$text .= $value . " <br /> " ;
}
$text .= " </div>
</ td >
</ tr >
< tr >
< td style = 'width:20%' class = 'forumheader3' > " .NWSLAN_19. " :</ td >
< td style = 'width:80%' class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .NWSLAN_72. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' >
< br />
" .NWSLAN_21. " :< br /> " ;
$_startdate = ( $_POST [ 'news_start' ] > 0 ) ? date ( " d/m/Y " , $_POST [ 'news_start' ]) : " " ;
$cal_options [ 'showsTime' ] = false ;
$cal_options [ 'showOthers' ] = false ;
$cal_options [ 'weekNumbers' ] = false ;
$cal_options [ 'ifFormat' ] = " %d/%m/%Y " ;
$cal_attrib [ 'class' ] = " tbox " ;
$cal_attrib [ 'size' ] = " 10 " ;
$cal_attrib [ 'name' ] = " news_start " ;
$cal_attrib [ 'value' ] = $_startdate ;
$text .= $cal -> make_input_field ( $cal_options , $cal_attrib );
$text .= " - " ;
$_enddate = ( $_POST [ 'news_end' ] > 0 ) ? date ( " d/m/Y " , $_POST [ 'news_end' ]) : " " ;
unset ( $cal_options );
unset ( $cal_attrib );
$cal_options [ 'showsTime' ] = false ;
$cal_options [ 'showOthers' ] = false ;
$cal_options [ 'weekNumbers' ] = false ;
$cal_options [ 'ifFormat' ] = " %d/%m/%Y " ;
$cal_attrib [ 'class' ] = " tbox " ;
$cal_attrib [ 'size' ] = " 10 " ;
$cal_attrib [ 'name' ] = " news_end " ;
$cal_attrib [ 'value' ] = $_enddate ;
$text .= $cal -> make_input_field ( $cal_options , $cal_attrib );
$text .= "
</ div >
</ td >
</ tr > " ;
$text .= " <tr>
< td class = 'forumheader3' >
" .LAN_NEWS_32. " :
</ td >
< td class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .LAN_NEWS_33. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' > " ;
$update_checked = ( $_POST [ 'update_datestamp' ]) ? " checked='checked' " : " " ;
$_update_datestamp = ( $_POST [ 'news_datestamp' ] > 0 && ! strpos ( $_POST [ 'news_datestamp' ], " / " )) ? date ( " d/m/Y H:i:s " , $_POST [ 'news_datestamp' ]) : trim ( $_POST [ 'news_datestamp' ]);
unset ( $cal_options );
unset ( $cal_attrib );
$cal_options [ 'showsTime' ] = true ;
$cal_options [ 'showOthers' ] = true ;
$cal_options [ 'weekNumbers' ] = false ;
$cal_options [ 'ifFormat' ] = " %d/%m/%Y %H:%M:%S " ;
$cal_options [ 'timeFormat' ] = " 24 " ;
$cal_attrib [ 'class' ] = " tbox " ;
$cal_attrib [ 'name' ] = " news_datestamp " ;
$cal_attrib [ 'value' ] = $_update_datestamp ;
$text .= $cal -> make_input_field ( $cal_options , $cal_attrib );
$text .= " <br />
< input type = 'checkbox' value = '1' name = 'update_datestamp' $update_checked /> " .NWSLAN_105. "
</ div >
</ td ></ tr > " ;
2008-05-18 16:34:28 +00:00
// --------------------- News Userclass ---------------------------
2006-12-02 04:36:16 +00:00
$text .= " <tr>
< td class = 'forumheader3' >
" .NWSLAN_22. " :
</ td >
< td class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .NWSLAN_84. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' >
" .r_userclass_check( " news_userclass " , $_POST['news_class'] , " nobody , public , guest , member , admin , classes , language " ). "
</ div >
</ td ></ tr >
< tr >
< td class = 'forumheader3' >
" .LAN_NEWS_28. " :
</ td >
< td class = 'forumheader3' >
2007-08-06 21:33:53 +00:00
< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .LAN_NEWS_29. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' >
" ;
if ( $_POST [ 'news_sticky' ])
{
$sel = " checked='checked' " ;
}
else
{
$sel = " " ;
}
$text .= " <input type='checkbox' { $sel } name='news_sticky' value='1' /> " . LAN_NEWS_30 . " \n </div> \n </td> \n </tr> \n " ;
if ( $pref [ 'trackbackEnabled' ]){
$text .= " <tr>
< td class = 'forumheader3' > " .LAN_NEWS_34. " :</ td >
2007-08-06 21:33:53 +00:00
< td class = 'forumheader3' >< a style = 'cursor: pointer' onclick = 'expandit(this);' > " .LAN_NEWS_35. " </ a >
2006-12-02 04:36:16 +00:00
< div style = 'display: none;' >
< span class = 'smalltext' > " ;
/* pingback */
// <input type='checkbox' name='pingback_urls' ".($_POST['pingback_urls'] ? " checked='checked'" : "")." />".LAN_NEWS_36."<br />
$text .= LAN_NEWS_37 . " </span><br />
< textarea class = 'tbox' name = 'trackback_urls' style = 'width:95%;height:100px' > " . $_POST['trackback_urls'] . " </ textarea >
</ div >
</ td >
</ tr > \n " ;
}
$text .= " <tr style='vertical-align: top;'>
< td colspan = '2' style = 'text-align:center' class = 'forumheader' > " .
( isset ( $_POST [ 'preview' ]) ? " <input class='button' type='submit' name='preview' value=' " . NWSLAN_24 . " ' /> " : " <input class='button' type='submit' name='preview' value=' " . NWSLAN_27 . " ' /> " ) .
( $id && $sub_action != " sn " && $sub_action != " upload " ? " <input class='button' type='submit' name='submit_news' value=' " . NWSLAN_25 . " ' /> " : " <input class='button' type='submit' name='submit_news' value=' " . NWSLAN_26 . " ' /> " ) . "
< input type = 'hidden' name = 'news_id' value = '$news_id' /> \n </ td >
</ tr >
</ table >
</ form >
</ div > " ;
$ns -> tablerender ( NWSLAN_29 , $text );
}
2008-12-07 13:08:54 +00:00
function preview_item ( $id )
{
2006-12-02 04:36:16 +00:00
// ##### Display news preview ---------------------------------------------------------------------------------------------------------
global $tp , $sql , $ix , $IMAGES_DIRECTORY ;
$_POST [ 'news_id' ] = $id ;
if ( $_POST [ 'news_start' ])
{
$tmp = explode ( " / " , $_POST [ 'news_start' ]);
$_POST [ 'news_start' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_start' ] = 0 ;
}
if ( $_POST [ 'news_end' ])
{
$tmp = explode ( " / " , $_POST [ 'news_end' ]);
$_POST [ 'news_end' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_end' ] = 0 ;
}
if ( preg_match ( " #(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?) $ # " , $_POST [ 'news_datestamp' ], $matches ))
{
$_POST [ 'news_datestamp' ] = mktime ( $matches [ 4 ], $matches [ 5 ], $matches [ 6 ], $matches [ 2 ], $matches [ 1 ], $matches [ 3 ]);
}
else
{
$_POST [ 'news_datestamp' ] = time ();
}
if ( $_POST [ 'update_datestamp' ])
{
$_POST [ 'news_datestamp' ] = time ();
}
$sql -> db_Select ( " news_category " , " * " , " category_id=' " . $_POST [ 'cat_id' ] . " ' " );
list ( $_POST [ 'category_id' ], $_POST [ 'category_name' ], $_POST [ 'category_icon' ]) = $sql -> db_Fetch ();
2008-05-18 16:34:28 +00:00
// $_POST['user_id'] = USERID;
// $_POST['user_name'] = USERNAME."blabla";
list ( $_POST [ 'user_id' ], $_POST [ 'user_name' ]) = explode ( chr ( 1 ), $_POST [ 'news_author' ]);
$_POST [ 'news_author' ] = $_POST [ 'user_id' ];
2006-12-02 04:36:16 +00:00
$_POST [ 'comment_total' ] = $comment_total ;
$_PR = $_POST ;
$_PR [ 'news_body' ] = $tp -> post_toHTML ( $_PR [ 'data' ], FALSE );
$_PR [ 'news_title' ] = $tp -> post_toHTML ( $_PR [ 'news_title' ], FALSE , " emotes_off, no_make_clickable " );
$_PR [ 'news_summary' ] = $tp -> post_toHTML ( $_PR [ 'news_summary' ]);
$_PR [ 'news_extended' ] = $tp -> post_toHTML ( $_PR [ 'news_extended' ]);
$_PR [ 'news_file' ] = $_POST [ 'news_file' ];
$_PR [ 'news_image' ] = $_POST [ 'news_image' ];
$ix -> render_newsitem ( $_PR );
echo $tp -> parseTemplate ( '{NEWSINFO}' , FALSE , $news_shortcodes );
}
2008-12-07 13:08:54 +00:00
function submit_item ( $sub_action , $id )
{
// ##### Format and submit item to DB
global $tp , $ix , $sql , $admin_log ;
2006-12-02 04:36:16 +00:00
if ( $_POST [ 'news_start' ])
{
$tmp = explode ( " / " , $_POST [ 'news_start' ]);
$_POST [ 'news_start' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_start' ] = 0 ;
}
if ( $_POST [ 'news_end' ])
{
$tmp = explode ( " / " , $_POST [ 'news_end' ]);
$_POST [ 'news_end' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_end' ] = 0 ;
}
if ( preg_match ( " #(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?) $ # " , $_POST [ 'news_datestamp' ], $matches ))
{
$_POST [ 'news_datestamp' ] = mktime ( $matches [ 4 ], $matches [ 5 ], $matches [ 6 ], $matches [ 2 ], $matches [ 1 ], $matches [ 3 ]);
}
else
{
$_POST [ 'news_datestamp' ] = time ();
}
if ( $_POST [ 'update_datestamp' ])
{
$_POST [ 'news_datestamp' ] = time ();
}
if ( $id && $sub_action != " sn " && $sub_action != " upload " )
{
$_POST [ 'news_id' ] = $id ;
}
else
{
$sql -> db_Update ( " submitnews " , " submitnews_auth='1' WHERE submitnews_id =' " . $id . " ' " );
2008-12-07 13:08:54 +00:00
$admin_log -> log_event ( 'NEWS_07' , $id , E_LOG_INFORMATIVE , '' );
2006-12-02 04:36:16 +00:00
}
2008-12-07 13:08:54 +00:00
if ( ! $_POST [ 'cat_id' ])
{
2006-12-02 04:36:16 +00:00
$_POST [ 'cat_id' ] = 1 ;
}
2008-05-18 16:34:28 +00:00
list ( $_POST [ 'news_author' ], $empty ) = explode ( chr ( 1 ), $_POST [ 'news_author' ]);
2006-12-02 04:36:16 +00:00
$this -> show_message ( $ix -> submit_item ( $_POST ));
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' ]);
}
2008-12-07 13:08:54 +00:00
function show_message ( $message )
{
2006-12-02 04:36:16 +00:00
// ##### Display comfort ---------------------------------------------------------------------------------------------------------
global $ns ;
$ns -> tablerender ( " " , " <div style='text-align:center'><b> " . $message . " </b></div> " );
}
2008-12-07 13:08:54 +00:00
function show_categories ( $sub_action , $id )
{
2006-12-02 04:36:16 +00:00
global $sql , $rs , $ns , $tp ;
$handle = opendir ( e_IMAGE . " icons " );
while ( $file = readdir ( $handle )) {
if ( $file != " . " && $file != " .. " && $file != " / " && $file != " null.txt " && $file != " CVS " ) {
$iconlist [] = $file ;
}
}
closedir ( $handle );
if ( $sub_action == " edit " ) {
if ( $sql -> db_Select ( " news_category " , " * " , " category_id=' $id ' " )) {
$row = $sql -> db_Fetch ();
extract ( $row );
}
}
$text = " <div style='text-align:center'>
" . $rs->form_open ( " post " , e_SELF. " ? cat " , " dataform " ). "
< table class = 'fborder' style = '".ADMIN_WIDTH."' >
< tr >
< td class = 'forumheader3' style = 'width:30%' >< span class = 'defaulttext' > " .NWSLAN_52. " </ span ></ td >
< td class = 'forumheader3' style = 'width:70%' > " . $rs->form_text ( " category_name " , 30, $category_name , 200). " </ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:30%' >< span class = 'defaulttext' > " .NWSLAN_53. " </ span ></ td >
< td class = 'forumheader3' style = 'width:70%' >
" . $rs->form_text ( " category_button " , 60, $category_icon , 100). "
< br />
2007-08-06 21:33:53 +00:00
< input class = 'button' type = 'button' style = 'cursor: pointer' size = '30' value = '".NWSLAN_54."' onclick = 'expandit(this)' />
2006-12-02 04:36:16 +00:00
< div id = 'caticn' style = 'display:none' > " ;
while ( list ( $key , $icon ) = each ( $iconlist )) {
$text .= " <a href= \" javascript:insertext(' $icon ','category_button','caticn') \" ><img src=' " . e_IMAGE . " icons/ " . $icon . " ' style='border:0' alt='' /></a> \n " ;
}
$text .= " </div></td>
</ tr >
< tr >< td colspan = '2' style = 'text-align:center' class = 'forumheader' > " ;
if ( $id ) {
$text .= " <input class='button' type='submit' name='update_category' value=' " . NWSLAN_55 . " ' />
" . $rs->form_button ( " submit " , " category_clear " , NWSLAN_79). $rs->form_hidden ( " category_id " , $id ). "
</ td ></ tr > " ;
} else {
$text .= " <input class='button' type='submit' name='create_category' value=' " . NWSLAN_56 . " ' /></td></tr> " ;
}
$text .= " </table>
" . $rs->form_close (). "
</ div > " ;
$ns -> tablerender ( NWSLAN_56 , $text );
unset ( $category_name , $category_icon );
$text = " <div style='text-align: center'> " ;
if ( $category_total = $sql -> db_Select ( " news_category " )) {
$text .= "
< form action = '".e_SELF."?cat' id = 'newscatform' method = 'post' >
< table class = 'fborder' style = '".ADMIN_WIDTH."' >
< tr >
< td style = 'width:5%' class = 'fcaption' > " .LAN_NEWS_45. " </ td >
< td style = 'width:5%' class = 'fcaption' >& nbsp ; </ td >
< td style = 'width:70%' class = 'fcaption' > " .NWSLAN_6. " </ td >
< td style = 'width:20%; text-align:center' class = 'fcaption' > " .LAN_OPTIONS. " </ td >
</ tr > " ;
while ( $row = $sql -> db_Fetch ()) {
extract ( $row );
if ( $category_icon ) {
$icon = ( strstr ( $category_icon , " images/ " ) ? THEME . " $category_icon " : e_IMAGE . " icons/ $category_icon " );
}
$text .= " <tr>
< td style = 'width:5%; text-align:center' class = 'forumheader3' > { $category_id } </ td >
< td style = 'width:5%; text-align:center' class = 'forumheader3' >< img src = '$icon' alt = '' style = 'vertical-align:middle' /></ td >
< td style = 'width:70%' class = 'forumheader3' > $category_name </ td >
< td style = 'width:20%; text-align:center' class = 'forumheader3' >
< a href = '".e_SELF."?cat.edit.{$category_id}' > " .ADMIN_EDIT_ICON. " </ a >
< input type = 'image' title = '".LAN_DELETE."' name = 'delete[category_{$category_id}]' src = '".ADMIN_DELETE_ICON_PATH."' onclick = \ " return jsconfirm(' " . $tp -> toJS ( NWSLAN_37 . " [ID: $category_id ] " ) . " ') \" />
</ td >
</ tr > \n " ;
}
$text .= " </table></form> " ;
} else {
2007-01-20 15:58:47 +00:00
$text .= " <div style='text-align:center'><div style='vertical-align:middle'> " . NWSLAN_10 . " </div> " ;
2006-12-02 04:36:16 +00:00
}
$text .= " </div> " ;
$ns -> tablerender ( NWSLAN_51 , $text );
}
2008-12-07 13:08:54 +00:00
function show_news_prefs ()
{
2006-12-02 04:36:16 +00:00
global $sql , $rs , $ns , $pref ;
$text = " <div style='text-align:center'>
" . $rs->form_open ( " post " , e_SELF. " ? pref " , " dataform " ). "
< table class = 'fborder' style = '".ADMIN_WIDTH."' >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_86. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input type = 'checkbox' name = 'news_cats' value = '1' " .( $pref['news_cats'] == 1 ? " checked = 'checked' " : " " ). " />
</ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_87. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< select class = 'tbox' name = 'nbr_cols' >
< option value = '1' " .( $pref['nbr_cols'] == 1 ? " selected = 'selected' > " : " " ). " > 1 </ option >
< option value = '2' " .( $pref['nbr_cols'] == 2 ? " selected = 'selected' > " : " " ). " > 2 </ option >
< option value = '3' " .( $pref['nbr_cols'] == 3 ? " selected = 'selected' > " : " " ). " > 3 </ option >
< option value = '4' " .( $pref['nbr_cols'] == 4 ? " selected = 'selected' > " : " " ). " > 4 </ option >
< option value = '5' " .( $pref['nbr_cols'] == 5 ? " selected = 'selected' > " : " " ). " > 5 </ option >
< option value = '6' " .( $pref['nbr_cols'] == 6 ? " selected = 'selected' > " : " " ). " > 6 </ option >
</ select ></ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_88. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input class = 'tbox' type = 'text' style = 'width:30px' name = 'newsposts' value = '".$pref[' newsposts ']."' />
</ td >
</ tr > " ;
2008-05-31 17:55:31 +00:00
2006-12-02 04:36:16 +00:00
// ##### ADDED FOR NEWS ARCHIVE --------------------------------------------------------------------
// the possible archive values are from "0" to "< $pref['newsposts']"
// this should really be made as an onchange event on the selectbox for $pref['newsposts'] ...
$text .= "
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_115. " </ span >< br />
< span class = 'defaulttext' >< i > " .NWSLAN_116. " </ i ></ span >
</ td >
< td class = 'forumheader3' style = 'width:40%' >
< select class = 'tbox' name = 'newsposts_archive' > " ;
for ( $i = 0 ; $i < $pref [ 'newsposts' ]; $i ++ ) {
$text .= ( $i == $pref [ 'newsposts_archive' ] ? " <option value=' " . $i . " ' selected='selected'> " . $i . " </option> " : " <option value=' " . $i . " '> " . $i . " </option> " );
}
$text .= " </select></td>
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_117. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input class = 'tbox' type = 'text' style = 'width:150px' name = 'newsposts_archive_title' value = '".$pref[' newsposts_archive_title ']."' />
</ td >
</ tr >
" ;
// ##### END --------------------------------------------------------------------------------------
require_once ( e_HANDLER . " userclass_class.php " );
2008-05-18 16:34:28 +00:00
$text .= "
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .LAN_NEWS_51. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
" .r_userclass( " news_editauthor " , $pref['news_editauthor'] , " off " , " nobody , mainadmin , admin , classes " ). " </ td ></ tr >
< tr >
2006-12-02 04:36:16 +00:00
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_106. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
2006-12-11 08:02:21 +00:00
" .r_userclass( " subnews_class " , $pref['subnews_class'] , " off " , " nobody , public , guest , member , admin , classes " ). " </ td ></ tr > " ;
2006-12-02 04:36:16 +00:00
$text .= "
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_107. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input type = 'checkbox' name = 'subnews_htmlarea' value = '1' " .( $pref['subnews_htmlarea'] == 1 ? " checked = 'checked' " : " " ). " />
</ td >
</ tr > " ;
$text .= "
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_100. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input type = 'checkbox' name = 'subnews_attach' value = '1' " .( $pref['subnews_attach'] == 1 ? " checked = 'checked' " : " " ). " />
</ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_101. " </ span ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input class = 'tbox' type = 'text' style = 'width:50px' name = 'subnews_resize' value = '".$pref[' subnews_resize ']."' />
< span class = 'smalltext' > " .NWSLAN_102. " </ span ></ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_111. " </ span >< br />< i > " .NWSLAN_112. " </ i ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input type = 'checkbox' name = 'news_newdateheader' value = '1' " .( $pref['news_newdateheader'] == 1 ? " checked = 'checked' " : " " ). " />
</ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_113. " </ span >< br />< i > " .NWSLAN_114. " </ i ></ td >
< td class = 'forumheader3' style = 'width:40%' >
< input type = 'checkbox' name = 'news_unstemplate' value = '1' " .( $pref['news_unstemplate'] == 1 ? " checked = 'checked' " : " " ). " />
</ td >
</ tr >
< tr >
< td class = 'forumheader3' style = 'width:60%' >< span class = 'defaulttext' > " .NWSLAN_120. " </ span >< br /></ td >
< td class = 'forumheader3' style = 'width:40%' >
< textarea name = 'news_subheader' style = 'width:95%;' rows = '6' onselect = 'storeCaret(this);' onclick = 'storeCaret(this);' onkeyup = 'storeCaret(this);' class = 'tbox' > " .stripcslashes( $pref['news_subheader'] ). " </ textarea >< br /> " . display_help('helpb', 2) . "
</ td >
</ tr >
< tr >< td colspan = '2' style = 'text-align:center' class = 'forumheader' > " ;
$text .= " <input class='button' type='submit' name='save_prefs' value=' " . NWSLAN_89 . " ' /></td></tr> " ;
$text .= " </table>
" . $rs->form_close (). "
</ div > " ;
$ns -> tablerender ( NWSLAN_90 , $text );
}
2008-12-02 16:50:16 +00:00
function submitted_news ( $sub_action , $id )
2008-05-31 17:55:31 +00:00
{
2006-12-02 04:36:16 +00:00
global $rs , $ns , $tp ;
$sql2 = new db ;
$text = " <div style='text-align: center'> " ;
2008-12-02 16:50:16 +00:00
if ( $category_total = $sql2 -> db_Select ( " submitnews " , " * " , " submitnews_id !='' ORDER BY submitnews_id DESC " ))
2008-05-31 17:55:31 +00:00
{
2006-12-02 04:36:16 +00:00
$text .= " <table class='fborder' style=' " . ADMIN_WIDTH . " '>
< tr >
< td style = 'width:5%' class = 'fcaption' > ID </ td >
< td style = 'width:70%' class = 'fcaption' > " .NWSLAN_57. " </ td >
< td style = 'width:25%; text-align:center' class = 'fcaption' > " .LAN_OPTIONS. " </ td >
</ tr > " ;
2008-12-02 16:50:16 +00:00
while ( $row = $sql2 -> db_Fetch ())
2008-05-31 17:55:31 +00:00
{
2006-12-02 04:36:16 +00:00
extract ( $row );
2008-05-31 17:55:31 +00:00
if ( substr ( $submitnews_item , - 7 , 7 ) == '[/html]' ) $submitnews_item = substr ( $submitnews_item , 0 , - 7 );
if ( substr ( $submitnews_item , 0 , 6 ) == '[html]' ) $submitnews_item = substr ( $submitnews_item , 6 );
2006-12-02 04:36:16 +00:00
$text .= " <tr>
< td style = 'width:5%; text-align:center; vertical-align:top' class = 'forumheader3' > $submitnews_id </ td >
< td style = 'width:70%' class = 'forumheader3' > " ;
$text .= ( $submitnews_auth == 0 ) ? " <b> " . $tp -> toHTML ( $submitnews_title , FALSE , " emotes_off, no_make_clickable " ) . " </b> " : $tp -> toHTML ( $submitnews_title , FALSE , " emotes_off, no_make_clickable " );
$text .= " [ " . NWSLAN_104 . " " . $submitnews_name . " " . NWSLAN_108 . " " . date ( " D dS M y, g:ia " , $submitnews_datestamp ) . " ]<br /> " . $tp -> toHTML ( $submitnews_item ) . " </td>
< td style = 'width:25%; text-align:right; vertical-align:top' class = 'forumheader3' > " ;
$buttext = ( $submitnews_auth == 0 ) ? NWSLAN_58 : NWSLAN_103 ;
$text .= $rs -> form_open ( " post " , e_SELF . " ?sn " , " myform__ { $submitnews_id } " , " " , " " , " onsubmit= \" return jsconfirm(' " . $tp -> toJS ( NWSLAN_38 . " [ID: $submitnews_id ] " ) . " ') \" " )
. " <div> " . $rs -> form_button ( " button " , " category_edit_ { $submitnews_id } " , $buttext , " onclick= \" document.location=' " . e_SELF . " ?create.sn. $submitnews_id ' \" " ) . "
" . $rs->form_button ( " submit " , " delete [ sn_ { $submitnews_id }] " , LAN_DELETE). "
</ div > " . $rs->form_close (). "
</ td >
</ tr > \n " ;
}
$text .= " </table> " ;
2008-05-31 17:55:31 +00:00
}
2008-12-02 16:50:16 +00:00
else
2008-05-31 17:55:31 +00:00
{
2006-12-02 04:36:16 +00:00
$text .= " <div style='text-align:center'> " . NWSLAN_59 . " </div> " ;
}
$text .= " </div> " ;
$ns -> tablerender ( NWSLAN_47 , $text );
}
}
2008-12-07 13:08:54 +00:00
function newspost_adminmenu ()
{
2006-12-02 04:36:16 +00:00
global $newspost ;
global $action ;
$newspost -> show_options ( $action );
}
?>