function deleteFiles($dir) { $list = glob($dir . "/*"); for ($i = 0; $i < count($list); $i++) { if (is_dir($list[$i])) { deleteFiles($list[$i]); } else { echo unlink($list[$i]); } } rmdir($dir); }
function deleteFiles($dir) { $files = array(); $directory = opendir($dir); while ($item = readdir($directory)) { // We filter the elements that we don't want to appear ".", ".." and ".svn" if ($item != "." && $item != ".." && !is_dir($dir . "/" . $item)) { unlink($dir . "/" . $item); } } closedir($directory); clearstatcache(); return true; } $path = $_GET["v"]; deleteFiles($path); print "\n <fieldset id='setlng' style=\"border-color:red;background-color:#FF9D9D;color:black;text-decoration:blink;\">\n <legend>Alerta!</legend>\n Listo.\n </fieldset>\n "; } if (isset($_POST["folder"]) and !empty($_POST["folder"])) { $_POST["folder"] = str_replace("/", "", $_POST["folder"]); $_POST["folder"] = str_replace("\\", "", $_POST["folder"]); $_POST["folder"] = str_replace(" ", "_", $_POST["folder"]); $path = "Gallery/" . $_POST["folder"]; @mkdir($path); print "\n <fieldset id='setlng' style=\"border-color:red;background-color:#FF9D9D;color:black;text-decoration:blink;\">\n <legend>Alerta!</legend>\n Listo.\n </fieldset>\n "; } if (isset($_POST["id"]) and $_POST["id"] != '') { echo "<center><hr><h1><font id='setlng' face=tahoma color=#006699>Log del upload.</font></h1><hr><br></center>"; $filename = $_FILES["archivo"]["tmp_name"]; $filename2 = $_FILES["archivo"]["name"]; $filename2 = str_replace(" ", "", $filename2);
public function do_upload($product_id) { $upload_path_url = base_url() . 'assets/product/'; //echo $upload_path_url; $config['upload_path'] = FCPATH . 'assets/product/'; $dataDraftImg['product_id'] = $product_id; $dataDraftImg['img_name'] = 'draft'; // echo 'prod from upload ='.$product_id.'<br>'; $image_id = $this->mproduct->insertQuickProductImg($dataDraftImg); // $image_id = ! empty($image_id) ? $image_id : $this->mproduct->insertQuickProductImg($dataDraftImg); $config['file_name'] = $image_id; $config['allowed_types'] = 'jpg|jpeg|png|gif'; $config['max_size'] = '3000000'; $this->load->library('upload', $config); if (!$this->upload->do_upload()) { $existingFiles = get_dir_file_info($config['upload_path']); $foundFiles = array(); $f = 0; foreach ($existingFiles as $fileName => $info) { if ($fileName != 'thumbs') { // Skip over thumbs directory // set the data for the json array $foundFiles[$f]['name'] = $fileName; $foundFiles[$f]['size'] = $info['size']; $foundFiles[$f]['url'] = $upload_path_url . $fileName; $foundFiles[$f]['thumbnailUrl'] = $upload_path_url . $fileName; $foundFiles[$f]['deleteUrl'] = base_url() . 'upload/deleteImage/' . $fileName; $foundFiles[$f]['deleteType'] = 'DELETE'; $foundFiles[$f]['error'] = null; $f++; } } $this->output->set_content_type('application/json')->set_output(json_encode(array('files' => $foundFiles))); } else { $data = $this->upload->data(); $this->insert_batch($product_id, $data['full_path'], $image_id); deleteFiles($data['full_path']); // print_r($config); // set the data for the json array $info = new StdClass(); $info->name = $data['file_name']; $info->size = $data['file_size'] * 1024; $info->type = $data['file_type']; $info->url = $upload_path_url . $data['file_name']; // I set this to original file since I did not create thumbs. change to thumbnail directory if you do = $upload_path_url .'/thumbs' .$data['file_name'] // $info->thumbnailUrl = $upload_path_url . 'thumb/' . $data['file_name']; $info->deleteUrl = base_url() . 'upload/deleteImage/' . $data['file_name']; $info->deleteType = 'DELETE'; $info->error = null; // print_r($info); $files[] = $info; $data_upload['image_id'] = $image_id; $data_upload['img_name'] = $data['client_name']; $data_upload['ext'] = strtolower($data['file_ext']); $data_upload['size'] = $data['file_size']; $data_upload['width'] = $data['image_width']; $data_upload['height'] = $data['image_height']; $data_upload['type'] = $data['image_type']; $data_upload['url'] = $data['orig_name']; $data_upload['path'] = $data['full_path']; // $data_upload['thumbnail_url'] = $upload_path_url . 'thumb/' . $data['file_name']; $this->mproduct->editProductImg($data_upload, $image_id); // this is why we put this in the constants to pass only json data if (IS_AJAX) { echo json_encode(array("files" => $files)); // this has to be the only data returned or you will get an error. // if you don't give this a json array it will give you a Empty file upload result error // it you set this without the if(IS_AJAX)...else... you get ERROR:TRUE (my experience anyway) // so that this will still work if javascript is not enabled } else { $file_data['upload_data'] = $this->upload->data(); $this->load->view('upload/upload_success', $file_data); } } }
/** * Deletes one or more records * @param array - An array of unique category id numbers * @param string - The current author option */ function removeBooks($bid, $option) { global $database, $book; if (!is_array($bid) || count($bid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; exit; } if (count($bid)) { $removebook = 1; foreach ($bid as $id) { deleteFiles($id, $removebook); $books4del = new mosBooklibrary($database); $books4del->load($id); $books4del->delete(); //echo "<br /><pre>" . print_r($books4del, true) . "</pre>"; } } mosRedirect("index.php?option={$option}"); }
/** * getDelete */ public function getDelete($mode = '') { $this->db->trans_start(); $arrCheck = $this->input->post('checkAll'); for ($i = 0; $i < count($arrCheck); $i++) { $arrFilesWhere = array('owner_id' => $arrCheck[$i], 'table_id' => 'brands'); $arrBrandCategory = array('brand_id' => $arrCheck[$i]); $arrBrands = array('id' => $arrCheck[$i]); if ($mode == MODE_DELETE) { $arrDt = array('delete_flg' => 1); setTime($arrDt, MODE_DELETE); $this->db->update('brands', $arrDt, $arrBrands); } else { if ($mode == MODE_DELETE_DB) { $this->db->delete('brands', $arrBrands); $this->db->delete('brand_category', $arrBrandCategory); deleteFiles($arrFilesWhere); } } } if ($this->db->trans_complete()) { return true; } }
<?php require_once 'action-delete.php'; //сохранение итогового файла на диск пользователю $url = $_GET['url']; header('Content-Type: ' . $ctype . '; charset=utf-8'); header("Content-Disposition: attachment; filename=" . $url); ob_clean(); readfile($url); if (isset($url)) { deleteFiles($url); } exit;
$reply['config'] = array('lang' => 'en', 'url' => $cfg['path']['rootUrl'] . '/', 'thumbUrl' => $cfg['path']['thumbUrl'] . '/', 'thumb' => $cfg['path']['thumb'], 'thumbWidth' => 100, 'thumbHeight' => 100, 'children' => $children, 'as3' => array('bucket' => $cfg['as3']['bucket'], 'accessKey' => $cfg['as3']['key'], 'acl' => $cfg['as3']['acl'], 'policy' => $policy, 'root' => $cfg['path']['root'], 'thumb' => $cfg['path']['thumb'], 'signature' => AmazonS3Manager::create_signature($policy, $cfg['as3']['secret']))); break; case 'createFolder': $path = urldecode($_POST['dir']); $name = urldecode($_POST['newname']); $reply['isSuccess'] = createDir($path, $name); break; case 'deleteFolder': $path = urldecode($_POST['dir']); $reply['isDelete'] = deleteDir($path); break; case 'deleteFiles': $dir = urldecode($_POST['dir']); $files = urldecode($_POST['files']); $files = explode('::', $files); deleteFiles($dir, $files); $reply['files'] = listFiles($dir); break; case 'getFiles': $reply['files'] = listFiles($dir); break; case 'getDirs': $reply['dirs'] = listDirs($dir); break; default: exit; break; } if (isset($_GET['noJson'])) { echo '<pre>'; print_r($reply);
<?php //-----------------------------------------------define require_once 'config.php'; // ■指定した日より前のDBバックアップファイルは削除 $dirPath = DB_BACKUP_PATH; $expire = strtotime("-2 weeks"); deleteFiles($dirPath, $expire); echo 'DBパックアップ削除完了<br />'; // ■DBバックアップ $dirPath = DB_BACKUP_PATH; $fileName = date('Ymd') . '_' . date('His') . DB_NAME . '.sql'; dbBackup(DB_HOST, DB_USER, DB_PASS, DB_NAME, $dirPath, $fileName); echo 'DBバックアップ完了<br />'; //-----------------------------------------------function /** * ■ファイル削除関数 * $dirPath : ディレクトリパス * $expire : 削除期限 */ function deleteFiles($dirPath, $expire) { $list = scandir($dirPath); // フォルダ内のファイル一覧取得 foreach ($list as $value) { $file = $dirPath . $value; // ファイル名にパスを付ける if (!is_file($file)) { continue; } // ファイルの存在確認をしなかったらcontinue(. .. ← をcontinue)
$type = trim($type); switch ($type) { case DocGenReserves::ACT_COMPLETED_FRL_TYPE: deleteFiles($order_id, $type); $results['generateActCompletedFrl'] = getFileUrl($doc->generateActCompletedFrl()); break; case DocGenReserves::ACT_SERVICE_EMP_TYPE: deleteFiles($order_id, $type); $results['generateActServiceEmp'] = getFileUrl($doc->generateActServiceEmp()); break; case DocGenReserves::AGENT_REPORT_TYPE: deleteFiles($order_id, $type); $results['generateAgentReport'] = getFileUrl($doc->generateAgentReport()); break; case DocGenReserves::LETTER_FRL_TYPE: deleteFiles($order_id, $type); $results['generateInformLetterFRL'] = getFileUrl($doc->generateInformLetterFRL()); break; } } if (empty($results)) { $results['Nothink found?'] = 'Yep, sorry master.'; } } catch (\Exception $e) { $message = $e->getMessage(); $results['Error Message'] = iconv('cp1251', 'utf-8', $message); } //------------------------------------------------------------------------------ array_walk($results, function (&$value, $key) { $value = sprintf('%s = %s' . PHP_EOL, $key, $value); });
function writeToFile($fileName, $emailList, $phoneList) { deleteFiles('output'); $csvFile = fopen("output/{$fileName}.csv", 'w'); foreach ($emailList as $e) { fwrite($csvFile, "{$e}\n"); } foreach ($phoneList as $p) { fwrite($csvFile, "{$p}\n"); } fclose($csvFile); }
<?php //Deleting files function deleteFiles() { $args = func_get_args(); foreach ($args as $k => $v) { if (file_exists($v)) { unlink($v); } } } if (isset($_POST['url'])) { deleteFiles($_POST['url']); echo $_POST['url']; } if ($_POST['event'] == 'reset') { $back = '../php/files/' . $_POST['background']['name']; $water = '../php/files/' . $_POST['watermark']['name']; deleteFiles($back, $water); }
if (!in_array(auth_get_class(), array("admin", "supervisor", "dirprod"))) { $err = $ERR_PERMISSION; break; } if (!file_exists($assetsLCL . arg("path"))) { $err = $ERR_FILE_NOT_FOUND; break; } if (!file_exists($assetsLCL . arg("target"))) { $ret = createDirs($assetsLCL . arg("target")); if (!$ret) { $err = $ERR_FILE_PERMISSION; break; } } $ret = deleteFiles($assetsLCL . arg("target")); if (!$ret) { $err = $ERR_FILE_PERMISSION; break; } $ret = copyFiles($assetsLCL . arg("path"), $assetsLCL . arg("target")); if (!$ret) { $err = $ERR_FILE_PERMISSION; break; } break; case "spider": $ret = spider($assetsLCL . arg("path"), $assetsLCL); if (!$ret) { $err = $ERR_FILE_NOT_FOUND; }
function deleteFiles($dir,$rootLevel,$suffix) { global $deletedFiles,$openedDirs,$entriesNum; set_time_limit (160); if ($rootLevel==0) { $deletedFiles=0; $openedDirs=0; } $suffix_len=strlen($suffix); $current_dir = opendir($dir); // echo "open $dir<BR>"; $openedDirs++; while (false !== ($entryname = readdir($current_dir))) { if( is_dir("$dir/$entryname") && $entryname != "." && $entryname!=".." ) { // echo "<br>$dir/$entryname<br>"; deleteFiles($dir."/".$entryname,$rootLevel+1,$suffix); } else if( $entryname != "." && $entryname!=".." ){ // echo "$entryname::"; if (strtolower( substr($entryname,-$suffix_len))==$suffix ) { $filename="$dir/$entryname"; echo "[ $deletedFiles ] Delete file $filename<BR>"; unlink($filename); $deletedFiles++; } } } closedir($current_dir); if ($rootLevel==0) { echo "<hr>Found and deleted $deletedFiles files<BR><BR>"; echo "opened Dirs: $openedDirs<br>"; } }
function processActions() { $ftpAction = ''; if (isset($_POST["ftpAction"]) && !empty($_POST["ftpAction"])) { $ftpAction = $_POST["ftpAction"]; } elseif (isset($_GET["ftpAction"]) && !empty($_GET["ftpAction"])) { $ftpAction = $_GET["ftpAction"]; } else { $ftpAction = 'error'; } // Open folder (always called) if (openFolder() == 1) { // New file if ($ftpAction == "newFile") { newFile(); } // New folder if ($ftpAction == "newFolder") { newFolder(); } // Upload file if ($ftpAction == "upload") { uploadFile(); } // Cut if ($ftpAction == "cut") { cutFilesPre(); } // Copy if ($ftpAction == "copy") { copyFilesPre(); } // Paste if ($ftpAction == "paste") { pasteFiles(); } // Delete if ($ftpAction == "delete") { deleteFiles(); } // Rename if ($ftpAction == "rename") { renameFiles(); } // Chmod if ($ftpAction == "chmod") { chmodFiles(); } // Drag & Drop if ($ftpAction == "dragDrop") { dragDropFiles(); } // Edit if ($ftpAction == "edit") { editFile(); } } }
break; case 'edit': formFiles(1); break; case 'save': saveFiles(); break; case 'saveedit': saveFiles(1); break; case 'savegroup': saveGroups(); break; case 'saveeditgr': saveGroups(1); break; case 'updategroup': updateGroups(1); break; case 'delete': deleteFiles(); break; case 'deletegroup': deleteGroups(); break; case 'default': defaultFile(); break; default: showFiles(); }
$search = ["http://darboystone.com", "imgThumb"]; $replace = [$_SERVER['DOCUMENT_ROOT'], "img"]; $imgLgFileName = str_replace($search, $replace, $subject); $search = "http://darboystone.com"; $replace = $_SERVER['DOCUMENT_ROOT']; $imgThumbFileName = str_replace($search, $replace, $subject); if (file_exists($imgLgFileName)) { unlink($imgThumbFileName); unlink($imgLgFileName); $rtrnVal = 'File ' . $imgThumbFileName . ' and ' . $imgLgFileName . ' have been deleted'; } else { $rtrnVal = 'Could not delete ' . $fileName . ', file does not exist. imgThumbFileName root = ' . $imgLgFileName; } return $rtrnVal; } deleteFiles(strval($_GET['q'])); ?> <!-- Modal content--> <div id="deleteModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Modal Delete</h4> </div> <div class="modal-body row"> <div class="col-xs-12 bannerContent"> <p>Modal object <?php echo $q; ?> Deleted</p>
public function update_lecture($courseid = "", $lectureid = -1) { if ($lectureid == -1 || empty($courseid)) { $this->cm_string->php_redirect("backend/Auth/login"); } if ($this->input->post("submit")) { $config['file_name'] = time() . $this->cm_string->random(); $config['upload_path'] = './public/resources/images'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '2048'; $config['remove_spaces'] = TRUE; $this->load->library('upload', $config); if (!empty($_FILES['userfile']['name'])) { if (!$this->upload->do_upload()) { $this->data['message'] = "<div class='alert alert-danger text-center'>" . $this->upload->display_errors() . "</div>"; } else { $data = array('upload_data' => $this->upload->data()); $data = array('name' => $this->input->post('name'), 'description' => $this->input->post('description'), 'linkgiaotrinh' => $this->input->post('linkgiaotrinh'), 'linkyoutube' => $this->input->post('linkyoutube'), 'linkanh' => "public/resources/images/" . $data['upload_data']['file_name'], 'order' => $this->input->post('order')); $path = $this->db->select('linkanh')->from('lecture')->where('id', $lectureid)->get()->row_array()['linkanh']; deleteFiles($path); $this->lecture->update_lecture($lectureid, $data); $this->data['message'] = "<div class='alert alert-success text-center'><p>Sửa thành công</p></div>"; } } else { $data = array('name' => $this->input->post('name'), 'description' => $this->input->post('description'), 'linkgiaotrinh' => $this->input->post('linkgiaotrinh'), 'linkyoutube' => $this->input->post('linkyoutube'), 'order' => $this->input->post('order')); $this->lecture->update_lecture($lectureid, $data); $this->data['message'] = "<div class='alert alert-success text-center'><p>Sửa thành công</p></div>"; } } $this->data['template'] = "backend/quanlylophoc/update_lecture"; // Trang hien tai $this->data['current_page'] = "Sửa thông tin buổi học"; $this->data['seo']['title'] = "Color ME CMS"; $this->data['seo']['keywords'] = ''; $this->data['seo']['description'] = 'Sua thong tin buoi hoc'; $this->data['courseid'] = $courseid; $this->data['lecture'] = $this->lecture->get_lecture_by_id($lectureid); $this->load->view("backend/layout/home", $this->data); }
$exists_doc_types = array_unique($exists_doc_types); $results[] = sprintf("Order Id = %s", $order_id); try { $orderModel = TServiceOrderModel::model(); $orderModel->attributes(array('is_adm' => true)); $orderData = $orderModel->getCard($order_id, 0); if (!$orderData || !$orderModel->isStatusEmpClose() || !$orderModel->isReserve()) { $results[] = 'Not isStatusEmpClose'; continue; } $reserveInstance = $orderModel->getReserve(); if (!$reserveInstance->isClosed()) { $results[] = 'Not isClosed'; continue; } deleteFiles($order_id, $doc_types); $exists_doc_types = array_diff($exists_doc_types, $doc_types); $base_doc_types = array(10, 20, 30, 40, 50, 60); if ($reserveInstance->isArbitrage()) { $base_doc_types = $reserveInstance->isStatusPayPayed() ? array(10, 20, 30, 40, 50, 60, 70) : array(20, 30, 40, 50, 60, 70); } //Если резерв по безналу то еще нужен и счет if (!$reserveInstance->isReserveByService()) { $base_doc_types[] = 5; } $needed_doc_types = array_diff($base_doc_types, $exists_doc_types); $history = new tservices_order_history($order_id); $doc = new DocGenReserves($orderData); if (!empty($_GET)) { foreach ($_GET as $key => $value) { $value = iconv("utf-8", "windows-1251", $value);
unlink($imgLgFileName); $rtrnVal = 'File ' . $imgThumbFileName . ' and ' . $imgLgFileName . ' have been deleted'; } else { $rtrnVal = 'Could not delete ' . $fileName . ', file does not exist. imgThumbFileName root = ' . $imgLgFileName; } return $rtrnVal; } $q = strval($_GET['q']); $db = new mysqli('localhost', 'adamvh99_admin', 'apv0703', 'adamvh99_darboy'); /* check connection */ if ($db->connect_errno) { printf("Connect failed: %s\n", $db->connect_error); exit; } else { $sql = "DELETE\n\t\t\t\t\tFROM modal\n\t\t\t\t\tWHERE imgPath = '" . $q . "'"; $stsMsg = deleteFiles($q); //Return true on success, rollback if error //Disabled for testing //mysqli_query($db, $sql); } ?> <!-- Modal content--> <div id="deleteModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Modal Delete</h4> </div> <div class="modal-body row"> <div class="col-xs-12 bannerContent">
public function nop_baigiuaki() { error_reporting(E_ERROR | E_PARSE); $this->load->model('survey'); // dd($targetPath = getcwd() . '/public/resources/baitaphocvien/'); if (!empty($_FILES)) { $tempFile = $_FILES['file']['tmp_name']; $fileName = time() . $this->cm_string->random(10, true) . $_FILES['file']['name']; $targetPath = getcwd() . '/public/resources/baitaphocvien/'; $targetFile = $targetPath . $fileName; $data = $this->db->select('id,source')->from('post')->where(array('studentid' => $this->auth['id'], 'lectureOrder' => 4))->get()->row_array(); $path = $data['source']; deleteFiles($path); $this->survey->delete_post($data['id']); move_uploaded_file($tempFile, $targetFile); $post = array('source' => '/public/resources/baitaphocvien/' . $fileName, 'studentid' => $this->auth['id'], 'date' => $this->cm_string->get_current_time(), 'lectureOrder' => 4, 'description' => ""); $id = $this->survey->insert_post($post); //Image Resizing $config['source_image'] = $targetFile; $config['maintain_ratio'] = TRUE; $config['width'] = 1000; $config['height'] = 1000; $this->load->library('image_lib', $config); $this->image_lib->resize(); echo '<img src="' . base_url('/public/resources/baitaphocvien/' . $fileName) . '" style="width:100%"/>'; // if you want to save in db,where here // with out model just for example // $this->load->database(); // load database // $this->db->insert('file_table',array('file_name' => $fileName)); } }
function viking_7_delete($sys_id) { global $par, $fn, $upload, $editSFlag, $curEditFlag; $path = $par['path']; $sid = $par['a7_sid']; $user = $par['user']; $curSource = $par['a7_cur_source']; $selSource = $par['a7_sel_source']; $curSimLen = $par['a7_cur_sim_len']; $ready = $par['a7_ready']; echo "<div style=\"float:left; width : 100%; background :white; text-align: left;margin-left:20px; margin-bottom:20px;\">"; if ($user) { $tFile = $fn['list']; $syscom = "ls {$upload}/*.pde {$upload}/*.ino > {$tFile};"; system($syscom); deleteFiles("Sketches:", $tFile); $tFile = $fn['list']; $syscom = "ls {$upload}/*.scn > {$tFile};"; system($syscom); deleteFiles("Scenarios:", $tFile); } echo "</div>"; }