isLeader()) die('access denied'); function saveNews() { global $newsCache, $latestNewsCache; file_put_contents(__DIR__ . '/../../config/news.inc.php', ' .*? <\/div> /', '
'.renderNews().'
', $indexData, 1); $indexData = preg_replace('/ data-newsid="[^"]*">/', ' data-newsid="'.getNewsId().'">', $indexData, 1); file_put_contents('../../play.pokemonshowdown.com/index.html', $indexData); } include '../style/wrapper.inc.php'; $page = 'news'; $pageTitle = "News"; includeHeader(); ?>

csrfCheck()) die('csrf error'); $topic_id = $_POST['topic_id']; $title = $_POST['title']; // summary parse $summary = $_POST['summary']; $newsCache[$topic_id]['summary'] = $summary; $summary = str_replace("\r", '', $summary); $summary = str_replace("\n\n", '

', $summary); $summary = str_replace("\n", '
', $summary); $summary = str_replace("\n", '
', $summary); $summary = preg_replace('/\[url="([^\]]+)"\]/', '', $summary); $summary = preg_replace('/\[url=([^\]]+)\]/', '', $summary); $summary = str_replace("[/url]", '', $summary); $summary = str_replace("[b]", '', $summary); $summary = str_replace("[/b]", '', $summary); $summary = preg_replace('/\[psicon (pokemon|item|type|category)="([^\]]+)"\]/', '', $summary); $title = preg_replace('/\[psicon (pokemon|item|type|category)=([^\]]+)\]/', '', $title); $summary = '

'.$summary.'

'; $newsCache[$topic_id]['summary_html'] = $summary; // details parse if (isset($_POST['details'])) { $details = $_POST['details']; if ($details) { $newsCache[$topic_id]['details'] = $details; $details = str_replace("\r", '', $details); $details = str_replace("\n\n", '

', $details); $details = str_replace("\n", '
', $details); $details = str_replace("\n", '
', $details); $details = preg_replace('/\[url="([^\]]+)"\]/', '', $details); $details = preg_replace('/\[url=([^\]]+)\]/', '', $details); $details = str_replace("[/url]", '', $details); $details = str_replace("[b]", '', $details); $details = str_replace("[/b]", '', $details); $details = preg_replace('/\[psicon (pokemon|item|type|category)="([^\]]+)"\]/', '', $details); $details = preg_replace('/\[psicon (pokemon|item|type|category)=([^\]]+)\]/', '', $details); $details = '

'.$details.'

'; $newsCache[$topic_id]['details_html'] = $details; } else { unset($newsCache[$topic_id]['details']); unset($newsCache[$topic_id]['details_html']); } } if ($title) { $newsCache[$topic_id]['title'] = $title; $newsCache[$topic_id]['title_html'] = htmlspecialchars($title); } saveNews(); echo '

Edit successful

'; } if (@$_POST['act'] === 'newentry') { if (!$users->csrfCheck()) die('csrf error'); $topic_id = intval($latestNewsCache[0]) + 1; $title = $_POST['title']; $summary = $_POST['summary']; $pre_summary = $summary; $summary = str_replace("\r", '', $summary); $summary = str_replace("\n\n", '

', $summary); $summary = str_replace("\n", '
', $summary); $summary = str_replace("\n", '
', $summary); $summary = preg_replace('/\[url=([^\]]+)\]/', '', $summary); $summary = str_replace("[/url]", '', $summary); $summary = str_replace("[b]", '', $summary); $summary = str_replace("[/b]", '', $summary); $summary = str_replace("[i]", '', $summary); $summary = str_replace("[/i]", '', $summary); $summary = '

'.$summary.'

'; $time = ''.time(); $newsCache[$topic_id] = array( 'topic_id' => ''.$topic_id, 'title' => $title, 'authorname' => $curuser['username'], 'date' => $time, 'topic_time' => $time, 'summary' => $pre_summary, 'summary_html' => $summary, 'title_html' => htmlspecialchars($title), ); array_unshift($latestNewsCache, ''.$topic_id); saveNews(); echo '

New post successful

'; } foreach ($latestNewsCache as $i => $topic_id) { $topic = $newsCache[$topic_id]; ?>

on