allow_php = true; if( !$action ) $action = "list"; if( $action == "list" ) { $_SESSION['admin_referrer'] = $_SERVER['REQUEST_URI']; echoheader( "static", "static" ); $search_field = $db->safesql( trim( htmlspecialchars( stripslashes( urldecode( $_GET['search_field'] ) ), ENT_QUOTES ) ) ); if ($_GET['fromnewsdate']) $fromnewsdate = strtotime( $_GET['fromnewsdate'] ); else $fromnewsdate = ""; if ($_GET['tonewsdate']) $tonewsdate = strtotime( $_GET['tonewsdate'] ); else $tonewsdate = ""; if ($fromnewsdate === -1 OR !$fromnewsdate) $fromnewsdate = ""; if ($tonewsdate === -1 OR !$tonewsdate) $tonewsdate = ""; $start_from = intval( $_GET['start_from'] ); $news_per_page = intval( $_GET['news_per_page'] ); $gopage = intval( $_REQUEST['gopage'] ); if( ! $news_per_page or $news_per_page < 1 ) { $news_per_page = 50; } if( $gopage ) $start_from = ($gopage - 1) * $news_per_page; if( $start_from < 0 ) $start_from = 0; $where = array (); if( $search_field != "" ) { $where[] = "(template like '%$search_field%' OR descr like '%$search_field%')"; } if( $fromnewsdate != "" ) { $where[] = "date >= '$fromnewsdate'"; } if( $tonewsdate != "" ) { $where[] = "date <= '$tonewsdate'"; } if( count( $where ) ) { $where = implode( " AND ", $where ); $where = " WHERE " . $where; } else { $where = ""; } $order_by = array (); if( $_REQUEST['search_order_t'] == "asc" or $_REQUEST['search_order_t'] == "desc" ) $search_order_t = $_REQUEST['search_order_t']; else $search_order_t = ""; if( $_REQUEST['search_order_d'] == "asc" or $_REQUEST['search_order_d'] == "desc" ) $search_order_d = $_REQUEST['search_order_d']; else $search_order_d = ""; if( ! empty( $search_order_t ) ) {$order_by[] = "name $search_order_t";} if( ! empty( $search_order_d ) ) {$order_by[] = "date $search_order_d";} $order_by = implode( ", ", $order_by ); if( ! $order_by ) $order_by = "date desc"; $search_order_date = array ('----' => '', 'asc' => '', 'desc' => '' ); if( isset( $_REQUEST['search_order_d'] ) ) { $search_order_date[$search_order_d] = 'selected'; } else { $search_order_date['desc'] = 'selected'; } $search_order_title = array ('----' => '', 'asc' => '', 'desc' => '' ); if( ! empty( $search_order_t ) ) { $search_order_title[$search_order_t] = 'selected'; } else { $search_order_title['----'] = 'selected'; } $db->query( "SELECT id, name, descr, template, views, date FROM " . PREFIX . "_static" . $where . " ORDER BY " . $order_by . " LIMIT $start_from,$news_per_page" ); // Prelist Entries if( $start_from == "0" ) { $start_from = ""; } $i = $start_from; $entries_showed = 0; $entries = ""; while ( $row = $db->get_array() ) { $i ++; $itemdate = @date( "d.m.Y H:i", $row['date'] ); $title = htmlspecialchars( stripslashes( $row['name'] ), ENT_QUOTES ); $descr = stripslashes($row['descr']); $vlink = $config['http_home_url'] . $row['name'] . ".html"; $entries .= " $itemdate - $title $descr {$row['views']} "; $entries_showed ++; if( $i >= $news_per_page + $start_from ) { break; } } // End prelisting $result_count = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_static" . $where ); $all_count_news = $result_count['count']; if ( $fromnewsdate ) $fromnewsdate = date("Y-m-d", $fromnewsdate ); if ( $tonewsdate ) $tonewsdate = date("Y-m-d", $tonewsdate ); /////////////////////////////////////////// // Options Bar echo <<
HTML; // End Options Bar echo << JSCRIPT; if( $entries_showed == 0 ) { echo <<
{$lang['static_advanced_search']}


{$lang['edit_nostatic']}


   
HTML; } else { echo <<
HTML; if( $all_count_news > $news_per_page ) { echo << HTML; } } echo <<
{$lang['static_advanced_search']}
{$entries}
{$lang['static_title']} {$lang['static_descr']}  {$lang['st_views']} 
HTML; // pagination $npp_nav = "
"; if( $start_from > 0 ) { $previous = $start_from - $news_per_page; $npp_nav .= "<< "; } if( $all_count_news > $news_per_page ) { $enpages_count = @ceil( $all_count_news / $news_per_page ); $enpages_start_from = 0; $enpages = ""; if( $enpages_count <= 10 ) { for($j = 1; $j <= $enpages_count; $j ++) { if( $enpages_start_from != $start_from ) { $enpages .= "$j "; } else { $enpages .= "$j "; } $enpages_start_from += $news_per_page; } $npp_nav .= $enpages; } else { $start = 1; $end = 10; if( $start_from > 0 ) { if( ($start_from / $news_per_page) > 4 ) { $start = @ceil( $start_from / $news_per_page ) - 3; $end = $start + 9; if( $end > $enpages_count ) { $start = $enpages_count - 10; $end = $enpages_count - 1; } $enpages_start_from = ($start - 1) * $news_per_page; } } if( $start > 2 ) { $enpages .= "1 ... "; } for($j = $start; $j <= $end; $j ++) { if( $enpages_start_from != $start_from ) { $enpages .= "$j "; } else { $enpages .= "$j "; } $enpages_start_from += $news_per_page; } $enpages_start_from = ($enpages_count - 1) * $news_per_page; $enpages .= "... $enpages_count "; $npp_nav .= $enpages; } } if( $all_count_news > $i ) { $how_next = $all_count_news - $i; if( $how_next > $news_per_page ) { $how_next = $news_per_page; } $npp_nav .= ">>"; } $npp_nav .= "
"; // pagination if( $entries_showed != 0 ) { echo <<
{$npp_nav}
{$lang['edit_go_page']}
   
HTML; } echofooter(); } elseif( $action == "addnew" ) { echoheader( "static", "static" ); echo " "; echo "
"; echo <<
HTML; include (SYSTEM_DIR . '/inc/include/inserttag.php'); echo << HTML; $fix_br = " {$lang['static_br_html']}
{$lang['static_br_html_1']}"; if ($member_id['user_group'] == 1 ) $fix_br .= "
{$lang['static_br_html_2']}"; $groups = get_groups(); echo <<
{$lang['static_title']} [?]
{$lang['static_descr']} [?]
{$lang['edit_edate']}   {$lang['edit_jdate']}
{$lang['static_templ']} {$bb_code}
{$lang['static_type']}{$fix_br}
  {$lang['add_metatags']}[?]
{$lang['meta_title']}
{$lang['meta_descr']} ({$lang['meta_descr_max']})
{$lang['meta_keys']}
 
{$lang['stat_allow']}
 

   

HTML; echofooter(); } elseif( $action == "dosavenew" ) { if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) { die( "Hacking attempt! User not found" ); } $allow_br = intval( $_POST['allow_br'] ); if ($member_id['user_group'] != 1 AND $allow_br > 1 ) $allow_br = 1; if ($allow_br == 2) { if( function_exists( "get_magic_quotes_gpc" ) && get_magic_quotes_gpc() ) $_POST['template'] = stripslashes( $_POST['template'] ); $template = trim( addslashes( $_POST['template'] ) ); } else { $template = $parse->process( $_POST['template'] ); $template = $parse->BB_Parse( $template, false ); } $metatags = create_metatags( $template ); $name = trim( totranslit( $_POST['name'], true, false ) ); $descr = trim( $db->safesql( htmlspecialchars( $_POST['description'] ) ) ); $template = $db->safesql( $template ); $newdate = $_POST['newdate']; if( isset( $_POST['allow_now'] ) ) $allow_now = $_POST['allow_now']; else $allow_now = ""; $name = str_replace( "-", "_", $name ); if( ! count( $_POST['grouplevel'] ) ) $_POST['grouplevel'] = array ("all" ); $grouplevel = $db->safesql( implode( ',', $_POST['grouplevel'] ) ); // Обработка даты и времени $added_time = time() + ($config['date_adjust'] * 60); $newsdate = strtotime( $newdate ); if( ($allow_now == "yes") or ($newsdate === - 1) or (trim( $newdate ) == "") ) { $thistime = $added_time; } else { $thistime = $newsdate; if( ! intval( $config['no_date'] ) and $newsdate > $added_time ) $thistime = $added_time; } if( $name == "" or $descr == "" or $template == "" ) msg( "error", $lang['static_err'], $lang['static_err_1'], "javascript:history.go(-1)" ); $static_count = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_static WHERE name='$name'" ); if ($static_count['count']) msg( "error", $lang['static_err'], $lang['static_err_2'], "javascript:history.go(-1)" ); $db->query( "INSERT INTO " . PREFIX . "_static (name, descr, template, allow_br, grouplevel, metadescr, metakeys, date, metatitle) values ('$name', '$descr', '$template', '$allow_br', '$grouplevel', '{$metatags['description']}', '{$metatags['keywords']}', '{$thistime}', '{$metatags['title']}')" ); $row = $db->insert_id(); $db->query( "UPDATE " . PREFIX . "_static_files SET static_id='{$row}' WHERE author = '{$member_id['name']}' AND static_id = '0'" ); msg( "info", $lang['static_addok'], $lang['static_addok_1'], "?mod=static" ); } elseif( $action == "doedit" ) { $id = intval( $_GET['id'] ); $row = $db->super_query( "SELECT * FROM " . PREFIX . "_static where id='$id'" ); if ($row['allow_br'] == 2) { if ($member_id['user_group'] != 1) msg( "error", $lang['index_denied'], $lang['static_not_allowed'] ); $row['template'] = htmlspecialchars( stripslashes( $row['template'] ) ); } else { $row['template'] = $parse->decodeBBCodes( $row['template'], false ); } $row['descr'] = stripslashes($row['descr']); $row['metatitle'] = stripslashes( $row['metatitle'] ); $itemdate = @date( "Y-m-d H:i", $row['date'] ); echoheader( "static", "static" ); echo << HTML; echo " "; echo "
"; echo <<
{$lang['ajax_info']}

HTML; echo << HTML; echo << HTML; include (SYSTEM_DIR . '/inc/include/inserttag.php'); echo << HTML; $check = array(); $check[$row['allow_br']] = "checked=\"checked\""; $fix_br = " {$lang['static_br_html']}
{$lang['static_br_html_1']}"; if ($member_id['user_group'] == 1 ) $fix_br .= "
{$lang['static_br_html_2']}"; $groups = get_groups( explode( ',', $row['grouplevel'] ) ); if( $row['grouplevel'] == "all" ) $check_all = "selected"; else $check_all = ""; echo << HTML; echo <<
{$lang['static_title']} [?]
{$lang['static_descr']} [?]
{$lang['edit_edate']}   {$lang['edit_ndate']}  {$lang['edit_jdate']}
{$lang['static_templ']} {$bb_code}
{$lang['static_type']}{$fix_br}
  {$lang['add_metatags']}[?]
{$lang['meta_title']}
{$lang['meta_descr']} ({$lang['meta_descr_max']})
{$lang['meta_keys']}
 
 
       

HTML; echofooter(); } elseif( $action == "dosaveedit" ) { if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) { die( "Hacking attempt! User not found" ); } $allow_br = intval( $_POST['allow_br'] ); if ($member_id['user_group'] != 1 AND $allow_br > 1 ) $allow_br = 1; if ($allow_br == 2) { if( function_exists( "get_magic_quotes_gpc" ) && get_magic_quotes_gpc() ) $_POST['template'] = stripslashes( $_POST['template'] ); $template = trim( addslashes( $_POST['template'] ) ); } else { $template = $parse->process( $_POST['template'] ); $template = $parse->BB_Parse( $template, false ); } $metatags = create_metatags( $template ); $name = trim( $db->safesql( htmlspecialchars( $_POST['name'] ) ) ); $descr = trim( $db->safesql( htmlspecialchars( $_POST['description'] ) ) ); if( ! count( $_POST['grouplevel'] ) ) $_POST['grouplevel'] = array ("all" ); $grouplevel = $db->safesql( implode( ',', $_POST['grouplevel'] ) ); $name = str_replace( "-", "_", $name ); $template = $db->safesql( $template ); $newdate = $_POST['newdate']; if( isset( $_POST['allow_date'] ) ) $allow_date = $_POST['allow_date']; else $allow_date = ""; if( isset( $_POST['allow_now'] ) ) $allow_now = $_POST['allow_now']; else $allow_now = ""; // Обработка даты и времени $added_time = time() + ($config['date_adjust'] * 60); $newsdate = strtotime( $newdate ); if( $allow_date != "yes" ) { if( $allow_now == "yes" ) $thistime = $added_time; elseif( ($newsdate === - 1) or (trim( $newdate ) == "") ) { $thistime = $added_time; } else { $thistime = $newsdate; if( ! intval( $config['no_date'] ) and $newsdate > $added_time ) { $thistime = $added_time; } } } else { $thistime = intval( $_POST['static_date'] ); } $id = intval( $_GET['id'] ); if( $name == "" or $descr == "" or $template == "" ) msg( "error", $lang['static_err'], $lang['static_err_1'], "javascript:history.go(-1)" ); $db->query( "UPDATE " . PREFIX . "_static set name='$name', descr='$descr', template='$template', allow_br='$allow_br', grouplevel='$grouplevel', metadescr='{$metatags['description']}', metakeys='{$metatags['keywords']}', date='{$thistime}', metatitle='{$metatags['title']}' WHERE id='$id'" ); msg( "info", $lang['static_addok'], $lang['static_addok_1'], "?mod=static" ); msg( "info", $lang['static_addok'], $lang['static_addok_1'], "?mod=static" ); } elseif( $action == "dodelete" ) { if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) { die( "Hacking attempt! User not found" ); } $id = intval( $_GET['id'] ); $db->query( "DELETE FROM " . PREFIX . "_static WHERE id='$id'" ); $db->query( "SELECT name, onserver FROM " . PREFIX . "_static_files WHERE static_id = '$id'" ); while ( $row = $db->get_row() ) { if( $row['onserver'] ) { @unlink( ROOT_DIR . "/uploads/files/" . $row['onserver'] ); } else { $url_image = explode( "/", $row['name'] ); if( count( $url_image ) == 2 ) { $folder_prefix = $url_image[0] . "/"; $dataimages = $url_image[1]; } else { $folder_prefix = ""; $dataimages = $url_image[0]; } @unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . $dataimages ); @unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . "thumbs/" . $dataimages ); } } $db->query( "DELETE FROM " . PREFIX . "_static_files WHERE static_id = '$id'" ); msg( "info", $lang['static_del'], $lang['static_del_1'], "$PHP_SELF?mod=static" ); } ?>