/** * Copy folder to new location */ public function copy($newpath = "") { $path = $this->getPath(); $newpath = Sanitize::toPath($newpath); $output = 0; if (is_dir($path) && !empty($newpath)) { mkdir($newpath, 0777, true); $stream = opendir($path); while (false !== ($item = @readdir($stream))) { if ($item === "." || $item === "..") { continue; } $from = Sanitize::toPath($path . "/" . $item); $to = Sanitize::toPath($newpath . "/" . $item); if (is_dir($from)) { $folder = new Folder($from); $folder->copy($to) && $output++; continue; } if (is_file($from)) { $file = new File($from); $file->copy($to) && $output++; continue; } } @closedir($stream); } return $output ? true : false; }
/** * Logs an error message to file */ private function _logError() { if (!empty($this->_path_logdir)) { $date = date('Y.m.d h:i A'); $head = '[' . $this->_status_code . ': ' . $this->_error_type . ']'; $tail = '[' . $this->_error_line . ': ' . $this->_error_file . ']'; $logfile = $this->_path_logdir; $logfile .= '/' . date('Y'); // add year subfolder (/2015) $logfile .= '/' . date('F'); // add month subfolder (/January) $logfile .= '/' . date('Y\\-F\\-d\\-l') . '-Errors.log'; // final (/2015-January-01-Monday-Errors.log) $folder = new Folder($this->_path_logdir); $folder->create(); $folder->garbageCollect(strtotime('-5 days')); $folder->setPath(dirname($logfile)); $folder->create(); $message = $date . ' - ' . $head . ' - ' . $this->_error_message . ' - ' . $tail; $message = $this->filterEvent('logMessage', $message); return @error_log(trim($message) . "\r\n", 3, $logfile); } return false; }