06.28
php
saved
kiger
Note
kiger did not leave a note
kiger did not leave a note
- <?php
- class Toolkit extends Object
- {
- /**
- * Returns a singleton instance.
- *
- * @return Configure instance
- * @access public
- */
- function &getInstance() {
- if (!$instance) {
- $instance =& new Toolkit();
- }
- return $instance;
- }
- /**
- * put your comment there...
- *
- * @param mixed $length
- */
- function hash($string, $type='sha256', $salt=true)
- {
- if ($salt === true)
- {
- $salt = Configure::read('OS.salt');
- $string = $salt . $string;
- }
- if ($type === 'sha256')
- {
- {
- return hash('SHA256', $string);
- }
- {
- }
- $type = 'sha1';
- }
- if ($type === 'sha1')
- {
- {
- return hash('sha1', $string);
- }
- {
- }
- $type = 'md5';
- }
- if ($type === 'md5')
- {
- {
- return hash('md5', $string);
- }
- {
- }
- }
- }
- /**
- * put your comment there...
- *
- * @param mixed $length
- */
- function randomString($length = 32)
- {
- $charset = 'abcdfghijklmnopqrstvwxyz0123456789';
- $key = '';
- for ($i=0; $i<$length; $i++)
- {
- }
- return $key;
- }
- /**
- * put your comment there...
- *
- * @param mixed $length
- */
- function randomNumber($length = 32, $security = 'high')
- {
- if ($security === 'high')
- {
- $charset = '0123456789';
- $key = '';
- for ($i=0; $i<$length; $i++)
- {
- }
- }
- else
- if ($security === 'low')
- {
- $key = '';
- for ($i=1; $i<=$count; $i++)
- {
- }
- }
- return $key;
- }
- /**
- * put your comment there...
- *
- * @param mixed $length
- */
- function randomPassword($length = 10)
- {
- $password = '';
- $cons = array('b', 'c', 'd', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', 'tr',
- 'cr', 'br', 'fr', 'th', 'dr', 'ch', 'ph', 'wr', 'st', 'sp', 'sw', 'pr', 'sl', 'cl');
- for($i = 0; $i < $length; $i++)
- {
- }
- }
- /**
- * Converts a file size in bytes to a readable size.
- *
- * @param mixed $size
- * @param mixed $retstring
- * @return string
- */
- function toReadableSize($size, $retstring = null)
- {
- // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
- if ($retstring === null) { $retstring = '%01.2f %s'; }
- foreach ($sizes as $sizestring)
- {
- if ($size < 1024) { break; }
- if ($sizestring != $lastsizestring) { $size /= 1024; }
- }
- if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional
- }
- }
- ?>
Parsed in 0.217 seconds, using GeSHi 1.0.7.14