<?php
	define('thisscript','adminphrase');

	require_once 'globalad.php';
	require_once '../class/Phrase.php';
	$phrase = new Phrase();

	if (empty($userid)){
		redirecting("index.php");
	}
	
	if (empty($useraccess['manage_phrase'])){
		redirecting('index.php');
	}
	
	if (empty($general['showperpageadmin'])){
		$general['showperpageadmin'] = 20;
	}
	
	/* sanitize post, get, request */
	$_POST['replayedit'] = ((empty($_POST['replayedit']))?"":$_POST['replayedit']);
	$_GET['getlist'] = ((empty($_GET['getlist']))?"":$_GET['getlist']);
	$_GET['keyword'] = ((empty($_GET['keyword']))?array():$_GET['keyword']);
	$_GET['field'] = ((empty($_GET['field']))?array():$_GET['field']);
	/* end sanitize */
	
	$listr = '';
	$pagelink = '';
	
	if ($_GET['getlist'] == 'pagenav'){
		$keywords = $_GET['keyword'];
		$fields = $_GET['field'];
		$alls = $phrase->searchPhrase($keywords,$fields,'','','pagenav',$_GET['p']);
		echo $alls;
		exit;
	}
	else if ($_GET['getlist'] == 'ajax'){
		$keywords = $_GET['keyword'];
		$fields = $_GET['field'];
		$alls = $phrase->searchPhrase($keywords,$fields,'','','totaldata');
		$totalrows = empty($alls['totalitem'])?0:$alls['totalitem'];
		$totalpgs = ceil($totalrows / $general['showperpageadmin']);
		$pgs = handlepage($_GET['p'],$totalpgs);
		$dblast = $phrase->searchPhrase($keywords,$fields,$_GET['sortf'],$_GET['sortd'],'data',$pgs);
		if (sizeof($dblast) > 0){
			foreach ($dblast as $result){
				$listr .= '
				<!--<div class="hovertr" ondblclick="window.open(\'adminphrasedetail.php?id='.$result['phraseid'].'\',\'_self\')">
					<div align="center">
						<table border="0" width="100%" cellspacing="3" cellpadding="0">-->
							<tr ondblclick="window.open(\'adminphrasedetail.php?id='.$result['phraseid'].'\',\'_self\')">
								<td width="20%" height="25" align="left"><a href="adminphrasedetail.php?id='.$result['phraseid'].'">'.$result['phrasevar'].'</a></td>
								<td width="40%" height="25" align="left">'.strip_tags($result['phrasetext_1']).'</td>
								<td width="40%" height="25" align="left">'.strip_tags($result['phrasetext_2']).'</td>
							</tr>
							<!--</tr>
						</table>
					</div>
				</div>
				<div style="width: 100%; height: 3px" class="line_h"></div>-->
			';
			}
		}
		else{
			$listr = 'NO DATA';
		}
			
		echo $listr;
		exit;
	}
	
	require_once 'incl/global_template.php';
	
	$theme = gettemplate('adminphrase');
	eval("\$theme = \"$theme\";");
	echo $theme;
?>