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


PHP FileUtil::rrmdir方法代码示例

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


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

示例1: deleteModuleData

 /**
  * Helper function to remove the files and SQL data associated with a module
  * @param string $moduleName Name of the module to delete
  */
 private function deleteModuleData($moduleName)
 {
     $config = (include 'protected/modules/' . $moduleName . '/register.php');
     $uninstall = $config['uninstall'];
     if (isset($config['version'])) {
         foreach ($uninstall as $sql) {
             // New convention:
             // If element is a string, treat as a path to an SQL script file.
             // Otherwise, if array, treat as a list of SQL commands to run.
             $sqlComm = $sql;
             if (is_string($sql)) {
                 if (file_exists($sql)) {
                     $sqlComm = explode('/*&*/', file_get_contents($sql));
                 }
             }
             foreach ($sqlComm as $sqlLine) {
                 $query = Yii::app()->db->createCommand($sqlLine);
                 try {
                     $query->execute();
                 } catch (CDbException $e) {
                 }
             }
         }
     } else {
         // The old way, for backwards compatibility:
         foreach ($uninstall as $sql) {
             $query = Yii::app()->db->createCommand($sql);
             $query->execute();
         }
     }
     X2Model::model('Fields')->deleteAllByAttributes(array('modelName' => $moduleName));
     X2Model::model('Fields')->updateAll(array('linkType' => null, 'type' => 'varchar'), "linkType='{$moduleName}'");
     X2Model::model('FormLayout')->deleteAllByAttributes(array('model' => $moduleName));
     X2Model::model('Relationships')->deleteAll('firstType = :model OR secondType = :model', array(':model' => $moduleName));
     $auth = Yii::app()->authManager;
     $ucName = ucfirst($moduleName);
     $auth->removeAuthItem($ucName . 'GetItems');
     $auth->removeAuthItem($ucName . 'View');
     $auth->removeAuthItem($ucName . 'Create');
     $auth->removeAuthItem($ucName . 'Update');
     $auth->removeAuthItem($ucName . 'Index');
     $auth->removeAuthItem($ucName . 'Admin');
     $auth->removeAuthItem($ucName . 'Delete');
     $auth->removeAuthItem($ucName . 'GetTerms');
     $auth->removeAuthItem($ucName . 'DeleteNote');
     $auth->removeAuthItem($ucName . 'Search');
     $auth->removeAuthItem($ucName . 'AdminAccess');
     $auth->removeAuthItem($ucName . 'FullAccess');
     $auth->removeAuthItem($ucName . 'PrivateFullAccess');
     $auth->removeAuthItem($ucName . 'UpdateAccess');
     $auth->removeAuthItem($ucName . 'PrivateUpdateAccess');
     $auth->removeAuthItem($ucName . 'BasicAccess');
     $auth->removeAuthItem($ucName . 'ReadOnlyAccess');
     $auth->removeAuthItem($ucName . 'PrivateReadOnlyAccess');
     $auth->removeAuthItem($ucName . 'MinimumRequirements');
     $auth->removeAuthItem($ucName . 'ViewPrivate');
     $auth->removeAuthItem($ucName . 'UpdatePrivate');
     $auth->removeAuthItem($ucName . 'DeletePrivate');
     FileUtil::rrmdir('protected/modules/' . $moduleName);
 }
开发者ID:xl602,项目名称:X2CRM,代码行数:64,代码来源:AdminController.php

示例2: testDownloadSourceFile

 public function testDownloadSourceFile()
 {
     $ube = $this->instantiateUBe();
     $file = "protected/components/views/requirements.php";
     if (is_dir($tmpdir = $ube->webRoot . DIRECTORY_SEPARATOR . 'tmp')) {
         FileUtil::rrmdir($tmpdir);
     }
     //  rename($file, "{$ube->webRoot}/requirements-original.php");
     $ube->downloadSourceFile($file, $ube->getSourceFileRoute('opensource', 'none'));
     $this->assertFileExists($tmpdir . DIRECTORY_SEPARATOR . $file);
     FileUtil::rrmdir($tmpdir);
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:12,代码来源:UpdaterBehaviorTest.php

示例3: installStage


//.........这里部分代码省略.........
                    include "initialize_{$ed}.php";
                }
            }
            break;
        default:
            // Look for a named SQL file and run it:
            $stagePath = "protected/data/{$stage}.sql";
            if ($stage == 'dummy_data') {
                $stageLabels['dummy_data'] = sprintf($stageLabels['dummy_data'], $config['dummy_data'] ? 'insert' : 'delete');
            }
            if ((bool) (int) $config['dummy_data'] || $stage != 'dummy_data') {
                if ($sqlFile = realpath($stagePath)) {
                    $sql = explode('/*&*/', file_get_contents($sqlFile));
                    foreach ($sql as $sqlLine) {
                        $statement = $dbo->prepare($sqlLine);
                        try {
                            if (!$statement->execute()) {
                                RIP(installer_tr('Could not {stage}. SQL statement "{sql}" from {file} failed', array('{stage}' => $stageLabels[$stage], '{sql}' => substr(trim($sqlLine), 0, 50) . (strlen(trim($sqlLine)) > 50 ? '...' : ''), '{file}' => $sqlFile)) . '; ' . implode(',', $statement->errorInfo()));
                            }
                        } catch (PDOException $e) {
                            RIP(installer_tr("Could not {stage}", array('{stage}' => $stageLabels[$stage])) . '; ' . $e->getMessage());
                        }
                    }
                    // Hunt for init SQL files associated with other editions:
                    foreach ($editions as $ed) {
                        if ($sqlFile = realpath("protected/data/{$stage}-{$ed}.sql")) {
                            $sql = explode('/*&*/', file_get_contents($sqlFile));
                            foreach ($sql as $sqlLine) {
                                $statement = $dbo->prepare($sqlLine);
                                try {
                                    if (!$statement->execute()) {
                                        RIP(installer_tr('Could not {stage}. SQL statement "{sql}" from {file} failed', array('{stage}' => $stageLabels[$stage], '{sql}' => substr(trim($sqlLine), 0, 50) . (strlen($sqlLine) > 50 ? '...' : ''), '{file}' => $sqlFile)) . '; ' . implode(',', $statement->errorInfo()));
                                    }
                                } catch (PDOException $e) {
                                    RIP(installer_tr("Could not {stage}", array('{stage}' => $stageLabels[$stage])) . '; ' . $e->getMessage());
                                }
                            }
                        }
                    }
                    if ($stage == 'dummy_data') {
                        // Need to update the timestamp fields on all the sample data that has been inserted.
                        $dateGen = @file_get_contents(realpath("protected/data/dummy_data_date")) or RIP("Sample data generation date not set.");
                        $time = time();
                        $time2 = $time * 2;
                        $timeDiff = $time - (int) trim($dateGen);
                        foreach ($dateFields as $table => $fields) {
                            $tableEdition = 'opensource';
                            foreach ($editions as $ed) {
                                if (in_array($table, $nonFreeTables[$ed])) {
                                    $tableEdition = $ed;
                                    break;
                                }
                            }
                            if (!(bool) $editionHierarchy[$config['edition']][$tableEdition]) {
                                // Table not "contained" in the current edition
                                continue;
                            }
                            foreach ($fields as $field) {
                                try {
                                    $dbo->exec("UPDATE `{$table}` SET `{$field}`=`{$field}`+{$timeDiff} WHERE `{$field}` IS NOT NULL AND `{$field}`!=0 AND `{$field}`!=''");
                                } catch (Exception $e) {
                                    // Ignore it and move on; table/column doesn't exist.
                                    continue;
                                }
                            }
                            // Fix timestamps that are in the future.
                            /*
                             $ordered = array('lastUpdated','createDate');
                             if(count(array_intersect($ordered,$fields)) == count($ordered)) {
                             $affected = 0;
                             foreach($ordered as $field) {
                             $affected += $dbo->exec("UPDATE `$table` SET `$field`=$time2-`$field` WHERE `$field` > $time");
                             }
                             if($affected)
                             $dbo->exec("UPDATE `$table` set `lastUpdated`=`createDate`,`createDate`=`lastUpdated` WHERE `createDate` > `lastUpdated`");
                             }
                            */
                        }
                    }
                } else {
                    RIP(installer_t("Could not find installation stage database script") . " {$stagePath}");
                }
            } else {
                // This is the dummy data stage, and we need to clear out all unneeded files.
                // However, we should leave the files alone if this is a testing database reinstall.
                $stageLabels[$stage] = sprintf($stageLabels[$stage], 'remove');
                if (($paths = @(require_once realpath('protected/data/dummy_data_files.php'))) && !$config['test_db']) {
                    foreach ($paths as $pathClear) {
                        if ($path = realpath($pathClear)) {
                            FileUtil::rrmdir($path, '/\\.htaccess$/');
                        }
                    }
                }
            }
            break;
    }
    if (in_array($stage, array_keys($stageLabels)) && $stage != 'finalize' && !($stage == 'validate' && $silent)) {
        ResponseUtil::respond(installer_tr("Completed: {stage}", array('{stage}' => $stageLabels[$stage])));
    }
}
开发者ID:keyeMyria,项目名称:CRM,代码行数:101,代码来源:initialize.php

示例4: cleanupModule

 /**
  * Copy a module directory structure from the tests/data directory
  */
 protected function cleanupModule($moduleName)
 {
     $dest = implode(DIRECTORY_SEPARATOR, array(Yii::app()->basePath, 'modules', $moduleName));
     FileUtil::rrmdir($dest);
     $this->assertTrue(!is_dir($dest));
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:9,代码来源:AdminControllerTest.php

示例5: testFailPathRmDir

 public function testFailPathRmDir()
 {
     $this->setupTestDirs();
     FileUtil::rrmdir(FileUtil::rpath($this->baseDir . '/subdir1/.'));
     $this->assertFileNotExists(FileUtil::rpath($this->baseDir . '/subdir1/testFile'));
     $this->removeTestDirs();
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:7,代码来源:FileUtilTest.php

示例6: updateUpdater

 /**
  * In which the updater downloads a new version of itself.
  * 
  * @param type $updaterCheck New version of the update utility
  * @return array
  */
 public function updateUpdater($updaterCheck)
 {
     if (version_compare($this->configVars['updaterVersion'], $updaterCheck) >= 0) {
         return array();
     }
     $updaterFiles = $this->updaterFiles;
     // Retrieve the update package contents' files' digests:
     $md5sums_content = FileUtil::getContents($this->updateServer . '/' . $this->getUpdateDataRoute($this->configVars['updaterVersion']) . '/contents.md5');
     // If there's an error on the server end the response will be a JSON
     $tryJson = json_decode($md5sums_content, 1);
     if (!(bool) $md5sums_content) {
         $admin = CActiveRecord::model('Admin')->findByPk(1);
         if ($this->scenario === 'upgrade' && isset($admin) && empty($admin->unique_key)) {
             $updaterSettingsLink = CHtml::link(Yii::t('admin', 'Updater Settings page'), array('admin/updaterSettings'));
             throw new CException(Yii::t('admin', 'You must first set a product key on the ' . $updaterSettingsLink));
         } else {
             throw new CException(Yii::t('admin', 'Unknown update server error.'), self::ERR_UPSERVER);
         }
     } else {
         if (is_array($tryJson)) {
             // License key error
             if (isset($tryJson['errors'])) {
                 throw new CException($tryJson['errors']);
             } else {
                 throw new CException(Yii::t('admin', 'Unknown update server error.') . ' ' . $md5sums_content);
             }
         }
     }
     preg_match_all(':^(?<md5sum>[a-f0-9]{32})\\s+source/protected/(?<filename>\\S.*)$:m', $md5sums_content, $md5s);
     $md5sums = array();
     for ($i = 0; $i < count($md5s[0]); $i++) {
         $md5sums[$md5s['md5sum'][$i]] = $md5s['filename'][$i];
     }
     // These are the files that need to be downloaded -- only those which have changed:
     $updaterFiles = array_intersect($md5sums, $updaterFiles);
     // Try to retrieve the files:
     $failed2Retrieve = array();
     foreach ($updaterFiles as $md5 => $file) {
         $pass = 0;
         $tries = 0;
         $downloadedFile = FileUtil::relpath(implode(DIRECTORY_SEPARATOR, array($this->webRoot, self::TMP_DIR, 'protected', FileUtil::rpath($file))), $this->thisPath . DIRECTORY_SEPARATOR);
         while (!$pass && $tries < 2) {
             $remoteFile = $this->updateServer . '/' . $this->sourceFileRoute . "/protected/{$file}";
             try {
                 $this->downloadSourceFile("protected/{$file}");
             } catch (Exception $e) {
                 break;
             }
             // Only call it done if it's intact and ready for use:
             $pass = md5_file($downloadedFile) == $md5;
             $tries++;
         }
         if (!$pass) {
             $failed2Retrieve[] = "protected/{$file}";
         }
     }
     $failedDownload = (bool) count($failed2Retrieve);
     // Copy the files into the live install
     if (!$failedDownload && (bool) count($updaterFiles)) {
         $this->applyFiles(self::TMP_DIR);
         // Remove the temporary directory:
         FileUtil::rrmdir($this->webRoot . DIRECTORY_SEPARATOR . self::TMP_DIR);
     } else {
         $errorResponse = json_decode($md5sums_content, 1);
         if (isset($errorResponse['errors'])) {
             throw new CException($errorResponse['errors']);
         }
     }
     // Write the new updater version into the configuration; else
     // the app will get stuck in a redirect loop
     if (!$failedDownload) {
         $this->regenerateConfig(Null, $updaterCheck, Null);
     }
     return $failed2Retrieve;
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:81,代码来源:UpdaterBehavior.php

示例7: tearDown

 public function tearDown()
 {
     $files = array_diff(scandir($this->mediaSrc), $this->exclude);
     foreach ($files as $file) {
         FileUtil::rrmdir($this->migrationDest . DIRECTORY_SEPARATOR . $file);
     }
     $this->assertEquals($this->migrationCount, count(array_diff(scandir($this->migrationDest), $this->exclude)));
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:8,代码来源:MigrateMediaFiles.php

示例8: deleteModuleData

 /**
  * Helper function to remove the files and SQL data associated with a module
  * @param string $moduleName Name of the module to delete
  */
 private function deleteModuleData($moduleName)
 {
     $registerFile = 'protected/modules/' . $moduleName . '/register.php';
     if (!is_file($registerFile)) {
         return;
     }
     $config = (include $registerFile);
     $uninstall = $config['uninstall'];
     if (isset($config['version'])) {
         foreach ($uninstall as $sql) {
             // New convention:
             // If element is a string, treat as a path to an SQL script file.
             // Otherwise, if array, treat as a list of SQL commands to run.
             $sqlComm = $sql;
             if (is_string($sql)) {
                 if (file_exists($sql)) {
                     $sqlComm = explode('/*&*/', file_get_contents($sql));
                 }
             }
             foreach ($sqlComm as $sqlLine) {
                 $query = Yii::app()->db->createCommand($sqlLine);
                 try {
                     $query->execute();
                 } catch (CDbException $e) {
                 }
             }
         }
     } else {
         // The old way, for backwards compatibility:
         foreach ($uninstall as $sql) {
             $query = Yii::app()->db->createCommand($sql);
             $query->execute();
         }
     }
     X2Model::model('Fields')->deleteAllByAttributes(array('modelName' => ucfirst($moduleName)));
     X2Model::model('Fields')->updateAll(array('linkType' => null, 'type' => 'varchar'), "linkType='{$moduleName}'");
     X2Model::model('FormLayout')->deleteAllByAttributes(array('model' => $moduleName));
     X2Model::model('Relationships')->deleteAll('firstType = :model OR secondType = :model', array(':model' => $moduleName));
     $auth = Yii::app()->authManager;
     $ucName = ucfirst($moduleName);
     $auth->removeAuthItem($ucName . 'GetItems');
     $auth->removeAuthItem($ucName . 'View');
     $auth->removeAuthItem($ucName . 'Create');
     $auth->removeAuthItem($ucName . 'Update');
     $auth->removeAuthItem($ucName . 'Index');
     $auth->removeAuthItem($ucName . 'Admin');
     $auth->removeAuthItem($ucName . 'Delete');
     $auth->removeAuthItem($ucName . 'GetTerms');
     $auth->removeAuthItem($ucName . 'DeleteNote');
     $auth->removeAuthItem($ucName . 'Search');
     $auth->removeAuthItem($ucName . 'AdminAccess');
     $auth->removeAuthItem($ucName . 'FullAccess');
     $auth->removeAuthItem($ucName . 'PrivateFullAccess');
     $auth->removeAuthItem($ucName . 'UpdateAccess');
     $auth->removeAuthItem($ucName . 'PrivateUpdateAccess');
     $auth->removeAuthItem($ucName . 'BasicAccess');
     $auth->removeAuthItem($ucName . 'ReadOnlyAccess');
     $auth->removeAuthItem($ucName . 'PrivateReadOnlyAccess');
     $auth->removeAuthItem($ucName . 'MinimumRequirements');
     $auth->removeAuthItem($ucName . 'ViewPrivate');
     $auth->removeAuthItem($ucName . 'UpdatePrivate');
     $auth->removeAuthItem($ucName . 'DeletePrivate');
     $auth->removeAuthItem($ucName . 'MobileView');
     $auth->removeAuthItem($ucName . 'QuickView');
     $auth->removeAuthItem($ucName . 'MobileIndex');
     $auth->removeAuthItem($ucName . 'MobileCreate');
     $auth->removeAuthItem($ucName . 'MobileDelete');
     $auth->removeAuthItem($ucName . 'MobileUpdate');
     $auth->removeAuthItem($ucName . 'GetX2ModelInput');
     $auth->removeAuthItem($ucName . 'AjaxGetModelAutocomplete');
     $auth->removeAuthItem($ucName . 'X2GridViewMassAction');
     $auth->removeAuthItem($ucName . 'InlineEmail');
     // Remove related Summary widgets
     foreach (Profile::model()->findAll() as $profile) {
         $settings = $profile->getProfileWidgetLayout();
         foreach ($settings as $key => $data) {
             if (isset($data['modelType']) && $data['modelType'] === $ucName) {
                 $settings[$key] = null;
             }
         }
         $profile->setProfileWidgetLayout($settings);
         $profile->save();
     }
     FileUtil::rrmdir('protected/modules/' . $moduleName);
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:89,代码来源:AdminController.php


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