<?php

function smarty_function_bitwise($params)
{
  if (!empty($params['var1']) && !empty($params['var2']) && !empty($params['op']))
    {
      switch ($params['op'])
	{
	case '&':  return $params['var1'] & $params['var2']; break;
	case '|':  return $params['var1'] | $params['var2']; break;
	case '^':  return $params['var1'] ^ $params['var2']; break;
	case '~':  return ~$params['var1']; break;
	case '<<': return $params['var1'] << $params['var2']; break;
	case '>>': return $params['var1'] >> $params['var2']; break;
	default:   return $params['var1'] & $params['var2']; break;
      }
    }
  else
    {
      return false;
    }
}


?>