Location: PHPKode > projects > Nitrotech > nitrotech/includes/functions.php
<?php

function make_time($time)
{
	//to go from the timestamp to time ;)

    $time = explode(',', $time);

    $year = $time['0'];
    $month = $time['1'];
    $day = $time['2'];
    $hour = $time['3'];
    $min = $time['4'];
    $day_text = $time['5'];

    $time = $hour . ":" . $min;

	if ($month == 1)
	{
	        $month_name= 'January';
	}
	if ($month == 2)
	{
	        $month_name= 'February';
	}
	if ($month == 3)
	{
	        $month_name= 'March';
	}
	if ($month == 4)
	{
	        $month_name= 'April';
	}
	if ($month == 5)
	{
	        $month_name= 'May';
	}
	if ($month == 6)
	{
	        $month_name= 'June';
	}
	if ($month == 7)
	{
	        $month_name= 'July';
	}
	if ($month == 8)
	{
	        $month_name= 'August';
	}
	if ($month == 9)
	{
	        $month_name= 'September';
	}
	if ($month == 10)
	{
	        $month_name= 'October';
	}
	if ($month == 11)
	{
	        $month_name= 'November';
	}
	if ($month == 12)
	{
	        $month_name= 'December';
	}
    //crapy way of doing it :P
    $date = $day_text . " " . $month_name . " " . $year . ", " . $time;

    return $date;
}

function message($message, $type)
{
	global $admin, $root;

	if($type == 'die')
    {
    	die($message);
    }
    else if($type == 'comment')
    {
    	echo("<center>" . $message . "</center>");
    }
    else if($type == 'message')
    {
    	$included_files = get_included_files();

        foreach($included_files as $filename)
        {
    		$find_header = strpos($filename, 'header.php');
            if($find_header === true)
	    	{
                $header = 1;
            }
            echo($header);
		}

	    if($header)
	    {
   			$style = get_userinfo('style');

            if($admin)
            {
	            include($root . "admin/includes/header.php");
	            echo($message);
	            include($root . "admin/includes/header.php");
            }
            else
            {
	            include($root . "styles/" . $style . "/header.php");
	            echo($message);
	            include($root . "styles/" . $style . "/footer.php");
            }
	    }
	    else
	    {
	        echo($message);
	    }

    }
    exit;
}

function text_submit($text, $disable_html)
{
	addslashes($text);
    if($disable_html)
    {
    	htmlspecialchars($text);
    }
    return $text;
}

function text_edit($text)
{
	stripslashes($text);
    return $text;
}

function text_read($text)
{
	global $site_data, $table, $root;
	$text = str_replace("\n", "\n<br />\n", $text);
    stripslashes($text);

    //smilies :)
    $smilie_info = explode(',', $site_data['smilies']);
    if($smilie_info['0'])
    {
		$query1 = "SELECT * FROM " . $table['smilies'];
	    $result1 = mysql_query($query1);
	    if (!$result1)
	    {
	        message("Could not successfully run query ($query1) from DB: " . mysql_error(), 'die');
        }

	    while ($smilie = mysql_fetch_assoc($result1))
	    {
        	$code = preg_quote(stripslashes($smilie['code']));
	        $text_find = strpos($text, $smilie['code']);

	        if($text_find === false)
	        {
	            $text = $text;
	        }
	        else
	        {
	            $text = ereg_replace ($code, '<img src="'.$root.$smilie_info['1'].$smilie['url'].'">', $text);
	        }
	    }
    }

    return $text;
}

?>
Return current item: Nitrotech