query("SELECT "); //NEWSTICKER $time = time(); $vTick = $SQL->query("SELECT " .$SQL->fieldName('date'). " FROM " .$SQL->tableName('z_news_tickers'). " WHERE " .$SQL->fieldName('hide_ticker'). " = '0'")->fetch(); if(isset($vTick['date'])){ $news_content .= '
Contentbox headline
'; //##################### ADD NEW TICKER ##################### if($action == "newticker") { if($group_id_of_acc_logged >= $config['site']['access_tickers']) { $ticker_text = stripslashes(trim($_POST['new_ticker'])); $ticker_icon = (int) $_POST['icon_id']; if(empty($ticker_text)) { $news_content .= 'You can\'t add empty ticker.'; } else { if(empty($ticker_icon)) { $news_icon = 0; } $SQL->query('INSERT INTO '.$SQL->tableName('z_news_tickers').' (date, author, image_id, text, hide_ticker) VALUES ('.$SQL->quote($time).', '.$account_logged->getId().', '.$ticker_icon.', '.$SQL->quote($ticker_text).', 0)'); $news_content .= '

Added new ticker:


'.date("d/m/Y", $time).' -
'; $news_content .= ' '; $news_content .= short_text($ticker_text, 60).'
'; $news_content .= ''; $news_content .= $ticker_text.'

'; } } else { $news_content .= 'You don\'t have admin rights. You can\'t add new ticker.'; } $news_content .= '
'; } //#################### DELETE (HIDE only!) TICKER ############################ if($action == "deleteticker") { if($group_id_of_acc_logged >= $config['site']['access_tickers']) { header("Location: "); $date = (int) $_REQUEST['id']; $SQL->query('UPDATE '.$SQL->tableName('z_news_tickers').' SET hide_ticker = 1 WHERE '.$SQL->fieldName('date').' = '.$date.';'); $news_content .= '
News tickets with date '.date("j F Y, g:i a", $date).' has been deleted.
'; } else { $news_content .= '
You don\'t have admin rights. You can\'t delete tickers.
'; } } //show tickers if any in database or not blocked (tickers limit = 0) $tickers = $SQL->query('SELECT * FROM `z_news_tickers` WHERE hide_ticker != 1 ORDER BY date DESC LIMIT 5;'); $number_of_tickers = 0; if(is_object($tickers)) { foreach($tickers as $ticker) { if(is_int($number_of_tickers / 2)) $color = "Odd"; else $color = "Even"; $tickers_to_add .= '
'.date("d/m/Y", $ticker['date']).' -
'; //if admin show button to delete (hide) ticker if($group_id_of_acc_logged >= $config['site']['access_admin_panel']) { $tickers_to_add .= ''; } $tickers_to_add .= short_text($ticker['text'], 60).'
'; //if admin show button to delete (hide) ticker if($group_id_of_acc_logged >= $config['site']['access_admin_panel']) { $tickers_to_add .= ''; } $tickers_to_add .= $ticker['text'].'
'; $number_of_tickers++; } } } //adding news if($action == "newnews") { if($group_id_of_acc_logged >= $config['site']['access_news']) { $text = ($_REQUEST['text']); $char_id = (int) $_REQUEST['char_id']; $post_topic = stripslashes(trim($_REQUEST['topic'])); $smile = (int) $_REQUEST['smile']; $news_icon = (int) $_REQUEST['icon_id']; if(empty($news_icon)) { $news_icon = 0; } if(empty($post_topic)) { $an_errors[] .= 'You can\'t add news without topic.'; } if(empty($text)) { $an_errors[] .= 'You can\'t add empty news.'; } if(empty($char_id)) { $an_errors[] .= 'Select character.'; } //execute query if(empty($an_errors)) { $SQL->query("INSERT INTO `z_forum` (`id` ,`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`, `icon_id`) VALUES ('NULL', '0', '".time()."', '1', '0', '0', '".$account_logged->getId()."', '".(int) $char_id."', ".$SQL->quote($text).", ".$SQL->quote($post_topic).", '".(int) $smile."', '".time()."', '0', '0', '".$_SERVER['REMOTE_ADDR']."', '".$news_icon."')"); $thread_id = $SQL->lastInsertId(); $SQL->query("UPDATE `z_forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);//show added data $main_content .= '
'; } else { //show errors $main_content .= '
The Following Errors Have Occurred:
'; foreach($an_errors as $an_error) { $main_content .= '
  • '.$an_error; } $main_content .= '

  • '; //okno edycji newsa z wpisanymi danymi przeslanymi wczesniej $main_content .= '
    Select icon:
    Topic:
    News
    text:
    Character:
    CancelAddNews
    '; } } else { $main_content .= 'You don\'t have site-admin rights. You can\'t add news.';} } if(!empty($tickers_to_add)) { //show table with tickers if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] && $action!=newticker) $news_content .= '
    AddTicker

    '; //add tickers list $news_content .= $tickers_to_add; //koniec $news_content .= '
    '; } //NEWSTICKER END //FEATURED ARTICLE $featured_article = $SQL->query("SELECT * FROM z_featured_article ORDER BY id DESC LIMIT 1")->fetchAll(); if(isset($featured_article[0])) { foreach($featured_article as $featured) { $news_content .= '
    Contentbox headline
    '; if(!empty($featured['read_more'])){ $news_content .= ' '; } $news_content .= ' '; if(!empty($featured['read_more'])){ $news_content .= ' '; } $news_content .= '
    '; if(!empty($featured['read_more'])){ $news_content .= ' » read more'; } $news_content .= '
    '.$featured['title'].'
    '.$featured['text'].'
    '; } } //FEATURED ARTICLE END function replaceSmile($text, $smile) { $smileys = array( ':p' => 1, ':eek:' => 2, ':rolleyes:' => 3, ';)' => 4, ':o' => 5, ':D' => 6, ':(' => 7, ':mad:' => 8, ':)' => 9, ':cool:' => 10 ); if($smile == 1) return $text; else { foreach($smileys as $search => $replace) $text = str_replace($search, '', $text); return $text; } } function replaceAll($text, $smile) { $rows = 0; while(stripos($text, '[code]') !== false && stripos($text, '[/code]') !== false ) { $code = substr($text, stripos($text, '[code]')+6, stripos($text, '[/code]') - stripos($text, '[code]') - 6); if(!is_int($rows / 2)) { $bgcolor = 'ABED25'; } else { $bgcolor = '23ED25'; } $rows++; $text = str_ireplace('[code]'.$code.'[/code]', 'Code:
    '.$code.'
    ', $text); } $rows = 0; while(stripos($text, '[quote]') !== false && stripos($text, '[/quote]') !== false ) { $quote = substr($text, stripos($text, '[quote]')+7, stripos($text, '[/quote]') - stripos($text, '[quote]') - 7); if(!is_int($rows / 2)) { $bgcolor = 'AAAAAA'; } else { $bgcolor = 'CCCCCC'; } $rows++; $text = str_ireplace('[quote]'.$quote.'[/quote]', '
    '.$quote.'
    ', $text); } $rows = 0; while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false ) { $url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5); $text = str_ireplace('[url]'.$url.'[/url]', ''.$url.'', $text); } while(stripos($text, '[player]') !== false && stripos($text, '[/player]') !== false ) { $player = substr($text, stripos($text, '[player]')+8, stripos($text, '[/player]') - stripos($text, '[player]') - 8); $text = str_ireplace('[player]'.$player.'[/player]', ''.$player.'', $text); } while(stripos($text, '[img]') !== false && stripos($text, '[/img]') !== false ) { $img = substr($text, stripos($text, '[img]')+5, stripos($text, '[/img]') - stripos($text, '[img]') - 5); $text = str_ireplace('[img]'.$img.'[/img]', '', $text); } while(stripos($text, '[b]') !== false && stripos($text, '[/b]') !== false ) { $b = substr($text, stripos($text, '[b]')+3, stripos($text, '[/b]') - stripos($text, '[b]') - 3); $text = str_ireplace('[b]'.$b.'[/b]', ''.$b.'', $text); } while(stripos($text, '[i]') !== false && stripos($text, '[/i]') !== false ) { $i = substr($text, stripos($text, '[i]')+3, stripos($text, '[/i]') - stripos($text, '[i]') - 3); $text = str_ireplace('[i]'.$i.'[/i]', ''.$i.'', $text); } while(stripos($text, '[u]') !== false && stripos($text, '[/u]') !== false ) { $u = substr($text, stripos($text, '[u]')+3, stripos($text, '[/u]') - stripos($text, '[u]') - 3); $text = str_ireplace('[u]'.$u.'[/u]', ''.$u.'', $text); } return replaceSmile($text, $smile); } function showPost($topic, $text, $smile) { $text = nl2br($text); $post = ''; if(!empty($topic)) $post .= ''.replaceSmile($topic, $smile).''; $post .= replaceAll($text, $smile); return $post; } if($group_id_of_acc_logged >= $config['site']['access_admin_panel'] && $action != 'newnews') { $main_content .= ' Adding News
    '; //Tiny Editor $main_content .= ' '; $main_content .= '
    Select icon:
    Topic:
    News
    text:
    Character:

    '; } $last_threads = $SQL->query('SELECT ' . $SQL->tableName('players') . '.' . $SQL->fieldName('name') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_text') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_topic') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('icon_id') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_smile') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('id') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('replies') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_date') . ' FROM ' . $SQL->tableName('players') . ', ' . $SQL->tableName('z_forum') . ' WHERE ' . $SQL->tableName('players') . '.' . $SQL->fieldName('id') . ' = ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('author_guid') . ' AND ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('section') . ' = 1 AND ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('first_post') . ' = ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('id') . ' ORDER BY ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('last_post') . ' DESC LIMIT ' . $config['site']['news_limit'])->fetchAll(); //Here start news if(isset($last_threads[0])) { foreach($last_threads as $thread) { $main_content .= '
    \'\'
    '.date('M m Y', $thread['post_date']).' -
    '.htmlspecialchars($thread['post_topic']).'
    '; $martelLetter = substr($thread['post_text'],3,1); $main_content .= ' '; $main_content .= '
    ' . showPost('', substr_replace($thread['post_text'], '',3,1), $thread['post_smile']) . '

    ยป Comment on this news

    \'\'

    '; } } else $main_content .= '

    No news. Go forum and make new thread on board News.

    ';