Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function strip_zeros_from_date($marked_string = "")
- {
- // first remove the marked zeros
- $no_zeros = str_replace('*0', '', $marked_string);
- // then remove any remaining marks
- $cleaned_string = str_replace('*', '', $no_zeros);
- return $cleaned_string;
- }
- function redirect_to($location = NULL)
- {
- if ($location != NULL) {
- header("Location: {$location}");
- exit;
- }
- }
- function output_message($message = "")
- {
- if (!empty($message)) {
- return "<p class=\"message\">{$message}</p>";
- } else {
- return "";
- }
- }
- function __autoload($class_name)
- {
- //$class_name = strtolower($class_name);
- $path = "{$class_name}.php";
- if (require_once($path)) {
- } else {
- die("The file {$class_name}.php could not be found.");
- }
- }
- function include_layout_template($template = "")
- {
- $b = SITE_ROOT;
- include(SITE_ROOT . DS . 'public' . DS . 'layouts' . DS . $template);
- }
- function log_action($action, $message = "")
- {
- $logfile = SITE_ROOT . DS . 'logs' . DS . 'log.txt';
- $new = file_exists($logfile) ? false : true;
- if ($handle = fopen($logfile, 'a')) { // append
- $timestamp = strftime("%Y-%m-%d %H:%M:%S", time());
- $content = "{$timestamp} | {$action}: {$message}\n";
- fwrite($handle, $content);
- fclose($handle);
- if ($new) {
- chmod($logfile, 0755);
- }
- } else {
- echo "Could not open log file for writing.";
- }
- }
- function datetime_to_text($datetime = "")
- {
- $unixdatetime = strtotime($datetime);
- return strftime("%B %d, %Y at %I:%M %p", $unixdatetime);
- }
- function disable_magic_quotes()
- {
- $magicStatus = get_magic_quotes_gpc();
- if (get_magic_quotes_gpc()) {
- $process = array(
- &$_GET,
- &$_POST,
- &$_COOKIE,
- &$_REQUEST
- );
- while (list($key, $val) = each($process)) {
- foreach ($val as $k => $v) {
- unset($process[$key][$k]);
- if (is_array($v)) {
- $process[$key][stripslashes($k)] = $v;
- $process[] =& $process[$key][stripslashes($k)];
- } else {
- $process[$key][stripslashes($k)] = stripslashes($v);
- }
- }
- }
- unset($process);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement