<?php
if (is_admin()) {
		$post=array();

		if(@$_v['postime']<1) $_v['postime']=time();
		if(isset($_s['postime'])) $_v['postime']=$_s['postime'];
		$post['dt']=date('d/m/y, H:i', time() + $_s['time_offset'] * 3600);
		$sec=date('s',time());

		if (!isset($_v[$_lk['pt']]) || @$di) { if(@$di) {$_v[$_lk['pt']]=$di;} include_once($_s['tpl_dir'].'/'.$_s['tpl_postform']); }
		else if (!@trim($_v['text']) && !@trim($_v['title']) && file_exists($_s['ids_dir'].'/'.$_v[$_lk['pt']]))
		{
			$post = post_info($_v[$_lk['pt']]);
			$post['dt']=date('d/m/y, H:i', @$post['ida'] + $_s['time_offset'] * 3600);
			$sec=date('s',$post['ida']);
			@$post['text'] = str_replace(array("\r", "\n"), array("", "\r"), $post['text']);
			@$post['text'] = str_replace("\r", "\n", $post['text']);
			@$post['text'] = htmlspecialchars($post['text'], ENT_QUOTES);
			@$post['title'] = htmlspecialchars($post['title'], ENT_QUOTES);
			$c='value="ON" checked="checked"';

			if(@trim($post['nobr'])) $post['brchk']=$c;
			if(@trim($post['nocomm'])) $post['cmchk']=$c;
			if(@trim($post['close'])) $post['clchk']=$c;
			if(@trim($post['hidden'])) $post['hdchk']=$c;
			include_once($_s['tpl_dir'].'/'.$_s['tpl_postform']);
		} else if (@trim($_v['text']) || @trim($_v['title'])) {
			$nti=explode(',',$_v['datim']);
			$ntd=explode('/',trim($nti[0]));
			$ntt=explode(':',trim($nti[1]));
			$ntm=mktime($ntt[0],$ntt[1],$_v['sec'],$ntd[1],$ntd[0],$ntd[2]);

			$post = post_info($_v[$_lk['pt']]);

			if($ntm!=$_v['postime']) {
			if(@$ptl=$_v[$_lk['pt']]) {
			if(file_exists($fd=$_s['sav_dir'].'/posts.'.$post['author'])) @fsave($fd,'w+',str_replace($_v['postime'], $ntm, file_get_contents($fd)));
				@unlink($_s['post_dir'].'/'.$_v['postime']);
			}
			$_v['postime']=$ntm;
			}

			if(isset($_s['newid'])) $_v[$_lk['pt']] = $_s['newid'];
			elseif(!@trim($_v[$_lk['pt']])) $_v[$_lk['pt']]=genid();

			if(isset($post['author'])) { @$_s['mop'] .= ' $post[\'author\']=\''.$post['author'].'\';'; } else { @$_s['mop'] .= ' $post[\'author\']=\''.$_s['name'].'\';'; }
			if(!$post) {
				if(!file_exists($_s['ids_dir'].'/'.trim($_v[$_lk['pt']]))) fsave($_s['sav_dir'].'/posts.'.$_s['name'],'a',$_v['postime']."\n");
			}
			fsave($_s['ids_dir'].'/'.trim($_v[$_lk['pt']]),'w+','<?php $post[\'ida\']=\''.$_v['postime'].'\'; ?>');
			fsave($_s['post_dir'].'/'.$_v['postime'],'w+','<?php $post[\'id\']=\''.prp(trim($_v[$_lk['pt']])).'\'; $post[\'title\']=\''.prp($_v['title']).'\'; $post[\'text\']=\''.prp($_v['text']).'\'; $post[\'hidden\']=\''.@$_v['hidden'].'\'; $post[\'close\']=\''.@$_v['close'].'\'; $post[\'nocomm\']=\''.@$_v['closecomm'].'\'; $post[\'nobr\']=\''.@$_v['nobr'].'\'; '.@$_s['mop'].' ?>');
			if(!file_exists($_s['comm_dir'].'/'.trim($_v[$_lk['pt']]))) fsave($_s['comm_dir'].'/'.trim($_v[$_lk['pt']]),'w+','');

		redirect(plink($_v[$_lk['pt']]));
		}
}
?>