<?
session_start();

require_once('includes.php');

$invalidaccess=msg_n_goto("index.php",_Security._SecurityWarning.'\n'._EngineBlowOff);

if ($_GET['job']!=NULL){
	$myjob=$_GET['job'];
} else {
	$myjob=$_POST['job'];
}

switch($myjob):

	//-------------login----------------
	case "general_login":
		$l=new login($_POST['username'],$_POST['password'],$_POST['language']);
	break;

	//-------------logout----------------
	case "general_logout":
		$l=new logout(md5("logoutuser"));
	break;	

	//-------------news------------------
	case "news_add":
		$addresult=news_add($_POST['newsdate'], $_POST['newstitle'], $_POST['newssummary'], $_POST['newstext'], $_POST['newspicture'], $_POST['picturealignment'], $_POST['newsrelatedurl'], $_POST['redirect']);
	break;
	case "news_edit":
		$editresult=news_edit($_POST['newspkey'], $_POST['newsdate'], $_POST['newstitle'], $_POST['newssummary'], $_POST['newstext'], $_POST['newspicture'], $_POST['picturealignment'], $_POST['newsrelatedurl'], $_POST['redirect']);
	break;
	case "news_delete":
		$delresult=news_delete($_POST['newspkey'], $_POST['redirect']);
	break;
	case "news_editnewsflash":
		$editresult=news_editnewsflash($_POST['newsflash']);
	break;

	//-------------crawler----------------
	case "crawler_searchstart":
		$opresult=crawler_searchstart($_POST['crawlinitpkey'], $_POST['crawlname'], $_POST['crawlseedurl'], $_POST['crawlstartdate'], $_POST['crawlstarttime'], $_POST['crawlstopdate'], $_POST['crawlstoptime'], $_POST['crawlbreadth'], $_POST['crawldepth'], $_POST['crawlmaxsearched'], $_POST['crawlmaxfound'], $_POST['crawlkeywords'], $_POST['crawlclearcache'], $_POST['crawlfetchfromcache']);
	break;
	case "crawler_searchstop":
		$opresult=crawler_searchstop($_POST['crawlinitpkey']);
	break;
	case "crawler_spiadd":
		$opresult=crawler_spiadd($_POST['indexname'], $_POST['indexdescription'], $_POST['indexkeywords']);
	break;
	case "crawler_spiedit":
		$opresult=crawler_spiedit($_POST['indexpkey'], $_POST['indexname'], $_POST['indexdescription'], $_POST['indexkeywords']);
	break;
	case "crawler_spidelete":
		$opresult=crawler_spidelete($_POST['indexpkey']);
	break;

	//-------------browser----------------
	case "browser_search":
		$opresult=browser_search($_POST['crawlkeywords']);
	break;

        //-------------classifications---------------
	case "classifier_categoryadd":
                $opresult=classifier_categoryadd($_POST['categoryname'], $_POST['categorydescription']);
	break;
	case "classifier_categoryedit":
                $opresult=classifier_categoryedit($_POST['categorypkey'], $_POST['categoryname'], $_POST['categorydescription']);
	break;
	case "classifier_categorydelete":
		$opresult=classifier_categorydelete($_POST['categorypkey']);
	break;
	case "classifier_subjectadd":
                $opresult=classifier_subjectadd($_POST['subjectcategorypkey'], $_POST['subjectname'], $_POST['subjectdescription'], $_POST['subjectkeywords'], $_POST['subjectmatchrating']);
	break;
	case "classifier_subjectedit":
                $opresult=classifier_subjectedit($_POST['subjectpkey'], $_POST['subjectcategorypkey'], $_POST['subjectname'], $_POST['subjectdescription'], $_POST['subjectkeywords'], $_POST['subjectmatchrating']);
	break;
	case "classifier_subjectdelete":
                $opresult=classifier_subjectdelete($_POST['subjectpkey'], $_POST['subjectcategorypkey']);
	break;

	//-------------profile--------------

	case "profile_chgpwd":
		$chgpwd=users_chgpwd($_POST['currentpwd'], $_POST['newpwd'], $_POST['confirmpwd']);
	break;
	case "profile_remindpwd":
		$checkuser=users_validusername($_POST['username']);
		if ($checkuser==true) {
			$m=goto("index.php?module=login&task=pwdquestion");
			echo $m;			
		} else {
			$e=error_n_goto("-1","Ralat: Nama Pengguna yang dimasukkan adalah tidak sah!");
			echo $e;
		}
	break;

	//-------------users--------------
	case "user_add":
		$addresult=users_add($_POST['usergrouppkey'], $_POST['username'], $_POST['userpassword'], $_POST['userpasswordquestion'], $_POST['userpasswordanswer'], $_POST['userfullname'], $_POST['useralternateemail'], $_POST['userrole'], $_POST['useraccesslevelpkey'], $_POST['useravatar'], $_POST['userbosspkey'], $_POST['userstatus']);
	break;
        case "user_edit":
		$editresult=users_edit($_POST['userpkey'], $_POST['usergrouppkey'], $_POST['username'], $_POST['userfullname'], $_POST['useralternateemail'], $_POST['userrole'], $_POST['useraccesslevelpkey'], $_POST['useravatar'], $_POST['userbosspkey'], $_POST['userstatus']);
	break;
	case "user_resetpwd":
		$resetresult=users_resetpwd($_POST['userpkey']);
	break;

	//-------------hod foreword------------------
	case "hod_editforeword":
		$editresult=foreword_edithod($_POST['forewordpkey'], $_POST['forewordusergrouppkey'], $_POST['forewordtext'], $_POST['forewordbackground'], $_POST['forewordphoto']);
	break;

	case "":
	break;

	default:
	echo $invalidaccess;
	
endswitch;

if (is_null($myjob)){
	echo $invalidaccess;
}
?>