/** * Writes a line in the log file * * @param string $line */ public function write($line) { file::append($this->filepath, date($this->date_format) . ' - ' . $line . "\n"); // If the max size is exceeded if (file::getSize($this->filepath) >= $this->max_size) { file::delete($this->filepath . '.' . $this->nb_old_logs); for ($i = $this->nb_old_logs; $i >= 1; $i--) { if (file::exists($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)))) { file::rename($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)), $this->filepath . '.' . $i); } } } }
public function remove($id) { $file = new file(); $file->find($id); $file->delete(); try { unlink('app/' . $this->conf['blog_upload_folder'] . '/' . $file->name); $this->session->flash($this->l10n->__("Borrado")); } catch (Exception $e) { $this->session->flash($this->l10n->__("No se pudo borrar el archivo, comprueba los permisos del directorio")); } $this->redirect("files"); }
function deleteIn($loc) { global $db; $banners = $db->selectObjects('banner_ad', "location_data='" . serialize($loc) . "'"); foreach ($banners as $b) { $db->delete('banner_click', 'ad_id=' . $b->id); $file = $db->selectObject('file', 'id=' . $b->file_id); file::delete($file); } if (file_exists(BASE . 'files/bannermodule/' . $loc->src)) { rmdir(BASE . 'files/bannermodule/' . $loc->src); } $db->delete('banner_ad', "location_data='" . serialize($loc) . "'"); }
private function clear_directory() { //上传临时目录 file::delete(FILE_TEMP, true); //编译、缓存数据、session $cache_folder_list = array('smarty/compile', 'compile', 'session'); foreach ($cache_folder_list as $cache_folder) { file::delete(PATH_CACHE . $cache_folder, false); } //日志topic->curl,error,exception,mail,memcache,model,mysql,redis,server $log_folder_list = array('mail', 'mongo', 'run', 'sql', 'run', 'test', 'topic', 'trace', 'visit'); foreach ($log_folder_list as $log_folder) { file::delete(PATH_LOG . $log_folder, false); } }
public function delete($where) { if (!is_array($where)) { $key = $this->key(); if (empty($where)) { $where = array($key, '=', $this->{$key}); } if (is_numeric($where) || is_string($where)) { $where = array($key, '=', $where); } } $files = $this->db()->select('id,path')->where($where)->getAll(); foreach ($files as $file) { file::delete(ZOTOP_PATH_ROOT . DS . $file['path']); } return $this->db()->where($where)->delete(); }
function run() { global $user; global $layout; global $DB; global $website; $out = ''; $item = new file(); switch ($_REQUEST['act']) { case 1: // json retrieval & operations // json retrieval & operations case "json": if ($_REQUEST['op'] == 'upload') { $tmp_name = $_REQUEST['tmp_name']; if ($tmp_name == "{{BASE64}}") { $tmp_name = base64_encode($_REQUEST['name']); } $file = file::register_upload($tmp_name, $_REQUEST['name'], $_REQUEST['parent']); if (!empty($file)) { echo json_encode(array('id' => $file->id, 'name' => $file->name)); } else { echo json_encode(false); } } switch ($_REQUEST['op']) { case 'create_folder': file::create_folder($_REQUEST['name'], $_REQUEST['mime'], $_REQUEST['parent']); echo json_encode(true); break; case 'edit_folder': $f = new file(); $f->load(intval($_REQUEST['id'])); $f->name = $_REQUEST['name']; $f->mime = $_REQUEST['mime']; $ok = $f->save(); echo json_encode($ok); break; case 'edit_file': $f = new file(); $f->load(intval($_REQUEST['id'])); $f->name = $_REQUEST['name']; $ok = $f->save(); echo json_encode($ok); break; case 'duplicate_file': //error_reporting(~0); //ini_set('display_errors', 1); $status = false; $f = new file(); $f->load(intval($_REQUEST['id'])); $f->id = 0; $f->insert(); if (!empty($f->id)) { $done = copy(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . intval($_REQUEST['id']), NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $f->id); $status = "true"; if (!$done) { $f->delete(); $status = t(56, "Unexpected error"); } } echo $status; break; case 'move': if (is_array($_REQUEST['item'])) { $ok = true; for ($i = 0; $i < count($_REQUEST['item']); $i++) { unset($item); $item = new file(); $item->load($_REQUEST['item'][$i]); $item->parent = $_REQUEST['folder']; $ok = $ok & $item->update(); } echo json_encode($ok ? true : false); } else { $item->load($_REQUEST['item']); $item->parent = $_REQUEST['folder']; echo json_encode($item->update()); } break; case 'delete': try { $item->load($_REQUEST['id']); $status = $item->delete(); echo json_encode($status); } catch (Exception $e) { echo $e->getMessage(); } break; case 'permissions': $item->load($_REQUEST['id']); if (!empty($_POST)) { $item->access = intval($_POST['access']); $item->permission = intval($_POST['permission']); $item->enabled = intval($_POST['enabled']); $item->groups = $_POST['groups']; if ($item->access < 3) { $item->groups = array(); } $status = $item->save(); echo json_encode($status); } else { echo json_encode(array('access' => $item->access, 'groups' => $item->groups, 'permission' => $item->permission, 'enabled' => $item->enabled)); } break; case 'description': $item->load($_REQUEST['id']); if (!empty($_POST)) { $item->title = array(); $item->description = array(); foreach ($website->languages as $language) { $lcode = $language['code']; if (!isset($_REQUEST['titles'][$lcode])) { break; } $item->title[$lcode] = $_REQUEST['titles'][$lcode]; $item->description[$lcode] = $_REQUEST['descriptions'][$lcode]; } $status = $item->save(); echo json_encode($status); } else { // return file title and description (alt) $data = array('title' => $item->title, 'description' => $item->description); echo json_encode($data); } break; case 'focalpoint': $item->load($_REQUEST['id']); if (!empty($_POST)) { $item->focalpoint = $_REQUEST['top'] . '#' . $_REQUEST['left']; $status = $item->save(); // remove cached thumbnails file::thumbnails_remove($item->id); echo json_encode($status); } else { if (empty($item->focalpoint)) { $item->focalpoint = '50#50'; $item->save(); // remove cached thumbnails file::thumbnails_remove($item->id); } echo $item->focalpoint; } break; case 'video_info': if ($_REQUEST['provider'] == 'youtube') { $item->load_from_youtube($_REQUEST['reference'], false); // force cache reload } else { if ($_REQUEST['provider'] == 'vimeo') { $item->load_from_vimeo($_REQUEST['reference'], false); // force cache reload } else { if (!empty($_REQUEST['reference']) && is_numeric($_REQUEST['reference'])) { $item->load($_REQUEST['reference']); } else { if (is_numeric($_REQUEST['provider'])) { $item->load($_REQUEST['provider']); } else { unset($item); } } if (!empty($item)) { // add some extra data $item->extra = array('reference' => $item->id, 'link' => '', 'thumbnail' => 'img/icons/ricebowl/mimetypes/video.png', 'thumbnail_big' => 'img/icons/ricebowl/mimetypes/video.png', 'thumbnail_url' => 'img/icons/ricebowl/mimetypes/video.png', 'duration' => '', 'embed_code' => '<video src="' . file::file_url($item->id, 'inline') . '></video>'); } } } if (!empty($item)) { echo json_encode($item); } else { echo false; } break; } session_write_close(); $DB->disconnect(); exit; break; case 2: // show/edit item properties // show/edit item properties case "edit": $item->load($_REQUEST['id']); if (isset($_REQUEST['form-sent'])) { $item->load_from_post(); try { $item->save(); unset($item); $item = new file(); $item->load($_REQUEST['id']); $layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check'); } catch (Exception $e) { $layout->navigate_notification($e->getMessage(), true, true); } } $out = files_item_properties($item); break; case 10: case 'media_browser': files_media_browser($_GET['limit'], $_GET['offset']); break; case 92: // pixlr (image editor) overlay remover // pixlr (image editor) overlay remover case 'pixlr_exit': ob_clean(); file::thumbnails_remove(intval($_GET['id'])); echo ' <html> <head></head> <body> <script language="javascript" type="text/javascript"> //window.parent.eval("$(\'#thumbnail-cache\').attr(\'src\', $(\'#thumbnail-cache\').attr(\'src\') + \'&refresh=\' + new Date().getTime());"); window.parent.eval(\'$("#image-preview").attr("src", $("#image-preview").attr("src") + "&refresh=" + new Date().getTime());\'); window.parent.eval("pixlr.overlay.hide();"); </script> </body> </html> '; core_terminate(); break; /* case 91: // picnik editing ob_clean(); // $strPicnikUrl is the URL that we use to launch Picnik. $strPicnikUrl = "http://www.picnik.com/service"; // $aPicnikParams collects together all the params we'll give Picnik. Start with an API key $aPicnikParams['_apikey'] = $website->picnik_api_key; // tell Picnik where to send the exported image $aPicnikParams['_export'] = NAVIGATE_URL.'/navigate_upload.php?wid='.$website->id.'&engine=picnik&id='.$_REQUEST['id'].'&engine=picnik&session_id='.session_id(); // give the export button a title $aPicnikParams['_export_title'] = t(34, 'Save'); // turn on the close button, and tell it to come back here //$aPicnikParams['_close_target'] = $strRoot; // send in the previous "king" image in case the user feels like decorating it $aPicnikParams['_import'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=attachment&sid='.session_id(); // tell Picnik to redirect the user to the following URL after the HTTP POST instead of just redirecting to _export $aPicnikParams['_redirect'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=inline&ts='.core_time(); //'javascript: return false;'; // tell Picnik our name. It'll use it in a few places as appropriate $aPicnikParams['_host_name'] = 'Navigate'; // turn off the "Save & Share" tab so users don't get confused $aPicnikParams['_exclude'] = "out"; echo '<html><head></head><body>'; echo '<form id="picnik_form" method="POST" action="'.$strPicnikUrl.'" style=" visibility: hidden; ">'; // put all the API parameters into the form as hidden inputs foreach( $aPicnikParams as $key => $value ) { echo "<input type='hidden' name='$key' value='$value'/>\n"; } //echo "<input type='text' name='address' value='Your Majesty'/>\n"; echo "<input type='submit' value='Picnik'/>\n"; echo "</form>"; echo '<script language="javascript" type="text/javascript"> document.forms[0].submit(); </script>'; echo '</body></html>'; core_terminate(); break; */ /* case 91: // picnik editing ob_clean(); // $strPicnikUrl is the URL that we use to launch Picnik. $strPicnikUrl = "http://www.picnik.com/service"; // $aPicnikParams collects together all the params we'll give Picnik. Start with an API key $aPicnikParams['_apikey'] = $website->picnik_api_key; // tell Picnik where to send the exported image $aPicnikParams['_export'] = NAVIGATE_URL.'/navigate_upload.php?wid='.$website->id.'&engine=picnik&id='.$_REQUEST['id'].'&engine=picnik&session_id='.session_id(); // give the export button a title $aPicnikParams['_export_title'] = t(34, 'Save'); // turn on the close button, and tell it to come back here //$aPicnikParams['_close_target'] = $strRoot; // send in the previous "king" image in case the user feels like decorating it $aPicnikParams['_import'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=attachment&sid='.session_id(); // tell Picnik to redirect the user to the following URL after the HTTP POST instead of just redirecting to _export $aPicnikParams['_redirect'] = NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$_REQUEST['id'].'&disposition=inline&ts='.core_time(); //'javascript: return false;'; // tell Picnik our name. It'll use it in a few places as appropriate $aPicnikParams['_host_name'] = 'Navigate'; // turn off the "Save & Share" tab so users don't get confused $aPicnikParams['_exclude'] = "out"; echo '<html><head></head><body>'; echo '<form id="picnik_form" method="POST" action="'.$strPicnikUrl.'" style=" visibility: hidden; ">'; // put all the API parameters into the form as hidden inputs foreach( $aPicnikParams as $key => $value ) { echo "<input type='hidden' name='$key' value='$value'/>\n"; } //echo "<input type='text' name='address' value='Your Majesty'/>\n"; echo "<input type='submit' value='Picnik'/>\n"; echo "</form>"; echo '<script language="javascript" type="text/javascript"> document.forms[0].submit(); </script>'; echo '</body></html>'; core_terminate(); break; */ case 0: // list / search result // list / search result default: // show requested folder or search $out = files_browser($_REQUEST['parent'], $_REQUEST['navigate-quicksearch']); users_log::action($_REQUEST['fid'], intval($_REQUEST['parent']), 'list', '', json_encode($_REQUEST)); break; } return $out; }
function clear($mode = false) { //如果文件存在,删除文件 if ($this->is_exist()) { file::delete($this->file_name); } //删除目录 if ($mode && $this->is_exist(false)) { file::delete($this->save_dir, true); } }
function deleteIn($loc) { global $db; $data = $db->selectObject('swfitem', "location_data='" . serialize($loc) . "'"); if ($data) { $file = $db->selectObject('file', 'id=' . $data->alt_image_id); file::delete($file); $db->delete('file', 'id=' . $file->id); $file = $db->selectObject('file', 'id=' . $data->swf_id); file::delete($file); $db->delete('file', 'id=' . $file->id); $db->delete('swfitem', 'id=' . $data->id); } }
/** * garbage collection function * */ function _gc() { //remove expired file from session folder $dirHandler = @opendir($this->dir); $output = ''; $output .= "gc start at " . date('d/M/Y H:i:s') . "\n"; $fo = new file(); if ($dirHandler) { while (false !== ($file = readdir($dirHandler))) { // This is to preserve the empty index.html and during development - the hidden .svn folder. No need for Chamilo because ajaxfilemanager sessions are disabled //if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() ) if ($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() && $file != 'index.html' && $file != '.svn') { $path = $this->dir . $file; $output .= $path; //check if this is a expired session file if (filemtime($path) + $this->lifeTime < time()) { if ($fo->delete($path)) { $output .= ' Deleted at ' . date('d/M/Y H:i:s'); } else { $output .= " Failed at " . date('d/M/Y H:i:s'); } } $output .= "\n"; } } if ($this->debug) { $this->_log($output); } @closedir($dirHandler); } if (CONFIG_SYS_DEMO_ENABLE) { //remove expired files from uploaded folder $dirHandler = @opendir(CONFIG_SYS_ROOT_PATH); $output = ''; $output .= "gc start at " . date('d/M/Y H:i:s') . "\n"; $fo = new file(); if ($dirHandler) { while (false !== ($file = readdir($dirHandler))) { if ($file != '.' && $file != '..') { $path = CONFIG_SYS_ROOT_PATH . $file; $output .= $path; //check if this is a expired session file if (filemtime($path) + $this->lifeTime < time()) { if ($fo->delete($path)) { $output .= ' Deleted at ' . date('d/M/Y H:i:s'); } else { $output .= " Failed at " . date('d/M/Y H:i:s'); } } $output .= "\n"; } } if ($this->debug) { $this->_log($output); } @closedir($dirHandler); } } }
public static function deleteSessionOzsa($name) { $name = self::createFileName($name); $file = self::$sessionFolder . "/" . $name . ".ozsa"; if (file::check($file)) { file::delete($file); } else { return false; } }
/** * Delete cached value. You cand define what you want. * If you define nothing, all the cache will be deleted. * * @param array $prm Parameter for the cached variable to deleted: * - string callFrom: Representing CLASS-FUNCTION name of the original calling cache * - string type: Cache type, could be 'get' or 'start' (optionnal) * - string id: Cache id (optionnal) * - array tags: Tags for the id (optionnal) * @return int|bool Number of cache deleted or false * @see get, start */ public function delete(array $prm = array()) { if (config::initTab($prm, array('callFrom' => '*', 'type' => '*', 'id' => '*', 'tags' => false, 'request' => array('uri' => false, 'meth' => array())))) { $file = $this->file($prm); $file[strlen($file) - 1] = '*'; if (!empty($prm['tags'])) { for ($i = 0; $i < count($prm['tags']); $i++) { $file = str_replace(',' . $prm['tags'][$i] . ',', '*,' . $prm['tags'][$i] . ',', $file); } } $files = glob($file); $nb = 0; foreach ($files as $f) { if (file::delete($f)) { $nb++; } } return $nb; } return 0; }
function deleteIn($loc) { global $db; $directory = 'files/imagemanagermodule/' . $loc->src; foreach ($db->selectObjectsIndexedArray("file", "directory='{$directory}'") as $file) { file::delete($file); } rmdir(BASE . $directory); $db->delete('imagemanageritem', "location_data='" . serialize($loc) . "'"); }
function deleteIn($loc) { global $db; $config = $db->selectObject('pagemodule_config', "location_data='" . serialize($loc) . "'"); if ($config) { if ($config->file_id != 0) { $file = $db->selectObject('file', 'id=' . $config->file_id); if ($file) { file::delete($file); rmdir(BASE . $file->directory); } } $db->delete('pagemodule_config', "location_data='" . serialize($loc) . "'"); } }
public function delete() { global $DB; global $website; global $user; if ($user->permission("files.delete") == 'false') { throw new Exception(t(610, "Sorry, you are not allowed to execute this function.")); } if ($this->type == 'folder') { $DB->query('SELECT id FROM nv_files WHERE parent = ' . intval($this->id) . ' AND website = ' . $website->id); $all = $DB->result(); for ($i = 0; $i < count($all); $i++) { unset($tmp); $tmp = new file(); $tmp->load($all[$i]->id); $tmp->delete(); } } // remove the virtual folder/file and its data if (!empty($this->id)) { $DB->execute('DELETE FROM nv_files WHERE id = ' . intval($this->id) . ' AND website = ' . $website->id); if ($DB->get_affected_rows() == 1 && $this->type != 'folder') { @unlink(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $this->id); } } return $DB->get_affected_rows(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $rental = Rental::find(Input::get('id')); if ($rental) { file::delete('public/' . $rental->image); $rental->delete(); return Redirect('admin/rentals')->with('message', 'Rental Deleted'); } return Redirect('admin/rentals')->with('message', 'Something went wrong, please try again'); }
# You should have received a copy of the GNU # General Public License along with Exponent; if # not, write to: # # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # # $Id: revert_changes.php,v 1.1 2005/04/18 01:27:23 filetreefrog Exp $ ################################################## if (!defined('PATHOS')) { exit(''); } // PERM CHECK $original = $db->selectObject('imageworkshop_image', 'id=' . $_GET['id']); if ($original) { $working = $db->selectObject('imageworkshop_imagetmp', 'original_id=' . $original->id); if ($working) { $wfile = $db->selectObject('file', 'id=' . $working->file_id); if ($wfile) { file::delete($wfile); } $db->delete('file', 'id=' . $wfile->id); $db->delete('imageworkshop_imagetmp', 'id=' . $working->id); } pathos_flow_redirect(); } else { echo SITE_404_HTML; } // END PERM CHECK
/** * Delete the eventual thumbnail created for an image * Used in form_fileUploaded * * @param string $file The image uploaded * @param array $prm The parameter for the image */ public function delete($file, array $prm = null) { file::delete($this->addFilesRootIfNeeded($file)); file::multipleDelete($this->addFilesRootIfNeeded($this->makePath($file, '*')), '@' . str_replace('\\', '\\\\', $this->addFilesRootIfNeeded($this->makePath($file, '([^_]*)'))) . '$@i'); }
/** * Send a media to download, using HTTP range or not, is possible * * @param string $file File Path * @param bool $forceDownload True if the media should be forced to download * @param string $fileName Filename to send to the browser. If null, basename will be used * @param bool $delete Indicate if the file should be deleted after download */ protected function mediaDownload($file, $forceDownload = false, $fileName = null, $delete = false) { $fileName = $fileName ? $fileName : basename($file); if(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) $fileName = preg_replace('/\./', '%2e', $fileName, substr_count($fileName, '.') - 1); $fileModified = filemtime($file); $fileSize = filesize($file); $fileType = file::getType($file); $audio = strpos($fileType, 'audio') === 0; $video = strpos($fileType, 'video') === 0; $seekStart = 0; $seekEnd = -1; $bufferSize = 8*1024; $partialDownload = false; $httpRangeDownload = false; if (isset($_SERVER['HTTP_RANGE'])) { $range = explode('-', substr($_SERVER['HTTP_RANGE'], strlen('bytes='))); if($range[0] > 0) $seekStart = intval($range[0]); $seekEnd = $range[1] > 0 ? intval($range[1]) : -1; $partialDownload = true; $httpRangeDownload = true; } else if ($audio && request::isMobile()) { $partialDownload = true; $httpRangeDownload = true; } if ($seekEnd < $seekStart) $seekEnd = $fileSize - 1; $contentLength = $seekEnd - $seekStart + 1; if(!$fileHandle = fopen($file, 'rb')) $this->error(); // headers header('Pragma: public'); if ($forceDownload) { if (ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private', false); header('Content-Type: application/force-download'); header('Content-Type: application/octet-stream'); header('Content-Type: application/download'); header('Content-type: '.$fileType); header('Content-Disposition: attachment; filename='.$fileName.''); } else { header('Cache-Control: public'); header('Content-type: '.$fileType); header('Content-Disposition: inline; filename='.$fileName.''); } header('Last-Modified: '.date('D, d M Y H:i:s \G\M\T', $fileModified)); header("Content-Transfer-Encoding: binary\n"); if ($httpRangeDownload) { header('HTTP/1.0 206 Partial Content'); header('Status: 206 Partial Content'); header('Accept-Ranges: bytes'); header('Content-Range: bytes '.$seekStart.'-'.$seekEnd.'/'.$fileSize); } header('Content-Length: '.$contentLength); if ($seekStart > 0) { $partialDownload = true; fseek($fileHandle, $seekStart); if ($fileType == 'video/x-flv') echo 'FLV', pack('C', 1), pack('C', 1), pack('N', 9), pack('N', 9); } $this->setCompress(false); $this->beforeOut(); $speed = 0; $bytesSent = 0; $chunk = 1; $throttle = $video ? 320 : ($audio ? 84 : 0); $burst = 1024 * ($video ? 500 : ($audio ? 120 : 0)); while (!(connection_aborted() || connection_status() == 1) && $bytesSent < $contentLength) { // 1st buffer size after the first burst has been sent if ($bytesSent >= $burst) $speed = $throttle; // make sure we don't read past the total file size if ($bytesSent + $bufferSize > $contentLength) $bufferSize = $contentLength - $bytesSent; // send data echo fread($fileHandle, $bufferSize); $bytesSent+= $bufferSize; // clean up flush(); // throttle if($speed && ($bytesSent - $burst > $speed * $chunk*1024)) { sleep(1); $chunk++; } } fclose($fileHandle); if ($delete) file::delete($file); exit; }
if (sizeof($selectedDocuments)) { //get all files within the destination folder $allDocs = array(); if ($fh = @opendir($_GET['current_folder_path'])) { while (($file = readdir($fh)) && $file != '.' && $file != '..') { $allDocs[] = getRealPath($destFolderPath . $file); } } include_once CLASS_FILE; $file = new file(); //check if all files are allowed to cut or copy foreach ($selectedDocuments as $doc) { if (file_exists($doc) && isUnderRoot($doc)) { if (array_search(getRealPath($doc), $allDocs) === false || CONFIG_OVERWRITTEN) { if (CONFIG_OVERWRITTEN) { $file->delete($doc); } if ($file->copyTo($doc, $_GET['current_folder_path'])) { $finalPath = $destFolderPath . basename($doc); $objFile = new file($finalPath); $tem = $objFile->getFileInfo(); $obj = new manager($finalPath, false); $fileType = $obj->getFileType($finalPath, is_dir($finalPath) ? true : false); foreach ($fileType as $k => $v) { $tem[$k] = $v; } /* foreach ($folderInfo as $k=>$v) { $tem['i_' . $k] = $v; } if($folderInfo['type'] == 'folder' && empty($folderInfo['subdir']) && empty($folderInfo['file']))
function deleteIn($loc) { global $db; foreach ($db->selectObjects('resourceitem', "location_data='" . serialize($loc) . "'") as $res) { foreach ($db->selectObjects('resourceitem_wf_revision', 'wf_original=' . $res->id) as $wf_res) { $file = $db->selectObject('file', 'id=' . $wf_res->file_id); file::delete($file); $db->delete('file', 'id=' . $file->id); } $db->delete('resourceitem_wf_revision', 'wf_original=' . $res->id); } rmdir(BASE . 'files/ResourceModule/' . $loc->src); $db->delete('resourceitem', "location_data='" . serialize($loc) . "'"); }
if (isset($_FILES[$filefield]) && $_FILES[$filefield]['name'] != "") { if (isset($data->swf_id) && $data->swf_id != 0) { $file = $db->selectObject("file", "id=" . $data->swf_id); file::delete($file); $db->delete("file", "id=" . $file->id); } $file = file::update($filefield, $directory, null); if ($file != null) { $data->swf_id = $db->insertObject($file, "file"); } } $filefield = 'alt_image_name'; if (isset($_FILES[$filefield]) && $_FILES[$filefield]['name'] != "") { if (isset($data->alt_image_id) && $data->alt_image_id != 0) { $file = $db->selectObject("file", "id=" . $data->alt_image_id); file::delete($file); $db->delete("file", "id=" . $file->id); } $file = file::update($filefield, $directory, null); if ($file != null) { $data->alt_image_id = $db->insertObject($file, "file"); } } if (isset($data->id)) { $db->updateObject($data, "swfitem"); } else { $db->insertObject($data, "swfitem"); } pathos_flow_redirect(); } else { echo SITE_403_HTML;
/** * Delete the uploaded file * * @return string */ public function delete() { $ret = false; $current = $this->getCurrent(); if ($current && strpos($current, $this->cfg->dir) === false) { $current = $this->cfg->dir . $current; } if ($current && file::exists($current)) { $ret = $this->callHelper('delete', $current); file::delete($current); } $this->setCurrent(null); $this->saved = false; return $ret; }
function deleteIn($loc) { global $db; $slides = $db->selectObjects("slideshow_slide", "location_data='" . serialize($loc) . "'"); foreach ($slides as $slide) { $file = $db->selectObject("file", "id=" . $slide->file_id); file::delete($file); $db->delete('file', 'id=' . $file->id); } rmdir(BASE . "files/slideshowmodule/" . $loc->src); $db->delete("slideshowmodule_config", "location_data='" . serialize($loc) . "'"); $db->delete("slideshow_slide", "location_data='" . serialize($loc) . "'"); }
/** * garbage collection function * */ function _gc() { //remove expired file from session folder $dirHandler = @opendir($this->dir); $output = ''; $output .= "gc start at " . date('d/M/Y H:i:s') . "\n"; $fo = new file(); if($dirHandler) { while(false !== ($file = readdir($dirHandler))) { if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() ) { $path=$this->dir.$file; $output .= $path ; //check if this is a expired session file if(filemtime($path) + $this->lifeTime < time()) { if($fo->delete($path)) { $output .= ' Deleted at ' . date('d/M/Y H:i:s'); }else { $output .= " Failed at " . date('d/M/Y H:i:s'); } } $output .= "\n"; } } if($this->debug) { $this->_log($output); } @closedir($dirHandler); } if(CONFIG_SYS_DEMO_ENABLE) { //remove expired files from uploaded folder $dirHandler = @opendir(CONFIG_SYS_ROOT_PATH); $output = ''; $output .= "gc start at " . date('d/M/Y H:i:s') . "\n"; $fo = new file(); if($dirHandler) { while(false !== ($file = readdir($dirHandler))) { if($file != '.' && $file != '..') { $path=CONFIG_SYS_ROOT_PATH.$file; $output .= $path ; //check if this is a expired session file if(filemtime($path) + $this->lifeTime < time()) { if($fo->delete($path)) { $output .= ' Deleted at ' . date('d/M/Y H:i:s'); }else { $output .= " Failed at " . date('d/M/Y H:i:s'); } } $output .= "\n"; } } if($this->debug) { $this->_log($output); } @closedir($dirHandler); } } }
protected function execIndex(array $prm = array()) { $this->prepare(); $pattern = FILESROOT.$this->dir.DS.'*'; $search = http_vars::getInstance()->get('search'); if ($search) { $pattern.= strtolower($search).'*'; $this->uri.= 'search='.$search.'&'; } $delete = http_vars::getInstance()->get('delete'); if ($delete) { $file = FILESROOT.urldecode($delete); if (file::exists($file)) { file::delete($file); file::multipleDelete(substr($file, 0, -strlen(file::getExt($file))-1).'_*'); response::getInstance()->redirect($this->uri); } } $form = $this->getForm(); if (request::isPost()) { $form->refill(); if ($form->isValid()) response::getInstance()->sendText('ok'); } $files = array(); foreach(file::search($pattern) as $f) { if (strpos($f, 'nyroBrowserThumb') === false) { $name = basename($f); if ($this->type == 'image' && strlen($name) > 15) $name = substr($name, 0, 15).'...'.file::getExt($f); $files[] = array( $f, request::uploadedUri(str_replace(FILESROOT, '', $f), $this->myCfg['uploadedUri']), $name, file::humanSize($f), utils::formatDate(filemtime($f)), $this->uri.'delete='.urlencode(str_replace(FILESROOT, '', $f)).'&' ); } } $this->setViewVars(array( 'uri'=>$this->uri, 'form'=>$form, 'config'=>$this->config, 'type'=>$this->type, 'files'=>$files, 'searchButton'=>$this->myCfg['search'], 'search'=>$search, 'imgHelper'=>$this->myCfg['imgHelper'], 'filesTitle'=>$this->myCfg['filesTitle'], 'noFiles'=>$this->myCfg['noFiles'], 'name'=>$this->myCfg['name'], 'size'=>$this->myCfg['size'], 'date'=>$this->myCfg['date'], 'delete'=>$this->myCfg['delete'], )); }
public function actionDelete($file) { $file = empty($file) ? zotop::get('file') : $file; $file = trim(url::decode($file), '/'); $filepath = site::template($file); if (file::delete($filepath)) { msg::success('删除成功', url::referer()); } msg::error('删除失败'); }
/** * 删除文件夹 */ public static function delete($path, $deleteSelf = true) { $path = path::decode($path); // 判断是否是文件夹 if (!is_dir($path)) { return false; } // 删除文件夹下的全部文件 $files = folder::files($path, false, true, '', array()); if (count($files)) { if (file::delete($files) !== true) { return false; } } // 删除全部子文件夹 $folders = folder::folders($path, false, true, '.', array()); foreach ($folders as $folder) { if (folder::delete($folder) !== true) { return false; } } //删除自身,如果不删除自身,则为清理文件夹 if ($deleteSelf === true) { if (@rmdir($path)) { return true; } return false; } return true; }
if (!file_exists($_GET['delete'])) { $error = ERR_FILE_NOT_AVAILABLE; } elseif (!isUnderRoot($_GET['delete'])) { $error = ERR_FOLDER_PATH_NOT_ALLOWED; } else { include_once CLASS_FILE; $file = new file(); if (is_dir($_GET['delete']) && isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, getBaseName($_GET['delete'])) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, getBaseName($_GET['delete']))) { $file->delete(addTrailingSlash(backslashToSlash($_GET['delete']))); } elseif (is_file($_GET['delete']) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, getBaseName($_GET['delete'])) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, getBaseName($_GET['delete']))) { $file->delete($_GET['delete']); } } } else { if (!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1) { $error = ERR_NOT_FILE_SELECTED; } else { include_once CLASS_FILE; $file = new file(); foreach ($_POST['selectedDoc'] as $doc) { if (file_exists($doc) && isUnderRoot($doc)) { if (is_dir($doc) && isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $doc)) { $file->delete(addTrailingSlash(backslashToSlash($doc))); } elseif (is_file($doc) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $doc)) { $file->delete($doc); } } } } } echo "{error:'" . $error . "'}";
if (isset($_POST['id'])) { $slide = $db->selectObject('slideshow_slide', 'id=' . $_POST['id']); if ($slide) { $loc = unserialize($slide->location_data); } } if ($slide == null && pathos_permissions_check('create_slide', $loc) || $slide != null && pathos_permissions_check('edit_slide', $loc)) { $slide = slideshow_slide::update($_POST, $slide); $slide->location_data = serialize($loc); $directory = 'files/slideshowmodule/' . $loc->src; $file = file::update('file', $directory, null); if (is_object($file)) { if (isset($slide->id)) { // We have a slide already. Delete the old one $oldfile = $db->selectObject('file', 'id=' . $slide->file_id); file::delete($oldfile); } $slide->file_id = $db->insertObject($file, 'file'); } else { // If file::update() returns a non-object, it should be a string. That string is the error message. $post = $_POST; $post['_formError'] = $file; pathos_sessions_set('last_POST', $post); header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } if (isset($slide->id)) { $db->updateObject($slide, 'slideshow_slide'); } else { $db->insertObject($slide, 'slideshow_slide'); }