<?php
require_once "../config/config.php";
require_once INCLUDE_DIR."/users_class.php";
require_once PHYSICAL_DIR."/includes/system_get_set_options_class.php";
$users=new users_class();
$option_obj=new system_get_set_options_class();
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can manage paygear credentials')==false)
{
Redirect('admin_nopermission.php',true);
}
include_once(CONFIG_DIR.'/paygear_configuration.php');
if($_POST)
{
$username=encrypt($_POST['paygear_username']);
$lsPaygear_username=$username;
$lsPaygear_password=$_POST['paygear_password'];
$lsPaygear_password_salt=$_POST['paygear_password_salt'];
$clientId=$PaygearWebserviceClient->getPayGearUserId($_POST['paygear_username'],urlencode($_POST['paygear_password'])
,urlencode($_POST['paygear_password_salt']));
if($clientId=="" or $clientId==NULL or !isset($clientId))
$clientId=0;
$clientId=encrypt($clientId);
$clientId=$clientId;
$option_obj->update_option('PAYGEAR_USERNAME',$lsPaygear_username);
$_SESSION[SESSION_PREFIX.'PAYGEAR_USERNAME']= $lsPaygear_username;
$option_obj->update_option('PAYGEAR_USERID',$clientId);
$_SESSION[SESSION_PREFIX.'PAYGEAR_USERID']= $clientId;
$option_obj->update_option('PAYGEAR_SECRET_PASSWORD',$lsPaygear_password);
$_SESSION[SESSION_PREFIX.'PAYGEAR_SECRET_PASSWORD']= $lsPaygear_password;
$option_obj->update_option('PAYGEAR_SECRET_PASSWORD_SALT',$lsPaygear_password_salt);
$_SESSION[SESSION_PREFIX.'PAYGEAR_SECRET_PASSWORD_SALT']= $lsPaygear_password_salt;
$message->SetMessage('PayGear Credentials Updated Successfully.');
Redirect('admin_paygear_configuration_generate.php',true);
}
else
{
$lsUserName=decrypt(PAYGEAR_USERNAME);
$secPassDecode=urldecode(PAYGEAR_SECRET_PASSWORD);
$secPassSaltDecode=urldecode(PAYGEAR_SECRET_PASSWORD_SALT);
$smarty->assign('msg',$message->GetMessage());
if(isset($_GET['err']))
{
if($_GET['err']=='true')
$smarty->assign('err','true');
}
$smarty->assign('userName',$lsUserName);
$smarty->assign('pass',$secPassDecode);
$smarty->assign('passsolt',$secPassSaltDecode);
$smarty->display('admin_paygear_configuration_generate.tpl');
}
?>