本文整理汇总了PHP中copys函数的典型用法代码示例。如果您正苦于以下问题:PHP copys函数的具体用法?PHP copys怎么用?PHP copys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copys函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_dir
/**
* Public interface for adding a dir and its contents recursively to zip file
* @access public
* @param string $dir the real system directory that contains the files to add to the zip
* @param string $zip_prefix_dir the zip dir where the contents of $dir will be put in
* @param string $pre_pend_dir used during the recursion to keep track of the path, default=''
* @see $_base_path in include/vitals.inc.php
* @see priv_add_dir() in include/classes/zipfile.class.php
* @see add_file() in include/classes/zipfile.class.php
* @author Joel Kronenberg
*/
function add_dir($dir, $zip_prefix_dir, $pre_pend_dir = '')
{
if (!($dh = @opendir($dir . $pre_pend_dir))) {
echo 'cant open dir: ' . $dir . $pre_pend_dir;
exit;
}
//copy folder recursively into the temp folder.
copys($dir, $this->zipfile_dir . DIRECTORY_SEPARATOR . $zip_prefix_dir);
}
示例2: copys
function copys($source, $dest)
{
if (!is_dir($source)) {
return 0;
}
if (!is_dir($dest)) {
mkdir($dest);
}
$h = @dir($source);
while (@($entry = $h->read()) !== false) {
if ($entry != "." && $entry != "..") {
if (is_dir("{$source}/{$entry}") && $dest !== "{$source}/{$entry}") {
copys("{$source}/{$entry}", "{$dest}/{$entry}");
} else {
@copy("{$source}/{$entry}", "{$dest}/{$entry}");
}
}
}
$h->close();
return 1;
}
示例3: copys
function copys($source,$dest)
{
if (!is_dir($source))
return 0;
if (!is_dir($dest)) {
mkdir($dest);
}
$h = @dir($source);
while (@($entry=$h->read()) !== false) {
if (($entry != '.') && ($entry != '..')) {
if (is_dir("$source/$entry")&&$dest!=="$source/$entry") {
copys("$source/$entry", "$dest/$entry");
} else {
@copy("$source/$entry", "$dest/$entry");
}
}
}
$h->close();
return 1;
}
示例4: copys
/**
* Allows the copying of entire directories.
* @access public
* @param string $source the source directory
* @param string $dest the destination directory
* @return boolean whether the copy was successful or not
* @link http://www.php.net/copy
* @author www at w8c dot com
*/
function copys($source, $dest)
{
if (!is_dir($source)) {
return false;
}
if (!is_dir($dest)) {
mkdir($dest);
}
$h = @dir($source);
while (@($entry = $h->read()) !== false) {
if ($entry == '.' || $entry == '..') {
continue;
}
if (is_dir("{$source}/{$entry}") && $dest !== "{$source}/{$entry}") {
copys("{$source}/{$entry}", "{$dest}/{$entry}");
} else {
@copy("{$source}/{$entry}", "{$dest}/{$entry}");
}
}
$h->close();
return true;
}
示例5: copys
function copys($source, $target, $c = 0)
{
$source = realpath($source) . DIRECTORY_SEPARATOR;
if ($dh = opendir($source)) {
if (!is_dir($target)) {
mkdir($target);
}
$target = realpath($target) . DIRECTORY_SEPARATOR;
while (($f = readdir($dh)) !== false) {
if ($f != '.' && $f != '..') {
if (is_dir($source . $f)) {
copys($source . $f, $target . $f, $c);
} else {
if (copy($source . $f, $target . $f)) {
$c++;
}
}
}
}
closedir($dh);
}
return $c;
}
示例6: import_theme
//.........这里部分代码省略.........
}
$ext = pathinfo($_FILES['file']['name']);
$ext = $ext['extension'];
//error in the file
if ($_FILES['file']['error'] == 1) {
$errors = array('FILE_MAX_SIZE', ini_get('upload_max_filesize'));
$msg->addError($errors);
header('Location: index.php');
exit;
}
//If file has no name or no address or if the extension is not .zip
if (!$_FILES['file']['name'] || !is_uploaded_file($_FILES['file']['tmp_name']) && !$_POST['url']) {
$msg->addError('FILE_NOT_SELECTED');
header('Location: index.php');
exit;
}
if ($ext != 'zip') {
$msg->addError('IMPORT_NOT_PROPER_FORMAT');
header('Location: index.php');
exit;
}
//check if file size is ZERO
if ($_FILES['file']['size'] == 0) {
$msg->addError('IMPORTFILE_EMPTY');
header('Location: index.php');
exit;
}
// new directory name is the filename minus the extension
$fldrname = substr($_FILES['file']['name'], 0, -4);
$fldrname = str_replace(' ', '_', $fldrname);
$import_path = AT_SUBSITE_THEME_DIR . $fldrname;
//check if Folder by that name already exists
if (is_dir($import_path)) {
$i = 1;
while (is_dir($import_path . '_' . $i)) {
$i++;
}
$fldrname = $fldrname . '_' . $i;
$import_path = $import_path . '_' . $i;
}
//if folder does not exist previously
if (!@mkdir($import_path, 0700)) {
$msg->addError('IMPORTDIR_FAILED');
header('Location: index.php');
exit;
}
// unzip file and save into directory in themes
$archive = new PclZip($_FILES['file']['tmp_name']);
//extract contents to importpath/foldrname
if (!$archive->extract($import_path)) {
$errors = array('IMPORT_ERROR_IN_ZIP', $archive->errorInfo(true));
clr_dir($import_path);
$msg->addError($errors);
header('Location: index.php');
exit;
}
$handle = opendir($import_path);
while ($file = readdir($handle)) {
if (is_dir($import_path . '/' . $file) && $file != '.' && $file != '..') {
$folder = $file;
}
}
//copy contents from importpath/foldrname to importpath
copys($import_path . '/' . $folder, $import_path);
//delete importpath/foldrname
clr_dir($import_path . '/' . $folder);
$theme_xml = @file_get_contents($import_path . '/theme_info.xml');
//Check if XML file exists (if it doesnt send error and clear directory)
if ($theme_xml == false) {
$version = '1.4.x';
$extra_info = 'unspecified';
} else {
//parse information
$xml_parser = new ThemeParser();
$xml_parser->parse($theme_xml);
$version = $xml_parser->theme_rows['version'];
$extra_info = $xml_parser->theme_rows['extra_info'];
$type = $xml_parser->theme_rows['type'];
}
$title = str_replace('_', ' ', $fldrname);
$last_updated = date('Y-m-d');
$status = '1';
//if version number is not compatible with current Atutor version, set theme as disabled
if ($version != VERSION) {
$status = '0';
}
//save information in database
$sql = "INSERT INTO %sthemes (title, version, dir_name, type, last_updated, extra_info, status, customized) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %d, 1)";
$result = queryDB($sql, array(TABLE_PREFIX, $title, $version, $fldrname, $type, $last_updated, $extra_info, $status));
global $sqlout;
write_to_log(AT_ADMIN_LOG_INSERT, 'themes', $result, $sqlout);
if (!$result) {
$msg->addError('IMPORT_FAILED');
header('Location: index.php');
exit;
}
if (isset($_POST['url'])) {
@unlink($full_filename);
}
}
示例7: restore_files
function restore_files()
{
$sql = "SELECT max_quota FROM " . TABLE_PREFIX . "courses WHERE course_id={$this->course_id}";
$result = mysql_query($sql, $this->db);
$row = mysql_fetch_assoc($result);
if ($row['max_quota'] != AT_COURSESIZE_UNLIMITED) {
global $MaxCourseSize, $MaxCourseFloat;
if ($row['max_quota'] == AT_COURSESIZE_DEFAULT) {
$row['max_quota'] = $MaxCourseSize;
}
$totalBytes = dirsize($this->import_dir . 'content/');
$course_total = dirsize(AT_CONTENT_DIR . $this->course_id . '/');
$total_after = $row['max_quota'] - $course_total - $totalBytes + $MaxCourseFloat;
if ($total_after < 0) {
//debug('not enough space. delete everything');
// remove the content dir, since there's no space for it
clr_dir($this->import_dir);
return FALSE;
}
}
copys($this->import_dir . 'content/', AT_CONTENT_DIR . $this->course_id);
}
示例8: copys
function copys($s, $d, $c = 0)
{
if ($dh = opendir($s)) {
if (!@is_dir($d)) {
@mkdir($d);
}
while (($f = readdir($dh)) !== false) {
if ($f != '.' && $f != '..') {
if (@is_dir($s . DS . $f)) {
copys($s . DS . $f, $d . DS . $f);
} else {
copy($s . DS . $f, $d . DS . $f);
}
}
}
closedir($dh);
}
}
示例9: goURL
echo '<div class="title">' . $title . '</div>';
if (isset($_POST['submit']) && isset($_POST['is_action'])) {
echo '<div class="notice_failure">';
if (empty($_POST['path'])) {
echo 'Chưa nhập đầy đủ thông tin';
} else {
if ($dir == processDirectory($_POST['path'])) {
echo 'Đường dẫn mới phải khác đường dẫn hiện tại';
} else {
if (!is_dir($_POST['path'])) {
echo 'Đường dẫn mới không tồn tại';
} else {
if (isPathNotPermission(processDirectory($_POST['path']))) {
echo 'Bạn không thể sao chép tới đường dẫn của File Manager';
} else {
if (!copys($entry, $dir, processDirectory($_POST['path']))) {
echo 'Sao chép thất bại';
} else {
goURL('index.php?dir=' . $dirEncode . $pages['paramater_1']);
}
}
}
}
}
echo '</div>';
}
echo $entryHtmlList;
echo '<div class="list">
<span>' . printPath($dir, true) . '</span><hr/>
<form action="action.php?dir=' . $dirEncode . $pages['paramater_1'] . '" method="post">
<span class="bull">•</span>Đường dẫn tập tin mới:<br/>
示例10: print_progress
print_progress($step);
/* try copying the content over from the old dir to the new one */
require '../mods/_core/file_manager/filemanager.inc.php';
// for copys()
$content_dir = urldecode(trim($_POST['step5']['content_dir']));
$_POST['step5']['copy_from'] = urldecode(trim($_POST['step5']['copy_from'])) . DIRECTORY_SEPARATOR;
//copy if copy_from is not empty
if ($_POST['step5']['copy_from'] && $_POST['step5']['copy_from'] != DIRECTORY_SEPARATOR) {
if (is_dir($_POST['step5']['copy_from'])) {
$files = scandir($_POST['step5']['copy_from']);
foreach ($files as $file) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_dir($_POST['step5']['copy_from'] . $file)) {
copys($_POST['step5']['copy_from'] . $file, $content_dir . $file);
if (is_dir($content_dir . $course)) {
$progress[] = 'Course content directory <b>' . $file . '</b> copied successfully.';
} else {
$errors[] = 'Course content directory <b>' . $file . '</b> <strong>NOT</strong> copied.';
}
} else {
// a regular file
copy($_POST['step5']['copy_from'] . $file, $content_dir . $file);
}
}
}
} else {
$progress[] = 'Using existing content directory <strong>' . $content_dir . '</strong>.';
}
/////////////////////
示例11: restore
/**
* Restores this module into the given course
* @access public
* @param int $course_id ID of the course to restore into
* @param string $version version number of the ATutor installation used to make this backup
* @param string $import_dir the path to the import directory
* @author Joel Kronenberg
*/
function restore($course_id, $version, $import_dir)
{
static $CSVImport;
if (!file_exists($this->_module_path . $this->_directoryName . '/module_backup.php')) {
return;
}
if (!isset($CSVImport)) {
require_once AT_INCLUDE_PATH . 'classes/CSVImport.class.php';
$CSVImport = new CSVImport();
}
require $this->_module_path . $this->_directoryName . '/module_backup.php';
if (isset($sql)) {
foreach ($sql as $table_name => $table_sql) {
$CSVImport->import($table_name, $import_dir, $course_id, $version);
}
}
if ($this->_directoryName == '_core/content') {
if (version_compare($version, '1.6.4', '<')) {
$this->convertContent164($course_id);
}
}
if (isset($dirs)) {
foreach ($dirs as $src => $dest) {
$dest = str_replace('?', $course_id, $dest);
copys($import_dir . $src, $dest);
}
}
}
示例12: copys
$title = $_GET['title'];
} else {
if (isset($_POST["title"])) {
$title = $_POST["title"];
}
}
if (isset($_GET["permission_granted"])) {
$permission_granted = $_GET["permission_granted"];
} else {
if (isset($_POST["permission_granted"])) {
$permission_granted = $_POST["permission_granted"];
}
}
// copy theme from content folder into themes folder
if (isset($_GET["theme"])) {
copys($theme_content_folder . $theme, AT_SUBSITE_THEME_DIR . $theme);
$theme_xml = @file_get_contents(AT_SUBSITE_THEME_DIR . $theme . '/theme_info.xml');
//Check if XML file exists (if it doesnt send error and clear directory)
if ($theme_xml == false) {
$version = '1.4.x';
$extra_info = 'unspecified';
} else {
//parse information
$xml_parser = new ThemeParser();
$xml_parser->parse($theme_xml);
$version = $xml_parser->theme_rows['version'];
$type = $xml_parser->theme_rows['type'] ? $xml_parser->theme_rows['type'] : DESKTOP_DEVICE;
// accommodate the old themes, set default type to "desktop"
$extra_info = $xml_parser->theme_rows['extra_info'];
}
if ($title == '') {
示例13: header
$args .= SEP . 'core=1';
}
if (isset($_GET['standard']) && $_GET['standard']) {
$args .= SEP . 'standard=1';
}
if (isset($_GET['extra']) && $_GET['extra']) {
$args .= SEP . 'extra=1';
}
header('Location: index.php?' . $args);
exit;
}
}
}
// copy module from content folder into mods folder
if (isset($mod) && !isset($_GET['mod_in'])) {
copys($module_content_folder . $mod, AT_SUBSITE_MODULE_PATH . $mod);
}
require AT_INCLUDE_PATH . 'header.inc.php';
$moduleParser = new ModuleParser();
if (!file_exists(AT_SUBSITE_MODULE_PATH . $mod . '/module.xml')) {
?>
<form method="get" action="<?php
echo $_SERVER['PHP_SELF'];
?>
">
<input type="hidden" name="mod" value="<?php
echo $mod;
?>
" />
<input type="hidden" name="new" value="<?php
echo $new;
示例14: elseif
}
} elseif (is_dir($path)) {
if (rmdirs($path) > 0) {
$counter++;
}
}
} elseif ($massType == 'cut') {
$dest = $massPath . basename($path);
if (rename($path, $dest)) {
$counter++;
touch($dest, $preserveTimestamp);
}
} elseif ($massType == 'copy') {
$dest = $massPath . basename($path);
if (is_dir($path)) {
if (copys($path, $dest) > 0) {
$counter++;
}
} elseif (is_file($path)) {
if (copy($path, $dest)) {
$counter++;
}
}
} elseif ($massType == 'untar' || $massType == 'untargz' || $massType == 'unzip') {
if (decompress($massType, $path, $massValue)) {
$counter++;
return $counter;
}
} elseif (!empty($massValue)) {
if ($massType == 'chmod') {
if (chmod($path, octdec($massValue))) {
示例15: if
// theme content folder
$theme_content_folder = AT_CONTENT_DIR . "theme/";
if (isset($_GET["theme"])) $theme = str_replace(array('.','..'), '', $_GET['theme']);
else if (isset($_POST["theme"])) $theme = $_POST["theme"];
if (isset($_GET["title"])) $title = $_GET['title'];
else if (isset($_POST["title"])) $title = $_POST["title"];
if (isset($_GET["permission_granted"])) $permission_granted = $_GET["permission_granted"];
else if (isset($_POST["permission_granted"])) $permission_granted = $_POST["permission_granted"];
// copy theme from content folder into themes folder
if (isset($_GET["theme"]))
{
copys($theme_content_folder.$theme, '../../../themes/'.$theme);
$theme_xml = @file_get_contents('../../../themes/'.$theme . '/theme_info.xml');
//Check if XML file exists (if it doesnt send error and clear directory)
if ($theme_xml == false)
{
$version = '1.4.x';
$extra_info = 'unspecified';
}
else
{
//parse information
$xml_parser = new ThemeParser();
$xml_parser->parse($theme_xml);