PHP Classes
Icontem

File: utils.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Colin Sandy Pittendrigh  >  Site Bot  >  utils.php  
File: utils.php
Role: Auxiliary script
Content type: text/plain
Description: dbg utilities
Class: Site Bot
Recursive-automic site buider: static OR dynamic
 

Contents

Class file image Download
<?php

function tdbg($msg$funnycolor='red'$indent=0)
{
   echo 
"<table>";
   echo 
"<tr><td class=stuff>";
   
dbg($msg$funnycolor$indent);
   echo 
"</td></tr>\n";
   echo 
"</table>";
}

function 
dbg($inmsg$funnycolor='red'$indent=0)
{
   
   for(
$i=0$i<$indent$i++)
   echo 
" &nbsp; &nbsp ";
   
$msg sprintf("<b><font color=$funnycolor>%s</font></b><br>"$inmsg);
   echo 
"$msg";
}

function 
Alert($msg)
{
   echo 
"<script language=javascript> alert('$msg'); </script>";
}


function 
fixPath($path)
{
   if(
$path[0] != "/")
   
$path "/" $path;
   
$length strlen($path);
   if(
$path[$length-1] != "/")
   
$path .= "/";
   
   return (
$path);
}

function 
dispLabel($str)
{
   
   
$tmpLabel basename($str);
   
$tmpLabel ereg_replace ("^.+\-"""$tmpLabel);
   
$tmpLabel ereg_replace ("\..*$"""$tmpLabel);
   
$tmpLabel ereg_replace("_"" " ,    $tmpLabel);
   return(
$tmpLabel);
}

function 
mkLabel ($str)
{
   
$tmp basename($str);
   
$label ereg_replace ("\..*$"""$tmp);
   return (
$label);
}

function 
swapSuffix($srcfile$tosuffix)
{
   
$dotPos strrpos($srcfile,".");
   
$length strlen($srcfile);
   
$goodLength $dotPos+1;
   
$ret substr($srcfile,0$goodLength) . $tosuffix;
   return 
$ret;
}

function 
stripSuffix($srcfile)
{
   
$dotPos strrpos($srcfile,".");
   
$ret substr($srcfile,0$dotPos);
   return 
$ret;
}

function 
getSuffix($srcfile)
{
   
$dotPos strrpos($srcfile,".");
   if(
$dotPos == true)
   
$ret substr($srcfile$dotPos+1);
   else
   
$ret $srcfile;
   
// $ret = "";
   
return $ret;
}

function 
stripHttpStuff($srcfile)
{
   
$dotPos strrpos($srcfile,"/");
   
$ret substr($srcfile$dotPos+1);
   return 
$ret;
}

function 
getMimeType($file)
{
   
$mime_type "unknown";
   
$suffix substr($filestrrpos($file,"."));
   if(
strstr($suffix"jpg"))
   
$mime_type "image/jpeg";
   elseif (
strstr($suffix"gif"))
   
$mime_type "image/gif";
   elseif (
strstr($suffix"\.txt"))
   
$mime_type "text/plain";
   elseif (
strstr($suffix"\.htm"))
   
$mime_type "text/html";
   elseif (
strstr($suffix"\.cgi"))
   
$mime_type "text/html";
   elseif (
strstr($suffix"\.php"))
   
$mime_type "text/html";
   elseif (
strstr($suffix"\.cap"))
   
$mime_type "text/plain";
   
   return(
$mime_type);
}

function 
getPageType ($file)
{
   
$tmp basename($file);
   
$retval="unknown";
   
   if (
is_dir($file))
   {
      
$retval "dir";
   }
   elseif (
strstr ($tmp"html") || strstr ($tmp".php"))
   
$retval "html";
   elseif (
strstr ($tmp".cap"))
   
$retval "image_caption";
   elseif (
strstr ($tmp"htm") && !stristr ($tmp"html"))
   
$retval "htm";
   elseif (
strstr ($tmp".furl"))
   
$retval "furl";
   elseif (
strstr ($tmp".url"))
   
$retval "url";
   elseif (
strstr ($tmp".txt"))
   
$retval "text";
   elseif (
strstr ($tmp".lbl"))
   
$retval "lbl";
   elseif (
stristr ($tmp".pdf"))
   
$retval "downloadable";
   elseif (
stristr ($tmp".jpg") || stristr ($tmp".gif")
   || 
stristr ($tmp".png") || stristr ($tmp".jpeg"))
   
$retval "std_one_image";
   elseif (
strstr ($tmp"gz") || stristr ($tmp"zip") || stristr ($tmp"dxf") || stristr ($tmp"xls"))
   
$retval "downloadable";
   elseif (
stristr ($tmp"css"))
   
$retval "css";
   elseif (
$tmp == "keywords")
   
$retval "keywords";
   
   
//echo "retval: ", $retval, "<br/>";
   
return ($retval);
}
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products