Файл: lenta.php
Строк: 159
<?php
/*************************************************
 *    apwa.ru       sobytie.php
 *                 -------------
 *  Anv@r.all 2011
 ************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
$lang['User'] = 'Вами';
$lang['Users'] = 'Пользователем';
$lang['Topic_new'] = 'создана тема';
$lang['Album_new_img'] = 'добавленно изображение';
$lang['Album_comment'] = 'добавлен комментарий к %sизображению%s';
$lang['Weblog_new_entry'] = 'создана запись в дневниках';
$lang['Weblog_comments'] = 'добавлен %sкомментарий в дневнике%s';
$lang['Gb_text'] = 'написано сообщение в %sгостевой%s';
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : '';
$id = ( intval($HTTP_GET_VARS['id']) ) ? intval($HTTP_GET_VARS['id']) : '';
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : FALSE;
$confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : FALSE;
if ( $mode == 'delete' && $id != '')
{
     if ( $userdata['user_level'] != ADMIN )
     {
             message_die(GENERAL_MESSAGE, $lang['Reached_on_error']);
     }
     if ( !$confirm )
     {
         $s_hidden_fields .= '<input type="hidden" name="id" value="' . $id . '" />';
                         
         include($phpbb_root_path . 'includes/page_header.'.$phpEx);
         $template->set_filenames(array(
             'confirm_body' => 'confirm_body.tpl')
         );
        
         $template->assign_vars(array(
             'MESSAGE_TITLE' => $lang['Information'],
             'MESSAGE_TEXT' => $lang['Guest_delete_coment'],
             'L_YES' => $lang['Yes'],
             'L_NO' => $lang['No'],
             'S_CONFIRM_ACTION' => append_sid("lenta.$phpEx?mode=delete&id=" . $id),
             'S_HIDDEN_FIELDS' => $s_hidden_fields)
         );
         $template->pparse('confirm_body');
         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
      } 
      else
      {     
           $sql = "DELETE FROM " . SOBYTIE_TABLE . " 
               WHERE id = " . $id;
           if (!$result = $db->sql_query($sql)) 
           {
               message_die(GENERAL_ERROR, 'Error removing shout.', '', __LINE__, __FILE__, $sql);
           }
           else
           {                     
               message_die(GENERAL_MESSAGE, 'Успешно удалено!<br/>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>'));
           }
     } 
}
                
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
$result = $db->sql_query('SELECT COUNT(id) AS total FROM ' . SOBYTIE_TABLE);
$row = $db->sql_fetchrow($result);       
$num = $row['total'];               
$db->sql_freeresult($result);  
$pagination = ( $num == '0' ) ? '' : generate_pagination("lenta.$phpEx?mode=lenta", $num, '8', $start); 
define('SHOW_ONLINE', true);
$page_title = 'Последние события';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
     'body' => 'lenta_body.tpl')
);
$template->assign_vars(array(
         'PAGINATION' => $pagination)
);         
$sql = "SELECT * FROM " . SOBYTIE_TABLE . "
        ORDER BY time DESC LIMIT " . $start . ", 8";
if ( !$result = $db->sql_query($sql) )
{
    message_die(GENERAL_ERROR, "КосяГ какойто!", '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{        
    /*$time_del = mktime()-(1*86400);
    if ( $row['time'] < $time_del )
    {
                $id = $row['id'];
                $sql = "DELETE FROM " . SOBYTIE_TABLE . "
                        WHERE id = $id";
                if( !$db->sql_query($sql) )
                {
                         message_die(GENERAL_ERROR, 'Could not delete', '', __LINE__, __FILE__, $sql);
                }
    }*/
    $images = '';
    if ($row['link_type'] == "newtopic")
    {
            $links = $lang['Topic_new'] . ' <a href="' . append_sid('topic' . $row['link_id'] . '.xhtml') . '">' . $row['subject'] . '</a>';            
    }
    else if ($row['link_type'] == "album")
    {
            $links = $lang['Album_new_img'] . ' <a href="' . append_sid('album_page.' . $phpEx . '?pic_id=' . $row['link_id']) . '">' . $row['subject'] . '</a>';
            $images = '<img src="' . append_sid('album_thumbnail.'. $phpEx . '?pic_id=' . $row['link_id']) . '" alt="' . $row['subject'] . '"/>';
    }
    else if ($row['link_type'] == "album_comment")
    {
            $links = sprintf($lang['Album_comment'], '<a href="' . append_sid('album_comment.' . $phpEx . '?pic_id=' . $row['link_id']) . '">','</a>');
            $images = '<img src="' . append_sid('album_thumbnail.'. $phpEx . '?pic_id=' . $row['link_id']) . '" alt=""/>';
    }
    else if ($row['link_type'] == "gb_post")
    {
            $links = sprintf($lang['Gb_text'], '<a href="' . append_sid('gb.' . $phpEx) . '">','</a>');
    }    
    else if ($row['link_type'] == "weblog")
    {
            $links = $lang['Weblog_new_entry'] . ' <a href="' . append_sid("weblog_entry.$phpEx?" . 'e' . '=' . $row['link_id']) . '">' . $row['subject'] . '</a>';
    }
    else if ($row['link_type'] == "weblog_comment")
    {
            $links = sprintf($lang['Weblog_comments'], '<a href="' . append_sid("weblog_entry.$phpEx?" . 'e' . '=' . $row['link_id']) . '">', '</a>');
    }
    else
    {
            $links = $row['subject'];
    }
    
    $text = $row['text']; 
    if( strlen($text) > 250 )
    {
         $text = substr($text, 0, 250-strlen(strrchr(substr($text, 0, 250), ' '))) . '…';
    }
    else
    {        
         $text = $text;
    } 
    $text = preg_replace('#(<)([/]?.*?)(>)#is', "<\2>", $text);    
    $text = smilies_pass($text);
    $text = str_replace("n", "n<br />n", $text);        
    
    if ($userdata['user_level'] == ADMIN)
    {
            $delete = '<a href="' . append_sid("lenta.$phpEx?mode=delete&id=" . $row['id']) . '">' . $lang['Delete_post'] . '</a>';            
    }        
    $user_id = $row['user_id'];
    $users = ( $row['username'] == $userdata['username'] ) ? $lang['User'] : $lang['Users'];
    $user = ( $user_id == ANONYMOUS ) ? $lang['Guest'] : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $row['user_id']) . '">' . $row['username'] . '</a>';
        
    $template->assign_block_vars('viewrow', array(
        'LINKS' => $links,
        'TEXT' => $text,
        'IMAGES' => $images,
        'USER' => $users . ' ' . $user,
        'DELETE' => $delete,
        'DATE' => create_date($board_config['default_dateformat'], $row['time'], $board_config['board_timezone']))
    );
}
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>