<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="sr-RS">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php


/*
 * Demo: demo_math.php
 * 
 * Primer poziva API funkcije 'hash' koja racuna hash stringa. 
 *  
 */
 

include_once 'infoapi/infoapi.php';

$m_value = getPostValue ('value', 'aaa');

$miapiHandler = new iapiHandler;
$miapiHandler->APIServerURL = SERVER_URL;

$miapiHandler->DebugLevel = DEBUG_LEVEL;
$miapiHandler->DebugSections = DEBUG_SECTIONS;


// naziv API funkcije koja se poziva
$mAPIFunctionName = 'HASH';

$mQueryEnvelope = new iapiQueryEnvelope ($mAPIFunctionName);
$mQueryEnvelope->username = USERNAME;
$mQueryEnvelope->password = PASSWORD;

$mQueryEnvelope->data->ValueToHash = $m_value;

$mQuery = $mQueryEnvelope;
$mResponse  = $miapiHandler->Execute($mQuery);


$m_error = false;

if ($mResponse->error_state !='ok') {
  $m_error = true;
?>
Greska: <?php echo $mResponse->error_state; ?> - <?php echo $mResponse->error_message; ?>
<?php
} else {

  if ($mResponse->data->error_state !='ok') {
    $m_error = true;
?>
Greska: <?php echo $mResponse->data->error_state; ?> - <?php echo $mResponse->data->error_message; ?>
<?php
  }

}
?>

<hr />

<?php
if (!$m_error) {
  $m_result = $mResponse->data->hash;
} else {
  $m_result = 'ERR';
}  //  if (!$m_error) 
?>

<form id="form1" name="form1" method="post" action="">
<input name="value" type="text" value="<?php echo $m_value; ?>" size="25" maxlength="25" />
<input name="submit" type="submit" value="=" />
<input name="result" type="text" value="<?php echo $m_result; ?>" size="40" disabled="disabled" /> <?php echo md5 ($m_value); ?>
</form>

<hr />

<?php include_once 'inc_sysinfo.php'; ?>

</body>
</html>