13 |
* $Id$ |
* $Id$ |
14 |
* |
* |
15 |
* $Log$ |
* $Log$ |
16 |
|
* Revision 1.6 2003/04/16 16:24:23 joko |
17 |
|
* + odd and even from php.net |
18 |
|
* |
19 |
|
* Revision 1.5 2003/04/11 01:31:50 joko |
20 |
|
* + function log (from flib-shortcuts) |
21 |
|
* |
22 |
|
* Revision 1.4 2003/04/09 07:55:47 joko |
23 |
|
* + function untwingle_reference |
24 |
|
* |
25 |
|
* Revision 1.3 2003/04/08 22:35:16 joko |
26 |
|
* + 'function yesno' from utils/links.php |
27 |
|
* |
28 |
|
* Revision 1.2 2003/04/06 01:37:31 jonen |
29 |
|
* + added functions to generate and handle unique ID's |
30 |
|
* |
31 |
* Revision 1.1 2003/04/05 19:53:45 joko |
* Revision 1.1 2003/04/05 19:53:45 joko |
32 |
* moved here from ../ |
* moved here from ../ |
33 |
* |
* |
652 |
|
|
653 |
} |
} |
654 |
|
|
655 |
|
//examples on howto create unique id's |
656 |
|
// from: http://www.php.net/manual/en/function.uniqid.php |
657 |
|
function CreateGUID(){ |
658 |
|
srand((double)microtime()*1000000); |
659 |
|
$r = rand ; |
660 |
|
$u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
661 |
|
$m = md5 ($u); |
662 |
|
return($m); |
663 |
|
} |
664 |
|
|
665 |
|
function CompressID( $ID ){ |
666 |
|
return(Base64_encode(pack("H*",$ID))); |
667 |
|
} |
668 |
|
|
669 |
|
function ExpandID ($ID){ |
670 |
|
return ( implode(unpack("H*",Base64_decode($ID)), '') ); |
671 |
|
} |
672 |
|
|
673 |
|
// from: utils/links.php |
674 |
|
function yesno($bool) { |
675 |
|
return $bool ? 'yes' : 'no'; |
676 |
|
} |
677 |
|
|
678 |
|
function untwingle_reference($item, $options = array()) { |
679 |
|
|
680 |
|
// default |
681 |
|
if (!$options['seperator']) { $options['seperator'] = '_'; } |
682 |
|
|
683 |
|
if ( is_string($item) && (substr($item, 0, 2) == "o_") ) { |
684 |
|
//print "YAI!<br/>"; |
685 |
|
$parts = split($options['seperator'], $item); |
686 |
|
$result = array( |
687 |
|
ident => $parts[1], |
688 |
|
type => $parts[2], |
689 |
|
); |
690 |
|
return $result; |
691 |
|
} |
692 |
|
} |
693 |
|
|
694 |
|
// wrapper-function for getting the logger instance |
695 |
|
// TODO: review! what about php::append_log? |
696 |
|
function log($string, $level = PEAR_LOG_DEBUG) { |
697 |
|
global $app; |
698 |
|
$app->log($string, $level); |
699 |
|
} |
700 |
|
|
701 |
|
// from: http://www.php.net/manual/en/function.array-filter.php#AEN7432 |
702 |
|
function odd($var) { |
703 |
|
return ($var % 2 == 1); |
704 |
|
} |
705 |
|
function even($var) { |
706 |
|
return ($var % 2 == 0); |
707 |
|
} |
708 |
|
|
709 |
} |
} |
710 |
|
|