ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
MagicConfig Class Reference
+ Collaboration diagram for MagicConfig:

Public Member Functions

 MagicConfig ()
 detect_cpp ()
 detect_awk ()
 detect_perl ()
 detect_bash ()
 detect_rc ()
 detect_env ()
 detect_genericshell ()
 detect_diff ()
 detect_xdiff ()
 detect_swf ()
 detect_psfont ()
 detect_lex ()
 detect_lisp ()
 detect_magic ()
 detect_mime ()
 detect_postscript ()
 detect_rtf ()
 detect_html ()
 detect_xml ()
 detect_sgml ()
 detect_gif ()
 detect_jpeg ()
 detect_png ()
 detect_bmp ()
 detect_tif ()

Detailed Description

Definition at line 21 of file MagicConfig.php.

Member Function Documentation

MagicConfig::detect_awk ( )

Definition at line 118 of file MagicConfig.php.

{
if (preg_match("/^#!\s+\/bin\/nawk/", $this->file)
|| preg_match("/^#!\s+\/bin\/nawk/", $this->file)
|| preg_match("/^#!\s+\/usr\/bin\/nawk/", $this->file)
|| preg_match("/^#!\s+\/usr\/local\/bin\/nawk/", $this->file)
|| preg_match("/^#!\s+\/bin\/gawk/", $this->file)
|| preg_match("/^#!\s+\/usr\/bin\/gawk/", $this->file)
|| preg_match("/^#!\s+\/usr\/local\/bin\/gawk/", $this->file)
|| preg_match("/^#!\s+\/bin\/awk/", $this->file)
|| preg_match("/^#!\s+\/usr\/bin\/awk/", $this->file)
|| preg_match("/^BEGIN\s+/", $this->file)) return true;
else return false;
}
MagicConfig::detect_bash ( )

Definition at line 144 of file MagicConfig.php.

{
if (preg_match("/^#!\s+\/bin\/bash/", $this->file)
|| preg_match("/^#!\s+\/usr\/local\/bin\/bash/", $this->file)) return true;
else return false;
}
MagicConfig::detect_bmp ( )

Definition at line 273 of file MagicConfig.php.

{
return (substr($this->file, 0, 2) == "BM");
}
MagicConfig::detect_cpp ( )

Definition at line 113 of file MagicConfig.php.

{
return !(strpos($this->file, "//") === false);
}
MagicConfig::detect_diff ( )

Definition at line 169 of file MagicConfig.php.

{
if (preg_match("/^diff\s+/", $this->file)
|| preg_match("/^\*\*\*\s+/", $this->file)
|| preg_match("/^Only\s+in\s+/", $this->file)
|| preg_match("/^Common\s+subdirectories:\s+/", $this->file)) return true;
else return false;
}
MagicConfig::detect_env ( )

Definition at line 157 of file MagicConfig.php.

{
if (preg_match("/^#!\s*\/usr\/bin\/env/", $this->file)) return true;
else return false;
}
MagicConfig::detect_genericshell ( )

Definition at line 163 of file MagicConfig.php.

{
if (preg_match("/^#!/", $this->file)) return true;
else return false;
}
MagicConfig::detect_gif ( )

Definition at line 253 of file MagicConfig.php.

{
return (substr($this->file, 0, 6) == "GIF89a");
}
MagicConfig::detect_html ( )

Definition at line 228 of file MagicConfig.php.

{
if (preg_match("/\s*<!doctype\s+html/", $this->file)
|| preg_match("/\s*<head/", $this->file)
|| preg_match("/\s*<title/", $this->file)
|| preg_match("/\s*<html/", $this->file)) return true;
else return false;
}
MagicConfig::detect_jpeg ( )

Definition at line 258 of file MagicConfig.php.

{
return !(strpos(substr($this->file, 0, 16), "JFIF") === false);
}
MagicConfig::detect_lex ( )

Definition at line 196 of file MagicConfig.php.

{
if (substr($this->file, 53, 10)=="yyprevious"
|| substr($this->file, 21, 17)=="generated by flex") return true;
else return false;
}
MagicConfig::detect_lisp ( )

Definition at line 203 of file MagicConfig.php.

{
return !(strpos($this->file, ";;") === false);
}
MagicConfig::detect_magic ( )

Definition at line 208 of file MagicConfig.php.

{
return preg_match("/^#\s+Magic/", $this->file);
}
MagicConfig::detect_mime ( )

Definition at line 213 of file MagicConfig.php.

{
return preg_match("/^Content-Type:/", $this->file);
}
MagicConfig::detect_perl ( )

Definition at line 133 of file MagicConfig.php.

{
if (preg_match("/^#!\s+\/bin\/perl/", $this->file)
|| preg_match("/^eval\s+\"exec\s+\/bin\/perl/", $this->file)
|| preg_match("/^#!\s+\/usr\/bin\/perl/", $this->file)
|| preg_match("/^eval\s+\"exec\s+\/usr\/bin\/perl/", $this->file)
|| preg_match("/^#!\s+\/usr\/local\/bin\/perl/", $this->file)
|| preg_match("/^eval\s+\"exec\s+\/usr\/local\/bin\/perl/", $this->file)) return true;
else return false;
}
MagicConfig::detect_png ( )

Definition at line 263 of file MagicConfig.php.

{
$arr = unpack("C*", $this->file);
if (sizeof($arr)<9) return false;
return ($arr[1] == 0x89 && $arr[2] == 0x50
&& $arr[3] == 0x4E && $arr[4] == 0x47
&& $arr[5] == 0x0D && $arr[6] == 0x0A
&& $arr[7] == 0x1A && $arr[8] == 0x0A);
}
MagicConfig::detect_postscript ( )

Definition at line 218 of file MagicConfig.php.

{
return (substr($this->file, 0, 2)=="%!" || substr($this->file, 0, 3)==(string)(4)."%!");
}
MagicConfig::detect_psfont ( )

Definition at line 190 of file MagicConfig.php.

{
if (preg_match("/^(.*?)PS-AdobeFont-1\.0/", $this->file)) return true;
else return false;
}
MagicConfig::detect_rc ( )

Definition at line 151 of file MagicConfig.php.

{
if (preg_match("/^#!\s+\/bin\/rc/", $this->file)) return true;
else return false;
}
MagicConfig::detect_rtf ( )

Definition at line 223 of file MagicConfig.php.

{
return substr($this->file, 0, 5)=="{\\rtf";
}
MagicConfig::detect_sgml ( )

Definition at line 243 of file MagicConfig.php.

{
if (preg_match("/\s*<!doctype/", $this->file)
|| preg_match("/\s*<!subdoc/", $this->file)
|| preg_match("/\s*<!--/", $this->file)) return true;
else return false;
}
MagicConfig::detect_swf ( )

Definition at line 184 of file MagicConfig.php.

{
if (preg_match("/^FWS/", $this->file)) return true;
else return false;
}
MagicConfig::detect_tif ( )

Definition at line 278 of file MagicConfig.php.

{
return ((substr($this->file, 0, 2) == "MM") || (substr($this->file, 0, 2) == "II"));
}
MagicConfig::detect_xdiff ( )

Definition at line 178 of file MagicConfig.php.

{
if (preg_match("/^%XDZ/", $this->file)) return true;
else return false;
}
MagicConfig::detect_xml ( )

Definition at line 237 of file MagicConfig.php.

{
if (preg_match("/\s*<\?xml/", $this->file)) return true;
else return false;
}
MagicConfig::MagicConfig ( )

Definition at line 23 of file MagicConfig.php.

{
$this->separator = ".";
$this->extensions = array(
"a" => "ada95",
"ada" => "ada95",
"adb" => "ada95",
"ads" => "ada95",
"asm" => "asm_x86",
"asp" => "jscript|vb|vbdotnet",
"awk" => "awk",
"bas" => "vb|vbdotnet",
"c" => "c",
"cbl" => "cobol",
"cls" => "vb|vbdotnet",
"cob" => "cobol",
"cpy" => "cobol",
"cpp" => "cpp",
"cs" => "csharp",
"cxx" => "cpp",
"dat" => "mumps",
"dpr" => "delphi",
"e" => "eiffel|euphoria",
"ew" => "euphoria",
"eu" => "euphoria",
"ex" => "euphoria",
"exw" => "euphoria",
"exu" => "euphoria",
"frm" => "vb|vbdotnet",
"h" => "c",
"hpp" => "cpp",
"inc" => "turbopascal|vb|vbdotnet",
"java" => "javaswing",
"js" => "jscript|javascript",
"lsp" => "lisp",
"m" => "mumps",
"pas" => "delphi|turbopascal",
"php" => "php3",
"php3" => "php3",
"php4" => "php3",
"pl" => "perl",
"pm" => "perl",
"py" => "python",
"pyc" => "python",
"rtn" => "mumps",
"scm" => "scheme",
"vb" => "vb|vbdotnet",
"vbs" => "vb|vbdotnet|vbscript",
"wsf" => "vbscript"
);
$this->langfunctions = array(
// ASCII
// --- Languages
"awk",
"bash",
"perl",
"rc",
"env",
"cpp",
"diff",
"xdiff",
"swf",
"psfont",
"lex",
"lisp",
"magic",
"mime",
// --- Markup
"postscript",
"rtf",
"html",
"xml",
"sgml",
// --- Generic tests
"genericshell");
$this->binfunctions = array(
// Binary
// --- Images
"gif",
"jpeg",
"png",
"bmp",
"tif"
// --- Compressed
);
}

The documentation for this class was generated from the following file: