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


PHP File::close方法代码示例

本文整理汇总了PHP中File::close方法的典型用法代码示例。如果您正苦于以下问题:PHP File::close方法的具体用法?PHP File::close怎么用?PHP File::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


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

示例1: handle

 /**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     if ($input->post('FORM_SUBMIT') == 'tl_composer_migrate_undo') {
         /** @var RootPackage $rootPackage */
         $rootPackage = $this->composer->getPackage();
         $requires = $rootPackage->getRequires();
         foreach (array_keys($requires) as $package) {
             if ($package != 'contao-community-alliance/composer') {
                 unset($requires[$package]);
             }
         }
         $rootPackage->setRequires($requires);
         $lockPathname = preg_replace('#\\.json$#', '.lock', $this->configPathname);
         /** @var DownloadManager $downloadManager */
         $downloadManager = $this->composer->getDownloadManager();
         $downloadManager->setOutputProgress(false);
         $installer = Installer::create($this->io, $this->composer);
         if (file_exists(TL_ROOT . '/' . $lockPathname)) {
             $installer->setUpdate(true);
         }
         if ($installer->run()) {
             $_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
         } else {
             $_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
             $this->redirect('contao/main.php?do=composer&migrate=undo');
         }
         // load config
         $json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
         $config = $json->read();
         // remove migration status
         unset($config['extra']['contao']['migrated']);
         // write config
         $json->write($config);
         // disable composer client and enable repository client
         $inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
         $inactiveModules[] = '!composer';
         foreach (array('rep_base', 'rep_client', 'repository') as $module) {
             $pos = array_search($module, $inactiveModules);
             if ($pos !== false) {
                 unset($inactiveModules[$pos]);
             }
         }
         if (version_compare(VERSION, '3', '>=')) {
             $skipFile = new \File('system/modules/!composer/.skip');
             $skipFile->write('Remove this file to enable the module');
             $skipFile->close();
         }
         if (file_exists(TL_ROOT . '/system/modules/repository/.skip')) {
             $skipFile = new \File('system/modules/repository/.skip');
             $skipFile->delete();
         }
         $this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
         $this->redirect('contao/main.php?do=repository_manager');
     }
     $template = new \BackendTemplate('be_composer_client_migrate_undo');
     $template->composer = $this->composer;
     $template->output = $_SESSION['COMPOSER_OUTPUT'];
     unset($_SESSION['COMPOSER_OUTPUT']);
     return $template->parse();
 }
开发者ID:designs2,项目名称:composer-client,代码行数:63,代码来源:UndoMigrationController.php

示例2: afterSave

 /**
  * afterSave
  * 
  * Write out the routes.php file
  */
 public function afterSave($created, $options = array())
 {
     $aliases = $this->find('all');
     $routes = '';
     foreach ($aliases as $alias) {
         $alias['Alias']['name'] = $alias['Alias']['name'] == 'home' ? '' : $alias['Alias']['name'];
         // keyword home is the homepage
         $plugin = !empty($alias['Alias']['plugin']) ? '/' . $alias['Alias']['plugin'] : null;
         $controller = !empty($alias['Alias']['controller']) ? '/' . $alias['Alias']['controller'] : null;
         $action = !empty($alias['Alias']['action']) ? '/' . $alias['Alias']['action'] : null;
         $value = !empty($alias['Alias']['value']) ? '/' . $alias['Alias']['value'] : null;
         $url = $plugin . $controller . $action . $value;
         $routes .= 'Router::redirect(\'' . $url . '\', \'/' . $alias['Alias']['name'] . '\', array(\'status\' => 301));' . PHP_EOL;
         $routes .= 'Router::connect(\'/' . $alias['Alias']['name'] . '\', array(\'plugin\' => \'' . $alias['Alias']['plugin'] . '\', \'controller\' => \'' . $alias['Alias']['controller'] . '\', \'action\' => \'' . $alias['Alias']['action'] . '\', \'' . implode('\', \'', explode('/', $alias['Alias']['value'])) . '\'));' . PHP_EOL;
     }
     App::uses('File', 'Utility');
     $file = new File(ROOT . DS . SITE_DIR . DS . 'Config' . DS . 'routes.php');
     $currentRoutes = str_replace(array('<?php ', '<?php'), '', explode('// below this gets overwritten', $file->read()));
     $routes = '<?php ' . $currentRoutes[0] . '// below this gets overwritten' . PHP_EOL . PHP_EOL . $routes;
     if ($file->write($routes)) {
         $file->close();
     } else {
         $file->close();
         // Be sure to close the file when you're done
         throw new Exception(__('Error writing routes file'));
     }
     // <?php
     // Router::redirect('/webpages/webpages/view/113', '/lenovo', array('status' => 301));
     // Router::connect('/lenovo', array('plugin' => 'webpages', 'controller' => 'webpages', 'action' => 'view', 113));
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:35,代码来源:Alias.php

示例3: login

 public function login()
 {
     if ($this->request->is('post')) {
         if ($this->Auth->login()) {
             /* ログイン時に定期バックアップを判定して作成ここから */
             $file_pass = '../../backup';
             $file_name = 'sister_backup';
             $backup_flg = 1;
             $folder = new Folder($file_pass);
             $lists = $folder->read();
             foreach ($lists[1] as $list) {
                 //ファイル名から日付を取得
                 $name = str_replace(array($file_name . '_', '.txt'), '', $list);
                 if (date('Ymd', strtotime('-7 day')) < date($name)) {
                     //直近のファイルがあればflgを消去
                     $backup_flg = 0;
                     break;
                 }
             }
             if ($backup_flg == 1) {
                 //flgがあればバックアップを作成
                 //DBデータを取得する
                 $array_model = array('Administrator', 'Banner', 'Birthday', 'Diary', 'DiaryGenre', 'Game', 'Information', 'Link', 'Maker', 'Music', 'Photo', 'Product', 'SisterComment', 'Voice');
                 foreach ($array_model as $model) {
                     $this->{$model}->Behaviors->disable('SoftDelete');
                     $datas = $this->{$model}->find('all', array('order' => $model . '.id', 'recursive' => -1));
                     $this->set($model . '_datas', $datas);
                     $this->set($model . '_tbl', $this->{$model}->useTable);
                 }
                 $this->set('array_model', $array_model);
                 $this->layout = false;
                 $sql = $this->render('sql_backup');
                 $file = new File($file_pass . '/' . $file_name . '_' . date('Ymd') . '.sql', true);
                 if ($file->write($sql)) {
                     //バックアップ成功時の処理
                     $file->close();
                     foreach ($lists[1] as $list) {
                         $file = new File($file_pass . '/' . $list);
                         $file->delete();
                         $file->close();
                     }
                 } else {
                     //バックアップ失敗時の処理
                     $file->close();
                     $admin_mail = Configure::read('admin_mail');
                     $email = new CakeEmail('gmail');
                     $email->to($admin_mail)->subject('【虹妹prprシステム通知】バックアップエラー通知')->template('backup_error', 'sister_mail')->viewVars(array('name' => '管理者'));
                     //mailに渡す変数
                     $email->send();
                 }
             }
             /* ログイン時に定期バックアップを判定して作成ここまで */
             $this->redirect($this->Auth->redirect());
         } else {
             $this->Flash->error(__('ユーザ名かパスワードが間違っています。'));
             $this->redirect('/login/');
         }
     }
 }
开发者ID:klapp303,项目名称:sister,代码行数:59,代码来源:LoginController.php

示例4: dot

 function dot($projects, $relations, $userId, $calculatedProjectIds, $filtertype = "hide")
 {
     // TODO secure $graphname!
     App::import('Model', 'ProjectsUsers');
     $projectsUsersClass = new ProjectsUsers();
     $projectAssocs = $projectsUsersClass->find('list', array('conditions' => array('ProjectsUsers.user_id' => $userId, 'OR' => array('ProjectsUsers.done' => 1, 'ProjectsUsers.wanted' => 1)), 'fields' => array('ProjectsUsers.project_id', 'ProjectsUsers.wanted')));
     $data = 'digraph go4d {' . "\n";
     foreach ($projects as $id => $name) {
         $dotProjectArr = array('label = "WP0' . $id . ': ' . $name . '"');
         $dotProjectArr[] = 'href="project_' . $id . '_imap"';
         if (in_array($id, array_keys($projectAssocs)) && $projectAssocs[$id]['wanted'] == 1) {
             $dotProjectArr[] = 'color="red"';
         } elseif (in_array($id, array_keys($projectAssocs))) {
             $dotProjectArr[] = 'color="green"';
         } elseif (in_array($id, $calculatedProjectIds)) {
             $dotProjectArr[] = 'color="black"';
         } else {
             if ($filtertype == "focus") {
                 $dotProjectArr[] = 'color="#aaaaaa"';
                 $dotProjectArr[] = 'fontcolor="#aaaaaa"';
             } elseif ($filtertype == "hide") {
                 $dotProjectArr = null;
             }
         }
         if ($dotProjectArr) {
             $data .= $id . ' [' . implode(', ', $dotProjectArr) . ']' . ";\n";
         }
     }
     foreach ($relations as $r) {
         $relStart = $r['Relation']['project_preceding_id'] . ' -> ' . $r['Relation']['project_id'];
         $relData = array('color' => 'color="#000044"');
         if ($r['Relation']['type'] == 'constraint') {
             $relData['color'] = 'color="green"';
         }
         if (!(in_array($r['Relation']['project_preceding_id'], $calculatedProjectIds) && in_array($r['Relation']['project_id'], $calculatedProjectIds))) {
             if ($filtertype == "focus") {
                 $relData = array('color' => 'color="#aaaaaa"');
             } elseif ($filtertype == "hide") {
                 $relData = null;
             }
         }
         if ($relData) {
             $data .= $relStart . ' [' . implode(', ', $relData) . "];\n";
         }
     }
     $data .= '}';
     $file = new File(TMP . 'graphs' . DS . $userId . '.dot', true);
     $file->write($data);
     $file->close();
     $cmd = 'dot -v -Tpng -o"' . IMAGES . 'graphs' . DS . $userId . '.png" -Timap_np -o"' . TMP . 'graphs' . DS . $userId . '.map" ' . TMP . 'graphs' . DS . $userId . '.dot';
     $graphOutput = shell_exec($cmd);
     $fn = IMAGES . 'graphs' . DS . $userId . '.png';
     //        header('Content-Length: '.filesize($fn));
     Configure::write('debug', 0);
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT', true, 200);
     header('Content-Type: image/png');
     print file_get_contents($fn);
     exit;
     //      return $graphOutput;
 }
开发者ID:ruxkor,项目名称:go4d,代码行数:60,代码来源:project.php

示例5: find

 function find($conditions = null, $fields = array(), $order = null, $recursive = null)
 {
     if ($conditions != 'range') {
         return parent::find($conditions, $fields, $order, $recursive);
     }
     $file = Set::extract($fields, 'file');
     if (empty($file)) {
         $file = ROOT . DS . APP_DIR . DS . 'plugins/mobileip/config/mobile_ips.yml';
     }
     if (!file_exists($file)) {
         return false;
     }
     $cacheDir = $this->getCacheDir();
     $folder = new Folder($cacheDir);
     $folder->create($cacheDir, 0777);
     $cacheFile = $this->getCacheFile();
     if (file_exists($cacheFile) && $this->_getLastModified($file) <= filemtime($cacheFile)) {
         return include $cacheFile;
     }
     $mobile_ips =& Spyc::YAMLLoad($file);
     if (!is_array($mobile_ips)) {
         return false;
     }
     $data = $this->_get_ranges($mobile_ips);
     $file = new File($cacheFile, true);
     $file->write($data);
     $file->close();
     return include $cacheFile;
 }
开发者ID:kaz29,项目名称:mobileip,代码行数:29,代码来源:mobile_ip.php

示例6: updateBower

 /**
  * Bower update
  *
  * @param Model $model Model using this behavior
  * @param string $plugin Plugin namespace
  * @param string $option It is '' or '--save'. '--save' is used install.
  * @return bool True on success
  */
 public function updateBower(Model $model, $plugin, $option = '')
 {
     if (!$plugin) {
         return false;
     }
     $pluginPath = ROOT . DS . 'app' . DS . 'Plugin' . DS . Inflector::camelize($plugin) . DS;
     if (!file_exists($pluginPath . 'bower.json')) {
         return true;
     }
     $file = new File($pluginPath . 'bower.json');
     $bower = json_decode($file->read(), true);
     $file->close();
     foreach ($bower['dependencies'] as $package => $version) {
         CakeLog::info(sprintf('[bower] Start bower install %s#%s for %s', $package, $version, $plugin));
         $messages = array();
         $ret = null;
         exec(sprintf('cd %s && `which bower` --allow-root install %s#%s %s', ROOT, $package, $version, $option), $messages, $ret);
         // Write logs
         if (Configure::read('debug')) {
             foreach ($messages as $message) {
                 CakeLog::info(sprintf('[bower]   %s', $message));
             }
         }
         CakeLog::info(sprintf('[bower] Successfully bower install %s#%s for %s', $package, $version, $plugin));
     }
     return true;
 }
开发者ID:Onasusweb,项目名称:PluginManager,代码行数:35,代码来源:BowerBehavior.php

示例7: admin_index

 /**
  * [ADMIN] サイトマップXML生成実行ページ
  */
 public function admin_index()
 {
     $path = WWW_ROOT . Configure::read('Sitemapxml.filename');
     if ($this->request->data) {
         $sitemap = $this->requestAction('/admin/sitemapxml/sitemapxml/create', array('return', $this->request->data));
         ClassRegistry::removeObject('View');
         $File = new File($path);
         $File->write($sitemap);
         $File->close();
         $this->setMessage('サイトマップの生成が完了しました。');
         chmod($path, 0666);
     }
     $dirWritable = true;
     $fileWritable = true;
     if (file_exists($path)) {
         if (!is_writable($path)) {
             $fileWritable = false;
         }
     } else {
         if (!is_writable(dirname($path))) {
             $dirWritable = false;
         }
     }
     $this->set('path', $path);
     $this->set('fileWritable', $fileWritable);
     $this->set('dirWritable', $dirWritable);
     $this->pageTitle = 'サイトマップXML作成';
     $this->render('index');
 }
开发者ID:kaburk,项目名称:basercms-sitemapxml,代码行数:32,代码来源:SitemapxmlController.php

示例8: admin_reset

 public function admin_reset($user_id)
 {
     if ($this->Auth->user('role') > 1) {
         $dir = new Folder('../webroot/img/avatars/');
         if ($dir->path != null) {
             // On supprime le fichier
             $files = $dir->find($user_id . '.jpg');
             foreach ($files as $file) {
                 $file = new File($dir->pwd() . DS . $file);
                 $file->delete();
                 $file->close();
             }
             // On sauvegarde
             $user = $this->User->find('first', ['conditions' => ['User.id' => $user_id]]);
             $username = $user['User']['username'];
             $avatar = 'http://cravatar.eu/helmavatar/' . $username;
             $this->User->id = $user_id;
             $this->User->saveField('avatar', $avatar);
             // Redirection
             $this->Session->setFlash('L\'avatar de ' . $username . ' a été réinitialisé', 'toastr_success');
             return $this->redirect(['controller' => 'users', 'action' => 'edit', $user_id]);
         }
     } else {
         throw new NotFoundException();
     }
 }
开发者ID:Mortex68,项目名称:ExtazCMS,代码行数:26,代码来源:AvatarsController.php

示例9: download

 function download()
 {
     $result = array('success' => true, 'error' => null);
     $home = Configure::read('20Couch.home');
     App::import('Core', array('HttpSocket', 'File'));
     $Http = new HttpSocket();
     $Setting = ClassRegistry::init('Setting');
     $url = sprintf('%s/registrations/direct/%s/' . Configure::read('Update.file'), $home, $Setting->find('value', 'registration_key'));
     $latest = $Http->get($url);
     if ($latest === false || $Http->response['status']['code'] != 200) {
         if ($Http->response['status']['code'] == 401) {
             $msg = 'Invalid registration key';
         } else {
             $msg = 'Unable to retrieve latest file from ' . $home;
         }
         $this->log($url);
         $this->log($Http->response);
         $result = array('success' => false, 'error' => $msg);
         $this->set('result', $result);
         return;
     }
     $File = new File(TMP . Configure::read('Update.file'), false);
     $File->write($latest);
     $File->close();
     $latestChecksum = trim($Http->get($home . '/checksum'));
     $yourChecksum = sha1_file(TMP . Configure::read('Update.file'));
     if ($yourChecksum != $latestChecksum) {
         $result = array('success' => false, 'error' => 'Checksum doesn\'t match (' . $yourChecksum . ' vs ' . $latestChecksum . ')');
         $this->set('result', $result);
         return;
     }
     $result = array('success' => true, 'error' => null);
     $this->set('result', $result);
 }
开发者ID:rchavik,项目名称:20Couch,代码行数:34,代码来源:update_controller.php

示例10: _rawParse

 private function _rawParse($filename, $attributes)
 {
     App::import('Vendor', 'import.excelreader/excelreader');
     $buffer = array();
     if (file_exists($filename)) {
         if (isset($attributes['delimiter']) && (isset($attributes['excel_reader']) && $attributes['excel_reader'])) {
             $xl = new ExcelReader();
             $xl->read($filename);
             $tmp_array = $xl->toArray();
             for ($i = 0; $i < 10; $i++) {
                 if (isset($tmp_array[$i])) {
                     $buffer[] = implode("\t", $tmp_array[$i]);
                 }
             }
         } else {
             $file = new File($filename);
             if ($file->open('r', true)) {
                 for ($i = 0; $i < 10; $i++) {
                     if (isset($attributes['delimiter']) && $attributes['delimiter'] != "") {
                         if (isset($attributes['qualifier']) && $attributes['qualifier'] != "") {
                             $buffer[] = @fgetcsv($file->handle, null, $attributes['delimiter'], $attributes['qualifier']);
                         } else {
                             $buffer[] = @fgetcsv($file->handle, null, $attributes['delimiter']);
                         }
                     }
                 }
                 $file->close();
             } else {
                 // Error
             }
         }
     }
     return $buffer;
 }
开发者ID:nicoeche,项目名称:Finalus,代码行数:34,代码来源:import.php

示例11: clear

 /**
  * Delete all values from the cache
  *
  * @param boolean $check Optional - only delete expired cache items
  * @return boolean True if the cache was succesfully cleared, false otherwise
  * @access public
  */
 function clear($check)
 {
     if (!$this->__init) {
         return false;
     }
     $dir = dir($this->settings['path']);
     if ($check) {
         $now = time();
         $threshold = $now - $this->settings['duration'];
     }
     while (($entry = $dir->read()) !== false) {
         if ($this->__setKey($entry) === false) {
             continue;
         }
         if ($check) {
             $mtime = $this->__File->lastChange();
             if ($mtime === false || $mtime > $threshold) {
                 continue;
             }
             $expires = $this->__File->read(11);
             $this->__File->close();
             if ($expires > $now) {
                 continue;
             }
         }
         $this->__File->delete();
     }
     $dir->close();
     return true;
 }
开发者ID:masayukiando,项目名称:googlemap-search_ActionScript3.0,代码行数:37,代码来源:file.php

示例12: _setupDatabase

 /**
  * Execute Config/cakegallery.sql to create the tables
  * Create the config File
  * @param $db
  */
 private function _setupDatabase($db)
 {
     # Execute the SQL to create the tables
     $sqlFile = new File(App::pluginPath('Gallery') . 'Config' . DS . 'cakegallery.sql', false);
     $db->rawQuery($sqlFile->read());
     $sqlFile->close();
 }
开发者ID:brnagn7,项目名称:spydercake,代码行数:12,代码来源:InstallController.php

示例13: addUuids

 /**
  * add uuids to tl_gallery_creator_pictures version added in 4.8.0
  */
 public static function addUuids()
 {
     // add field
     if (!\Database::getInstance()->fieldExists('uuid', 'tl_gallery_creator_pictures')) {
         \Database::getInstance()->query("ALTER TABLE `tl_gallery_creator_pictures` ADD `uuid` BINARY(16) NULL");
     }
     $objDB = \Database::getInstance()->execute("SELECT * FROM tl_gallery_creator_pictures WHERE uuid IS NULL");
     while ($objDB->next()) {
         if ($objDB->path == '') {
             continue;
         }
         if (is_file(TL_ROOT . '/' . $objDB->path)) {
             \Dbafs::addResource($objDB->path);
         } else {
             continue;
         }
         $oFile = new \File($objDB->path);
         $oFile->close();
         $fileModel = $oFile->getModel();
         if (\Validator::isUuid($fileModel->uuid)) {
             \Database::getInstance()->prepare("UPDATE tl_gallery_creator_pictures SET uuid=? WHERE id=?")->execute($fileModel->uuid, $objDB->id);
             $_SESSION["TL_CONFIRM"][] = "Added a valid file-uuid into tl_gallery_creator_pictures.uuid ID " . $objDB->id . ". Please check if all the galleries are running properly.";
         }
     }
 }
开发者ID:Aiod,项目名称:gallery_creator,代码行数:28,代码来源:runonce.php

示例14: loadDebuggerstate

 public function loadDebuggerstate($varValue, $dc)
 {
     $objFile = new File('system/config/initconfig.php');
     $strContent = $objFile->getContent();
     $objFile->close();
     return $varValue && strpos($strContent, self::DEBUGCONFIG_STRING);
 }
开发者ID:unmaintained-stuff,项目名称:tl_debug,代码行数:7,代码来源:TYPOlightDebugHelper.php

示例15: _rawParse

 protected function _rawParse()
 {
     if (file_exists($this->filename)) {
         if (isset($this->options['delimiter']) && (isset($this->options['excel_reader']) && $this->options['excel_reader'])) {
             $xl = new ExcelReader();
             $xl->read($this->filename);
             $tmp_array = $xl->toArray();
             for ($i = 0; $i < 10; $i++) {
                 if (isset($tmp_array[$i])) {
                     $buffer[] = implode("\t", $tmp_array[$i]);
                 }
             }
         } else {
             $file = new File($this->filename);
             if ($file->open('r', true)) {
                 for ($i = 0; $i < 10; $i++) {
                     if (isset($this->options['delimiter']) && $this->options['delimiter'] != "") {
                         if (isset($this->options['qualifier']) && $this->options['qualifier'] != "") {
                             $buffer[] = @fgetcsv($file->handle, null, $this->options['delimiter'], $this->options['qualifier']);
                         } else {
                             $buffer[] = @fgetcsv($file->handle, null, $this->options['delimiter']);
                         }
                     }
                 }
                 $file->close();
             } else {
                 // Error
             }
         }
     }
     return $buffer;
 }
开发者ID:nicoeche,项目名称:Finalus,代码行数:32,代码来源:parser.php


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