<?php
$action = $_GET['action'];
$param = strip_tags($_POST['param']);

switch($action){
  case 'number':
    require_once('ArNumbers.class.php');
    $ArNumbers = new ArNumbers();
    $ArNumbers->setFeminine(2);
    $ArNumbers->setFormat(2);
    echo $param . ' ' .$ArNumbers->int2str($param);
    break;

  case 'hijri':
    require_once('ArDate.class.php');
    $ArDate = new ArDate();
    $time = time();

    echo $ArDate->date('l jS F Y', $time);

    break;

  case 'keyboard':
    require_once('ArKeySwap.class.php');
    $ArKeySwap = new ArKeySwap();
    $temp_ae = $ArKeySwap->swap_ae($param);
    $temp_ea = $ArKeySwap->swap_ea($param);

    $sim_ae = similar_text($param, $temp_ae);
    $sim_ea = similar_text($param, $temp_ea);
    
    if ($sim_ea >= $sim_ae) {
        echo $temp_ae;
    } else {
        echo $temp_ea;
    }

    break;

  case 'en_terms':
    if (preg_match("/^[\w\d\s]+$/i", $param)) {
        require_once('ArTransliteration.class.php');
        $ar = new ArTransliteration();
        echo $ar->en2ar($param) . " ($param)";
    } else {
        require_once('EnTransliteration.class.php');
        $ar = new EnTransliteration();
        echo $ar->ar2en($param) . " ($param)";
    }

    break;
}
?>
