Add date and hash helpers and autoload them

This commit is contained in:
Karsten Heiken
2011-05-08 19:56:13 +02:00
parent cb63df2405
commit 4b0f9f8099
3 changed files with 63 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Extends CI's date helpers.
*
* @author Karsten Heiken <karsten@disposed.de>
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Date Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/date_helper.html
*/
// ------------------------------------------------------------------------
/**
* Get "now" time formatted for MySQL
*
* Returns time() formatted for direct insertion into a DATETIME field.
*
* @access public
* @return integer
*/
if ( ! function_exists('mysql_now'))
{
function mysql_now()
{
return mdate('%Y-%m-%d %H:%i:%s', now());
}
}
/* End of file MY_date_helper.php */
/* Location: ./application/helpers/MY_date_helper.php */

View File

@@ -0,0 +1,23 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Helper for generating hash values.
*
* @author Karsten Heiken <karsten@disposed.de>
*/
/**
* Generate a pseudo-random SHA1-hash.
*
* @access public
* @return integer
*/
if ( ! function_exists('random_hash'))
{
function random_hash($len = 40)
{
return substr(sha1(rand(1,1000).now().rand(1001,2000)), 0, $len);
}
}
/* End of file MY_date_helper.php */
/* Location: ./application/helpers/MY_date_helper.php */