<?php

require_once '../../../../init.php';

// Required files
require_once MAX_PATH . '/lib/OA/Admin/Option.php';
require_once MAX_PATH . '/lib/OA/Admin/Settings.php';
require_once MAX_PATH . '/lib/OA/Creative/File.php';
require_once MAX_PATH . '/lib/max/Plugin/Translation.php';
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/lib/OA/Dal.php';
require_once MAX_PATH . '/lib/OA/Creative/File.php';
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/lib/max/other/common.php';
require_once MAX_PATH . '/lib/max/other/html.php';
require_once MAX_PATH . '/lib/OA/Admin/UI/component/Form.php';
require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php';
require_once LIB_PATH . '/Plugin/Component.php';

if($GLOBALS['_MAX']['CONF']['database']['type']=='mysql')
{
require_once MAX_PATH . '/lib/OA/Dal/Delivery/mysql.php';
}
else if($GLOBALS['_MAX']['CONF']['database']['type']=='pgsql')
{
require_once MAX_PATH . '/lib/OA/Dal/Delivery/pgsql.php';
}
else if($GLOBALS['_MAX']['CONF']['database']['type']=='mysqli')
{
require_once MAX_PATH . '/lib/OA/Dal/Delivery/mysqli.php';
}

session_start();
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN);
$table_prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
$id=$_GET['aid'];

	$tempQuery= OA_Dal_Delivery_query("Select * FROM {$table_prefix}terawurfl LIMIT 1");
$row=OA_Dal_Delivery_fetchAssoc($tempQuery);

$path="";
if($row)
{
	$path =  $row['terawurfl_path']; 
}


if (isset($_POST['submitok']) && $_POST['submitok'] == 'true') 
{
	$translation = new OX_Translation();
	
	$translated_message = $translation->translate ("Tera wurfl path saved");
			
	OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
	
	


	if($path)
	
{
		         OA_Dal_Delivery_query("UPDATE {$table_prefix}terawurfl SET `terawurfl_path`='".$_REQUEST['terawurfl_path']."'");	
				OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
}
	else	
{	      

				OA_Dal_Delivery_query("INSERT INTO {$table_prefix}terawurfl (`terawurfl_path`) VALUES ('".$_REQUEST['terawurfl_path']."')");
				OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
				
	}
	
	OX_Admin_Redirect::redirect("plugins/mobileAdsDelivery/tera-wurfl.php");
	exit();
				

}



$aErrormessage = array();
$oOptions = new OA_Admin_Option('tera');
$oHeaderModel = new OA_Admin_UI_Model_PageHeaderModel("terawurflpath");
phpAds_PageHeader('tera-wurfl', $oHeaderModel);
$aSettings = array(
		   array (
				'text'    => 'Add terawurflpath',
				'items'   => array (
							 array ('type'=> 'text','text' => 'tera wurfl path','name' => 'terawurfl_path','value'=> $path),
					
					  ),
					 	 
					
			 )
			 

);

?>

<style>
table .cellenabled
{
	padding-bottom:10px;
	
}

</style>
<?php
$oOptions->show($aSettings, null);
phpAds_PageFooter();

?>
