Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function full_copy($source, $target) {
- $source = (substr($source, -1) == '/' ? substr($source, 0, -1) : $source);
- $target = (substr($target, -1) == '/' ? substr($target, 0, -1) : $target);
- if (is_dir($source)) {
- @mkdir($target, true);
- $d = dir($source);
- while (FALSE !== ($entry = $d->read())) {
- if ($entry == '.' || $entry == '..') {
- continue;
- }
- $Entry = $source . '/' . $entry;
- if (is_dir($Entry)) {
- full_copy($Entry, $target . '/' . $entry);
- continue;
- }
- copy($Entry, $target . '/' . $entry);
- echo "Copied {$Entry} to " . $target . '/' . $entry . "\n";
- modPath($target . '/' . $entry);
- }
- $d->close();
- }
- else {
- copy($source, $target);
- echo "Copied {$source} to {$target}\n";
- modPath($target);
- }
- }
- function createDir($path) {
- if (!is_dir($path)) { // if the dir doesn't exist
- echo "Making directory at: {$path}\n";
- mkdir($path, 755, true); // create the dir (recursively)
- }
- else {
- echo "Directory exists at: {$path}\n";
- }
- modPath($path);
- }
- function modPath($path) {
- if (is_dir($path)) {
- $mod = 0755;
- }
- else {
- $mod = 0644;
- }
- chmod($path, $mod);
- $aPath = explode("/", $path);
- chown($path, $aPath[2]);
- chgrp($path, $aPath[2]);
- echo "Ownership of {$path} given to user: " . $aPath[2] . "\n";
- }
- class xmldoc {
- function build($name = 'index') {
- $dom = new DOMDocument("1.0", "utf-8");
- $dom->formatOutput = true;
- $root = $dom->createElement($name);
- $dom->appendChild($root);
- return array($root, $dom);
- }
- function add($xmlObject, $parent, $field, $value = false, $textNode = false) {
- $dom = $xmlObject[1];
- $field = $dom->createElement($field);
- $parent->appendChild($field);
- if ($value !== false) {
- $text = ($textNode !== false ? $dom->createTextNode($value) : $dom->createCDATASection($value));
- $field->appendChild($text);
- }
- return $field;
- }
- function attr($xmlObject, $field, $name, $text) {
- $dom = $xmlObject[1];
- $name = $dom->createAttribute($name);
- $field->appendChild($name);
- $value = $dom->createTextNode($text);
- $name->appendChild($value);
- }
- function save($xmlObject, $path, $save = true) {
- $dom = $xmlObject[1];
- echo $dom->saveXML();
- if ($save === true) {
- echo "Wrote to {$path}, " . $dom->save($path) . " bytes.\n" . date('r', time()) . "\n";
- modPath($path);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement