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


PHP unlink函数代码示例

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


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

示例1: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (is_null($this->dst) || "" === $this->dst) {
         return Result::error($this, 'You must specify a destination file with to() method.');
     }
     if (!$this->checkResources($this->files, 'file')) {
         return Result::error($this, 'Source files are missing!');
     }
     if (file_exists($this->dst) && !is_writable($this->dst)) {
         return Result::error($this, 'Destination already exists and cannot be overwritten.');
     }
     $dump = '';
     foreach ($this->files as $path) {
         foreach (glob($path) as $file) {
             $dump .= file_get_contents($file) . "\n";
         }
     }
     $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]);
     $dst = $this->dst . '.part';
     $write_result = file_put_contents($dst, $dump);
     if (false === $write_result) {
         @unlink($dst);
         return Result::error($this, 'File write failed.');
     }
     // Cannot be cross-volume; should always succeed.
     @rename($dst, $this->dst);
     return Result::success($this);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:31,代码来源:Concat.php

示例2: rmFile

 protected function rmFile($file)
 {
     if (is_file($file)) {
         chmod(dirname($file), 0777);
         unlink($file);
     }
 }
开发者ID:Kreed1346,项目名称:BookSmart,代码行数:7,代码来源:ProjectTestCase.php

示例3: template

 /**
  * Compiles a template and writes it to a cache file, which is used for inclusion.
  *
  * @param string $file The full path to the template that will be compiled.
  * @param array $options Options for compilation include:
  *        - `path`: Path where the compiled template should be written.
  *        - `fallback`: Boolean indicating that if the compilation failed for some
  *                      reason (e.g. `path` is not writable), that the compiled template
  *                      should still be returned and no exception be thrown.
  * @return string The compiled template.
  */
 public static function template($file, array $options = array())
 {
     $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
     $defaults = array('path' => $cachePath, 'fallback' => false);
     $options += $defaults;
     $stats = stat($file);
     $oname = basename(dirname($file)) . '_' . basename($file, '.php');
     $oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
     $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
     $template = "{$options['path']}/{$template}";
     if (file_exists($template)) {
         return $template;
     }
     $compiled = static::compile(file_get_contents($file));
     if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
         foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
             if ($expired !== $template) {
                 unlink($expired);
             }
         }
         return $template;
     }
     if ($options['fallback']) {
         return $file;
     }
     throw new TemplateException("Could not write compiled template `{$template}` to cache.");
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:38,代码来源:Compiler.php

示例4: delete

 public function delete()
 {
     $this->load->language('tool/upload');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('tool/upload');
     if (isset($this->request->post['selected']) && $this->validateDelete()) {
         foreach ($this->request->post['selected'] as $upload_id) {
             // Remove file before deleting DB record.
             $upload_info = $this->model_tool_upload->getUpload($upload_id);
             if ($upload_info && is_file(DIR_DOWNLOAD . $upload_info['filename'])) {
                 unlink(DIR_UPLOAD . $upload_info['filename']);
             }
             $this->model_tool_upload->deleteUpload($upload_id);
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $url = '';
         if (isset($this->request->get['filter_name'])) {
             $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
         }
         if (isset($this->request->get['filter_date_added'])) {
             $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         $this->redirect($this->url->link('tool/upload', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     }
     $this->getList();
 }
开发者ID:phpsa,项目名称:CoreCMS,代码行数:35,代码来源:upload.php

示例5: pic_cutOp

 /**
  * 图片裁剪
  *
  */
 public function pic_cutOp()
 {
     Uk86Language::uk86_read('admin_common');
     $lang = Uk86Language::uk86_getLangContent();
     uk86_import('function.thumb');
     if (uk86_chksubmit()) {
         $thumb_width = $_POST['x'];
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         $scale = $thumb_width / $w;
         $src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
         if (strpos($src, '..') !== false || strpos($src, BASE_UPLOAD_PATH) !== 0) {
             exit;
         }
         if (!empty($_POST['filename'])) {
             // 				$save_file2 = BASE_UPLOAD_PATH.'/'.$_POST['filename'];
             $save_file2 = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['filename']);
         } else {
             $save_file2 = str_replace('_small.', '_sm.', $src);
         }
         $cropped = uk86_resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
         @unlink($src);
         $pathinfo = pathinfo($save_file2);
         exit($pathinfo['basename']);
     }
     $save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']);
     $_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
     Tpl::output('height', uk86_get_height($save_file));
     Tpl::output('width', uk86_get_width($save_file));
     Tpl::showpage('common.pic_cut', 'null_layout');
 }
开发者ID:wangjiang988,项目名称:ukshop,代码行数:39,代码来源:common.php

示例6: tearDown

 public function tearDown()
 {
     if ($this->tempDirectory) {
         if (file_exists($this->tempDirectory . '/Controller/FooAdminController.php')) {
             unlink($this->tempDirectory . '/Controller/FooAdminController.php');
         }
         if (file_exists($this->tempDirectory . '/Admin/FooAdmin.php')) {
             unlink($this->tempDirectory . '/Admin/FooAdmin.php');
         }
         if (file_exists($this->tempDirectory . '/Resources/config/admin.yml')) {
             unlink($this->tempDirectory . '/Resources/config/admin.yml');
         }
         if (is_dir($this->tempDirectory . '/Controller')) {
             rmdir($this->tempDirectory . '/Controller');
         }
         if (is_dir($this->tempDirectory . '/Admin')) {
             rmdir($this->tempDirectory . '/Admin');
         }
         if (is_dir($this->tempDirectory . '/Resources/config')) {
             rmdir($this->tempDirectory . '/Resources/config');
         }
         if (is_dir($this->tempDirectory . '/Resources')) {
             rmdir($this->tempDirectory . '/Resources');
         }
         if (file_exists($this->tempDirectory) && is_dir($this->tempDirectory)) {
             rmdir($this->tempDirectory);
         }
     }
 }
开发者ID:jerome-fix,项目名称:SonataAdminBundle,代码行数:29,代码来源:GenerateAdminCommandTest.php

示例7: task_shutdown

function task_shutdown()
{
    $pid = posix_getpid();
    if (file_exists(LOCK_DIRECTORY . "/update_daemon-{$pid}.lock")) {
        unlink(LOCK_DIRECTORY . "/update_daemon-{$pid}.lock");
    }
}
开发者ID:rolfkleef,项目名称:Tiny-Tiny-RSS,代码行数:7,代码来源:update_daemon2.php

示例8: tableInsertBatch

 /**
  * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
  * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
  *
  * @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
  * @param array $fields array of unquoted field names
  * @param array $values array of data to be inserted
  * @param bool $throwException Whether to throw an exception that was caught while trying
  *                                LOAD DATA INFILE, or not.
  * @throws Exception
  * @return bool  True if the bulk LOAD was used, false if we fallback to plain INSERTs
  */
 public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
 {
     $filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
     $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
     $loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
     if ($loadDataInfileEnabled && Db::get()->hasBulkLoader()) {
         try {
             $fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => function ($str) {
                 return str_replace(array(chr(92), chr(34)), array(chr(92) . chr(92), chr(92) . chr(34)), $str);
             }, 'eol' => "\r\n", 'null' => 'NULL');
             // hack for charset mismatch
             if (!DbHelper::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) {
                 $fileSpec['charset'] = 'latin1';
             }
             self::createCSVFile($filePath, $fileSpec, $values);
             if (!is_readable($filePath)) {
                 throw new Exception("File {$filePath} could not be read.");
             }
             $rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
             if ($rc) {
                 unlink($filePath);
                 return true;
             }
         } catch (Exception $e) {
             Log::info("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage());
             if ($throwException) {
                 throw $e;
             }
         }
     }
     // if all else fails, fallback to a series of INSERTs
     @unlink($filePath);
     self::tableInsertBatchIterate($tableName, $fields, $values);
     return false;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:47,代码来源:BatchInsert.php

示例9: deleteConfiguration

 public function deleteConfiguration($namespace, $context, $language, $environment, $name)
 {
     $fileName = $this->getFilePath($namespace, $context, $language, $environment, $name);
     if (unlink($fileName) === false) {
         throw new ConfigurationException('[StatementConfigurationProvider::deleteConfiguration()] ' . 'Configuration with name "' . $fileName . '" cannot be deleted! Please check your ' . 'file system configuration, the file name, or your environment configuration.');
     }
 }
开发者ID:GeneralCrime,项目名称:code,代码行数:7,代码来源:StatementConfigurationProvider.php

示例10: Proses

function Proses()
{
    // Buat DBF
    include_once "../{$_SESSION['mnux']}.header.dbf.php";
    include_once "../func/dbf.function.php";
    $NamaFile = "../tmp/TRLSM_{$_SESSION['TahunID']}.DBF";
    $_SESSION['lmhsw_dbf'] = $NamaFile;
    $_SESSION['lmhsw_part'] = 0;
    $_SESSION['lmhsw_counter'] = 0;
    $_SESSION['lmhsw_total'] = HitungData();
    if (file_exists($NamaFile)) {
        unlink($NamaFile);
    }
    DBFCreate($NamaFile, $HeaderKelulusanMhsw);
    // tampilkan
    $ro = "readonly=true";
    echo <<<ESD
  <font size=+1>Proses Data Kelulusan Mahasiswa...</font> (<b>{$_SESSION['lmhsw_total']}</b> data)<br />
  <table class=box cellspacing=1 width=100%>
  <form name='frmMhsw'>
  <tr>
      <td valign=top width=10>
      Counter:<br />
      <input type=text name='Counter' size=4 {$ro} />
      </td>
      
      <td valign=top width=20>
      NIP:<br />
      <input type=text name='MhswID' size=10 {$ro} />
      </td>
      
      <td valign=top>
      Nama Mhsw:<br />
      <input type=text name='NamaMhsw' size=30 {$ro} />
      </td>
      
      <td valign=top align=right width=30>
      <input type=button name='Batal' value='Batal'
        onClick="location='../{$_SESSION['mnux']}.lulusmhsw.php?gos='" />
      </td>
      </tr>
  </form>
  </table>
  <br />
  
  <script>
  function Kembali() {
    window.onLoad=setTimeout("window.location='../{$_SESSION['mnux']}.lulusmhsw.php?gos=Selesai'", 0);
  }
  function Prosesnya(cnt, id, nama) {
    frmMhsw.Counter.value = cnt;
    frmMhsw.MhswID.value = id;
    frmMhsw.NamaMhsw.value = nama;
  }
  </script>
  <iframe src="../{$_SESSION['mnux']}.lulusmhsw.php?gos=ProsesDetails" width=90% height=50 frameborder=0 scrolling=no>
  </iframe>

ESD;
}
开发者ID:anggadjava,项目名称:sisfor,代码行数:60,代码来源:dikti.lulusmhsw.php

示例11: setUp

 protected function setUp()
 {
     $file = sys_get_temp_dir() . '/phinx.yml';
     if (is_file($file)) {
         unlink($file);
     }
 }
开发者ID:nguyenducduy,项目名称:haraapp,代码行数:7,代码来源:InitTest.php

示例12: co_star_edit

 public function co_star_edit()
 {
     if ($_POST['submit'] and $_POST['index'] != "") {
         $Stars = M('Co_stars');
         $index = $_POST['index'];
         $star = $Stars->where('photo_index=' . $index)->find();
         if ($_POST['title'] != "") {
             $data['photo_title'] = $_POST['title'];
         }
         $tmp_name = $_FILES['upfile']['tmp_name'];
         $file = $_FILES["upfile"];
         //上傳文件名稱
         //C('__PUBLIC__')爲 /Quanquan/Public
         move_uploaded_file($tmp_name, 'Public/WebResources/co_star/' . $file['name']);
         //將上傳文件移動到指定目錄待解壓
         if ($file['name']) {
             unlink($star['photo_url']);
             $data['photo_url'] = C('__PUBLIC__') . '/WebResources/co_star/' . $file['name'];
         }
         if ($Stars->where('photo_index=' . $index)->save($data)) {
             echo '修改成功';
         } else {
             echo $star['photo_url'];
         }
     } else {
         echo '未輸入數據';
     }
     $this->display();
 }
开发者ID:224-lab,项目名称:Quanquan,代码行数:29,代码来源:MoreController.class.php

示例13: beforeSave

 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (!parent::beforeSave($insert)) {
         return false;
     }
     if ($this->receiptImg) {
         if ($this->receiptImg->error) {
             return false;
         }
         $fileName = $this->receiptImg->baseName . '.' . $this->receiptImg->extension;
         if ($insert) {
             $this->file_name = $fileName;
             return true;
         }
         $existingFilePath = $this->filePath;
         $this->file_name = $fileName;
         $this->_file_path = null;
         // reset filePath so it is recalculated via magicMethod
         if (!$this->receiptImg->saveAs($this->filePath)) {
             throw new ServerErrorHttpException('Unable to save receipt image.');
         } elseif (!unlink($existingFilePath)) {
             throw new ServerErrorHttpException('Unable to delete existing receipt image.');
         }
     }
     return true;
 }
开发者ID:jslight,项目名称:helpdesk,代码行数:29,代码来源:Reimbursement.php

示例14: query

 public function query($domain, $postvars)
 {
     $this->log_proxy('  domain: ' . $domain);
     $this->log_proxy('POSTVARS: ' . $postvars);
     $ch = curl_init($domain);
     curl_setopt($ch, CURLOPT_POST, 0);
     curl_setopt($ch, CURLOPT_VERBOSE, 0);
     //   curl_setopt( $ch, CURLOPT_USERAGENT     , isset( $_SERVER[ 'User-Agent' ]) ? $_SERVER[ 'User-Agent' ] : '' );
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
     //   curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_REFERER, $domain);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
     curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
     curl_setopt($ch, CURLOPT_COOKIEJAR, 'ses_' . session_id());
     curl_setopt($ch, CURLOPT_COOKIEFILE, 'ses_' . session_id());
     //   curl_setopt( $ch, CURLOPT_COOKIE        , $COOKIE );
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FAILONERROR, 1);
     $content = curl_exec($ch);
     $response = curl_getinfo($ch);
     curl_close($ch);
     unlink('ses_' . session_id());
     return $content;
 }
开发者ID:shadobladez,项目名称:erp2,代码行数:27,代码来源:jky_export.php

示例15: buildSecFile

/**
 * Build a secured file with token name
 *
 * @param string $reqkey The reference key
 *
 * @return string The secure key
 */
function buildSecFile($reqkey)
{
    $CI =& get_instance();
    $skey = mt_rand();
    $dir = $CI->config->item('token_dir');
    $file = $skey . '.tok';
    //make the file with the reqkey value in it
    file_put_contents($dir . '/' . $file, $reqkey);
    //do some cleanup - find ones older then the threshold and remove
    $rm = $CI->config->item('token_rm');
    //this is in minutes
    if (is_dir($dir)) {
        if (($h = opendir($dir)) !== false) {
            while (($file = readdir($h)) !== false) {
                if (!in_array($file, array('.', '..'))) {
                    $p = $dir . '/' . $file;
                    if (filemtime($p) < time() - $rm * 60) {
                        unlink($p);
                    }
                }
            }
        }
    }
    return $skey;
}
开发者ID:Bittarman,项目名称:joind.in,代码行数:32,代码来源:reqkey_helper.php


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