/** * Generate the API documentation using the markdown and include files * * @param $folder * @return false|null */ public function generate($folder) { $source_dir = $folder . '/source'; if (!is_dir($source_dir)) { return false; } $parser = new Parser(); $document = $parser->parse(file_get_contents($source_dir . '/index.md')); $frontmatter = $document->getYAML(); $html = $document->getContent(); $renderer = new BladeRenderer([__DIR__ . '/../resources/views'], ['cache_path' => $source_dir . '/_tmp']); // Parse and include optional include markdown files if (isset($frontmatter['includes'])) { foreach ($frontmatter['includes'] as $include) { if (file_exists($include_file = $source_dir . '/includes/_' . $include . '.md')) { $document = $parser->parse(file_get_contents($include_file)); $html .= $document->getContent(); } } } $output = $renderer->render('index', ['page' => $frontmatter, 'content' => $html]); file_put_contents($folder . '/index.html', $output); // Copy assets rcopy($source_dir . '/assets/images/', $folder . '/images'); rcopy($source_dir . '/assets/stylus/fonts/', $folder . '/css/fonts'); }
function rcopy($source, $dest, $folderPermission = 0777) { $result = false; if (is_dir($source)) { if (!is_dir($dest)) { @mkdir($dest, $folderPermission); chmod($dest, $folderPermission); } $result = file_exists($dest) && is_dir($dest); if (substr($source, -1) != '/') { $source = $source . "/"; } if (substr($dest, -1) != '/') { $dest = $dest . "/"; } $dirHandle = opendir($source); while ($file = readdir($dirHandle)) { if ($file != '.' && $file != '..') { if (is_dir($source . $file)) { $result = rcopy($source . $file, $dest . $file, $folderPermission); } else { if ('.htaccess' == $file) { $result = copy($source . $file, $dest . $file); } } } } closedir($dirHandle); } return $result; }
function rcopy($src, $dst) { if (file_exists($dst)) { //rrmdir ( $dst ); } if (is_dir($src)) { $files = scandir($src); mkdir($dst); foreach ($files as $file) { if ($file != '.' && $file != '..') { rcopy($src . '/' . $file, $dst . '/' . $file); rrmdir($src . '/' . $file); } $iterator = new FilesystemIterator($src); $isDirEmpty = !$iterator->valid(); if ($isDirEmpty) { rmdir($src); } } } else { if (file_exists($src)) { copy($src, $dst); } } }
function rcopy($src, $dest) { // If source is not a directory stop processing if (!is_dir($src)) { return false; } // If the destination directory does not exist create it if (!is_dir($dest)) { if (!mkdir($dest)) { // If the destination directory could not be created stop processing return false; } } // Open the source directory to read in files $i = new DirectoryIterator($src); foreach ($i as $f) { if ($f->isFile()) { copy($f->getRealPath(), "{$dest}/" . $f->getFilename()); } else { if (!$f->isDot() && $f->isDir()) { rcopy($f->getRealPath(), "{$dest}/{$f}"); } } } }
function copyFiles($files, &$result) { foreach ($files as $key => $file) { if (is_int($key)) { $key = $file; } if (is_dir(ROOT . '/' . $key)) { $result->{$key} = @rcopy(ROOT . '/' . $key, BUILD . '/' . $file); } elseif (is_file(ROOT . '/' . $key)) { $result->{$key} = @copy(ROOT . '/' . $key, BUILD . '/' . $file); } i($result->{$key}, $key); } }
function file_put_contents_backup($filename, $data, $basepath = '.backup' . DIRECTORY_SEPARATOR) { global $file_put_contents_backup__counter; if (file_exists($filename)) { $bakfile = $filename; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && isset($bakfile[2]) && $bakfile[2] == ':') { $bakfile[2] = DIRECTORY_SEPARATOR; } $target = fakepath($basepath . $bakfile . '.' . date('Y-m-d--H-i-s') . '--' . ++$file_put_contents_backup__counter . '--' . md5(rand()) . '.bak'); if (!rcopy($filename, $target)) { trigger_error('copy ' . $filename . ' to ' . $bakfile . ' for backup failed', E_USER_NOTICE); } } return file_put_contents($filename, $data); }
function rcopy($src, $dst) { $dir = opendir($src); @mkdir($dst); while (false !== ($file = readdir($dir))) { if ($file != '.' and $file != '..') { if (is_dir($src . '/' . $file)) { rcopy($src . '/' . $file, $dst . '/' . $file); } else { copy($src . '/' . $file, $dst . '/' . $file); } } } closedir($dir); }
function rcopy($src, $dst) { if (is_dir($src)) { mkdir($dst); $files = scandir($src); foreach ($files as $file) { if ($file != "." && $file != "..") { rcopy("{$src}/{$file}", "{$dst}/{$file}"); } } } else { if (file_exists($src)) { copy($src, $dst); } } }
protected function _registerServices() { $loader = $this->loader; $dirs = $this->loader->getConfigDirs('../'); $this->di->set(Service::LOADER, function () use($loader) { return $loader; }, true); $theme = 'default/'; //$theme = 'javj/' ; $this->di->set(Service::VIEW, function () use($dirs, $theme) { $view = new \Phalcon\Mvc\View(); $view->setLayoutsDir('../../../' . $dirs->ui->themes . $theme); $view->setPartialsDir('../../../' . $dirs->ui->themes . $theme . 'partials/'); $view->setTemplateAfter('main'); $view->hook = new Hook(); //TODO manage themes if (is_dir($dirs->ui->themes . $theme . 'assets/')) { rcopy($dirs->ui->themes . $theme . 'assets/', $dirs->assets->themes . $theme, true); } return $view; }, true); $this->di->set(Service::THEME_NAME, function () use($theme) { return str_replace('/', '', $theme); }, true); $this->di->set(Service::URL, function () use($dirs) { $url = new \Phalcon\Mvc\Url(); $url->setBaseUri($dirs->base->uri); return $url; }, true); $this->di->set(Service::ROUTER, function () { $router = new Router(false); $router->add('core/ui/themes/default/', array('controller' => 'index'))->setName('theme'); return $router; }, true); $this->di->set(Service::DISPATCHER, function () { $dispatcher = new \Phalcon\Mvc\Dispatcher(); return $dispatcher; }, true); $this->di->set(Service::VOLT, function ($view, $di) use($dirs) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $volt->setOptions(array("compiledPath" => $dirs->cache->volt)); return $volt; }, true); $this->di->set(Service::DB, function () { return $this->loader->getDbConnection(self::$_token); }); }
function rcopy($src, $dst) { if (file_exists($dst)) { rrmdir($dst); } if (is_dir($src)) { mkdir($dst); $files = array_diff(scandir($src), array(".", "..")); foreach ($files as $file) { rcopy("{$src}/{$file}", "{$dst}/{$file}"); } } else { if (file_exists($src)) { copy($src, $dst); } } }
function rcopy($src, $dest) { if (!is_dir($src)) { return false; } if (!is_dir($dest)) { if (!mkdir($dest)) { return false; } } $i = new DirectoryIterator($src); foreach ($i as $f) { if ($f->isFile()) { copy($f->getRealPath(), "{$dest}/" . $f->getFilename()); } else { if (!$f->isDot() && $f->isDir()) { rcopy($f->getRealPath(), "{$dest}/{$f}"); } } } }
function rcopy($src, $dst) { if (file_exists($dst)) { //echo $dst; deleteDirectory($dst); } if (is_dir($src)) { mkdir($dst); $files = scandir($src); foreach ($files as $file) { if ($file != "." && $file != "..") { rcopy("{$src}/{$file}", "{$dst}/{$file}"); } } } else { if (file_exists($src)) { // echo $src."<br>"; copy($src, $dst); } } }
function rcopy($src, $dest, $cached = false) { /*var_dump($src); var_dump('dirname '.dirname($src));*/ /*var_dump($dest); var_dump('dirname '.dirname($dest));*/ if (!is_dir($src)) { return false; } if (!is_dir($dest)) { $cached = false; if (!mkdir($dest)) { return false; } } $i = new DirectoryIterator($src); foreach ($i as $f) { if ($f->isFile()) { if ($cached) { if (file_exists("{$dest}/" . $f->getFilename())) { $destTime = filemtime("{$dest}/" . $f->getFilename()); $srcTime = filemtime($f->getRealPath()); $diff = $srcTime - $destTime; if ($diff < 0) { continue; } var_dump('copy file'); } } copy($f->getRealPath(), "{$dest}/" . $f->getFilename()); } else { if (!$f->isDot() && $f->isDir()) { rcopy($f->getRealPath(), "{$dest}/{$f}", $cached); } } } }
function folder_append_files($src_folder, $dst_folder) { $files = scandir($src_folder); foreach ($files as $file) { if ($file != "." && $file != "..") { if (file_exists("{$dst_folder}/{$file}")) { rename("{$dst_folder}/{$file}", "{$dst_folder}/{$file}" . "_old"); } rcopy("{$src_folder}/{$file}", "{$dst_folder}/{$file}"); } } }
response('no action', 400)->send(); exit; } // check for writability if (is_really_writable($path) === FALSE || is_really_writable($path_thumb) === FALSE) { response(trans('Dir_No_Write') . '<br/>' . str_replace('../', '', $path) . '<br/>' . str_replace('../', '', $path_thumb), 403)->send(); exit; } // check if server disables copy or rename if (is_function_callable($action == 'copy' ? 'copy' : 'rename') === FALSE) { response(sprintf(trans('Function_Disabled'), $action == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut'))), 403)->send(); exit; } if ($action == 'copy') { rcopy($data['path'], $path); rcopy($data['path_thumb'], $path_thumb); } elseif ($action == 'cut') { rrename($data['path'], $path); rrename($data['path_thumb'], $path_thumb); // cleanup if (is_dir($data['path']) === TRUE) { rrename_after_cleaner($data['path']); rrename_after_cleaner($data['path_thumb']); } } // cleanup $_SESSION['RF']['clipboard']['path'] = NULL; $_SESSION['RF']['clipboard_action'] = NULL; break; case 'chmod': $mode = $_POST['new_mode'];
/** * Copy of directory. * @param string $src * @param string $dst * @param boolean $mkdirRecursive * @param int $mkdirMode */ function rcopy($src, $dst, $mkdirRecursive = false, $mkdirMode = 0771) { $dir = opendir($src); mkdir_fix($dst, $mkdirRecursive, $mkdirMode); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { rcopy($src . '/' . $file, $dst . '/' . $file, $mkdirMode, $mkdirRecursive); } else { copy($src . '/' . $file, $dst . '/' . $file); } } } closedir($dir); }
/** * Installer::_copyPayload() * * @return */ public function _copyPayload() { $this->parent->parent->debug($this::name_space . ': Copying payload...'); // Recursively copies the payload to the module dir if (!rcopy($this->tempModule . '/payload/', __MODULE__ . '/' . strtolower($this->namespace))) { $this->parent->parent->debug($this::name_space . ': Failed to copy payload!'); return new ActionResult($this, '/admin/modules/install/', 0, 'Failed to copy payload!', B_T_FAIL, array('status' => 0, 'msg' => 'Failed to copy payload!')); } $this->parent->parent->debug($this::name_space . ': Copied payload!'); // Copies the module.xml for later use (backing up) copy($this->tempModule . '/module.xml', __MODULE__ . '/' . strtolower($this->namespace) . '/module.xml'); // Return the status return new ActionResult($this, '/admin/modules/install/', 0, 'Registering pages...', B_T_SUCCESS, array('status' => 1, 'msg' => 'Registering pages...')); }
protected function copyTheme($strOriginalThemeFolder) { list($strCopyThemeFolder, $strPrettyThemeCopyName) = $this->generateThemeCopyNames($strOriginalThemeFolder); $d = YiiBase::getPathOfAlias('webroot') . "/themes"; //If this is a symbolic link, we have to handle this differently if (is_link($d . "/" . $strOriginalThemeFolder)) { return false; } //can't rename a symlink'd theme rcopy($d . "/" . $strOriginalThemeFolder, $d . "/" . $strCopyThemeFolder); $this->renameAdminForm($strOriginalThemeFolder, $strCopyThemeFolder, $strPrettyThemeCopyName); return $strCopyThemeFolder; }
function rcopy($source, $dest) { //error_log($source." -> ".$dest, 0); if (!file_exists($source)) { //error_log($source." does not exist", 0); return false; } if (is_dir($source)) { //error_log($source." is a dir", 0); // This is a directory. // Remove trailing '/' if (strrpos($source, '/') == sizeof($source) - 1) { $source = substr($source, 0, size_of($source) - 1); } if (strrpos($dest, '/') == sizeof($dest) - 1) { $dest = substr($dest, 0, size_of($dest) - 1); } if (!is_dir($dest)) { $res = @mkdir($dest, api_get_permissions_for_new_directories()); if ($res !== false) { return true; } else { // Remove latest part of path and try creating that. if (rcopy(substr($source, 0, strrpos($source, '/')), substr($dest, 0, strrpos($dest, '/')))) { return @mkdir($dest, api_get_permissions_for_new_directories()); } else { return false; } } } return true; } else { // This is presumably a file. //error_log($source." is a file", 0); if (!@copy($source, $dest)) { //error_log("Could not simple-copy $source", 0); $res = rcopy(dirname($source), dirname($dest)); if ($res === true) { //error_log("Welcome dir created", 0); return @copy($source, $dest); } else { return false; //error_log("Error creating path", 0); } } else { //error_log("Could well simple-copy $source", 0); return true; } } }
public function backup($sql = true) { if (!$this->module->getBackupTables()) { return array('s' => false, 'm' => 'Failed to fetch tables to back up!'); } if ($this->location_prefix) { $this->location .= 'mod_' . strtolower($this->module->namespace); if (!file_exists($this->location)) { mkdir($this->location, 0775, true); } } mkdir($this->location . DIRECTORY_SEPARATOR . 'sql'); foreach ($this->module->backup_tables as $table => $options) { $t = array(); $structure = ''; if ($options['s']) { $structure_query = $this->mySQL_r->query('SHOW CREATE TABLE `' . $this->mySQL_r->real_escape_string($table) . '`'); if (!$structure_query) { return array('s' => false, 'msg' => 'Failed to backup tables'); } $structure = $structure_query->fetch_row(); $structure = 'DROP TABLE IF EXISTS `' . $this->mySQL_r->real_escape_string($table) . '`' . PHP_EOL . $structure[1]; } $data = array(); if ($options['d']) { $data_query = $this->mySQL_r->query('SELECT * FROM `' . $this->mySQL_r->real_escape_string($table) . '`'); while ($d = $data_query->fetch_assoc()) { $d = $this->_replaceNULL($d); $d = $this->_toValueString($d); $data[] = $this->mySQL_r->real_escape_string($d); } } $insert = ''; if (count($data) != 0) { $insert = 'INSERT INTO `' . $this->mySQL_r->real_escape_string($table) . '` VALUES' . PHP_EOL . ' '; $insert .= implode(',' . PHP_EOL . ' ', $data); } $query = $structure . PHP_EOL . $insert; $file = fopen($this->location . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . $table . '.sql', 'w'); fwrite($file, $query); fclose($file); } rcopy(__MODULE__ . DIRECTORY_SEPARATOR . strtolower($this->module->namespace), $this->location . DIRECTORY_SEPARATOR . 'payload'); rename($this->location . DIRECTORY_SEPARATOR . 'payload' . DIRECTORY_SEPARATOR . 'module.xml', $this->location . DIRECTORY_SEPARATOR . 'module.xml'); if (file_exists($this->location . DIRECTORY_SEPARATOR . 'payload' . DIRECTORY_SEPARATOR . 'install.php')) { rename($this->location . DIRECTORY_SEPARATOR . 'payload' . DIRECTORY_SEPARATOR . 'install.php', $this->location . DIRECTORY_SEPARATOR . 'install.php'); } $this->_zipModule(); rrmdir($this->location); return array('s' => true, 'msg' => 'Succesfully backed up modules'); }
public function save() { $cache = cache::byKey('market::info::' . $this->getLogicalId()); if (is_object($cache)) { $cache->remove(); } $market = self::getJsonRpc(); $params = utils::o2a($this); if (isset($params['changelog'])) { unset($params['changelog']); } switch ($this->getType()) { case 'plugin': $cibDir = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId(); if (file_exists($cibDir)) { rrmdir($cibDir); } mkdir($cibDir); $exclude = array('tmp'); rcopy(realpath(dirname(__FILE__) . '/../../plugins/' . $this->getLogicalId()), $cibDir, true, $exclude, true); $tmp = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId() . '.zip'; if (file_exists($tmp)) { if (!unlink($tmp)) { throw new Exception(__('Impossible de supprimer : ', __FILE__) . $tmp . __('. Vérifiez les droits', __FILE__)); } } if (!create_zip($cibDir, $tmp)) { throw new Exception(__('Echec de création de l\'archive zip', __FILE__)); } break; default: $type = $this->getType(); if (!class_exists($type) || !method_exists($type, 'shareOnMarket')) { throw new Exception(__('Aucune fonction correspondante à : ', __FILE__) . $type . '::shareOnMarket'); } $tmp = $type::shareOnMarket($this); break; } if (!file_exists($tmp)) { throw new Exception(__('Impossible de trouver le fichier à envoyer : ', __FILE__) . $tmp); } $file = array('file' => '@' . realpath($tmp)); if (!$market->sendRequest('market::save', $params, 30, $file)) { throw new Exception($market->getError()); } $update = update::byTypeAndLogicalId($this->getType(), $this->getLogicalId()); if (!is_object($update)) { $update = new update(); $update->setLogicalId($this->getLogicalId()); $update->setType($this->getType()); } $update->setConfiguration('version', 'beta'); $update->setLocalVersion(date('Y-m-d H:i:s', strtotime('+10 minute' . date('Y-m-d H:i:s')))); $update->save(); $update->checkUpdate(); }
function rcopy($src, $dst, $_emptyDest = true, $_exclude = array(), $_noError = false) { if (!file_exists($src)) { return true; } if ($_emptyDest) { rrmdir($dst); } if (is_dir($src)) { if (!file_exists($dst)) { mkdir($dst); } $files = scandir($src); foreach ($files as $file) { if ($file != "." && $file != ".." && !in_array($file, $_exclude) && !in_array(realpath($src . '/' . $file), $_exclude)) { if (!rcopy($src . '/' . $file, $dst . '/' . $file, $_emptyDest, $_exclude, $_noError) && !$_noError) { return false; } } } } else { if (!in_array(basename($src), $_exclude) && !in_array(realpath($src), $_exclude)) { if (!$_noError) { return copy($src, $dst); } else { @copy($src, $dst); return true; } } } return true; }
public function copy($_data) { $_data['name'] = $_data['name'] == '' ? $this->getName() . '_copy' : $_data['name']; $_data['version'] = $_data['version'] != '' ? $_data['version'] : $this->getVersion(); $_data['type'] = $_data['type'] == 'none' ? $this->getType() : $_data['type']; $_data['subtype'] = $_data['subtype'] == 'none' ? $this->getSubtype() : $_data['subtype']; $dep = realpath(dirname(__FILE__) . '/../template/' . $this->getVersion()) . '/cmd.' . $this->getType() . '.' . $this->getSubtype() . '.' . $this->getName(); if (file_exists($dep)) { mkdir(realpath(dirname(__FILE__) . '/../template/' . $_data['version']) . '/cmd.' . $_data['type'] . '.' . $_data['subtype'] . '.' . $_data['name']); if (!rcopy($dep, realpath(dirname(__FILE__) . '/../template/' . $_data['version']) . '/cmd.' . $_data['type'] . '.' . $_data['subtype'] . '.' . $_data['name'], false, array(), true)) { throw new Exception(__('Impossible de copier ', __FILE__) . $cibDirs[1] . ' => ' . $tmp_dir); } } $widget = clone $this; $widget->setName($_data['name']); $widget->setVersion($_data['version']); $widget->setType($_data['type']); $widget->setSubtype($_data['subtype']); $widget->setpath(realpath($widget->generatePath())); $widget->setContent(str_replace('cmd.' . $this->getType() . '.' . $this->getSubtype() . '.' . $this->getName(), 'cmd.' . $_data['type'] . '.' . $_data['subtype'] . '.' . $_data['name'], $widget->getContent())); $widget->save(); return $widget; }
/** * Real copy of files, directories (recurrsively) and symbolic links in one handy function. * @param string $source Path to the source to copy * @param string $dest Path to the destination to copy to * @return boolean Whether copying was successful. When copying a directory, returns true if and only if copying of all files within the directory was successful. */ function rcopy($source, $dest) { if (is_link($source)) { return symlink(readlink($source), $dest); } if (is_file($source)) { return copy($source, $dest); } if (!is_dir($dest) && !mkdir($dest)) { return false; } $dir = opendir($source); if (!$dir) { logMsg('rcopy: failed to open directory ' . $source, 5, 5); return false; } $result = true; while ($file = readdir($dir)) { if ($file === '.' or $file === '..') { continue; } $tmp = rcopy("{$source}/{$file}", "{$dest}/{$file}"); if (!$tmp) { logMsg("rcopy: failed to copy file \"{$source}/{$file}\" to \"{$dest}/{$file}\"", 5, 5); } $result = $result && $tmp; } return $result; }
function linkfldrarr($klikit, $extlink, $fd = '', $retcwd = false) { global $__lang; $klikit = array(); $klikit[$__lang['folders']] = array(); #echo html_entity_decode($_GET['fd']);die(); #echo getcwd()." ".str_replace("//", "/", html_entity_decode($_GET['fd']))."<hr />"; #if (isset($_GET['fd']) &&strlen($_GET['fd'])>0 && is_Dir(str_replace("//", "/", html_entity_decode($_GET['fd'])))){ # echo $_GET['fd'];die(); if ($fd == '') { $fd = str_replace("//", "/", str_replace("%2F", "/", html_entity_decode(html_entity_decode($_GET['fd'])))); } #} if ($retcwd == true) { chdir($fd); return getcwd(); } if (isset($_GET['newfoldername'])) { $newname = filesystemcode($_GET['newfoldername'], 'b', 'c'); $chdir = getcwd(); chdir($fd); mkdir($newname, 755); chdir($chdir); unset($chdir); } elseif (isset($_GET['newfilename'])) { $newname = filesystemcode($_GET['newfilename'], 'b', 'c'); $chdir = getcwd(); chdir($fd); file_put_contents($newname, ""); chdir($chdir); unset($chdir); } elseif (isset($_GET['newname'])) { $chdir = getcwd(); chdir($fd); rename(rawurldecode($_GET['fn']), filesystemcode(rawurldecode($_GET['newname']), 'b', 'c')); chdir($chdir); } elseif (isset($_GET['cutcopy'])) { $chdir = getcwd(); chdir($fd); if ($_GET['cutcopy'] == 'cut') { rename(str_replace("+", " ", $_GET['pastefromlocation']), filesystemcode(str_replace("+", " ", $_GET['ccitemname']), 'b', 'c')); } elseif ($_GET['cutcopy'] == 'copy') { rcopy(str_replace("+", " ", $_GET['pastefromlocation']), filesystemcode(str_replace("+", " ", $_GET['ccitemname']), 'b', 'c')); } chdir($chdir); } #if ($fd=='' || $fd==$GLOBALS['_cfg']['global']['default_request_folder']){ #}else{} #if ($fd=='.'){$fd=$GLOBALS['_cfg']['global']['default_request_folder'];} #Prepare folder display selection with current userinput #echo "<pre>";print_r($__lang);die(); $filecont = '/*cat=' . $__lang['files'] . '_*/'; # $_GET['cat']=$__lang['files']; if (!isset($fd) || $fd == '') { $fd = $GLOBALS['_cfg']['global']['default_request_folder']; } if (!isset($fd) || $fd == '') { $fd = '.'; } #load defaults ;/ # echo $fd;die(); # echo $extlink;die(); $dircont = dir_ls($fd . "/", $extlink); #echo "<pre>";print_r($dircont); if (is_array($dircont)) { foreach ($extlink as $d => $test) { #echo "<pre>";print_r($dircont);die(); if (isset($dircont['fn'][$d]) && is_array($dircont['fn'][$d])) { foreach ($dircont['fn'][$d] as $b) { if (!isset($klikit[$__lang['files']][$b])) { if (isset($_GET) && isset($_GET['ele']) && $b == html_entity_decode($_GET['ele'])) { $klikit[$__lang['files']][$b] = file_get_contents(str_replace("//", "/", html_entity_decode($fd)) . "/" . $b); $klikit[$__lang['files']][$b] = mb_convert_encoding($klikit[$__lang['files']][$b], 'UTF-8', mb_detect_encoding($klikit[$__lang['files']][$b], 'UTF-8, ISO-8859-1', true)); #echo #strlen( #$klikit[$__lang['files']][$b] #) #."<br />"; } else { # if ($d=="no_ext" && $GLOBALS['_cfg']['global']['universal_unlinked_ext_files']!="none" || $d!="no_ext"){ if (!isset($klikit[$__lang['files']][$b])) { $klikit[$__lang['files']][$b] = ''; } # } } } } } } if (isset($dircont['fd']) && is_array($dircont['fd'])) { $klikit[$__lang['folders']] = array_flip($dircont['fd']); } } elseif (isset($_GET['cat']) && $dircont == "nf") { $klikit[html_entity_decode($_GET['cat'])]['LANGempty_folderIANG'] = ""; $_GET['ele'] = ''; } elseif (isset($_GET['cat']) && $dircont == "na") { $klikit[html_entity_decode($_GET['cat'])]['LANGaccess_deniedIANG'] = ""; $_GET['ele'] = ''; } $klikity['fd'] = $fd; $klikity['klikit'] = $klikit; # print_r($klikity);die(); #die(); return $klikity; }
protected function copyAssets($cached = false) { $src = $this->path . 'assets/'; $dest = TH_BASE_DIR . '/public/assets/modules/' . $this->baseDir; /*if($cached && file_exists($dest) && is_dir($dest)){ $seconds = time() - filemtime($dest) ; var_dump(time()); var_dump(filemtime($dest)); if($seconds < 5)return; }*/ rcopy($src, $dest, $cached); }
trigger_error("Impossible to copy the latest getid3 zip release file.", E_USER_WARNING); goto answering; } $htmlMessage = $htmlMessage . "<p/>getId3 downloaded to: '" . $id3DestPath . "'"; if (!exec("unzip " . $id3DestPath . " -d " . $tmpDir)) { trigger_error("Impossible to extract the downloaded zip file.", E_USER_WARNING); goto answering; } $htmlMessage = $htmlMessage . "<p/>Zip file successfully extracted."; $getId3SourceDir = first_dir($getId3DestDir, $tmpDir); if (!$getId3SourceDir) { trigger_error("Impossible to find the getid3 directory with the PHP code to copy.", E_USER_WARNING); goto answering; } $htmlMessage = $htmlMessage . "<p/>getId3 directory to copy found at: '" . $getId3SourceDir . "'"; rcopy($getId3SourceDir, $getId3DestDir); $htmlMessage = $htmlMessage . "<p/>getId3 directory copied to its final destination at: '" . realpath($getId3SourceDir) . "'"; rrmdir($tmpDir); $htmlMessage = $htmlMessage . "<p/>Deleted all temporal files at: '" . $tmpDir . "'"; } // getid3 downloaded. Let's create the database file. require_once "getid3/getid3.php"; $getID3 = new getID3(); $id3FileNames = array_diff(scandir($mediaDirectory), array(".", "..")); foreach ($id3FileNames as $id3FileName) { $id3 = $getID3->analyze($mediaDirectory . "/" . $id3FileName); $playfile = array("fileName" => $id3["filename"], "fileSize" => $id3["filesize"], "playTime" => $id3["playtime_seconds"], "audioStart" => $id3["avdataoffset"], "audioEnd" => $id3["avdataend"], "audioLength" => $id3["avdataend"] - $id3["avdataoffset"], "artist" => $id3["tags"]["id3v2"]["artist"][0], "title" => $id3["tags"]["id3v2"]["title"][0], "bitRate" => $id3["audio"]["bitrate"], "mimeType" => $id3["mime_type"], "fileFormat" => $id3["fileformat"]); if (empty($playfile["artist"]) || empty($playfile["title"])) { list($playfile["artist"], $playfile["title"]) = explode(" - ", substr($playfile["fileName"], 0, -4)); } $playFiles[] = $playfile;
/** * Recursive copy * @param string $sSourcePath * @param string $sDestinationPath * @throws \InvalidArgumentException */ function rcopy($sSourcePath, $sDestinationPath) { if (!file_exists($sSourcePath)) { throw new \InvalidArgumentException('Source file "' . $sSourcePath . '" does not exist'); } //Remove destination if (is_dir($sDestinationPath)) { emptyDir($sDestinationPath); if (!rmdir($sDestinationPath)) { $aLastError = error_get_last(); throw new \RuntimeException('Unable to remove directory "' . $sDestinationPath . '" - ' . $aLastError['message']); } } elseif (is_file($sDestinationPath) && !@unlink($sDestinationPath)) { $aLastError = error_get_last(); throw new \RuntimeException('Unable to remove file "' . $sDestinationPath . '" - ' . $aLastError['message']); } //Copy directory if (is_dir($sSourcePath)) { if (!mkdir($sDestinationPath, 0777, true)) { throw new \InvalidArgumentException('Destination directory "' . $sDestinationPath . '" can\'t be created'); } foreach (scandir($sSourcePath) as $sFileName) { if ($sFileName != '.' && $sFileName != '..') { rcopy($sSourcePath . DIRECTORY_SEPARATOR . $sFileName, $sDestinationPath . DIRECTORY_SEPARATOR . $sFileName); } } } elseif (!copy($sSourcePath, $sDestinationPath)) { throw new \RuntimeException(sprintf('"%s" can\'t by moved in "%s"', $sSourcePath, $sDestinationPath)); } }
function rcopy($source, $destination, $is_rec = FALSE) { if (is_dir($source)) { if ($is_rec === FALSE) { $pinfo = pathinfo($source); $destination = rtrim($destination, '/') . DIRECTORY_SEPARATOR . $pinfo['basename']; } if (is_dir($destination) === FALSE) { mkdir($destination, 0755, true); } $files = scandir($source); foreach ($files as $file) { if ($file != "." && $file != "..") { rcopy($source . DIRECTORY_SEPARATOR . $file, rtrim($destination, '/') . DIRECTORY_SEPARATOR . $file, TRUE); } } } else { if (file_exists($source)) { if (is_dir($destination) === TRUE) { $pinfo = pathinfo($source); $dest2 = rtrim($destination, '/') . DIRECTORY_SEPARATOR . $pinfo['basename']; } else { $dest2 = $destination; } copy($source, $dest2); } } }
/** * @param String */ public static function copyDefaultTheme($theme = null) { if (!$theme) { $theme = 'blackcandymobile'; } $src = '../' . MOBILE_DIR . '/themes/' . $theme; $dst = self::get_theme_copy_path(); if (!file_exists($dst)) { @mkdir($dst); if (is_writable($dst)) { rcopy($src, $dst); DB::alteration_message(sprintf('Default mobile theme "%s" has been copied into the themes directory', $theme), 'created'); } else { DB::alteration_message(sprintf('Could not copy default mobile theme "%s" into themes directory (permission denied). Please manually copy the "%s" directory from the mobile module into the themes directory.', $theme, $theme), 'error'); } } }