本文整理汇总了PHP中Folder::dirsize方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::dirsize方法的具体用法?PHP Folder::dirsize怎么用?PHP Folder::dirsize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::dirsize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteFile
/**
* ファイル削除
*
* @param Model $Model モデル
* @param array $data received post data
* @param string $alias 登録するモデル名
* @param string $fileIdColom ファイルIDのDBカラム名
* @param int $index File inputのindex
* @return mixed Array on success, false on error
* @throws InternalErrorException
*/
public function deleteFile(Model $Model, $data, $alias, $fileIdColom, $index = 0)
{
if (isset($data['DeleteFile'][$index]['File']['id']) && $data['DeleteFile'][$index]['File']['id'] > 0) {
//データ削除
if (!$Model->FileModel->deleteAll([$Model->FileModel->alias . '.id' => $data['DeleteFile'][$index]['File']['id']], true, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
if (!$Model->FileModel->deleteFileAssociated($data['DeleteFile'][$index]['File']['id'])) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
// 暫定対応(;'∀') コメントアウトする。
// 現在、path=フォルダなので、フォルダ削除になっている。2ファイルを1度にアップロードすると同じフォルダにアップロードされる。
// 更新時に1ファイルだけアップロードすると、下記フォルダ削除によりもう一方のファイルが消える問題あり。
//
// 1ファイルのアップロード毎にフォルダが別になれば、下記フォルダ削除のままでも問題解消する。
//ファイル削除
//$folder = new Folder();
//$folder->delete($data['DeleteFile'][$index]['File']['path']);
// サムネイルだったら、個別に削除したので、現在のままでも大丈夫
// ファイル削除
$file = new File($data['DeleteFile'][$index]['File']['path'] . $data['DeleteFile'][$index]['File']['name']);
$file->delete();
// サムネイル削除
$this->__deleteThumbnail($data['DeleteFile'][$index]['File'], 'url_big');
$this->__deleteThumbnail($data['DeleteFile'][$index]['File'], 'url_medium');
$this->__deleteThumbnail($data['DeleteFile'][$index]['File'], 'url_small');
$this->__deleteThumbnail($data['DeleteFile'][$index]['File'], 'url_thumbnail');
// 空ならアップロードディレクトリ削除
$folder = new Folder($data['DeleteFile'][$index]['File']['path']);
if ($folder->dirsize() === 0) {
$folder->delete();
}
$data[$alias][$fileIdColom] = 0;
}
return $data;
}
示例2: __advancedFolderFind
private function __advancedFolderFind($conditions)
{
if (empty($this->fileList[0])) {
$this->return = array();
return true;
}
$i = 0;
foreach ($this->fileList[0] as $folder) {
if (in_array($folder, $this->ignore)) {
continue;
}
if ($this->recursive > -2) {
$Folder = new Folder($this->path . DS . $folder);
$this->return[$i]['Folder']['path'] = $Folder->path;
$this->return[$i]['Folder']['name'] = basename($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['parent'] = dirname($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['relative'] = $this->__relativePath($this->return[$i]['Folder']['path']);
$stat = stat($this->return[$i]['Folder']['path']);
$this->__fileStatus($i, $stat);
if ($this->recursive > -1) {
$this->return[$i]['Folder']['accessed'] = date('Y-m-d H:i:s', $stat['atime']);
$this->return[$i]['Folder']['modified'] = date('Y-m-d H:i:s', $stat['mtime']);
$this->return[$i]['Folder']['created'] = date('Y-m-d H:i:s', $stat['ctime']);
if ($this->recursive > 0) {
$this->return[$i]['Folder']['size'] = $Folder->dirsize();
$this->return[$i]['Folder']['absolute'] = $Folder->isAbsolute($this->return[$i]['Folder']['path']);
$children = $Folder->tree($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['sub_folders'] = count($children[0]) - 1;
$this->return[$i]['Folder']['sub_files'] = count($children[1]);
if ($this->recursive > 1) {
$this->return[$i]['Folder']['realpath'] = $Folder->realpath($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['windows'] = $Folder->isWindowsPath($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['Children'] = $children;
$this->return[$i]['Folder']['Extended'] = $stat;
$i++;
continue;
}
$i++;
}
$i++;
}
$i++;
}
$i++;
}
return true;
}
示例3: edp
//.........这里部分代码省略.........
}
if ($this->Session->read('User.is_mr') == 0) {
$condition3 = array('DailyBackupDetail.employee_id' => $this->Session->read('User.employee_id'));
}
$finalCond = array('OR' => array($onlyBranch, $onlyOwn, $condition3));
if ($this->request->params['named']) {
if ($this->request->params['named']['published'] == null) {
$condition1 = null;
} else {
$condition1 = array('DailyBackupDetail.publish' => $this->request->params['named']['published']);
}
if ($this->request->params['named']['soft_delete'] == null) {
$condition2 = null;
} else {
$condition2 = array('DailyBackupDetail.soft_delete' => $this->request->params['named']['soft_delete']);
}
if ($this->request->params['named']['soft_delete'] == null) {
$conditions = array($onlyBranch, $onlyOwn, $condition1, $condition3, 'DailyBackupDetail.soft_delete' => 0);
} else {
$conditions = array($condition1, $condition2, $finalCond);
}
} else {
$conditions = array($finalCond, 'DailyBackupDetail.soft_delete' => 0);
}
$options = array('order' => array('DailyBackupDetail.sr_no' => 'DESC'), 'conditions' => array($conditions));
$this->DailyBackupDetail->recursive = 0;
$dailyBackupDetails = $this->DailyBackupDetail->find('all', $options);
$this->loadModel('Schedule');
$scheduleList = $this->Schedule->find('list', array('conditions' => array('Schedule.publish' => 1, 'Schedule.soft_delete' => 0), 'recursive' => -1));
foreach ($dailyBackupDetails as $key => $dailyBackupDetail) {
$test = $this->DatabackupLogbook->find('first', array('order' => array('DatabackupLogbook.sr_no' => 'DESC'), 'conditions' => array('DatabackupLogbook.daily_backup_detail_id' => $dailyBackupDetail['DailyBackupDetail']['id'], 'DatabackupLogbook.employee_id' => $dailyBackupDetail['DailyBackupDetail']['employee_id']), 'recursive' => -1));
$listOfComp = $this->ListOfComputer->find('first', array('conditions' => array('ListOfComputer.id' => $dailyBackupDetail['DailyBackupDetail']['list_of_computer_id']), 'fields' => array('make'), 'recursive' => -1));
$dailyBackupDetails[$key]['DataBackUp']['ScheduleName'] = $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']];
if (count($test)) {
if ($scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'dailly' || $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'Dailly' || $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'daily' || $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'Daily') {
if (date('Y-m-d', strtotime($test['DatabackupLogbook']['created'])) == date('Y-m-d')) {
$dailyBackupDetails[$key]['DatabackupLogbook'] = $test['DatabackupLogbook'];
} else {
$dailyBackupDetails[$key]['DatabackupLogbook'] = array();
}
} else {
if ($scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'weekly' || $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'Weekly') {
if (date('W', strtotime($test['DatabackupLogbook']['created'])) == date('W')) {
$dailyBackupDetails[$key]['DatabackupLogbook'] = $test['DatabackupLogbook'];
} else {
$dailyBackupDetails[$key]['DatabackupLogbook'] = array();
}
} else {
if ($scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'monthly' || $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'Monthly') {
if (date('m', strtotime($test['DatabackupLogbook']['created'])) == date('m')) {
$dailyBackupDetails[$key]['DatabackupLogbook'] = $test['DatabackupLogbook'];
} else {
$dailyBackupDetails[$key]['DatabackupLogbook'] = array();
}
} else {
if ($scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'quarterly' || $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'Quarterly') {
$created = date('Y-m-d', strtotime($dailyBackupDetail['DailyBackupDetail']['created']));
$currentDate = date('Y-m-d', strtotime($dailyBackupDetail['DailyBackupDetail']['created']));
$lastQuarter = date('Y-m-d');
$nextQuarter = date('Y-m-d');
$dateArray = array();
$i = 0;
while ($currentDate <= $lastQuarter) {
$nextQuarter = date('Y-m-d', strtotime('+3 month', strtotime($currentDate)));
$dateArray[$i]['currentDate'] = $currentDate;
$dateArray[$i]['nextQuarter'] = $nextQuarter;
$currentDate = $nextQuarter;
$i++;
}
$count = count($dateArray);
if (date('Y-m-d', strtotime($test['DatabackupLogbook']['created'])) >= $dateArray[$count - 1]['currentDate'] && date('Y-m-d', strtotime($test['DatabackupLogbook']['created'])) <= $dateArray[$count - 1]['nextQuarter']) {
$dailyBackupDetails[$key]['DatabackupLogbook'] = $test['DatabackupLogbook'];
} else {
$dailyBackupDetails[$key]['DatabackupLogbook'] = array();
}
} else {
if ($scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'yearly' || $scheduleList[$dailyBackupDetail['DataBackUp']['schedule_id']] == 'Yearly') {
if (date('y', strtotime($test['DatabackupLogbook']['created'])) == date('y')) {
$dailyBackupDetails[$key]['DatabackupLogbook'] = $test['DatabackupLogbook'];
} else {
$dailyBackupDetails[$key]['DatabackupLogbook'] = array();
}
}
}
}
}
}
}
if (count($listOfComp)) {
$dailyBackupDetails[$key]['DatabackupLogbook']['make'] = $listOfComp['ListOfComputer']['make'];
}
}
$this->set('dailyBackupDetails', $dailyBackupDetails);
$this->set('editId', $id);
//get folder details :
$folder = new Folder(APP . DS . 'webroot/files/');
$folderSize = $folder->dirsize();
$dbSize = $this->_getDbSize();
$this->set(array('dbSize' => $this->_format_file_size($dbSize), 'folderSize' => $this->_format_file_size($folderSize), 'totalSize' => $this->_format_file_size($dbSize + $folderSize)));
}