Location: PHPKode > projects > Skat Statistics > skatstat-1.7.1/skatstat/inc/auxiliary.php
<?
### Helper and auxilliary functions

require_once( "smconfig.php" );
include_once( "spielliste.php" );
#include_once( "cookie.php" );
include_once( "session.php" );

function getTime()
{
  $zeitmessung1=microtime();
  $zeittemp=explode(" ",$zeitmessung1);
  return $zeittemp[0]+$zeittemp[1];
}

function error_handler( $severity, $msg, $filename, $linenum )
{
  switch( $severity )
  {
  case E_USER_NOTICE:
    echo "Notice<br>";
    break;
  case E_USER_WARNING:
    echo "Warning<br>";
    break;
  case E_USER_ERROR:
    echo "Error<br>";
    echo "Msg: " . $msg . "<br>";
    echo "Filename: " . $filename . "<br>";
    echo "Lineno: "  .$linenum . "<br>";
    break;
  default:
    #  echo "Unknown<br>";
    break;
  }

}


function getPost( $name )
{
  unset($ret);
  if( isset( $_POST[ $name ] ) )
  {
    $ret = $_POST[ $name ];
    if( $ret == "on" )
    {
      $ret = 1;
    }
    if( $ret == "" )
    {
      $ret = 0;
    }
  }
  return $ret;
}

function getGet( $name )
{
	if( isset( $_REQUEST[$name] ))
	{
  		return $_REQUEST[$name];
}
return "";
}

function MyMkDir( $path )
{
  mkdir($path);
}

function MyRmDir( $path )
{
  rmdir($path);
}

function generateLink( $domdoc, $destination, $text )
{
  $link = CreateElement( $domdoc, "a" );
  SetAttribute( $link, "href", $destination );
  AppendChild( $link,  CreateTextNode( $domdoc, $text ) );
  return $link;
}

function createLink( $destination, $text )
{
  return "<a href='$destination'>$text</a>";
}

function echoLink( $destination, $text )
{
  echo createLink( $destination, $text );
}


function writeFile( $doc, $path, $filename )
{
  exit;
  global $CONF;
  $success = true;
  MyRmDir( $path );
  MyMkDir( $path );
  return $doc->dump_file( $path . "/" . $filename );
}

function createTitle( $title )
{
  echo "<div class='Title'>".$title."</div>\n";
}

function startContainer( $title = "" )
{
  if( $title )
  {
    echo "<div class='".$title."'>\n";
  }
  else
  {
    echo "<div>\n";
  }
}

function endContainer()
{
  echo "</div>\n";
}

function createCaption( $caption )
{
  echo "<caption>".$caption."</caption>\n";
}

function createCol( $content, $class = "", $colspan = 0, $rowspan = 0 )
{
  echo "<td ";
  if( $class )
  {
    echo "class='" . $class . "' ";
  }
  if( $colspan )
  {
    echo "colspan='" . $colspan . "' ";
  }
  if( $rowspan )
  {
    echo "rowspan='" . $rowspan . "' ";
  }
  echo ">$content</td>\n";
}

function createHCol( $c, $class="", $colspan=0, $rowspan=0 )
{
  echo "<th ";
  if( $class )
  {
    echo "class='" . $class . "' ";
  }
  if( $colspan )
  {
    echo "colspan='" . $colspan . "' ";
  }
  if( $rowspan )
  {
    echo "rowspan='" . $rowspan . "' ";
  }
  echo ">$c</th>\n";
}


function startTable( $title = "" )
{
  if( $title )
  {
    echo "<table class='".$title."'>\n";
  }
  else
  {
    echo "<table>\n";
  }
}

function endTable()
{
  echo "</table>\n";
}

function endRow()
{
  echo "</tr>\n";
}

function startRow()
{
  echo "<tr>\n";
}

function startCol()
{
  echo "<td>\n";
}

function endCol()
{
  echo "</td>\n";
}

#/  alert box popup confimation message function
#/ ********************************************************************/
function confirm($msg) 
{
  echo $msg;
}

function startTag( $name )
{
  echo "<$name ";
  $i = 1;
  while( $i < func_num_args() )
  {
    if( func_get_arg( $i ) )
    {
      echo func_get_arg( $i++ ). "=\"";
      echo func_get_arg( $i++ )."\" ";
    }
    else
    {
      $i+=2;
    }
  }
  echo ">\n";
}

function endTag( $name )
{
  echo "</$name>\n";
}

function displayPage( $domdoc, $page )
{
  if( $page )
  {
    AppendChild( $domdoc, $page );
    echo $domdoc->html_dump_mem();
  }
}

function debug( $msg )
{
  global $SKAT_SESSION;
  if( $SKAT_SESSION[debug] )
  {
    echo "$msg<br>";
  }
}

function handle_db_error( $sql = false )
{
  echo  errormsg( mysql_errno(), mysql_error(), $sql );
}

function errormsg()
{
  $Warning = "";
  for( $i = 0; $i < func_num_args(); $i++ )
  {
    $errorno = func_get_arg( $i );
    if( 1062 == $errorno )
    {
      $msg = "Name wird bereits verwendet! Waehlen Sie einen anderen!</div>";
    }
    else
    {
      $msg = $errorno;
    }
    $Warning .= getWarning( $msg );
  }
  return $Warning;
}

function getWarning( $text )
{
  return "<div class=\"Warning\">". $text . "</div>";
}

function getSuccess( $text )
{
  return "<div class=\"Success\">". $text . "</div>";
}

function ExtraPoints()
{
  return 50;
}

function PunkteGegner( $NumSpieler )
{
  if( $NumSpieler == 4 )
  {
    return 30;
  }
  else
  {
    return 40;
  }
}

/** Nur wenn Wert == 1 ist, ist auch eingepasst
 Wert==2 => Spiel wurde noch nicht angelegt
 **/
function isEingepasst( $val )
{
  return  $val == 1;
}

function isAngelegt( $val )
{
  return $val != 2;
}

?>
Return current item: Skat Statistics