本文整理汇总了PHP中rmdirr函数的典型用法代码示例。如果您正苦于以下问题:PHP rmdirr函数的具体用法?PHP rmdirr怎么用?PHP rmdirr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rmdirr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rmdirr
function rmdirr($dirname, $oc = 0)
{
// Sanity check
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname) && time() - fileatime($dirname) > 3600) {
return unlink($dirname);
}
// Loop through the folder
if (is_dir($dirname)) {
$dir = dir($dirname);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry === '.' || $entry === '..') {
continue;
}
// Recurse
rmdirr($dirname . '/' . $entry, $oc);
}
$dir->close();
}
// Clean up
if ($oc == 1) {
return rmdir($dirname);
}
}
示例2: processBlogSettingsForm
function processBlogSettingsForm()
{
global $manager;
$upload_path = $_POST['upload_path'];
$upload_url = "http://" . str_replace("http://", "", $_POST['upload_url']);
$old_uploadpath = $_POST['old_uploadpath'];
// Prepare path and url...
if (strrchr($upload_path, "/") != "/") {
$upload_path .= "/";
}
if (strrchr($upload_url, "/") != "/") {
$upload_url .= "/";
}
if ($upload_path != $old_uploadpath) {
// Need to move files then...
dircopy($old_uploadpath, $upload_path);
rmdirr($old_uploadpath);
}
$manager->clerk->updateSetting("blog_path", array($upload_path, $upload_url, ""));
$thumbWidth = empty($_POST['thumbWidth']) ? 0 : $_POST['thumbWidth'];
$thumbHeight = empty($_POST['thumbHeight']) ? 0 : $_POST['thumbHeight'];
$intelliScaling = $_POST['intelligentScaling'];
$manager->clerk->updateSetting("blog_thumbnail", array($thumbWidth, $thumbHeight, ""));
$manager->clerk->updateSetting("blog_intelliscaling", array($intelliScaling, "", ""));
$manager->message(1, false, "Settings updated!");
}
示例3: rmdirr
/**
* Delete a file, or a folder and its contents (recursive algorithm)
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.3
* @link http://aidanlister.com/repos/v/function.rmdirr.php
* @param string $dirname Directory to delete
* @return bool Returns TRUE on success, FALSE on failure
*/
function rmdirr($dirname)
{
// Sanity check
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname) || is_link($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..' || $entry == '.svn') {
continue;
}
// Recurse
rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
}
// Clean up
$dir->close();
return;
// rmdir($dirname);
}
示例4: testAddDocument
public function testAddDocument()
{
$configuration = za()->getConfig('services');
if (!$configuration) {
echo "No services config found\n";
return;
}
$searchConfig = ifset($configuration, 'SearchService');
if (!$searchConfig) {
echo "SearchService config not found\n";
return;
}
$path = ifset($searchConfig, 'index');
if (!$path) {
echo "No search path set\n";
return;
}
// Delete the search path
rmdirr($path);
$searchService = za()->getService('SearchService');
$example = new Task();
$example->id = 1;
$example->title = 'Task for testing';
$example->description = "Task description for testing";
try {
$searchService->index($example);
} catch (Exception $e) {
print_r($e);
}
$results = $searchService->search("testing");
$this->assertEqual(count($results), 1);
}
示例5: create_dummy_course
/**
* Create the dummy course
*/
function create_dummy_course($course_code)
{
$this->default_property['insert_user_id'] = '1';
$this->default_property['insert_date'] = date('Y-m-d H:i:s');
$this->default_property['lastedit_date'] = date('Y-m-d H:i:s');
$this->default_property['lastedit_user_id'] = '1';
$this->default_property['to_group_id'] = '0';
$this->default_property['to_user_id'] = null;
$this->default_property['visibility'] = '1';
$this->default_property['start_visible'] = '0000-00-00 00:00:00';
$this->default_property['end_visible'] = '0000-00-00 00:00:00';
$course = Database::get_course_info($course_code);
$this->course = new Course();
$tmp_path = api_get_path(SYS_COURSE_PATH) . $course['directory'] . '/document/tmp_' . uniqid('');
@mkdir($tmp_path, api_get_permissions_for_new_directories(), true);
$this->course->backup_path = $tmp_path;
$this->create_dummy_links();
$this->create_dummy_events();
$this->create_dummy_forums();
$this->create_dummy_announcements();
$this->create_dummy_documents();
$this->create_dummy_learnpaths();
$cr = new CourseRestorer($this->course);
$cr->set_file_option(FILE_OVERWRITE);
$cr->restore($course_code);
rmdirr($tmp_path);
}
示例6: up
function up()
{
$db = DBManager::get();
$db->exec("\n CREATE TABLE IF NOT EXISTS `blubber` (\n `topic_id` varchar(32) NOT NULL DEFAULT '',\n `parent_id` varchar(32) NOT NULL DEFAULT '',\n `root_id` varchar(32) NOT NULL DEFAULT '',\n `context_type` enum('public','private','course') NOT NULL DEFAULT 'public',\n `name` varchar(255) DEFAULT NULL,\n `description` text,\n `mkdate` int(20) NOT NULL DEFAULT '0',\n `chdate` int(20) NOT NULL DEFAULT '0',\n `author_host` varchar(255) DEFAULT NULL,\n `Seminar_id` varchar(32) NOT NULL DEFAULT '',\n `user_id` varchar(32) NOT NULL DEFAULT '',\n `external_contact` tinyint(4) NOT NULL DEFAULT '0',\n PRIMARY KEY (`topic_id`),\n KEY `root_id` (`root_id`),\n KEY `Seminar_id` (`Seminar_id`),\n KEY `parent_id` (`parent_id`),\n KEY `chdate` (`chdate`),\n KEY `mkdate` (`mkdate`),\n KEY `user_id` (`user_id`,`Seminar_id`)\n ) ENGINE=MyISAM;\n ");
//Spezialevents, bisher nur für Löschen von Beiträgen verwendet
$db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_events_queue` (\n `event_type` varchar(32) NOT NULL,\n `item_id` varchar(32) NOT NULL,\n `mkdate` int(11) NOT NULL,\n PRIMARY KEY (`event_type`,`item_id`,`mkdate`),\n KEY `item_id` (`item_id`)\n ) ENGINE=MyISAM\n ");
//Blubberautoren, die nicht in Stud.IP angemeldet sind wie anonyme
$db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_external_contact` (\n `external_contact_id` varchar(32) NOT NULL,\n `mail_identifier` varchar(256) DEFAULT NULL,\n `contact_type` varchar(16) NOT NULL DEFAULT 'anonymous',\n `name` varchar(256) NOT NULL,\n `data` text,\n `chdate` bigint(20) NOT NULL,\n `mkdate` bigint(20) NOT NULL,\n PRIMARY KEY (`external_contact_id`),\n KEY `mail_identifier` (`mail_identifier`),\n KEY `contact_type` (`contact_type`)\n ) ENGINE=MyISAM\n ");
$db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_follower` (\n `studip_user_id` varchar(32) NOT NULL,\n `external_contact_id` varchar(32) NOT NULL,\n `left_follows_right` tinyint(1) NOT NULL,\n KEY `studip_user_id` (`studip_user_id`),\n KEY `external_contact_id` (`external_contact_id`)\n ) ENGINE=MyISAM\n ");
//Rechte für private Blubber
$db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_mentions` (\n `topic_id` varchar(32) NOT NULL,\n `user_id` varchar(32) NOT NULL,\n `external_contact` tinyint(4) NOT NULL DEFAULT '0',\n `mkdate` int(11) NOT NULL,\n UNIQUE KEY `unique_users_per_topic` (`topic_id`,`user_id`,`external_contact`),\n KEY `topic_id` (`topic_id`),\n KEY `user_id` (`user_id`)\n ) ENGINE=MyISAM\n ");
$old_blubber = $db->query("SELECT * FROM plugins WHERE pluginclassname = 'Blubber' " . "")->fetch(PDO::FETCH_ASSOC);
if ($old_blubber) {
//Umschreiben des Ortes von Blubber
$db->exec("\n UPDATE plugins SET pluginpath = 'core/Blubber' WHERE pluginclassname = 'Blubber'\n ");
if ($old_blubber['pluginpath'] !== "core/Blubber") {
@rmdirr($GLOBALS['PLUGINS_PATH'] . "/" . $old_blubber['pluginpath']);
}
$db->exec("\n INSERT IGNORE INTO blubber (`topic_id`,`parent_id`,`root_id`,`context_type`,`name`,`description`,`mkdate`,`chdate`,`author_host`,`Seminar_id`,`user_id`,`external_contact`)\n SELECT `topic_id`,`parent_id`,`root_id`,'course',`name`,`description`,`mkdate`,`chdate`,`author_host`,`Seminar_id`,`user_id`,0\n FROM px_topics\n ");
} else {
//Installieren des Plugins
$db->exec("\n INSERT INTO plugins\n SET pluginclassname = 'Blubber',\n pluginpath = 'core/Blubber',\n pluginname = 'Blubber',\n plugintype = 'StandardPlugin,SystemPlugin',\n enabled = 'yes',\n navigationpos = '1'\n ");
$plugin_id = $db->lastInsertId();
$db->exec("\n INSERT IGNORE INTO roles_plugins (roleid, pluginid)\n SELECT roleid, " . $db->quote($plugin_id) . " FROM roles WHERE system = 'y'\n ");
}
}
示例7: installFile
public function installFile()
{
$hash = md5(uniqid());
$tmp_folder = $GLOBALS['TMP_PATH'] . "/temp_plugin_" . $hash;
mkdir($tmp_folder);
$file = $GLOBALS['TMP_PATH'] . "/temp_plugin_" . $hash . ".zip";
if ($this['repository_download_url']) {
file_put_contents($file, file_get_contents($this['repository_download_url']));
} elseif ($_FILES['release_file']['tmp_name']) {
move_uploaded_file($_FILES['release_file']['tmp_name'], $file);
} else {
return false;
}
unzip_file($file, $tmp_folder);
$objects = scandir($tmp_folder);
if (count($objects) === 3) {
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
$plugin_dir = $tmp_folder . "/" . $object;
}
}
} else {
$plugin_dir = $tmp_folder;
}
$this->installFromDirectory($plugin_dir, $file);
rmdirr($tmp_folder);
unlink($file);
$this['chdate'] = time();
NotificationCenter::postNotification("PluginReleaseDidUpdateCode", $this);
}
示例8: rmdirr
function rmdirr($dir)
{
if ($objs = glob($dir . "/*")) {
foreach ($objs as $obj) {
is_dir($obj) ? rmdirr($obj) : unlink($obj);
}
}
rmdir($dir);
}
示例9: clean_cache
/**
* 清理指定位置缓存
* @param $dirname
* @author 郑钟良<zzl@ourstu.com>
*/
function clean_cache($dirname = './Runtime/')
{
//清文件缓存
$dirs = array($dirname);
//清理缓存
foreach ($dirs as $value) {
rmdirr($value);
}
@mkdir($dirname, 0777, true);
}
示例10: cleanall
public function cleanall()
{
alogs("Global", 0, 1, '执行了所有缓存清除操作!');
//管理员操作日志
$dirs = array(C('APP_ROOT') . 'Runtime');
foreach ($dirs as $value) {
rmdirr($value);
echo "<div style='border:2px solid green; background:#f1f1f1; padding:20px;margin:20px;width:800px;font-weight:bold;color:green;text-align:center;'>\"" . $value . "\" 目录下缓存清除成功! </div> <br /><br />";
@mkdir($value, 0777, true);
}
}
示例11: deleteAction
public function deleteAction($key = null)
{
/* make sure we don't have any path /'s */
$key = str_replace('/', '', $key);
if (is_dir($this->config->item('cache_path') . '/' . $key)) {
$success = rmdirr($this->config->item('cache_path') . '/' . $key);
} else {
$success = $this->cache->delete($key);
}
$this->output->json('err', !$success);
}
示例12: importlabelresources
/**
* Function responsible to import label resources from a '.zip' file.
*
* @access public
* @return void
*/
public function importlabelresources()
{
if (!Permission::model()->hasGlobalPermission('labelsets', 'edit')) {
Yii::app()->session['flashmessage'] = gT('Access denied!');
$this->getController()->redirect(App()->createUrl("/admin"));
}
$lid = returnGlobal('lid');
if (!empty($lid)) {
if (Yii::app()->getConfig('demoMode')) {
$this->getController()->error(gT("Demo mode only: Uploading files is disabled in this system."), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
}
// Create temporary directory
// If dangerous content is unzipped
// then no one will know the path
$extractdir = $this->_tempdir(Yii::app()->getConfig('tempdir'));
$zipfilename = $_FILES['the_file']['tmp_name'];
$basedestdir = Yii::app()->getConfig('uploaddir') . "/labels";
$destdir = $basedestdir . "/{$lid}/";
Yii::app()->loadLibrary('admin.pclzip');
$zip = new PclZip($zipfilename);
if (!is_writeable($basedestdir)) {
$this->getController()->error(sprintf(gT("Incorrect permissions in your %s folder."), $basedestdir), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
}
if (!is_dir($destdir)) {
mkdir($destdir);
}
$aImportedFilesInfo = array();
$aErrorFilesInfo = array();
if (is_file($zipfilename)) {
if ($zip->extract($extractdir) <= 0) {
$this->getController()->error(gT("This file is not a valid ZIP file archive. Import failed. " . $zip->errorInfo(true)), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
}
// now read tempdir and copy authorized files only
$folders = array('flash', 'files', 'images');
foreach ($folders as $folder) {
list($_aImportedFilesInfo, $_aErrorFilesInfo) = $this->_filterImportedResources($extractdir . "/" . $folder, $destdir . $folder);
$aImportedFilesInfo = array_merge($aImportedFilesInfo, $_aImportedFilesInfo);
$aErrorFilesInfo = array_merge($aErrorFilesInfo, $_aErrorFilesInfo);
}
// Deletes the temp directory
rmdirr($extractdir);
// Delete the temporary file
unlink($zipfilename);
if (is_null($aErrorFilesInfo) && is_null($aImportedFilesInfo)) {
$this->getController()->error(gT("This ZIP archive contains no valid Resources files. Import failed."), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
}
} else {
$this->getController()->error(gT("An error occurred uploading your file. This may be caused by incorrect permissions for the application /tmp folder."), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
}
$aData = array('aErrorFilesInfo' => $aErrorFilesInfo, 'aImportedFilesInfo' => $aImportedFilesInfo, 'lid' => $lid);
$this->_renderWrappedTemplate('labels', 'importlabelresources_view', $aData);
}
}
示例13: edit_action
public function edit_action($material_id = null)
{
$this->material = new LernmarktplatzMaterial($material_id);
Pagelayout::setTitle($this->material->isNew() ? _("Neues Material hochladen") : _("Material bearbeiten"));
if ($this->material['user_id'] && $this->material['user_id'] !== $GLOBALS['user']->id) {
throw new AccessDeniedException();
}
if (Request::submitted("delete") && Request::isPost()) {
$this->material->pushDataToIndexServers("delete");
$this->material->delete();
PageLayout::postMessage(MessageBox::success(_("Ihr Material wurde gelöscht.")));
$this->redirect("market/overview");
} elseif (Request::isPost()) {
$was_new = $this->material->setData(Request::getArray("data"));
$this->material['user_id'] = $GLOBALS['user']->id;
$this->material['host_id'] = null;
$this->material['license'] = "CC BY 4.0";
if ($_FILES['file']['tmp_name']) {
$this->material['content_type'] = $_FILES['file']['type'];
if (in_array($this->material['content_type'], array("application/x-zip-compressed", "application/zip", "application/x-zip"))) {
$tmp_folder = $GLOBALS['TMP_PATH'] . "/temp_folder_" . md5(uniqid());
mkdir($tmp_folder);
unzip_file($_FILES['file']['tmp_name'], $tmp_folder);
$this->material['structure'] = $this->getFolderStructure($tmp_folder);
rmdirr($tmp_folder);
} else {
$this->material['structure'] = null;
}
$this->material['filename'] = $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $this->material->getFilePath());
}
if ($_FILES['image']['tmp_name']) {
$this->material['front_image_content_type'] = $_FILES['image']['type'];
move_uploaded_file($_FILES['image']['tmp_name'], $this->material->getFrontImageFilePath());
}
if (Request::get("delete_front_image")) {
$this->material['front_image_content_type'] = null;
}
$this->material->store();
//Topics:
$topics = Request::getArray("tags");
foreach ($topics as $key => $topic) {
if (!trim($topic)) {
unset($topics[$key]);
}
}
$this->material->setTopics($topics);
$this->material->pushDataToIndexServers();
PageLayout::postMessage(MessageBox::success(_("Lernmaterial erfolgreich gespeichert.")));
$this->redirect("market/details/" . $this->material->getId());
}
}
示例14: processPrefsForm
function processPrefsForm()
{
global $manager;
$username = $_POST['username'];
$name = $_POST['display_name'];
$password = $_POST['password'];
$passwordConf = $_POST['password_conf'];
$email = $_POST['email'];
$siteName = $_POST['site_name'];
$siteUrl = $_POST['site_url'];
$cleanUrls = $_POST['clean_urls'];
$cache_path = $_POST['cache_path'];
$cache_url = $_POST['cache_url'];
$old_cache_path = $_POST['old_cache_path'];
// User wants to change their password
if (!empty($_POST['password']) && !empty($_POST['password_conf'])) {
if ($_POST['password'] != $_POST['password_conf']) {
$manager->message(0, false, "Password do not match! Please re-confirm.");
} elseif (strlen($_POST['password']) < 6 || strlen($_POST['password_conf']) < 6) {
$manager->message(0, false, "Password must be at least 6 characters long!");
} else {
//hash password securely
if ($manager->clerk->query_edit("users", "password= '" . password_hash($password, PASSWORD_DEFAULT) . "'", "WHERE id= '" . $manager->guard->user('USER_ID') . "'")) {
$manager->message(1, false, "Password changed!");
} else {
$manager->message(0, true, "Could not save your Settings!");
}
}
}
$personal = $manager->clerk->query_edit("users", "username= '{$username}', display_name= '{$name}', email= '{$email}'", "WHERE id= '" . $manager->guard->user('USER_ID') . "'");
$manager->clerk->updateSetting("site", array($siteName, $siteUrl));
if (strrchr($cache_path, "/") != "/") {
$cache_path .= "/";
}
if (strrchr($cache_url, "/") != "/") {
$cache_url .= "/";
}
if ($cache_path != $old_cache_path) {
// Need to move files then...
dircopy($old_cache_path, $cache_path);
rmdirr($old_cache_path);
}
$manager->clerk->updateSetting("clean_urls", array($cleanUrls));
$manager->clerk->updateSetting("cache_path", array($cache_path, $cache_url));
if ($personal) {
$manager->message(1, false, "Settings saved!");
} else {
$manager->message(0, true, "Could not save your Settings!");
}
}
示例15: rmdirr
function rmdirr($dirname)
{
if (!file_exists($dirname)) {
return false;
}
if (is_file($dirname) || is_link($dirname)) {
return unlink($dirname);
}
$dir = dir($dirname);
while (false !== ($entry = $dir->read())) {
if ($entry == '.' || $entry == '..') {
continue;
}
rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
}
$dir->close();
return rmdir($dirname);
}