2005-06-18 23:26:35 +00:00
|
|
|
|
<?php
|
2005-07-04 01:45:26 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2005-07-04 01:46:23 +00:00
|
|
|
|
// + $Id$
|
2005-07-04 01:45:26 +00:00
|
|
|
|
// +------------------------------------------------------------------+ //
|
2005-07-04 02:07:21 +00:00
|
|
|
|
// + Cake PHP : Rapid Development Framework <http://www.cakephp.org/> + //
|
2005-07-04 02:59:39 +00:00
|
|
|
|
// + Copyright: (c) 2005, CakePHP Authors/Developers + //
|
2005-07-04 01:45:26 +00:00
|
|
|
|
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
|
|
|
|
|
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
|
|
|
|
|
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
|
|
|
|
|
// +------------------------------------------------------------------+ //
|
|
|
|
|
// + Licensed under The MIT License + //
|
|
|
|
|
// + Redistributions of files must retain the above copyright notice. + //
|
|
|
|
|
// + See: http://www.opensource.org/licenses/mit-license.php + //
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2005-06-18 23:26:35 +00:00
|
|
|
|
|
2005-07-04 01:45:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* Purpose:
|
|
|
|
|
*
|
|
|
|
|
* @filesource
|
2005-07-04 02:07:21 +00:00
|
|
|
|
* @author CakePHP Authors/Developers
|
2005-07-04 02:59:39 +00:00
|
|
|
|
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
|
2005-07-04 01:45:26 +00:00
|
|
|
|
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
|
|
|
|
|
* @package cake
|
|
|
|
|
* @subpackage cake.libs
|
2005-07-04 02:07:21 +00:00
|
|
|
|
* @since CakePHP v 0.2.9
|
2005-07-04 01:46:23 +00:00
|
|
|
|
* @version $Revision$
|
|
|
|
|
* @modifiedby $LastChangedBy$
|
2005-07-04 01:45:26 +00:00
|
|
|
|
* @lastmodified $Date$
|
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
|
*/
|
2005-06-18 23:26:35 +00:00
|
|
|
|
|
2005-07-04 01:45:26 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enter description here...
|
2005-07-04 04:16:20 +00:00
|
|
|
|
* @package cake
|
|
|
|
|
* @subpackage cake.libs
|
|
|
|
|
* @since CakePHP v 0.2.9
|
2005-07-04 01:45:26 +00:00
|
|
|
|
* @static
|
|
|
|
|
*/
|
|
|
|
|
class NeatString{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enter description here...
|
|
|
|
|
*
|
|
|
|
|
* @param unknown_type $string
|
|
|
|
|
* @return unknown
|
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
|
function toArray ($string)
|
|
|
|
|
{
|
|
|
|
|
return preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-04 01:45:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* Enter description here...
|
|
|
|
|
*
|
|
|
|
|
* @param unknown_type $string
|
|
|
|
|
* @return unknown
|
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
|
function toRoman ($string)
|
|
|
|
|
{
|
|
|
|
|
$pl = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','<27>?','Ń','Ó','Ś','Ź','Ż');
|
|
|
|
|
$ro = array('a','c','e','l','n','o','s','z','z','A','C','E','L','N','O','S','Z','Z');
|
2005-06-18 23:26:35 +00:00
|
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
|
return str_replace($pl, $ro, $string);
|
|
|
|
|
}
|
2005-06-18 23:26:35 +00:00
|
|
|
|
|
2005-07-04 01:45:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* Enter description here...
|
|
|
|
|
*
|
|
|
|
|
* @param unknown_type $string
|
|
|
|
|
* @return unknown
|
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
|
function toCompressed ($string)
|
|
|
|
|
{
|
|
|
|
|
$whitespace = array("\n", "\t", "\r", "\0", "\x0B", " ");
|
|
|
|
|
return strtolower(str_replace($whitespace, '', $string));
|
|
|
|
|
}
|
2005-06-18 23:26:35 +00:00
|
|
|
|
|
2005-07-04 01:45:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* Enter description here...
|
|
|
|
|
*
|
|
|
|
|
* @param unknown_type $length
|
|
|
|
|
* @param unknown_type $available_chars
|
|
|
|
|
* @return unknown
|
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
|
function randomPassword ($length, $available_chars = 'ABDEFHKMNPRTWXYABDEFHKMNPRTWXY23456789')
|
|
|
|
|
{
|
|
|
|
|
$chars = preg_split('//', $available_chars, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
|
$char_count = count($chars);
|
|
|
|
|
|
|
|
|
|
$out = '';
|
|
|
|
|
for ($ii=0; $ii<$length; $ii++)
|
|
|
|
|
{
|
|
|
|
|
$out .= $chars[rand(1, $char_count)-1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
|
}
|
2005-06-18 23:26:35 +00:00
|
|
|
|
|
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
2005-06-18 23:26:35 +00:00
|
|
|
|
?>
|