PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/add.php

http://github.com/taylorchu/goolog
PHP | 103 lines | 97 code | 6 blank | 0 comment | 22 complexity | 085d9ecc27ffff3edfc06218eb2c66e6 MD5 | raw file
  1<?php
  2
  3$out['self'] = 'add';
  4require 'header.php';
  5
  6if(isGET('post') && isAdmin())
  7{
  8	$out['subtitle'] = lang('add post');
  9	if(checkBot() && check('title') && check('content', 1, 2000))
 10	{
 11		$postEntry['title'] = clean($_POST['title']);
 12		$postEntry['content'] = transNL(clean($_POST['content']));
 13		$postEntry['view'] = 0;
 14		$postEntry['reply'] = array();
 15		$postEntry['category'] = '';
 16		$postEntry['locked'] = false;
 17		$post = newEntry();
 18		saveEntry('post', $post, $postEntry);
 19		$out['content'] .= '<p><a href="view.php/post/' .$post. '">? ' .$lang['redirect']. ' : ' .$postEntry['title']. '</a></p>';
 20	}
 21	else
 22	{
 23		$out['content'] .= form('add.php/post',
 24			text('title').
 25			textarea('content').
 26			submit()).
 27		preview('content');
 28	}
 29}
 30else if(isGETValidEntry('post', 'reply'))
 31{
 32	$postEntry = readEntry('post', $_GET['reply']);
 33	if($postEntry['locked'])
 34	{
 35		exit;
 36	}
 37	$out['subtitle'] = lang('add reply : %s', $postEntry['title']);
 38	if(checkBot() && check('trip', 0, 20) && check('content', 1, 2000))
 39	{
 40		$replyEntry['content'] = transNL(clean($_POST['content']));
 41		$replyEntry['post'] = $_GET['reply'];
 42		$reply = newEntry();
 43		$replyEntry['trip'] = trip(clean($_POST['trip']), $reply);
 44		saveEntry('reply', $reply, $replyEntry);
 45
 46		$postEntry['reply'][$reply] = $reply;
 47		saveEntry('post', $_GET['reply'], $postEntry);
 48
 49		$_SESSION[$reply] = $reply;
 50		$out['content'] .= '<p><a href="view.php/post/' .$_GET['reply']. '/p/' .onPage($reply, $postEntry['reply']). '#' .$reply. '">? ' .$lang['redirect']. ' : ' .$postEntry['title']. '</a></p>';
 51	}
 52	else
 53	{
 54		$out['content'] .= form('add.php/reply/' .$_GET['reply'],
 55			text('trip').
 56			textarea('content', isGETValidEntry('reply', 'q')? '[quote]' .$_GET['q']. '[/quote]' : '').
 57			submit()).
 58		preview('content');
 59	}
 60}
 61else if(isGET('link') && isAdmin())
 62{
 63	$out['subtitle'] = lang('add link');
 64	if(checkBot() && check('name') && check('url', 1, 80))
 65	{
 66		$linkEntry['name'] = clean($_POST['name']);
 67		$linkEntry['url'] = clean($_POST['url']);
 68		saveEntry('link', newEntry(), $linkEntry);
 69		$out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
 70	}
 71	else
 72	{
 73		$out['content'] .= form('add.php/link',
 74			text('name').
 75			text('url').
 76			submit());
 77	}
 78}
 79else if(isGET('category') && isAdmin())
 80{
 81	$out['subtitle'] = lang('add category');
 82	if(checkBot() && check('name'))
 83	{
 84		$categoryEntry['name'] = clean($_POST['name']);
 85		$categoryEntry['post'] = array();
 86		saveEntry('category', newEntry(), $categoryEntry);
 87		$out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
 88	}
 89	else
 90	{
 91		$out['content'] .= form('add.php/category',
 92			text('name').
 93			submit());
 94	}
 95}
 96else
 97{
 98	exit;
 99}
100
101require 'footer.php';
102
103?>