summaryrefslogtreecommitdiff
path: root/web/osika.php
blob: a5abb4fc7c9724a40ad2b5f15d2ce07e83298df0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

// path to Evaluator goes here.
require_once('../bin/lib/OsikaEvaluator.php');

$hand = $_REQUEST['h'];
try {
  $eval = new OsikaEvaluator($hand);
  $res = $eval->evaluate();
}
catch (OsikaParserException $e) {
  $res = array('error' => $e->getMessage());
}

if (!isset($_REQUEST['f'])) {
  $_REQUEST['f'] = '';
}

switch ($_REQUEST['f']) {
case 'json':
  echo json_encode($res);
  exit;
default:
  if (isset($res['error'])) {
    echo 'Błąd: '.$res['error']."\n";
    exit;
  }
  else {
    print_r($res);
  }
}

?>