本文整理汇总了PHP中clr_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP clr_dir函数的具体用法?PHP clr_dir怎么用?PHP clr_dir使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clr_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clr_dir
/**
* Enables deletion of directory if not empty
* @access public
* @param string $dir the directory to delete
* @return boolean whether the deletion was successful
* @author Joel Kronenberg
*/
function clr_dir($dir)
{
if (!($opendir = @opendir($dir))) {
return false;
}
while (($readdir = readdir($opendir)) !== false) {
if ($readdir !== '..' && $readdir !== '.') {
$readdir = trim($readdir);
clearstatcache();
/* especially needed for Windows machines: */
if (is_file($dir . '/' . $readdir)) {
if (!@unlink($dir . '/' . $readdir)) {
return false;
}
} else {
if (is_dir($dir . '/' . $readdir)) {
/* calls itself to clear subdirectories */
if (!clr_dir($dir . '/' . $readdir)) {
return false;
}
}
}
}
}
/* end while */
@closedir($opendir);
if (!@rmdir($dir)) {
return false;
}
return true;
}
示例2: backups_delete
function backups_delete($course)
{
global $db;
$path = AT_BACKUP_DIR . $course . '/';
clr_dir($path);
$sql = "DELETE FROM " . TABLE_PREFIX . "backups WHERE course_id={$course}";
$result = mysql_query($sql, $db);
}
示例3: chat_delete
function chat_delete($course)
{
global $db;
$path = AT_CONTENT_DIR . 'chat/' . $course . '/';
if (is_dir($path)) {
clr_dir($path);
}
}
示例4: backups_delete
function backups_delete($course)
{
global $db;
$path = AT_BACKUP_DIR . $course . '/';
clr_dir($path);
$sql = "DELETE FROM %sbackups WHERE course_id=%d";
$result = queryDB($sql, array(TABLE_PREFIX, $course));
}
示例5: basiclti_delete
function basiclti_delete($course)
{
global $db;
// delete basiclti course table entries
$sql = "DELETE FROM %sbasiclti_content WHERE course_id=%d";
queryDB($sql, array(TABLE_PREFIX, $course));
// delete basiclti course files
$path = AT_CONTENT_DIR . 'basiclti/' . $course . '/';
clr_dir($path);
}
示例6: basiclti_delete
function basiclti_delete($course)
{
global $db;
// delete basiclti course table entries
$sql = "DELETE FROM " . TABLE_PREFIX . "basiclti WHERE course_id={$course}";
mysql_query($sql, $db);
// delete basiclti course files
$path = AT_CONTENT_DIR . 'basiclti/' . $course . '/';
clr_dir($path);
}
示例7: clear_dir
function clear_dir($dir)
{
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_dir($dir . $file)) {
clr_dir($dir . $file);
} else {
unlink($dir . $file);
}
}
closedir($dh);
}
}
示例8: clear_dir
function clear_dir($dir)
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (($file == '.') || ($file == '..'))
continue;
if (is_dir($dir.$file))
clr_dir($dir.$file);
else
unlink($dir.$file);
}
closedir($dh);
}
}
示例9: define
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/****************************************************************/
// $Id$
define('AT_INCLUDE_PATH', '../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
admin_authenticate(AT_ADMIN_PRIV_ADMIN);
if (isset($_POST['submit_no'])) {
$msg->addFeedback('CANCELLED');
header('Location: ./error_logging.php');
exit;
} else {
if (isset($_POST['submit_yes'])) {
//clean up the db
require_once AT_INCLUDE_PATH . '../mods/_core/file_manager/filemanager.inc.php';
if ($result = clr_dir(AT_CONTENT_DIR . 'logs/')) {
$msg->addFeedback('ERROR_LOG_RESET');
} else {
$msg->addError('ERROR_LOG_NOT_RESET');
}
header('Location: ./error_logging.php');
exit;
}
}
require AT_INCLUDE_PATH . 'header.inc.php';
//print confirmation
$hidden_vars['all'] = TRUE;
$confirm = array('RESET_ERROR_LOG', $_SERVER['PHP_SELF']);
$msg->addConfirm($confirm, $hidden_vars);
$msg->printConfirm();
require AT_INCLUDE_PATH . 'footer.inc.php';
示例10: restore_files
function restore_files()
{
$sql = "SELECT max_quota FROM " . TABLE_PREFIX . "courses WHERE course_id={$this->course_id}";
$result = mysql_query($sql, $this->db);
$row = mysql_fetch_assoc($result);
if ($row['max_quota'] != AT_COURSESIZE_UNLIMITED) {
global $MaxCourseSize, $MaxCourseFloat;
if ($row['max_quota'] == AT_COURSESIZE_DEFAULT) {
$row['max_quota'] = $MaxCourseSize;
}
$totalBytes = dirsize($this->import_dir . 'content/');
$course_total = dirsize(AT_CONTENT_DIR . $this->course_id . '/');
$total_after = $row['max_quota'] - $course_total - $totalBytes + $MaxCourseFloat;
if ($total_after < 0) {
//debug('not enough space. delete everything');
// remove the content dir, since there's no space for it
clr_dir($this->import_dir);
return FALSE;
}
}
copys($this->import_dir . 'content/', AT_CONTENT_DIR . $this->course_id);
}
示例11: delete_theme
function delete_theme ($theme_dir) {
global $msg, $db;
//check status
$sql = "SELECT status FROM ".TABLE_PREFIX."themes WHERE dir_name='$theme_dir'";
$result = mysql_query ($sql, $db);
$row = mysql_fetch_assoc($result);
$status = intval($row['status']);
//can't delete original default or current default theme
if (($theme_dir == 'default') || ($status == 2)) {
$msg->addError('THEME_NOT_DELETED');
return FALSE;
} else { //disable, clear directory and delete theme from db
require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() */
if ($status != 0) {
disable_theme($theme_dir);
$msg->deleteFeedback('THEME_DISABLED');
}
$dir = '../../../themes/' . $theme_dir;
//chmod($dir, 0777);
@clr_dir($dir);
$sql1 = "DELETE FROM ".TABLE_PREFIX."themes WHERE dir_name = '$theme_dir'";
$result1 = mysql_query ($sql1, $db);
write_to_log(AT_ADMIN_LOG_DELETE, 'themes', mysql_affected_rows($db), $sql);
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
return TRUE;
}
}
示例12: deleteAlbum
/**
* Delete an album and all associations
*/
function deleteAlbum()
{
//TODO Error checking on each step, if anyone fails, should report it to user
global $db;
$id = $this->id;
//clean directory
$sql = 'SELECT created_date FROM ' . TABLE_PREFIX . "pa_albums WHERE id={$id}";
$result = mysql_query($sql, $db);
if ($result) {
$row = mysql_fetch_assoc($result);
}
$filepath = AT_PA_CONTENT_DIR . getAlbumFilePath($id, $row['created_date']);
//orig
$filepath_tn = $filepath . '_tn';
//thumbnails
//delete files
if (is_dir($filepath) && is_dir($filepath_tn)) {
clr_dir($filepath);
clr_dir($filepath_tn);
}
//delete all photo comments
$sql = 'DELETE c.* FROM ' . TABLE_PREFIX . 'pa_photo_comments c LEFT JOIN ' . TABLE_PREFIX . "pa_photos p ON c.photo_id=p.id WHERE p.album_id={$id}";
mysql_query($sql, $db);
//delete all photos within this album
$sql = "DELETE FROM " . TABLE_PREFIX . "pa_photos WHERE album_id={$id}";
mysql_query($sql, $db);
//delete all album comments
$sql = 'DELETE FROM ' . TABLE_PREFIX . "pa_album_comments WHERE album_id={$id}";
mysql_query($sql, $db);
//delete album
$sql = "DELETE FROM " . TABLE_PREFIX . "pa_albums WHERE id={$id}";
mysql_query($sql, $db);
}
示例13: SqlUtility
* a web browser. It will only execute if required from within an ATutor script,
* in our case the Module::uninstall() method.
*/
if (!defined('AT_INCLUDE_PATH')) { exit; }
/********
* the following code is used for removing a module-specific directory created in module_install.php.
* it generates appropriate error messages to aid in its creation.
*/
$directory = AT_CONTENT_DIR .'bigbluebutton';
// check if the directory exists
if (is_dir($directory)) {
require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!clr_dir($directory))
$msg->addError(array('MODULE_UNINSTALL', '<li>'.$directory.' can not be removed. Please manually remove it.</li>'));
}
/******
* the following code checks if there are any errors (generated previously)
* then uses the SqlUtility to run reverted database queries of module.sql,
* ie. "create table" statement in module.sql is run as drop according table.
*/
if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
// deal with the SQL file:
require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
$sqlUtility = new SqlUtility();
/*
* the SQL file could be stored anywhere, and named anything, "module.sql" is simply
示例14: import_theme
/**
* Imports a theme from a URL or Zip file to Atutor
* @access private
* @author Shozub Qureshi
*/
function import_theme()
{
global $db;
global $msg;
if (isset($_POST['url']) && $_POST['url'] != 'http://') {
if ($content = @file_get_contents($_POST['url'])) {
// save file to /themes/
$filename = pathinfo($_POST['url']);
$filename = $filename['basename'];
$full_filename = AT_CONTENT_DIR . '/' . $filename;
if (!($fp = fopen($full_filename, 'w+b'))) {
//Cannot open file ($filename)";
$errors = array('CANNOT_OPEN_FILE', $filename);
$msg->addError($errors);
header('Location: index.php');
exit;
}
if (fwrite($fp, $content, strlen($content)) === FALSE) {
//"Cannot write to file ($filename)";
$errors = array('CANNOT_WRITE_FILE', $filename);
$msg->addError($errors);
header('Location: index.php');
exit;
}
fclose($fp);
}
$_FILES['file']['name'] = $filename;
$_FILES['file']['tmp_name'] = $full_filename;
$_FILES['file']['size'] = strlen($content);
unset($content);
$url_parts = pathinfo($_POST['url']);
$package_base_name_url = $url_parts['basename'];
}
$ext = pathinfo($_FILES['file']['name']);
$ext = $ext['extension'];
//error in the file
if ($_FILES['file']['error'] == 1) {
$errors = array('FILE_MAX_SIZE', ini_get('upload_max_filesize'));
$msg->addError($errors);
header('Location: index.php');
exit;
}
//If file has no name or no address or if the extension is not .zip
if (!$_FILES['file']['name'] || !is_uploaded_file($_FILES['file']['tmp_name']) && !$_POST['url']) {
$msg->addError('FILE_NOT_SELECTED');
header('Location: index.php');
exit;
}
if ($ext != 'zip') {
$msg->addError('IMPORT_NOT_PROPER_FORMAT');
header('Location: index.php');
exit;
}
//check if file size is ZERO
if ($_FILES['file']['size'] == 0) {
$msg->addError('IMPORTFILE_EMPTY');
header('Location: index.php');
exit;
}
// new directory name is the filename minus the extension
$fldrname = substr($_FILES['file']['name'], 0, -4);
$fldrname = str_replace(' ', '_', $fldrname);
$import_path = AT_SUBSITE_THEME_DIR . $fldrname;
//check if Folder by that name already exists
if (is_dir($import_path)) {
$i = 1;
while (is_dir($import_path . '_' . $i)) {
$i++;
}
$fldrname = $fldrname . '_' . $i;
$import_path = $import_path . '_' . $i;
}
//if folder does not exist previously
if (!@mkdir($import_path, 0700)) {
$msg->addError('IMPORTDIR_FAILED');
header('Location: index.php');
exit;
}
// unzip file and save into directory in themes
$archive = new PclZip($_FILES['file']['tmp_name']);
//extract contents to importpath/foldrname
if (!$archive->extract($import_path)) {
$errors = array('IMPORT_ERROR_IN_ZIP', $archive->errorInfo(true));
clr_dir($import_path);
$msg->addError($errors);
header('Location: index.php');
exit;
}
$handle = opendir($import_path);
while ($file = readdir($handle)) {
if (is_dir($import_path . '/' . $file) && $file != '.' && $file != '..') {
$folder = $file;
}
}
//copy contents from importpath/foldrname to importpath
//.........这里部分代码省略.........
示例15: if
// module content folder
$module_content_folder = AT_CONTENT_DIR . "module/";
if (isset($_GET["mod"])) $mod = str_replace(array('.','..'), '', $_GET['mod']);
else if (isset($_POST["mod"])) $mod = $_POST["mod"];
if (isset($_GET["new"])) $new = $_GET["new"];
else if (isset($_POST["new"])) $new = $_POST["new"];
if (isset($_GET["permission_granted"])) $permission_granted = $_GET["permission_granted"];
else if (isset($_POST["permission_granted"])) $permission_granted = $_POST["permission_granted"];
if (isset($_POST['submit_no']))
{
clr_dir('../../../mods/'.$_POST['mod']);
// if write permission on the mods folder has been granted, re-direct to the page of removing permission,
// otherwise, back to start page.
if ($_POST['permission_granted']==1)
header('Location: '.AT_BASE_HREF.'mods/_core/modules/module_install_step_3.php?cancelled=1');
else
{
$msg->addFeedback('CANCELLED');
header('Location: '.AT_BASE_HREF.'mods/_core/modules/install_modules.php');
}
exit;
}
else if (isset($_POST['submit_yes']))
{