function del_hook($type, $sender) { if (is_array($this->hooks[$type])) { $key = array_Search($this->hooks[$type], $sender); if ($key !== FALSE) { unset($this->hooks[$type][$key]); } } }
function __construct($file, $arg = 'R', $must_exists = true) { $this->file = $file; $error = array(); if (!file_exists($file) && $must_exists) { throw new Exception(sprintf("File (%s) does not exists. [%s:%s]", $file, __FILE__, __LINE__)); } // $args = strtoarray(strtoupper($arg)); if (strpos(strtoupper($arg), 'R')) { // check to make sure file is readable $args[] = 'R'; } if (strpos(strtoupper($arg), 'W')) { // check to make sure file is writeable $args[] = 'W'; } if (count($error) < 1 && $args) { // create file if it doesnt exist. if (array_Search('C', $args)) { $res = fopen($file, 'w+'); fclose($res); } foreach ($args as $k => $v) { switch ($v) { case 'R': if (!is_readable($file) && file_exists($file)) { // make sure file is readable and exists $error[] = sprintf("File (%s) is not readable.", $file); } break; case 'W': // is writable if (file_exists($file)) { if (!is_writeable($file)) { $error[] = sprintf("File (%s) is not writeable.", $file); } } if (!is_writable(dirname($file))) { $error[] = sprintf("Directory (%s) is not writeable.", dirname($file)); } break; default: } } } if (count($error) > 0) { $errors = '<br /> ' . join(' <Br />', $error); throw new Exception($errors); } }