Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Librería de funciones básicas V1.0 (June, 16th 2009) 19 * 20 * 21 * @author Daniel Mühlrad 22 * @link daniel.muhlrad@uvcms.com 23 * @version 1.0 24 * @copyright 2009 25 * 26 */ 27 28 29 30 31 /** 32 * Make a Handler error with an exception msg error 33 * 34 * @param integer $errno 35 * @param string $errstr 36 * @param string $errfile 37 * @param string $errline 38 */ 39 function errorHandler($errno, $errstr, $errfile, $errline) { 40 // si deseas podes guardarlos en un archivo 41 ($errfile);($errline); 42 throw new Exception($errstr, $errno); 43 } 44 45 46 47 /** 48 * Return de mime-type of a file 49 * 50 * @param string $file 51 * @param string $default_type 52 * 53 */ 54 function file_mime_type ($file, $default_type = 'application/octet-stream'){ 55 $ftype = $default_type; 56 $magic_path = __DIR__ 57 . DIRECTORY_SEPARATOR 58 . '..' 59 . DIRECTORY_SEPARATOR 60 . 'magic' 61 . DIRECTORY_SEPARATOR 62 . 'magic'; 63 $finfo = @finfo_open(FILEINFO_MIME , $magic_path); 64 if ($finfo !== false) { 65 66 $fres = @finfo_file($finfo, $file); 67 68 if ( is_string($fres) && !empty($fres) ) { 69 $ftype = $fres; 70 } 71 @finfo_close($finfo); 72 } 73 return $ftype; 74 } 75 76 77 78 79 function array_remove_by_value($arr,$value) { 80 return array_values(array_diff($arr,array($value))); 81 82 } 83 84 85 function array_remove_by_key($arr,$key) { 86 return array_values(array_diff_key($arr,array($key))); 87 88 } 89 90 91 function cc_print_object($object) { 92 echo '<pre>' . htmlspecialchars(print_r($object,true), ENT_COMPAT) . '</pre>'; 93 } 94 95 96 97 /** 98 * IndexOf - first version of find an element in the Array given 99 * returns the index of the *first* occurance 100 * @param mixed $needle 101 * @param array $haystack 102 * @return mixed The element or false if the function didnt find it 103 */ 104 105 function indexOf($needle, $haystack) { 106 for ($i = 0; $i < count($haystack) ; $i++) { 107 if ($haystack[$i] == $needle) { 108 return $i; 109 } 110 } 111 return false; 112 } 113 114 115 /** 116 * IndexOf2 - second version of find an element in the Array given 117 * 118 * @param mixed $needle 119 * @param array $haystack 120 * @return mixed The index of the element or false if the function didnt find it 121 */ 122 123 function indexOf2($needle, $haystack) { 124 for($i = 0,$z = count($haystack); $i < $z; $i++){ 125 if ($haystack[$i] == $needle) { //finds the needle 126 return $i; 127 } 128 } 129 return false; 130 } 131
title
Description
Body
title
Description
Body
title
Description
Body
title
Body