当前位置: 首页>>代码示例>>PHP>>正文


PHP copy函数代码示例

本文整理汇总了PHP中copy函数的典型用法代码示例。如果您正苦于以下问题:PHP copy函数的具体用法?PHP copy怎么用?PHP copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了copy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $remoteFilename = 'http://get.insight.sensiolabs.com/insight.phar';
     $localFilename = $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-temp.phar';
     try {
         copy($remoteFilename, $tempFilename);
         if (md5_file($localFilename) == md5_file($tempFilename)) {
             $output->writeln('<info>insight is already up to date.</info>');
             unlink($tempFilename);
             return;
         }
         chmod($tempFilename, 0777 & ~umask());
         // test the phar validity
         $phar = new \Phar($tempFilename);
         // free the variable to unlock the file
         unset($phar);
         rename($tempFilename, $localFilename);
         $output->writeln('<info>insight updated.</info>');
     } catch (\Exception $e) {
         if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
             throw $e;
         }
         unlink($tempFilename);
         $output->writeln('<error>The download is corrupt (' . $e->getMessage() . ').</error>');
         $output->writeln('<error>Please re-run the self-update command to try again.</error>');
     }
 }
开发者ID:ftdysa,项目名称:insight,代码行数:31,代码来源:SelfUpdateCommand.php

示例2: generate

 public function generate($pages)
 {
     $out = $this->path;
     $path = APP_DIR . "/src/Data/themes/{$this->theme}";
     // The theme path
     if ($this->delete == 1) {
         $this->log("Emptying Output Directory");
         /**
          * Empty the Output Dir just in case
          */
         $this->recursiveRemoveDirectory($out);
         $this->log("Finished Emptying Output Directory");
     }
     if ($this->init) {
         /* Start copying the theme contents to output directory */
         $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
         foreach ($objects as $location => $object) {
             $name = str_replace("{$path}/", "", $location);
             // Make into relative path
             $outLoc = "{$out}/{$name}";
             if ($object->isFile() && $name != "layout.html" && $name != "thumbnail.png" && $name != "example.html") {
                 $this->log("Copying {$name} to Ouput Directory");
                 copy($location, $outLoc);
             } elseif ($object->isDir() && !file_exists($outLoc)) {
                 /* Make sub directories on output folder */
                 mkdir($outLoc);
             }
         }
         /* Start creating pages */
         $layout = "{$path}/layout.html";
         foreach ($pages as $page) {
             $this->page($page['slug'], array("{{page-title}}" => $page['title'], "{{page-content}}" => $page['body']));
         }
     }
 }
开发者ID:saviobosco,项目名称:lobby,代码行数:35,代码来源:class.site.php

示例3: activate

 /**
  * Activate plugin action
  */
 function activate()
 {
     if (!$this->locked() && !@copy(W3TC_INSTALL_FILE_OBJECT_CACHE, W3TC_ADDIN_FILE_OBJECT_CACHE)) {
         w3_writable_error(W3TC_ADDIN_FILE_OBJECT_CACHE);
     }
     $this->schedule();
 }
开发者ID:niko-lgdcom,项目名称:archives,代码行数:10,代码来源:ObjectCache.php

示例4: getImage

 /**
  *  fetch image from protected location and manipulate it and copy to public folder to show in front-end
  *  This function cache the fetched image with same width and height before
  * 
  * @author A.Jafaripur <mjafaripur@yahoo.com>
  * 
  * @param integer $id image id number to seprate the folder in public folder
  * @param string $path original image path
  * @param float $width width of image for resize
  * @param float $heigh height of image for resize
  * @param integer $quality quality of output image
  * @return string fetched image url
  */
 public function getImage($id, $path, $width, $heigh, $quality = 70)
 {
     $fileName = $this->getFileName(Yii::getAlias($path));
     $fileNameWithoutExt = $this->getFileNameWithoutExtension($fileName);
     $ext = $this->getFileExtension($fileName);
     if ($width == 0 && $heigh == 0) {
         $size = Image::getImagine()->open($path)->getSize();
         $width = $size->getWidth();
         $heigh = $size->getHeight();
     }
     $newFileName = $fileNameWithoutExt . 'x' . $width . 'w' . $heigh . 'h' . '.' . $ext;
     $upload_number = (int) ($id / 2000) + 1;
     $savePath = Yii::getAlias('@webroot/images/' . $upload_number);
     $baseImageUrl = Yii::$app->getRequest()->getBaseUrl() . '/images/' . $upload_number;
     FileHelper::createDirectory($savePath);
     $savePath .= DIRECTORY_SEPARATOR . $newFileName;
     if ($width == 0 && $heigh == 0) {
         copy($path, $savePath);
     } else {
         if (!file_exists($savePath)) {
             Image::thumbnail($path, $width, $heigh)->interlace(\Imagine\Image\ImageInterface::INTERLACE_PLANE)->save($savePath, ['quality' => $quality]);
         }
     }
     return $baseImageUrl . '/' . $newFileName;
 }
开发者ID:rocketyang,项目名称:admap,代码行数:38,代码来源:ImageHelper.php

示例5: getMockResourceByImagePath

 /**
  * Creates an Image object from a file using a mock resource (in order to avoid a database resource pointer entry)
  * @param string $imagePathAndFilename
  * @return \TYPO3\Flow\Resource\Resource
  */
 protected function getMockResourceByImagePath($imagePathAndFilename)
 {
     $imagePathAndFilename = \TYPO3\Flow\Utility\Files::getUnixStylePath($imagePathAndFilename);
     $hash = sha1_file($imagePathAndFilename);
     copy($imagePathAndFilename, 'resource://' . $hash);
     return $mockResource = $this->createMockResourceAndPointerFromHash($hash);
 }
开发者ID:hhoechtl,项目名称:neos-development-collection,代码行数:12,代码来源:AbstractTest.php

示例6: copyr

 public static function copyr($source, $dest)
 {
     // recursive function to copy
     // all subdirectories and contents:
     if (is_dir($source)) {
         $dir_handle = opendir($source);
         $sourcefolder = basename($source);
         if (!is_dir($dest . "/" . $sourcefolder)) {
             mkdir($dest . "/" . $sourcefolder);
         }
         while ($file = readdir($dir_handle)) {
             if ($file != "." && $file != "..") {
                 if (is_dir($source . "/" . $file)) {
                     self::copyr($source . "/" . $file, $dest . "/" . $sourcefolder);
                 } else {
                     copy($source . "/" . $file, $dest . "/" . $file);
                 }
             }
         }
         closedir($dir_handle);
     } else {
         // can also handle simple copy commands
         copy($source, $dest);
     }
 }
开发者ID:ASDAFF,项目名称:RosYama.2,代码行数:25,代码来源:Y.php

示例7: __construct

 /**
  * @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception.
  *
  * @param string $documentTemplate The fully qualified template filename.
  * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  * @throws \PhpOffice\PhpWord\Exception\CopyFileException
  */
 public function __construct($documentTemplate)
 {
     // Temporary document filename initialization
     $this->temporaryDocumentFilename = tempnam(Settings::getTempDir(), 'PhpWord');
     if (false === $this->temporaryDocumentFilename) {
         throw new CreateTemporaryFileException();
     }
     // Template file cloning
     if (false === copy($documentTemplate, $this->temporaryDocumentFilename)) {
         throw new CopyFileException($documentTemplate, $this->temporaryDocumentFilename);
     }
     // Temporary document content extraction
     $this->zipClass = new ZipArchive();
     $this->zipClass->open($this->temporaryDocumentFilename);
     $index = 1;
     while ($this->zipClass->locateName($this->getHeaderName($index)) !== false) {
         $this->temporaryDocumentHeaders[$index] = $this->zipClass->getFromName($this->getHeaderName($index));
         $index++;
     }
     $index = 1;
     while ($this->zipClass->locateName($this->getFooterName($index)) !== false) {
         $this->temporaryDocumentFooters[$index] = $this->zipClass->getFromName($this->getFooterName($index));
         $index++;
     }
     $this->temporaryDocumentMainPart = $this->zipClass->getFromName('word/document.xml');
 }
开发者ID:cakpep,项目名称:spk-tht,代码行数:33,代码来源:TemplateProcessor.php

示例8: upload

 /**
  * Uploads and unpacks a file
  * @return boolean True on success, False on error
  */
 function upload($uploadfile)
 {
     if (substr(strtolower($this->_realname), -4) != ".xml") {
         if (!$this->extractArchive($uploadfile)) {
             $this->error = JText::_('AUP_EXTRACT_ERROR');
             JError::raiseWarning(0, $this->error);
             return false;
         }
     }
     if (!is_array($this->_uploadfile)) {
         if (!@copy($this->_uploadfile, $this->_plugindir . DS . $this->_realname)) {
             $this->errno = 2;
             $this->error = JText::_('AUP_FILEUPLOAD_ERROR');
             JError::raiseWarning(0, $this->error);
             return false;
         } else {
             $file = $this->_foldername . DS . $this->_realname;
         }
     } else {
         $file = array();
         $i = 0;
         foreach ($this->_uploadfile as $_file) {
             if (!@copy($this->_unpackdir . DS . $_file, $this->_plugindir . DS . $_file)) {
                 $this->errno = 2;
                 $this->error = JText::_('AUP_FILEUPLOAD_ERROR');
                 JError::raiseWarning(0, $this->error);
                 return false;
             }
             $file[$i] = $this->_foldername . DS . $_file;
             $i++;
         }
     }
     return $file;
 }
开发者ID:q0821,项目名称:esportshop,代码行数:38,代码来源:alphauserpoints.installer.php

示例9: convert_file

 private function convert_file($source, $dest)
 {
     // Узнаем какая кодировка у файла
     $teststring = file_get_contents($source, null, null, null, 1000000);
     // Кодировка - UTF8
     if (preg_match('//u', $teststring)) {
         // Просто копируем файл
         return copy($source, $dest);
     } else {
         // Конвертируем в UFT8
         if (!($src = fopen($source, "r"))) {
             return false;
         }
         if (!($dst = fopen($dest, "w"))) {
             return false;
         }
         while (($line = fgets($src, 4096)) !== false) {
             $line = $this->win_to_utf($line);
             fwrite($dst, $line);
         }
         fclose($src);
         fclose($dst);
         return true;
     }
 }
开发者ID:OkayCMS,项目名称:Okay,代码行数:25,代码来源:MultiImportAdmin.php

示例10: cacheImage

/**
 * Generate a cached thumbnail for object lists (eg. carrier, order states...etc)
 *
 * @param string $image Real image filename
 * @param string $cacheImage Cached filename
 * @param integer $size Desired size
 */
function cacheImage($image, $cacheImage, $size, $imageType = 'jpg')
{
    if (file_exists($image)) {
        if (!file_exists(_PS_TMP_IMG_DIR_ . $cacheImage)) {
            $imageGd = $imageType == 'gif' ? imagecreatefromgif($image) : imagecreatefromjpeg($image);
            $x = imagesx($imageGd);
            $y = imagesy($imageGd);
            /* Size is already ok */
            if ($y < $size) {
                copy($image, _PS_TMP_IMG_DIR_ . $cacheImage);
            } else {
                $ratioX = $x / ($y / $size);
                $newImage = $imageType == 'gif' ? imagecreate($ratioX, $size) : imagecreatetruecolor($ratioX, $size);
                /* Allow to keep nice look even if resized */
                $white = imagecolorallocate($newImage, 255, 255, 255);
                imagefill($newImage, 0, 0, $white);
                imagecopyresampled($newImage, $imageGd, 0, 0, 0, 0, $ratioX, $size, $x, $y);
                imagecolortransparent($newImage, $white);
                /* Quality alteration and image creation */
                if ($imageType == 'gif') {
                    imagegif($newImage, _PS_TMP_IMG_DIR_ . $cacheImage);
                } else {
                    imagejpeg($newImage, _PS_TMP_IMG_DIR_ . $cacheImage, 86);
                }
            }
        }
        return '<img src="../img/tmp/' . $cacheImage . '" alt="" class="imgm" />';
    }
    return '';
}
开发者ID:sealence,项目名称:local,代码行数:37,代码来源:images.inc.php

示例11: save_page

 function save_page($page)
 {
     $file_content = "";
     // set content
     foreach ($page as $key => $value) {
         if ($value) {
             if ($key == 'slug') {
                 $file_content .= "{: " . $key . " :} " . strtolower(url_title($value)) . "\n";
             } else {
                 $file_content .= "{: " . $key . " :} " . $value . "\n";
             }
         }
     }
     // if it is placed as subpage
     if (!empty($page['parent'])) {
         // if parent still as standalone file (not in folder)
         if (file_exists(PAGE_FOLDER . $page['parent'] . '.md')) {
             // create folder and move the parent inside
             mkdir(PAGE_FOLDER . $page['parent'], 0775);
             rename(PAGE_FOLDER . $page['parent'] . '.md', PAGE_FOLDER . $page['parent'] . '/index.md');
             // create index.html file
             copy(PAGE_FOLDER . 'index.html', PAGE_FOLDER . $page['parent'] . '/index.html');
         }
     }
     if (write_file(PAGE_FOLDER . $page['parent'] . '/' . $page['slug'] . '.md', $file_content)) {
         $this->pusaka->sync_page();
         return true;
     } else {
         return false;
     }
 }
开发者ID:nurulimamnotes,项目名称:pusakacms,代码行数:31,代码来源:Pages_m.php

示例12: copyDir

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-7-11
 * Time: 上午10:40
 */
function copyDir($dirSrc, $dirTo)
{
    if (is_file($dirTo)) {
        //如果目标不是一个目录则退出
        echo "目标不是目录不能创建!!";
        return;
    }
    if (!file_exists($dirTo)) {
        //如果目标不存在,则创建目录
        mkdir($dirTo);
    }
    if ($dir_handle = @opendir($dirSrc)) {
        //打开目录并判断是否成功
        while ($filename = readdir($dir_handle)) {
            //循环遍历目录
            if ($filename != "." && $filename != "..") {
                //排除两个特殊目录
                $subSrcFile = $dirSrc . "/" . $filename;
                $subToFile = $dirTo . "/" . $filename;
                if (is_dir($subSrcFile)) {
                    //如果是子目录,则递归
                    copyDir($subSrcFile, $subToFile);
                }
                if (is_file($subSrcFile)) {
                    //如果是文件,则使用copy直接拷贝
                    copy($subSrcFile, $subToFile);
                }
            }
        }
        closedir($dir_handle);
        //最后记得一定要关闭目录句柄
    }
}
开发者ID:skyler2tao,项目名称:languageStudy,代码行数:39,代码来源:copyDir.php

示例13: configure

 /**
  * Configure the Hostnet code style
  */
 public static function configure()
 {
     $file = Path::VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf';
     if (!file_exists($file)) {
         copy(__DIR__ . '/CodeSniffer.conf.php', $file);
     }
 }
开发者ID:hostnet,项目名称:phpcs-tool,代码行数:10,代码来源:Installer.php

示例14: recursiveCopy

 /**
  * Recursively copy files from one directory to another.
  *
  * @param $path
  * @param $destinationPath
  * @return bool
  */
 protected static function recursiveCopy($path, $destinationPath)
 {
     // If source is not a directory stop processing
     if (!is_dir($path)) {
         return false;
     }
     // If the destination directory does not exist create it
     if (!is_dir($destinationPath)) {
         if (!mkdir($destinationPath)) {
             // If the destination directory could not be created stop processing
             return false;
         }
     }
     // Open the source directory to read in files
     $i = new \DirectoryIterator($path);
     foreach ($i as $f) {
         if ($f->isFile()) {
             copy($f->getRealPath(), $destinationPath . DIRECTORY_SEPARATOR . $f->getFilename());
         } else {
             if (!$f->isDot() && $f->isDir()) {
                 self::recursiveCopy($f->getRealPath(), $destinationPath . DIRECTORY_SEPARATOR . $f);
             }
         }
     }
     return true;
 }
开发者ID:shsrain,项目名称:ypyzApi,代码行数:33,代码来源:Folder.php

示例15: do_upload

function do_upload($tid)
{
    global $nick;
    if ($_FILES['attachment-file']['size'] < 1) {
        return "File size is too small!";
    }
    $file_name = $_FILES['attachment-file']['name'];
    $file_ext = strtolower(substr($file_name, -4));
    if ($file_ext != ".jpg" && $file_ext != ".png" && $file_ext != ".pdf" && $file_ext != ".log" && $file_ext != ".txt") {
        return "You can only upload jpg/png/pdf/log/txt files!";
    }
    $file_type = $_FILES['attachment-file']['type'];
    $file_size = $_FILES['attachment-file']['size'];
    $file_desc = "Attachment by " . $nick;
    if (!is_numeric($file_size)) {
        safe_die("Error! Invalid number in file size!");
    }
    $query = squery("INSERT INTO karnaf_files(tid,file_name,file_type,file_desc,file_size,lastupd_time) VALUES(%d,'%s','%s','%s',%d,%d)", $tid, $file_name, $file_type, $file_desc, $file_size, time());
    if (!$query) {
        return "SQL Error! Query failed on do_upload() function: " . mysql_error();
    }
    $id = sql_insert_id();
    $fn = KARNAF_UPLOAD_PATH . "/" . $tid;
    if (!file_exists($fn)) {
        if (!mkdir($fn)) {
            return "Can't create attachment directory!";
        }
    }
    $fn .= "/" . $id . $file_ext;
    if (!copy($_FILES['attachment-file']['tmp_name'], $fn)) {
        return "Couldn't create attachment file!";
    }
    return "";
}
开发者ID:nirn,项目名称:karnaf,代码行数:34,代码来源:view.php


注:本文中的copy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。