本文整理汇总了PHP中FileUtil::unlinkDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::unlinkDir方法的具体用法?PHP FileUtil::unlinkDir怎么用?PHP FileUtil::unlinkDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::unlinkDir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unlinkDir
/**
* 删除文件夹
*
* @param string $aimDir
* @return boolean
*/
function unlinkDir($aimDir)
{
$aimDir = str_replace('', '/', $aimDir);
$aimDir = substr($aimDir, -1) == '/' ? $aimDir : $aimDir . '/';
if (!is_dir($aimDir)) {
return false;
}
$dirHandle = opendir($aimDir);
while (false !== ($file = readdir($dirHandle))) {
if ($file == '.' || $file == '..') {
continue;
}
if (!is_dir($aimDir . $file)) {
FileUtil::unlinkFile($aimDir . $file);
} else {
FileUtil::unlinkDir($aimDir . $file);
}
}
closedir($dirHandle);
return rmdir($aimDir);
}
示例2: lookupRowAccess
//.........这里部分代码省略.........
$rolewhere['tableid'] = $rval;
$rolewhere['tablename'] = 'rolegroup';
$roleInfo = $listLimitModel->where($rolewhere)->find();
if ($roleInfo != null) {
//对已有数据进行修改
$roledata['modelname'] = $modelName;
$roledata['allowfields'] = json_encode($roleData['allow']);
$roledata['denyfields'] = json_encode($roleData['deny']);
$roledata['updateid'] = $_SESSION[C('USER_AUTH_KEY')];
$roledata['updatetime'] = time();
$roleList = $listLimitModel->where('id=' . $roleInfo['id'])->save($roledata);
} else {
$roledata['modelname'] = $modelName;
$roledata['tablename'] = 'rolegroup';
$roledata['allowfields'] = json_encode($roleData['allow']);
$roledata['denyfields'] = json_encode($roleData['deny']);
$roledata['createid'] = $_SESSION[C('USER_AUTH_KEY')];
$roledata['createtime'] = time();
$roleList = $listLimitModel->add($roledata);
}
}
}
//对当前专家允许或禁止
$expertarr = explode(",", $expertid);
if ($expertid != null) {
foreach ($expertarr as $ek => $eval) {
$expertdata['tableid'] = $eval;
$expertwhere['modelname'] = $modelName;
$expertwhere['tableid'] = $eval;
$expertwhere['tablename'] = 'mis_expert_list';
$expertInfo = $listLimitModel->where($expertwhere)->find();
if ($expertInfo != null) {
//对已有数据进行修改
$expertdata['modelname'] = $modelName;
$expertdata['allowfields'] = json_encode($expertData['allow']);
$expertdata['denyfields'] = json_encode($expertData['deny']);
$expertdata['updateid'] = $_SESSION[C('USER_AUTH_KEY')];
$expertdata['updatetime'] = time();
$expertList = $listLimitModel->where('id=' . $expertInfo['id'])->save($expertdata);
} else {
$expertdata['modelname'] = $modelName;
$expertdata['tablename'] = 'mis_expert_list';
$expertdata['allowfields'] = json_encode($expertData['allow']);
$expertdata['denyfields'] = json_encode($expertData['deny']);
$expertdata['createid'] = $_SESSION[C('USER_AUTH_KEY')];
$expertdata['createtime'] = time();
$expertList = $listLimitModel->add($expertdata);
}
}
}
if ($issub) {
$model->setSubDetail($modelName, $detailList);
} else {
$model->setDetail($modelName, $detailList);
}
//删除缓存文件
$p = C("DATA_CACHE_PATH") . "Dynamicconf/Models/" . $modelName;
if (file_exists($p)) {
$FileUtil = new FileUtil();
$boolean = $FileUtil->unlinkDir($p);
if (!$boolean) {
$this->error("更新缓存文件失败");
}
}
$this->success(L('_SUCCESS_'));
exit;
} else {
$this->error("模块不存在!");
}
} else {
$model = D('SystemConfigDetail');
$modelName = $_GET['setmodule'];
$issub = $_GET['issub'];
if ($issub) {
$list = $model->getSubDetail($modelName, false);
} else {
$list = $model->getDetail($modelName, false);
}
if ($list) {
$modeluser = M("user");
foreach ($list as $k => $v) {
if (isset($v["row_access"])) {
$access = $v["row_access"];
if ($access["deny"]) {
$map["id"] = array("in", $access["deny"]['userid']);
$list[$k]["row_access"]["deny_username"] = implode(",", $modeluser->where($map)->getField("name", true));
}
if ($access["allow"]) {
$map["id"] = array("in", $access["allow"]['userid']);
$list[$k]["row_access"]["allow_username"] = implode(",", $modeluser->where($map)->getField("name", true));
}
}
}
}
$this->assign('list', $list);
$this->assign("module", $modelName);
$this->assign("issub", $issub);
$this->display();
}
}
示例3: delArticleBanner
/**
* 删除专题
* @param int .管理员id
* @param int .专题Id
* @return int
*/
public function delArticleBanner($man_id, $top_id)
{
//检查专题是否存在
$sql = 'select top_unique,top_thumb from topic where top_id=? limit 1';
$result = $this->getReadConnection()->fetchOne($sql, Phalcon\Db::FETCH_ASSOC, [$top_id]);
if (!$result) {
return 404;
}
//删除数据
$sql = 'delete from topic where top_id=?';
$this->getReadConnection()->execute($sql, [$top_id]);
if (!$this->getReadConnection()->affectedRows()) {
return 500;
}
//删除专题缩略图
if (is_file(UPLOAD_PATH . $result['top_thumb'])) {
unlink(UPLOAD_PATH . $result['top_thumb']);
}
//删除专题html
$phtml = TOPIC_HTML_PATH . '/' . $result['top_unique'] . '.phtml';
if (is_file($phtml)) {
unlink($phtml);
}
//删除专题资源
$extract = TOPIC_ROOT_PATH . '/' . $result['top_unique'];
$util = new FileUtil();
$util->unlinkDir($extract);
//管理员操作记录
$this->log($man_id, 'del_topic', '删除专题:', $top_id);
return 200;
}
示例4: initializeLookupObj
public function initializeLookupObj()
{
$model = D($this->getActionName());
// 删除原有的文件夹
if (is_dir(Dynamicconf . "/LookupObj")) {
import('@.ORG.xhprof.FileUtil');
$fileUtil = new FileUtil();
$fileUtil->unlinkDir(Dynamicconf . "/LookupObj");
}
$lookupobjlist = $model->where('status=1')->select();
// print_r(count($lookupobjlist));
// echo 99;
// exit;
$conlist = array();
$path = $model->GetDetailsPath();
if (!file_exists($path)) {
createFolder($path);
}
foreach ($lookupobjlist as $k => $v) {
if ($v['viewtype'] == 1) {
$viewmasid = getFieldBy($v['viewname'], "name", "id", "mis_system_dataview_mas");
$chinaarr = array();
if ($viewmasid) {
$viewsub = M("mis_system_dataview_sub")->field("otherfield,title")->where("masid=" . $viewmasid)->select();
$fieldsarr = explode(',', $v['fields']);
foreach ($fieldsarr as $key2 => $val2) {
foreach ($viewsub as $key1 => $val1) {
if ($val2 == $val1['otherfield']) {
$chinaarr[$val1['otherfield']] = $val1['title'] ? $val1['title'] : $val1['otherfield'];
}
}
}
}
$conlist[$v['id']] = array('title' => $v['title'], 'fields' => $v['fields'], 'fields_china' => $chinaarr, 'checkforfields' => $v['checkforfields'], 'fieldcom' => $v['fieldcom'], 'listshowfields' => $v['listshowfields'], 'listshowfields_china' => $this->getDeatilshowname($v['mode'], $v['listshowfields'], '', 'china'), 'funccheck' => $v['funccheck'], 'funccheck_china' => $this->getDeatilshowname($v['mode'], $v['funccheck'], '', 'china'), 'funcinfo' => unserialize(base64_decode($v['funcinfo'])), 'url' => $v['url'], 'mode' => $v['mode'], 'checkformodel' => $v['checkformodel'], 'filed' => $v['filed'], 'filed1' => $v['filed1'], 'val' => $v['val'], 'showrules' => $v['showrules'], 'rulesinfo' => $v['rulesinfo'], 'rules' => $v['rules'], 'viewname' => $v['viewname'], 'viewtype' => $v['viewtype'], 'condition' => $v['rules'], 'dialogwidth' => $v['dialogwidth'], 'dialogheight' => $v['dialogheight'], 'status' => $v['status'], 'level' => $v['level'], 'datasort' => $v['datasort'], 'conftype' => $v['conftype'] ? $v['conftype'] : 0);
} else {
$conlist[$v['id']] = array('title' => $v['title'], 'fields' => $v['fields'], 'fields_china' => $this->getDeatilshowname($v['mode'], $v['fields'], '', 'china'), 'checkforfields' => $v['checkforfields'], 'fieldcom' => $v['fieldcom'], 'listshowfields' => $v['listshowfields'], 'listshowfields_china' => $this->getDeatilshowname($v['mode'], $v['listshowfields'], '', 'china'), 'funccheck' => $v['funccheck'], 'funccheck_china' => $this->getDeatilshowname($v['mode'], $v['funccheck'], '', 'china'), 'funcinfo' => unserialize(base64_decode($v['funcinfo'])), 'url' => $v['url'], 'mode' => $v['mode'], 'checkformodel' => $v['checkformodel'], 'filed' => $v['filed'], 'filed1' => $v['filed1'], 'val' => $v['val'], 'showrules' => $v['showrules'], 'rulesinfo' => $v['rulesinfo'], 'rules' => $v['rules'], 'viewname' => $v['viewname'], 'viewtype' => $v['viewtype'], 'condition' => $v['rules'], 'dialogwidth' => $v['dialogwidth'], 'dialogheight' => $v['dialogheight'], 'status' => $v['status'], 'level' => $v['level'], 'datasort' => $v['datasort'], 'conftype' => $v['conftype'] ? $v['conftype'] : 0);
}
if ($v['dtinfo']) {
$conlist[$v['id']]['dt'] = unserialize(base64_decode($v['dtinfo']));
$conlist['versions'] = '1.0';
} else {
if ($v['datetable']) {
$conlist[$v['id']]['proid'] = $v['proid'];
$conlist[$v['id']]['fieldback'] = $v['fieldback'];
if ($v['orderfield']) {
$conlist[$v['id']]['orderfield'] = $v['orderfield'];
$conlist[$v['id']]['ordersort'] = $v['ordersort'];
}
// $conlist[$v['id']]['fieldcom']=$v['fieldcom'];
$conlist[$v['id']]['dt'] = unserialize(base64_decode($v['datetable']));
if ($v['dtfuncfields']) {
$conlist['dtfuncfields'] = $v['dtfuncfields'];
$conlist['dtfuncinfo'] = $v['dtfuncinfo'];
}
}
}
$filename = $path . "/" . $v['id'] . ".php";
$model->SetSongleRule($filename, $conlist[$v['id']]);
$fileindex[$v['id']] = $v['title'];
}
$pathconf = DConfig_PATH . '/LookupObj/Index';
if (!file_exists($pathconf)) {
createFolder($pathconf);
}
$num = $model->SetSongleRule($pathconf . '/list.inc.php', $fileindex);
$model->commit();
if ($num) {
$json = '{"status":1,"statusCode":1,"navTabId":null,"message":"\\u64cd\\u4f5c\\u6210\\u529f","forward":null,"forwardUrl":null,"callbackType":null,"data":"","checkfield":null,"refreshtabs":null,"rel":null,"redalert":0}';
echo '<script>reloadindexview(' . $json . ')</script>';
exit;
} else {
$this->error('转换失败');
}
// $this->success('操作成功');
}
示例5: pJAccesslist
/**
* @Title: pJAccesslist
* @Description: todo(任务节点权限初始化)
* @author 谢友志
* @date 2015-4-7 下午2:54:02
* @throws
*/
public function pJAccesslist()
{
// 删除原有的文件夹
if (is_dir(Dynamicconf . "/PJAccessList")) {
import('@.ORG.xhprof.FileUtil');
$fileUtil = new FileUtil();
$fileUtil->unlinkDir(Dynamicconf . "/PJAccessList");
}
//查找带模板的任务节点
$map['formobj'] = array('neq', '');
$tasklist = M("mis_system_flow_form")->where($map)->select();
//任务节点权限文件夹
$pathconf = DConfig_PATH . '/PJAccessList';
if (!file_exists($pathconf)) {
createFolder($pathconf);
}
foreach ($tasklist as $k => $v) {
$Action = $val['formobj'];
if ((int) $Action > 0) {
continue;
}
$new[$v['formobj']] = $v;
}
//调用lookupobj模型的写入文件方法
$lookupmodel = D("LookupObj");
foreach ($new as $key => $val) {
$Action = $val['formobj'];
if ((int) $Action > 0) {
continue;
}
$nodedetails = M("node")->where("name='" . $Action . "'")->find();
if (!$nodedetails) {
logs("模板" . $Action . "没有对应模板节点", "taskNodeRole");
} else {
//$nodeid = getFieldBy($action,"name","id","node");
//查找该模板的操作节点
$nodemodel = M("node");
$list = $nodemodel->where("pid=" . $nodedetails['id'])->select();
/**
索引文件以“paaccess_”+任务节点id为key值 已对应模板名称为value值组成数组
*/
if ($list) {
//组合一个索引文件的元素
$name = "pjaccess_" . $Action;
$title = $nodedetails['title'];
$arr[$name] = $title;
//array($name=>$title);
//对操作节点数据进行重组$detailes
$temp = array('GROUPID' => $nodedetails['group_id']);
foreach ($list as $k => $v) {
$optionname = strtoupper($v['name']);
if ($optionname == "CHANGEEDIT" || $optionname == "EDIT") {
$temp1 = array($optionname => $v['id'] . "-4");
} else {
$temp1 = array($optionname => $v['id'] . "-1");
}
$temp = array_merge($temp, $temp1);
}
$detailes = array($Action => $temp);
//套表 组合表情况下 添加权限详情元素
$model = D($this->getActionName());
$isbinddetailes = $model->pjAccessisbind($Action);
$detailes = array_merge($detailes, $isbinddetailes);
//暂时生成文件 其操作节点权限全部为1
//任务节点详情文件 每个任务节点生成单独的文件
$detailesfile = $pathconf . '/' . $name . '.php';
//$roledetailsdir.'/'.$name.'.inc.php';
$detailesnum = $lookupmodel->SetSongleRule($detailesfile, $detailes);
} else {
logs("节点" . $Action . "没有对应下级操作", "taskNodeRole");
}
}
}
echo "初始化完成!";
// //任务节点进入索引文件
// $indexnum = $lookupmodel->SetSongleRule($roleindexdir.'/indexlist.inc.php',$arr);
}