copyDirectory() public static method

Copy a directory from one location to another.
public static copyDirectory ( string $directory, string $destination, integer $options = null ) : boolean
$directory string
$destination string
$options integer
return boolean
Example #1
0
 /**
  * @covers Kotchasan\File::makeDirectory
  * @todo   Implement testMakeDirectory().
  */
 public function testFile()
 {
     $this->object->makeDirectory('temp/');
     $this->object->makeDirectory('temp/test/');
     $f = fopen('temp/test/index.php', 'w');
     fclose($f);
     $this->object->copyDirectory('temp/test/', 'temp/');
     $result = array();
     $this->object->listFiles('temp/test/', $result);
     $this->object->removeDirectory('temp/');
     $this->assertEquals(array('temp/test/index.php'), $result);
 }
 /**
  * Run the package migrations.
  */
 public function handle()
 {
     \File::copyDirectory(__DIR__ . '/../../../config', base_path() . '/config');
     $appDeviseConfigpath = config_path() . '/devise';
     foreach ($this->emptyTargets as $fileName) {
         \File::put($appDeviseConfigpath . '/' . $fileName, "<?php return array();\n// data will merge with Devise " . $fileName);
     }
 }
Example #3
0
 /**
  * Migrates the database and set the mailer to 'pretend'.
  * This will cause the tests to run quickly.
  */
 private function prepareForTests()
 {
     if (!\File::exists(base_path() . '/config/testing')) {
         \File::copyDirectory(__DIR__ . '/../config/testing/', base_path() . '/config/testing');
     }
     Artisan::call('migrate');
     Mail::pretend(true);
 }
Example #4
0
 public function setUp()
 {
     parent::setUp();
     $this->tmpDir = $this->testsDir . '/data/files/tmp';
     $this->storageDir = $this->testsDir . '/data/files/storage';
     File::deleteDirectory($this->tmpDir);
     File::copyDirectory($this->testsDir . '/data/files/upload', $this->tmpDir);
 }
Example #5
0
 public function setUp()
 {
     parent::setUp();
     $this->userFileStorage = $this->app->make(InterfaceFileStorage::class);
     $this->tmpDir = $this->testsDir . '/data/files/tmp';
     $this->storageDir = $this->testsDir . '/data/files/storage';
     File::deleteDirectory($this->tmpDir);
     File::copyDirectory($this->testsDir . '/data/files/upload', $this->tmpDir);
 }
Example #6
0
 protected function copyDirectories()
 {
     $directories = \File::directories(base_path());
     foreach ($directories as $directory) {
         if (!strpos($directory, 'vendor') && !strpos($directory, 'backup')) {
             $folder = str_replace(base_path(), '', $directory);
             \File::copyDirectory($directory, base_path() . '/backup/' . $this->timestamp . $folder);
         }
     }
 }
Example #7
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // In vendor as package
     if (!WB()) {
         // Themes path
         $themes_to_copy = base_path('vendor/pongocms/site/src/themes');
         // Copy dir
         \File::copyDirectory($themes_to_copy, base_path('themes'));
         $this->info('Themes folder exported to root!');
     } else {
         $this->info('This command only run under vendor/package!');
     }
     return;
 }
Example #8
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $path_to_copy_from = base_path('workbench/static/public');
     $dirs_to_copy = \File::directories($path_to_copy_from);
     $path_to_copy_into = base_path('workbench/pongocms/cms/public');
     foreach ($dirs_to_copy as $dir) {
         $dir_arr = explode('/', $dir);
         $dir_name = end($dir_arr);
         \File::copyDirectory($dir, $path_to_copy_into . '/' . $dir_name);
         $this->info($dir_name . ' copied!');
     }
     $this->info('Assets imported successfully!');
     // Calling asset:publish
     $this->call('asset:publish', array('--bench' => 'pongocms/cms'));
     return;
 }
 public function postContent(Request $request)
 {
     $content = new Content();
     $content->user_id = \Auth::user()->id;
     $content->slug = $request->input('title');
     $content->fill($request->all());
     $content->save();
     $template = Template::find($request->input('template_id'));
     // make directory for content
     $contentDir = base_path() . $this->contentDir;
     if (!\File::exists($contentDir)) {
         \File::makeDirectory($contentDir, 755);
     }
     $contentDir = $contentDir . $content->id;
     \File::makeDirectory($contentDir, 755);
     $templateDir = base_path() . $this->templateDir . $template->slug;
     \File::copyDirectory($templateDir, $contentDir);
     return response()->json($content->id, 200);
 }
Example #10
0
 public function backup($tempDir, $targetDir)
 {
     $service = App::make('Tee\\Backup\\Services\\BackupService');
     $fileBackup = new \Tee\Backup\Package\Directory();
     if (!$targetDir) {
         throw new \Exception("targetDir cannot be empty");
     }
     $fileBackup->directory = $service->getBaseRelativePath($targetDir);
     $name = md5($targetDir) . '.zip';
     $filename = "{$tempDir}/{$name}";
     $fileBackup->filename = $name;
     $zippy = App::make('backup.zippy');
     $tempTargetDir = tempnam(sys_get_temp_dir(), 'tmp');
     unlink($tempTargetDir);
     mkdir($tempTargetDir);
     $success = \File::copyDirectory($targetDir, $tempTargetDir);
     $zippy->create($filename, $tempTargetDir);
     $fileBackup->md5 = md5_file($filename);
     \File::deleteDirectory($tempTargetDir);
     return $fileBackup;
 }
    static function CompleteStructure()
    {
        define("PAGE_ID", isset($_GET['PageID']) ? $_GET['PageID'] : "");
        switch (PAGE_ID) {
            case 'FileEditor':
                define("DIRECTORY", !is_file($_GET['directory']) ? Others::redirect("?") : realpath(urldecode($_GET['directory'])));
                define("EDIRECTORY", urlencode(DIRECTORY));
                define("ODIRECTORY", dirname(DIRECTORY));
                unset($dirName);
                define("FILEINODE", fileinode(DIRECTORY));
                define("FILENAME", basename(DIRECTORY));
                define("FILEBYTE", filesize(DIRECTORY));
                define("FILECTIME", filectime(DIRECTORY));
                define("FILEATIME", fileatime(DIRECTORY));
                define("FILEOWNER", fileowner(DIRECTORY));
                define("FILETYPE", strtolower(substr(strrchr(FILENAME, "."), 1)));
                if (FILEBYTE / 1024 > 1024) {
                    die('Dosya çok büyük <button onClick="javascript:window.close();">Kapat</button>');
                }
                if (isset($_POST['fileContents']) && is_string($_POST['fileContents'])) {
                    file_put_contents(DIRECTORY, urldecode($_POST['fileContents']));
                    Others::redirect(URLm::url("fileEditor", array("file" => DIRECTORY)));
                }
                Page::write("editor", array("Title" => "Dosya.Düzenle \"" . FILENAME . "\"", "CSSFile" => Settings::get("CSSFilePath"), "File" => DIRECTORY));
                break;
            default:
                if (isset($_GET['directory']) && !is_dir($_GET['directory'])) {
                    Others::redirect("?");
                }
                if (isset($_GET['directory']) && is_dir($_GET['directory'])) {
                    $directoryPath = (string) $_GET['directory'];
                } elseif (isset($_SERVER['DOCUMENT_ROOT']) && is_dir($_SERVER['DOCUMENT_ROOT'])) {
                    $directoryPath = $_SERVER['DOCUMENT_ROOT'];
                } else {
                    $directory = ".";
                }
                define("DIRECTORY", realpath($directoryPath));
                define("EDIRECTORY", urlencode(DIRECTORY));
                if (isset($_REQUEST['procName']) && isset($_REQUEST['filesArray'])) {
                    $filesExp = explode("{}", $_REQUEST['filesArray']);
                    $var = (string) $_REQUEST['variable'];
                    switch ($_REQUEST['procName']) {
                        case 'Move':
                            foreach ($filesExp as $dd) {
                                if (is_dir(DIRECTORY . "/" . $dd) || is_file(DIRECTORY . "/" . $dd)) {
                                    rename(DIRECTORY . "/" . $dd, $var . "/" . $dd);
                                }
                            }
                            break;
                        case 'Copy':
                            foreach ($filesExp as $dd) {
                                if (is_dir(DIRECTORY . "/" . $dd)) {
                                    File::copyDirectory(DIRECTORY . "/" . $dd, $var . "/" . $dd);
                                } elseif (is_file(DIRECTORY . "/" . $dd)) {
                                    copy(DIRECTORY . "/" . $dd, $var . "/" . $dd);
                                }
                            }
                            break;
                        case 'CHMOD':
                            foreach ($filesExp as $dd) {
                                if ($var >= 0 && $var <= 777) {
                                    chmod(DIRECTORY . "/" . $dd, $var);
                                }
                            }
                            break;
                        case 'Delete':
                            foreach ($filesExp as $dd) {
                                if (is_dir(DIRECTORY . "/" . $dd)) {
                                    File::deleteDirectory(DIRECTORY . "/" . $dd);
                                } elseif (is_file(DIRECTORY . "/" . $dd)) {
                                    unlink(DIRECTORY . "/" . $dd);
                                }
                            }
                    }
                    Others::redirect(URLm::url("folderView", array("dir" => DIRECTORY)));
                }
                if (isset($_GET['proc'])) {
                    switch ($_GET['proc']) {
                        case 'move':
                            if ($_GET['var'] != "") {
                                rename(DIRECTORY, $_GET['var']);
                                Others::redirect(URLm::url("folderView", array("dir" => $_GET['var'])));
                            }
                            break;
                        case 'copy':
                            if ($_GET['var'] != "") {
                                File::copyDirectory(DIRECTORY, $_GET['var']);
                                Others::redirect(URLm::url("folderView", array("dir" => $_GET['var'])));
                            }
                            break;
                        case 'create':
                            if ($_GET['var'] != "") {
                                $exp = explode(":", $_GET['var']);
                                switch ($exp['0']) {
                                    case 'f':
                                        File::makeFile(DIRECTORY . "/" . $exp[1]);
                                        break;
                                    case 'd':
                                        if ($exp[1] != 0 && $exp[1] != null) {
                                            File::makeDir(DIRECTORY . "/" . $exp[1], intval($exp[2]));
                                        } else {
                                            File::forceDirectory(DIRECTORY . "/" . $exp[1]);
                                        }
                                }
                                Others::redirect(URLm::url("folderView", array("dir" => DIRECTORY)));
                            }
                            break;
                        case 'jump':
                            if ((string) $_GET['var'] != "") {
                                $var = $_GET['var'];
                                if (is_file($var)) {
                                    Others::redirect(URLm::url("fileView", array("filePath" => realpath($var))));
                                } elseif (is_dir($var)) {
                                    Others::redirect(URLm::url("folderView", array("dir" => realpath($var))));
                                }
                            }
                            break;
                        case 'delete':
                            if (DIRECTORY != realpath($_SERVER['DOCUMENT_ROOT'])) {
                                File::deleteDirectory(DIRECTORY);
                            }
                            $dirName = explode("/", DIRECTORY);
                            array_pop($dirName);
                            $dirName = implode("/", $dirName);
                            Others::redirect(URLm::url("folderView", array("dir" => $dirName)));
                            break;
                        case 'addFav':
                            if ((string) $_GET['var'] != "") {
                                DBLite::addFavorite($_GET['var'], DIRECTORY);
                            }
                            Others::redirect(URLm::url("folderView", array("dir" => DIRECTORY)));
                            break;
                        case 'deleteFav':
                            DBLite::deleteFavorite(DIRECTORY);
                            Others::redirect(URLm::url("folderView", array("dir" => DIRECTORY)));
                            break;
                        case 'compress':
                            if ((string) $_GET['var'] != "") {
                                $zip = new ZipArchive();
                                if (!$zip->open($_GET['var'], ZipArchive::OVERWRITE)) {
                                    Others::redirect(URLm::url("folderView", array("dir" => DIRECTORY)));
                                    exit;
                                }
                                foreach (File::getFileList(DIRECTORY, array("method" => "explode")) as $File) {
                                    $FullPath = str_replace(dirname(DIRECTORY) . "/", "", $File);
                                    $zip->addFile($File, $FullPath);
                                }
                                $zip->addFromString("CreatedBy", "This zip file created by OOP File Manager\n\n\t- vtWebApp ®\n\t- veli.tasali@gmail.com");
                                $zip->close();
                                Others::redirect(URLm::url("fileView", array("filePath" => $_GET['var'])));
                            }
                            break;
                        case 'iFile':
                            $var = (string) $_REQUEST['var'];
                            if ($var != "") {
                                set_time_limit(5000);
                                $url = parse_url($var);
                                $fName = $url['path'] == "" ? $url['host'] . "_file_" . time() : $url['path'];
                                $fName = preg_replace("/([^a-zA-Z0-9._-])/si", "", $fName);
                                touch(DIRECTORY . "/" . $fName);
                                // $write = fopen(DIRECTORY."/".$fName);
                                $dt = fopen(urldecode($var), "rb");
                                if (is_file(DIRECTORY . "/" . $fName)) {
                                    fseek($dt, filesize(DIRECTORY . "/" . $fName));
                                }
                                if ($dt) {
                                    while (!feof($dt)) {
                                        file_put_contents(DIRECTORY . "/" . $fName, fread($dt, 8192), FILE_APPEND);
                                    }
                                    fclose($dt);
                                }
                                // $source = Others::quickCurl(urldecode($var));
                                Others::redirect(URLm::url("fileView", array("filePath" => DIRECTORY . "/" . $fName)));
                            }
                            unset($var);
                    }
                }
                if (DBLite::isFavorite(DIRECTORY)) {
                    $Shortcuts = '<a href="' . URLm::url("proc", array("dir" => DIRECTORY, "procName" => "deleteFav")) . '">Fav. Çıkart</a>';
                } else {
                    $Shortcuts = '<a href="javascript:sendPrompt(\'Favori Adı Belirleyin\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "addFav")) . '\', {value: \'' . basename(DIRECTORY) . '\'});">Fav. Ekle</a>';
                }
                $Shortcuts .= '
<a href="' . URLm::url("upload", array("dir" => DIRECTORY)) . '">Yükle</a>
<a href="javascript:sendPrompt(\'Bir dosya belirtin.\\n* Kısır döngüleri önlemek için aynı klasörler ile çakıştırmayın\\n\\nDosya: /sdcard/Dosya.zip\\nSıkıştır: /sdcard \\nYukarıdaki gibi bir durum kısır döngüye yol açabilir\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "compress")) . '\', {value: \'' . DIRECTORY . '.zip' . '\'});">Sıkıştır</a>
<a href="javascript:sendPrompt(\'Başka sunuculardan dosya indirin\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "iFile")) . '\', {value:\'http://\', urlEncode: true});">i-Dosya</a>
<a href="javascript:sendPrompt(\'Şu Dosya Yoluna Atla\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "jump")) . '\', {value: \'' . DIRECTORY . '\', urlEncode: true});">Atla</a>
<a href="javascript:checkConfirm(\'Bu klasörü silmek üzeresiniz\\n' . DIRECTORY . '\', \'' . URLm::url("proc", array("dir" => DIRECTORY, "procName" => "delete")) . '\');">Sil</a>
<a href="javascript:sendPrompt(\'Kopyala\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "copy")) . '\', {value: \'' . DIRECTORY . '-Copy\', urlEncode: true});">Kopyala</a>
<a href="javascript:sendPrompt(\'Taşı: \\nYeni tam klasör yolunu girin\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "move")) . '\', {value: \'' . DIRECTORY . '\', urlEncode: true});">Taşı</a>
<a href="javascript:sendPrompt(\'f - Dosya , d - Klasör\\nÖrnek: f:dosya_adi\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "create")) . '\', {value: \'\'});">Oluştur</a>
				';
                $favsRes = DBLite::query("SELECT * FROM `favorites`");
                if (DBLite::querySingle("SELECT * FROM `favorites`", TRUE)) {
                    $Favorites = null;
                    while ($Favs = $favsRes->fetchArray()) {
                        $Favorites .= Html::writef("DirListSC", array("dir" => $Favs['value'], "dirname" => $Favs['name']));
                    }
                } else {
                    $Favorites = Html::export("NoFavMsg");
                }
                Page::write("Top", array("Title" => "Klasör \"" . basename(DIRECTORY) . "\"", "CSSFile" => Settings::get("CSSFilePath"), "BodyTop" => Page::returnPage("Shortcuts", array("SiteName" => "FileManager v1.0", "ShortcutsLinks" => $Shortcuts, "Contents" => Html::writef("Title", array("Title" => "Aygıt Listesi")) . $Favorites . Html::writef("Title", array("Title" => "Disk Özeti")) . Html::writef("DirInfo", array("info" => "Toplam", "value" => File::sizeExpression(File::diskSpace(DIRECTORY, TOTAL)))) . Html::writef("DirInfo", array("info" => "Kullanılan", "value" => File::sizeExpression(File::diskSpace(DIRECTORY, USED)))) . Html::writef("DirInfo", array("info" => "Kullanılabilir", "value" => File::sizeExpression(File::diskSpace(DIRECTORY, FREE)))) . Html::writef("DirInfo", array("info" => "Dol. Oranı", "value" => ceil(File::diskSpace(DIRECTORY, PER_USED)) . "%")) . Html::writef("DirInfo", array("info" => "Boş. Oranı", "value" => ceil(File::diskSpace(DIRECTORY, PER_FREE)) . "%"))))));
                $files = array();
                $folders = array();
                if (is_readable(DIRECTORY)) {
                    $openDir = opendir(DIRECTORY);
                    while ($Name = readdir($openDir)) {
                        $fName = DIRECTORY . "/" . $Name;
                        if ($Name == "." || $Name == "..") {
                            continue;
                        }
                        if (is_file($fName)) {
                            $files[] = $Name;
                        }
                        if (is_dir($fName)) {
                            $folders[] = $Name;
                        }
                    }
                }
                $Counter = array("files" => count($files), "folders" => count($folders));
                $Counter['total'] = $Counter['files'] + $Counter['folders'];
                if ($Counter['total'] == "") {
                    Html::write("Info", "Bu klasörde içerik bulunmuyor");
                } else {
                    echo Html::writef("Title", array("Title" => basename(DIRECTORY) != "" ? strtoupper(basename(DIRECTORY)) : "İsim Yok"));
                }
                echo '
<script>Selector.PRO_FOLDER = "' . DIRECTORY . '";</script>
<form name="multiProc" action="' . URLm::url("folderView", array("dir" => DIRECTORY)) . '" method="post">
	<input type="hidden" name="variable" value="" />
	<input type="hidden" name="procName" value="" />
	<input type="hidden" name="filesArray" value="" />
				';
                if ($Counter['folders'] > 0) {
                    sort($folders);
                    foreach ($folders as $folder) {
                        $fDir = DIRECTORY . "/" . $folder;
                        Html::cloneObject("DirList", "currDirItem");
                        Html::editObject("currDirItem", array("id" => $folder), ARG);
                        if (!is_readable($fDir)) {
                            Html::editObject("currDirItem", array("onMouseOver" => "", "onMouseOut" => ""), ARG);
                        }
                        echo Html::writef("currDirItem", array("dir" => $fDir, "dirname" => $folder, "extras" => '<input type="checkbox" id="input' . $folder . '" name="selected" value="' . $folder . '" onClick="Selector.select(\'' . $folder . '\', Selector.SELECT_AUTO)"/> &nbsp; '));
                    }
                }
                if ($Counter['files'] > 0) {
                    sort($files);
                    foreach ($files as $file) {
                        $fFile = DIRECTORY . "/" . $file;
                        $fileSize = File::sizeExpression(fileSize($fFile));
                        $fileinfo = pathinfo($fFile);
                        if (isset($fileinfo['extension']) && ($fileinfo['extension'] == "jpg" || $fileinfo['extension'] == "png" || $fileinfo['extension'] == "gif")) {
                            Html::editObject("FileListImg", array("id" => $file), ARG);
                            $isize = getimagesize($fFile);
                            echo Html::writef("FileListImg", array("resolution" => $isize[0] . "x" . $isize[1], "img" => URLm::url("imgCache", array("file" => urlencode($fFile))), "size" => $fileSize, "filename" => $file, "filePath" => $fFile, "extras" => '<input type="checkbox" id="input' . $file . '" name="selected" value="' . $file . '" onClick="Selector.select(\'' . $file . '\', Selector.SELECT_AUTO)"/> &nbsp; '));
                        } else {
                            Html::editObject("FileList", array("id" => $file), ARG);
                            echo Html::writef("FileList", array("size" => $fileSize, "filename" => $file, "filePath" => $fFile, "extras" => '<input type="checkbox" id="input' . $file . '" name="selected" value="' . $file . '" onClick="Selector.select(\'' . $file . '\', Selector.SELECT_AUTO)"/> &nbsp; '));
                        }
                    }
                }
                $NavigateDir = null;
                if (is_dir(DIRECTORY)) {
                    if (DIRECTORY == "/") {
                        $NavigateDir .= '<a href="' . URLm::url("folderView", array("dir" => "/")) . '">/ {Kök} </a>';
                    } else {
                        $directoryPath = File::pathListing(DIRECTORY);
                        $countDP = 0;
                        foreach ($directoryPath as $dP) {
                            $dP[0] = $dP[0] == "" ? '<span style="color: green;">/</span>' : $dP[0];
                            $dP[1] = $dP[1] == "" ? '/' : $dP[1];
                            if ($countDP > 0) {
                                $NavigateDir .= ' <b>&gt;</b> ';
                            }
                            $NavigateDir .= '<a href="' . URLm::url("folderView", array("dir" => $dP[1])) . '">' . $dP[0] . '</a>';
                            $countDP++;
                        }
                    }
                }
                Page::write("Bottom", array("Extras" => '</form>', "DirNavigation" => $NavigateDir));
                break;
            case 'file':
                define("DIRECTORY", !is_file($_GET['directory']) ? Others::redirect("?") : realpath(urldecode($_GET['directory'])));
                define("EDIRECTORY", urlencode(DIRECTORY));
                $dirName = explode("/", DIRECTORY);
                array_pop($dirName);
                define("ODIRECTORY", implode("/", $dirName));
                unset($dirName);
                define("FILEINODE", fileinode(DIRECTORY));
                define("FILENAME", basename(DIRECTORY));
                define("FILEBYTE", filesize(DIRECTORY));
                define("FILECTIME", filectime(DIRECTORY));
                define("FILEATIME", fileatime(DIRECTORY));
                define("FILEOWNER", fileowner(DIRECTORY));
                define("FILETYPE", strtolower(substr(strrchr(FILENAME, "."), 1)));
                if (isset($_GET['proc'])) {
                    switch ($_GET['proc']) {
                        case 'move':
                            if ($_GET['var'] != "") {
                                rename(DIRECTORY, $_GET['var']);
                                Others::redirect(URLm::url("fileView", array("filePath" => $_GET['var'])));
                            }
                            break;
                        case 'copy':
                            if ($_GET['var'] != "") {
                                copy(DIRECTORY, $_GET['var']);
                                Others::redirect(URLm::url("fileView", array("filePath" => $_GET['var'])));
                            }
                            break;
                        case 'delete':
                            unlink(DIRECTORY);
                            Others::redirect(URLm::url("folderView", array("dir" => ODIRECTORY)));
                            break;
                        case 'download':
                            Others::redirect(URLm::url("imgCache", array("file" => DIRECTORY)));
                            break;
                        case 'makeApart':
                            if ($_GET['var'] != "") {
                                $currentKB = FILEBYTE / 1024;
                                $var = (int) $_GET['var'];
                                if ($currentKB > $var && $var > 1) {
                                    $parts = array();
                                    $dt = fopen(DIRECTORY, "rd");
                                    $partInfoFile = DIRECTORY . ".partInfo";
                                    touch($partInfoFile);
                                    file_put_contents($partInfoFile, "Aparted file notifier. Use this file when unaparting");
                                    for ($i = 0; $i < $currentKB; $i += $var) {
                                        if ($i + $var > $currentKB) {
                                            $parts[] = $currentKB * 1024;
                                        } else {
                                            $parts[] = ($i + $var) * 1024;
                                        }
                                    }
                                    foreach ($parts as $pNum => $currSize) {
                                        $partFile = DIRECTORY . ".part" . $pNum;
                                        touch($partFile);
                                        if ($dt) {
                                            while (ftell($dt) <= $currSize && !feof($dt)) {
                                                file_put_contents($partFile, fread($dt, 8192), FILE_APPEND);
                                            }
                                        }
                                    }
                                    fclose($dt);
                                }
                                Others::redirect(URLm::url("fileView", array("filePath" => $partInfoFile)));
                            }
                            break;
                        case 'unapart':
                            $fileInfo = pathinfo(DIRECTORY);
                            $pref = $fileInfo['dirname'] . "/" . $fileInfo['filename'];
                            $presearch = glob($pref . ".part*");
                            if (is_file($pref)) {
                                rename($pref, $pref . "_moved");
                            } else {
                                touch($pref);
                            }
                            for ($i = 0; $i <= count($presearch); $i++) {
                                $tf = $pref . ".part" . $i;
                                if (!is_file($tf)) {
                                    break;
                                }
                                $dt = fopen($tf, "rd");
                                if ($dt) {
                                    while (!feof($dt)) {
                                        file_put_contents($pref, fread($dt, 8192), FILE_APPEND);
                                    }
                                    fclose($dt);
                                }
                            }
                            Others::redirect(URLm::url("fileView", array("filePath" => $pref)));
                            break;
                        case 'deleteParts':
                            $fileInfo = pathinfo(DIRECTORY);
                            $pref = $fileInfo['dirname'] . "/" . $fileInfo['filename'] . ".part";
                            $presearch = glob($pref . "*");
                            foreach ($presearch as $path) {
                                if (is_file($path)) {
                                    @unlink($path);
                                }
                            }
                            Others::redirect(URLm::url("folderView", array("dir" => ODIRECTORY)));
                            break;
                        case 'uncompress':
                            if ($_GET['var'] != "" && is_dir($_GET['var'])) {
                                $Zip = new ZipArchive();
                                $isZip = $Zip->open(DIRECTORY);
                                if ($isZip) {
                                    $l = $Zip->extractTo(realpath($_GET['var']));
                                    if ($l) {
                                        Others::redirect(URLm::url("folderView", array("dir" => $_GET['var'])));
                                    }
                                }
                            }
                    }
                }
                $Shortcuts = '
<a href="javascript:sendPrompt(\'Şu Dosya Yoluna Atla\', \'' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "jump")) . '\', {value: \'' . DIRECTORY . '\'});">Atla</a>
<a href="javascript:checkConfirm(\'Bu dosyayı silmek üzeresiniz\\n' . DIRECTORY . '\', \'' . URLm::url("procFile", array("dir" => DIRECTORY, "procName" => "delete")) . '\');">Sil</a>
<a href="javascript:sendPrompt(\'Kopyala\', \'' . URLm::url("procFileVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "copy")) . '\', {value: \'' . DIRECTORY . '-Copy\'});">Kopyala</a>
<a href="javascript:sendPrompt(\'Taşı: \\nYeni tam dosya yolunu girin\', \'' . URLm::url("procFileVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "move")) . '\', {value: \'' . DIRECTORY . '\'});">Taşı</a>
<a href="' . URLm::url("procFile", array("dir" => DIRECTORY, "procName" => "download")) . '">İndir</a>
<a href="#" onClick="window.open(\'' . URLm::url("fileEditor", array("file" => DIRECTORY)) . '\');">Düzenle</a>
<a href="javascript:sendPrompt(\'Dosyayı parçalara ayırın (kB cinsinden boyut girin)\', \'' . URLm::url("procFileVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "makeApart")) . '\', {value: \'20000\'});">Ayır</a>
				';
                if (FILETYPE == "zip") {
                    $Shortcuts .= '
<a href="javascript:sendPrompt(\'Klasöre Çıkart\', \'' . URLm::url("procFileVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "uncompress")) . '\', {value: \'' . DIRECTORY . '\'});">Çıkart</a>
					';
                }
                if (FILETYPE == "partinfo") {
                    $Shortcuts .= '
<a href="' . URLm::url("procFile", array("dir" => DIRECTORY, "procName" => "unapart")) . '">Birleştir</a>
<a href="javascript:checkConfirm(\'Parçalanmış dosyayı parçaları ile birlikte silmek üzeresiniz\', \'' . URLm::url("procFile", array("dir" => DIRECTORY, "procName" => "deleteParts")) . '\');">Parçaları Sil</a>
					';
                }
                $favsRes = DBLite::query("SELECT * FROM `favorites`");
                $Favorites = null;
                if (DBLite::querySingle("SELECT * FROM `favorites`", TRUE)) {
                    while ($Favs = $favsRes->fetchArray()) {
                        $Favorites .= Html::writef("DirListSC", array("dir" => $Favs['value'], "dirname" => $Favs['name']));
                    }
                } else {
                    $Favorites = Html::export("NoFavMsg");
                }
                Page::write("Top", array("Title" => "Dosya \"" . FILENAME . "\"", "CSSFile" => Settings::get("CSSFilePath"), "BodyTop" => Page::returnPage("Shortcuts", array("SiteName" => "Dosyayı Görüntüle", "ShortcutsLinks" => $Shortcuts, "Contents" => Html::writef("Title", array("Title" => "Aygıt Listesi")) . $Favorites . Html::writef("Title", array("Title" => "Disk Özeti")) . Html::writef("DirInfo", array("info" => "Toplam", "value" => File::sizeExpression(File::diskSpace(ODIRECTORY, TOTAL)))) . Html::writef("DirInfo", array("info" => "Kullanılan", "value" => File::sizeExpression(File::diskSpace(ODIRECTORY, USED)))) . Html::writef("DirInfo", array("info" => "Kullanılabilir", "value" => File::sizeExpression(File::diskSpace(ODIRECTORY, FREE)))) . Html::writef("DirInfo", array("info" => "Dol. Oranı", "value" => ceil(File::diskSpace(ODIRECTORY, PER_USED)) . "%")) . Html::writef("DirInfo", array("info" => "Boş. Oranı", "value" => ceil(File::diskSpace(ODIRECTORY, PER_FREE)) . "%"))))));
                if (is_file(DIRECTORY)) {
                    if (DIRECTORY == "/") {
                        $NavigateDir .= '<a href="' . URLm::url("folderView", array("dir" => "/")) . '">/ {Kök} </a>';
                    } else {
                        $directoryPath = File::pathListing(DIRECTORY);
                        $countDP = 0;
                        $NavigateDir = null;
                        foreach ($directoryPath as $dP) {
                            $dP[0] = $dP[0] == "" ? '<span style="color: green;">/</span>' : $dP[0];
                            $dP[1] = $dP[1] == "" ? '/' : $dP[1];
                            if ($countDP > 0) {
                                $NavigateDir .= ' <b>&gt;</b> ';
                            }
                            $NavigateDir .= '<a href="' . URLm::url("folderView", array("dir" => $dP[1])) . '">' . $dP[0] . '</a>';
                            $countDP++;
                        }
                    }
                }
                if (FILETYPE == "partinfo") {
                    echo Html::write("Info", "Parçalanmış Dosya Bilgi Dosyası (*.partInfo)");
                }
                echo Html::writef("Title", array("Title" => basename(DIRECTORY) != "" ? strtoupper(basename(DIRECTORY)) : "İsim Yok"));
                echo Html::writef("FileInfo", array("info" => "Dosya Boyutu", "value" => File::sizeExpression(FILEBYTE)));
                echo Html::writef("FileInfo", array("info" => "Değiştirilme Tarihi", "value" => date("Y/m/d H:i", FILECTIME)));
                echo Html::writef("FileInfo", array("info" => "Son Erişim Tarihi", "value" => date("Y/m/d H:i", FILEATIME)));
                echo Html::writef("FileInfo", array("info" => "Düğüm Numarası", "value" => FILEINODE));
                echo Html::writef("FileInfo", array("info" => "Dosya Sahibi", "value" => FILEOWNER));
                if (FILETYPE == "partinfo") {
                    $fileInfo = pathinfo(DIRECTORY);
                    $pref = $fileInfo['dirname'] . "/" . $fileInfo['filename'];
                    $presearch = glob($pref . ".part*");
                    Html::cloneObject("List", "FileM");
                    Html::editObject("FileM", array(), '<a href="%eval{return URLm::url("fileView", array("filePath" => "%{file}%"));}%">%{(basename)file}% &nbsp;</a> <small>%{size}%</small>');
                    if (count($presearch) > 0) {
                        echo "<br />\n" . Html::writef("Title", array("Title" => "İlişkili Olabilecek Dosyalar"));
                        foreach ($presearch as $fid) {
                            echo Html::writef("FileM", array("file" => $fid, "size" => filesize($fid) . " B"));
                        }
                    }
                }
                if (FILEBYTE < 102400 && (FILETYPE == "php" || FILETYPE == "txt" || FILETYPE == "html" || FILETYPE == "js" || FILETYPE == "xml" || FILETYPE == "dump")) {
                    echo Html::writef("List", array("Content" => str_replace(array("\n", "\t"), array('<br />', " &nbsp; &nbsp; "), String::escapeHTML(file_get_contents(DIRECTORY)))));
                }
                if (FILETYPE == "jpg" || FILETYPE == "png" || FILETYPE == "gif") {
                    Html::cloneObject("List", "Img");
                    Html::editObject("Img", array("style" => "text-align: center;"), '<img src="%{img}%" style="width: 250px;" />
					');
                    echo Html::writef("Img", array("img" => URLm::url("imgCache", array("file" => DIRECTORY))));
                }
                if (FILETYPE == "mp3" || FILETYPE == "m4a" || FILETYPE == "aac" || FILETYPE == "ogg") {
                    Html::cloneObject("List", "MP3");
                    Html::editObject("MP3", array("style" => "text-align: center;"), '<audio style="width: 90%;" controls>
							<source src="%{src}%">
						</audio>
						');
                    echo Html::writef("MP3", array("src" => URLm::url("imgCache", array("file" => DIRECTORY))));
                }
                if (FILETYPE == "mp4" || FILETYPE == "avi" || FILETYPE == "m4a") {
                    Html::cloneObject("List", "VideoArea");
                    Html::editObject("VideoArea", array("style" => "text-align: center;"), '<video style="width: 90%;" controls>
							<source src="%{src}%">
						</video>
						');
                    echo Html::writef("VideoArea", array("src" => URLm::url("imgCache", array("file" => DIRECTORY))));
                }
                Page::write("Bottom", array("DirNavigation" => $NavigateDir));
                break;
            case 'upload':
                define("DIRECTORY", !is_dir($_GET['directory']) ? Others::redirect("?") : realpath($_GET['directory']));
                // define ( "DIRECTORY", ((! is_dir ( $_GET ['directory'] )) ? realpath ( $_SERVER ['DOCUMENT_ROOT'] ) : realpath ( $_GET ['directory'] )) );
                define("EDIRECTORY", urlencode(DIRECTORY));
                $Shortcuts = '
<a href="' . URLm::url("folderView", array("dir" => DIRECTORY)) . '">Geri Dön</a>
<a href="javascript:alert(\'Yükleyeceğiniz dosyayı seçin. Ardından yükle butonuna basın ve sabırlı olun dosya yüklendikten sonra yönlendirileceksiniz\');">Nasıl Yüklerim?</a>
				';
                $favsRes = DBLite::query("SELECT * FROM `favorites`");
                $Favorites = null;
                if (DBLite::querySingle("SELECT * FROM `favorites`", TRUE)) {
                    while ($Favs = $favsRes->fetchArray()) {
                        $Favorites .= Html::writef("DirListSC", array("dir" => $Favs['value'], "dirname" => $Favs['name']));
                    }
                } else {
                    $Favorites = Html::export("NoFavMsg");
                }
                if (isset($_FILES['file'])) {
                    $baseName = str_replace(array("\"", "'", "{", "}", "^", "<", ">"), "", $_FILES['file']['name']);
                    $tp = DIRECTORY . "/" . $baseName;
                    if (is_file($tp)) {
                        rename($tp, $tp . "_old");
                    }
                    move_uploaded_file($_FILES['file']['tmp_name'], $tp);
                    Others::redirect(URLm::url("folderView", array("dir" => DIRECTORY)));
                }
                Page::write("Top", array("Title" => "Klasör.Upload \"" . basename(DIRECTORY) . "\"", "CSSFile" => Settings::get("CSSFilePath"), "BodyTop" => Page::returnPage("Shortcuts", array("SiteName" => "FileManager.Upload", "ShortcutsLinks" => $Shortcuts, "Contents" => Html::writef("Title", array("Title" => "Aygıt Listesi")) . $Favorites . Html::writef("Title", array("Title" => "Disk Özeti")) . Html::writef("DirInfo", array("info" => "Toplam", "value" => File::sizeExpression(File::diskSpace(DIRECTORY, TOTAL)))) . Html::writef("DirInfo", array("info" => "Kullanılan", "value" => File::sizeExpression(File::diskSpace(DIRECTORY, USED)))) . Html::writef("DirInfo", array("info" => "Kullanılabilir", "value" => File::sizeExpression(File::diskSpace(DIRECTORY, FREE)))) . Html::writef("DirInfo", array("info" => "Dol. Oranı", "value" => ceil(File::diskSpace(DIRECTORY, PER_USED)) . "%")) . Html::writef("DirInfo", array("info" => "Boş. Oranı", "value" => ceil(File::diskSpace(DIRECTORY, PER_FREE)) . "%"))))));
                echo Html::writef("Title", array("Title" => "Dosya Yükleyin")) . '
<form enctype="multipart/form-data" action="' . URLm::url("upload", array("dir" => DIRECTORY)) . '" method="POST">
					' . Html::export("List", '
	<input name="file" type="file" style="width: 80%; margin-bottom: 8px;" />
					', array("style" => "text-align: center;")) . Html::writef("ListSubmit", array("Content" => '
	<input type="submit" value="Yükle" />
					')) . '
</form>
<br />
				' . Html::writef("Title", array("Title" => "i-Dosya ile Karşı Sunucudan Yükle")) . '
<form enctype="multipart/form-data" action="' . URLm::url("procVar", array("dir" => DIRECTORY, "variable" => "%s", "procName" => "iFile")) . '" method="POST">
					' . Html::export("List", '
	<input name="var" type="text" style="width: 80%; margin-bottom: 8px;" value="http://" />
					', array("style" => "text-align: center;")) . Html::writef("ListSubmit", array("Content" => '
	<input type="submit" value="Bağlan ve İndir" />
					')) . '
</form>
				';
                $NavigateDir = null;
                if (is_dir(DIRECTORY)) {
                    if (DIRECTORY == "/") {
                        $NavigateDir = '<a href="' . URLy::url("folderView", array("dir" => "/")) . '">/ {Kök} </a>';
                    } else {
                        $directoryPath = File::pathListing(DIRECTORY);
                        $countDP = 0;
                        foreach ($directoryPath as $dP) {
                            $dP[0] = $dP[0] == "" ? '<span style="color: green;">/</span>' : $dP[0];
                            $dP[1] = $dP[1] == "" ? '/' : $dP[1];
                            if ($countDP > 0) {
                                $NavigateDir .= ' <b>&gt;</b> ';
                            }
                            $NavigateDir .= '<a href="' . URLm::url("folderView", array("dir" => $dP[1])) . '">' . $dP[0] . '</a>';
                            $countDP++;
                        }
                    }
                }
                Page::write("Bottom", array("DirNavigation" => $NavigateDir));
        }
    }
Example #12
0
 protected function copyAssets($in, $out)
 {
     $out_dir = dirname($out);
     \File::makeDirectory($out_dir, 0777, true, true);
     \File::copyDirectory($in, $out);
     return true;
 }
Example #13
0
/**
 * Copy a folder
 * @param string $src Source folder
 * @param string $dest Destination folder
 */
function zbase_file_copy_folder($src, $dest)
{
    \File::copyDirectory($src, $dest);
}
Example #14
0
 public function copyJs()
 {
     if (!is_dir(public_path() . '/js')) {
         \File::copyDirectory(__DIR__ . '/../../templates/js', public_path() . '/js');
     }
 }
Example #15
0
/**
 * Copy directory to another directory
 * @param string $src
 * @param string $dst
 * @param array|mixed $options
 */
function zbase_directory_copy($src, $dst, $options = null)
{
    \File::copyDirectory($src, $dst, $options);
}
Example #16
0
 /**
  *  Create the view files.
  *
  * @return bool
  */
 public function createView()
 {
     $sourceDir = base_path('resources/views/admin/authproviders');
     $destinationDir = dirname($sourceDir) . DIRECTORY_SEPARATOR . strtolower(str_plural($this->class));
     return \File::copyDirectory($sourceDir, $destinationDir);
 }
Example #17
0
 protected function copyThemeFiles($theme)
 {
     $this->info('* Copy theme files to app folders: ');
     if ($this->option('path')) {
         $this->path = $this->option('path');
     }
     $themePath = base_path() . $this->path . '/' . $theme;
     $this->info('  - components');
     \File::copyDirectory($themePath . '/app/Components', base_path() . '/app/Components');
     $this->info('  - events');
     \File::copyDirectory($themePath . '/app/Events', base_path() . '/app/Events');
     $this->info('  - queues');
     \File::copyDirectory($themePath . '/app/Queues', base_path() . '/app/Queues');
     $this->info('  - assets');
     \File::copyDirectory($themePath . '/assets', base_path() . '/public/assets/themes/' . $theme);
     $this->info('  - views');
     \File::copyDirectory($themePath . '/views', base_path() . '/resources/themes/' . $theme);
     $this->info('  - language files');
     \File::copyDirectory($themePath . '/lang', base_path() . '/resources/lang');
     $this->actually_did_it = true;
 }
 public function postStore()
 {
     $sid = \Input::get('id');
     /*
      * Validate
      */
     $rules = array('image' => 'mimes:jpg,jpeg,png,gif|max:500', 'name' => 'required|unique:medias,name' . (isset($sid) ? ',' . $sid : ''), 'short_description' => 'required', 'sku' => 'required|alpha_dash|unique:medias,sku' . (isset($sid) ? ',' . $sid : ''), 'category_id' => 'required', 'tags' => 'regex:/^[a-z,0-9 -]+$/i');
     $validation = \Validator::make(\Input::all(), $rules);
     if ($validation->passes()) {
         $name = \Input::get('name');
         $sku = \Input::get('sku');
         $short_description = \Input::get('short_description');
         $long_description = \Input::get('long_description');
         $image = \Input::file('image');
         $featured = \Input::get('featured') == '' ? false : true;
         $active = \Input::get('active') == '' ? false : true;
         $category_id = \Input::get('category_id');
         $tags = \Input::get('tags');
         $media = isset($sid) ? Media::find($sid) : new Media();
         if ($media == null) {
             $errors = new \Illuminate\Support\MessageBag();
             $errors->add('editError', "The media cannot be found because it does not exist or may have been deleted.");
             return redirect('/admin/medias')->withErrors($errors);
         }
         $media->name = $name;
         $media->sku = $sku;
         $media->short_description = $short_description;
         $media->long_description = $long_description;
         $media->featured = $featured;
         $media->active = $active;
         if (isset($sid)) {
             // Check if category has changed
             if ($media->category_id != $category_id) {
                 $old_cat_folder = public_path() . '/assets/medias/' . $media->category_id . '/' . $sid;
                 $new_cat_folder = public_path() . '/assets/medias/' . $category_id . '/' . $sid;
                 // Create the directory
                 if (!file_exists($new_cat_folder)) {
                     mkdir($new_cat_folder, 0777, true);
                 }
                 // Copy existing media to new category
                 \File::copyDirectory($old_cat_folder, $new_cat_folder);
                 // Delete old media folder
                 \File::deleteDirectory($old_cat_folder);
             }
         } else {
             $media->path = 'broken.pdf';
         }
         $media->category_id = $category_id;
         // Create or save changes
         $media->save();
         // Save translations
         $translations = \Config::get('redminportal::translation');
         foreach ($translations as $translation) {
             $lang = $translation['lang'];
             if ($lang == 'en') {
                 continue;
             }
             $translated_content = array('name' => \Input::get($lang . '_name'), 'short_description' => \Input::get($lang . '_short_description'), 'long_description' => \Input::get($lang . '_long_description'));
             // Check if lang exist
             $translated_model = $media->translations->where('lang', $lang)->first();
             if ($translated_model == null) {
                 $translated_model = new Translation();
             }
             $translated_model->lang = $lang;
             $translated_model->content = json_encode($translated_content);
             $media->translations()->save($translated_model);
         }
         if (!empty($tags)) {
             // Delete old tags
             $media->tags()->detach();
             // Save tags
             foreach (explode(',', $tags) as $tagName) {
                 Tag::addTag($media, $tagName);
             }
         }
         if (\Input::hasFile('image')) {
             //Upload the file
             $helper_image = new RImage();
             $filename = $helper_image->upload($image, 'medias/' . $media->id, true);
             if ($filename) {
                 // create photo
                 $newimage = new Image();
                 $newimage->path = $filename;
                 // save photo to the loaded model
                 $media->images()->save($newimage);
             }
         }
         //if it validate
     } else {
         if (isset($sid)) {
             return redirect('admin/medias/edit/' . $sid)->withErrors($validation)->withInput();
         } else {
             return redirect('admin/medias/create')->withErrors($validation)->withInput();
         }
     }
     return redirect('admin/medias');
 }