<?php
/*
 * This file is part of Web Pro Manager.
 * 
 * Web Pro Manager is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Web Pro Manager is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Web Pro Manager.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author The Web Pro Miami, Inc. <info@thewebpro.com>
 * @copyright The Web Pro Miami, Inc. <info@thewebpro.com>, http://www.thewebpro.com/
 * @license http://www.gnu.org/licenses/gpl.html GNU GPL
 * @package WebProManager
*/

function nImg_GetExtension($nImgFile){
	if(!$nImgFile){ return; }
	$nImgInfo = pathinfo($nImgFile);
	$nExt = strtolower($nImgInfo["extension"]);
	return $nExt;
}

function nColorHex2RGB($nColor){
	$nColor = str_replace("#","",$nColor);
	if (strlen($nColor) == 6){
		list($r, $g, $b) = array($nColor[0].$nColor[1],$nColor[2].$nColor[3],$nColor[4].$nColor[5]);
	} elseif (strlen($nColor) == 3) {
		list($r, $g, $b) = array($nColor[0].$nColor[0], $nColor[1].$nColor[1], $nColor[2].$nColor[2]);
	} else { return false; }
	$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
	return array($r, $g, $b);
}

function nGetImgTagHTML($nImgFile){
	if(!$nImgFile){ return; }
	$nImgTagARRAY = getimagesize($nImgFile);
	$nImgTagWH = $nImgTagARRAY[3];
	$nTag = "<img src=\"$nImgFile\" alt=\"\" $nImgTagWH border=\"0\">";
	return $nTag;
}

function nSanitizeFilename($nFilename){
	if(!$nFilename){ return; }
	$nBadCharsARRAY = array("amp;",",","!","@","#","$","%","^","&","*","(",")",":",";","/","\"","'","?","<",">","[","]","{","}","|","+","=","~","`");
	$nFilename = str_replace($nBadCharsARRAY,"",$nFilename);
	$nFilename = str_replace(" ","-",$nFilename);
	$nFilename = str_replace("--","-",$nFilename);
	$nFilename = strtolower($nFilename);
	return $nFilename;
}
?>