public static function copyTo($destination = ROOT) { if (file_exists(self::$open)) { $destination = (array) $destination; foreach ($destination as $dest) { $dest = self::path($dest); if (is_dir($dest)) { if (!file_exists($dest)) { mkdir($dest, 0777, true); } $dest = rtrim(self::path($dest), DS) . DS . self::B(self::$open); } else { if (!file_exists(self::D($dest))) { mkdir(self::D($dest), 0777, true); } } if (!file_exists($dest) && !file_exists(preg_replace('#\\.(.*?)$#', '.' . self::$index . '.$1', $dest))) { self::$index = 0; copy(self::$open, $dest); } else { self::$index++; copy(self::$open, preg_replace('#\\.(.*?)$#', '.' . self::$index . '.$1', $dest)); } } self::$index = 0; } }