本文整理汇总了PHP中delete_files函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_files函数的具体用法?PHP delete_files怎么用?PHP delete_files使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_files函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
public function upload()
{
// prepare to upload file
$config = array();
$config["upload_path"] = '/tmp/photo/';
$config["allowed_types"] = 'jpg|jpeg';
$config["max_size"] = '1024';
$config["overwrite"] = TRUE;
$this->load->library('upload', $config);
// run the upload
if ($this->upload->do_upload("photo")) {
$photo = $this->upload->data();
// open the file
$this->load->helper("file");
if ($binary = read_file($photo["full_path"])) {
// load the database
$this->load->database("default");
$data = array("type" => $photo["image_type"], "mime" => $photo["file_type"], "width" => $photo["image_width"], "height" => $photo["image_height"], "size" => $photo["file_size"], "photo" => $binary);
$result = $this->db->insert("photo", $data);
// remove the temporary file
delete_files($photo["full_path"]);
// inform the end use
if ($result) {
return $this->response(array("photo_id" => $this->db->insert_id()));
} else {
return $this->response(array("response" => "Unable to insert photo into database!"), TRUE);
}
} else {
return $this->response(array("response" => "Unable to open uploaded photo!"), TRUE);
}
} else {
return $this->response(array("response" => "Unable to upload photo! " . $this->upload->display_errors(), "info" => $this->upload->data()), TRUE);
}
}
示例2: compressed_chapter
public function compressed_chapter($path, $filename, $chapter_id)
{
$chapter = new Chapter();
$chapter->where("id", $chapter_id)->get();
$uniqid = uniqid();
if (is_dir($path)) {
$this->folder_chapter($path, $chapter);
return TRUE;
}
$cachedir = 'content/cache/' . time() . "_" . $uniqid;
if (!mkdir($cachedir)) {
log_message('error', 'compressed_chapter: failed creating dir');
return FALSE;
}
if (function_exists('rar_open') && strtolower(substr($filename, -4)) == '.rar') {
$this->uncompress_rar($path, $cachedir);
}
if (strtolower(substr($filename, -4)) == '.zip') {
$this->uncompress_zip($path, $cachedir);
}
$pages_added = $this->folder_chapter($cachedir, $chapter);
// Let's delete all the cache
if (!delete_files($cachedir, TRUE)) {
log_message('error', 'compressed_chapter: files inside cache dir could not be removed');
return FALSE;
} else {
if (!rmdir($cachedir)) {
log_message('error', 'compressed_chapter: cache dir could not be removed');
return FALSE;
}
}
return $pages_added;
}
示例3: delete_files
/**
* Delete Files
*
* Deletes all files contained in the supplied directory path.
* Files must be writable or owned by the system in order to be deleted.
* If the second parameter is set to TRUE, any directories contained
* within the supplied base directory will be nuked as well.
*
* @access public
* @param string path to file
* @param bool whether to delete any directories found in the path
* @return bool
*/
public static function delete_files($path, $del_dir = FALSE, $level = 0)
{
// Trim the trailing slash
$path = rtrim($path, DIRECTORY_SEPARATOR);
if (!($current_dir = @opendir($path))) {
return FALSE;
}
while (FALSE !== ($filename = @readdir($current_dir))) {
if ($filename != "." and $filename != "..") {
if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) {
// Ignore empty folders
if (substr($filename, 0, 1) != '.') {
delete_files($path . DIRECTORY_SEPARATOR . $filename, $del_dir, $level + 1);
}
} else {
unlink($path . DIRECTORY_SEPARATOR . $filename);
}
}
}
@closedir($current_dir);
if ($del_dir == TRUE and $level > 0) {
return @rmdir($path);
}
return TRUE;
}
示例4: delete
function delete($theme_name = "")
{
$this->load->helper('file');
$name_array = $theme_name != "" ? array($theme_name) : $this->input->post('delete');
// Delete multiple
if (!empty($name_array)) {
$deleted = 0;
$to_delete = 0;
foreach ($name_array as $theme_name) {
$theme_name = urldecode($theme_name);
$to_delete++;
if ($this->settings->item('default_theme') == $theme_name) {
$this->session->set_flashdata('error', 'You cant delete youre default theme "' . $theme_name . '".');
} else {
$theme_dir = APPPATH . 'themes/' . $theme_name;
delete_files($theme_dir, TRUE);
if (@rmdir($theme_dir)) {
$deleted++;
} else {
$this->session->set_flashdata('error', 'Unable to delete dir <em>themes/' . $theme_name . '</em>.');
}
}
}
if ($deleted == $to_delete) {
$this->session->set_flashdata('success', $deleted . ' themes out of ' . $to_delete . ' successfully deleted.');
} else {
$this->session->set_flashdata('error', $deleted . ' themes out of ' . $to_delete . ' successfully deleted.');
}
} else {
$this->session->set_flashdata('error', 'You need to select themes to delete first.');
}
redirect('admin/themes');
}
示例5: delete
function delete($theme_name = "")
{
$this->load->helper('file');
$name_array = $theme_name != "" ? array($theme_name) : $this->input->post('action_to');
// Delete multiple
if (!empty($name_array)) {
$deleted = 0;
$to_delete = 0;
foreach ($name_array as $theme_name) {
$theme_name = urldecode($theme_name);
$to_delete++;
if ($this->settings->item('default_theme') == $theme_name) {
$this->session->set_flashdata('error', sprintf($this->lang->line('theme_default_delete_error'), $theme_name));
} else {
$theme_dir = APPPATH . 'themes/' . $theme_name;
delete_files($theme_dir, TRUE);
if (@rmdir($theme_dir)) {
$deleted++;
} else {
$this->session->set_flashdata('error', sprintf($this->lang->line('theme_delete_error')), $theme_name);
}
}
}
if ($deleted == $to_delete) {
$this->session->set_flashdata('success', sprintf($this->lang->line('theme_mass_delete_success'), $delete, $to_delete));
} else {
$this->session->set_flashdata('error', sprintf($this->lang->line('theme_mass_delete_error')), $delete, $to_delete);
}
} else {
$this->session->set_flashdata('error', $this->lang->line('theme_delete_select_error'));
}
redirect('admin/themes');
}
示例6: do_upload
function do_upload()
{
$config['upload_path'] = './temp_upload/';
$config['allowed_types'] = 'xls';
$this->load->library('upload', $config);
if (!$this->upload->do_upload()) {
$data = array('error' => $this->upload->display_errors());
} else {
$data = array('error' => false);
$upload_data = $this->upload->data();
$this->load->library('excel_reader');
$this->excel_reader->setOutputEncoding('CP1251');
$file = $upload_data['full_path'];
$this->excel_reader->read($file);
error_reporting(E_ALL ^ E_NOTICE);
// Sheet 1
$data = $this->excel_reader->sheets[0];
$dataexcel = array();
for ($i = 1; $i <= $data['numRows']; $i++) {
if ($data['cells'][$i][1] == '') {
break;
}
$dataexcel[$i - 1]['nama'] = $data['cells'][$i][1];
$dataexcel[$i - 1]['alamat'] = $data['cells'][$i][2];
}
delete_files($upload_data['file_path']);
$this->load->model('User_model');
$this->User_model->tambahuser($dataexcel);
$data['user'] = $this->User_model->getuser();
}
$this->load->view('hasil', $data);
}
示例7: update
/**
* 检查下载程序
*/
public function update()
{
if (DR_VERSION_ID != $this->input->get('id') - 1) {
$this->admin_msg('对不起,您的系统版本不满足升级条件');
}
$data = dr_catcher_data(urldecode($this->input->get('fid')));
if (!$data) {
$this->admin_msg('对不起,您的服务器不支持远程下载');
}
$save = FCPATH . 'cache/down/update.zip';
$check = FCPATH . 'cache/down/update/';
if (!@file_put_contents($save, $data)) {
$this->admin_msg('目录/cache/down/没有写入权限');
}
// 解压缩文件
$this->load->helper('file');
$this->load->library('Pclzip');
$this->pclzip->PclFile($save);
if ($this->pclzip->extract(PCLZIP_OPT_PATH, $check, PCLZIP_OPT_REPLACE_NEWER) == 0) {
@unlink($save);
delete_files(FCPATH . 'cache/down/', TRUE);
$this->admin_msg("Error : " . $this->pclzip->errorInfo(true));
}
// 检查版本文件
if (!is_file($check . 'config/version.php') || !filesize($check . 'config/version.php')) {
delete_files(FCPATH . 'cache/down/', TRUE);
$this->admin_msg('升级文件不完整,没有找到版本文件');
}
$config = (require $check . 'config/version.php');
// 覆盖至网站根目录
$this->pclzip->extract(PCLZIP_OPT_PATH, FCPATH, PCLZIP_OPT_REPLACE_NEWER);
$this->dcache->set('install', TRUE);
delete_files(FCPATH . 'cache/down/', TRUE);
// 运行SQL语句
if (is_file(FCPATH . 'update.sql')) {
$sql = file_get_contents(FCPATH . 'update.sql');
$sql = str_replace('{dbprefix}', $this->db->dbprefix, $sql);
$sql_data = explode(';SQL_OmWeb_EOL', trim(str_replace(array(PHP_EOL, chr(13), chr(10)), 'SQL_OmWeb_EOL', $sql)));
foreach ($sql_data as $query) {
if (!$query) {
continue;
}
$queries = explode('SQL_OmWeb_EOL', trim($query));
$ret = '';
foreach ($queries as $query) {
$ret .= $query[0] == '#' || $query[0] . $query[1] == '--' ? '' : $query;
}
if (!$ret) {
continue;
}
$this->db->query($ret);
}
@unlink(FCPATH . 'update.sql');
}
//检查update控制器
if (is_file(FCPATH . 'omooo/controllers/admin/Update.php')) {
$this->admin_msg('正在升级数据,请稍候...', dr_url('update/index'), 2);
}
$this->admin_msg('升级完成,请按F5刷新整个页面<script src="http://www.omooo.com/index.php?c=sys&m=updated&site=' . SITE_URL . '&vid=' . $config['DR_VERSION_ID'] . '"></script>', dr_url('home/main'), 1);
}
示例8: index
function index()
{
$this->load->helper('file');
delete_files('images/captcha/');
$this->load->helper('captcha');
$this->load->database();
$this->load->library('session');
$username = $this->session->userdata('username');
if ($username = "" || $username == null) {
/*$img = $this->session->userdata('captcha');
if($img!=null&&$img!="")
{
$imgsrc = $img['imgsrc'];
if($imgsrc!=null||imgsrc!="")
{
unlink($imgsrc);
}
}*/
$vals = array('img_path' => 'images/captcha/', 'img_url' => base_url('images/captcha') . '/', 'img_width' => '60', 'img_height' => '32');
$cap = create_captcha($vals);
$data = array('image' => $cap['image'], 'word' => $cap['word'], 'imgsrc' => $cap['imgsrc'], 'menu' => 0, 'smenu' => 0);
$this->session->set_userdata('captcha', $data);
$data = array('title' => '后台登陆-' . $this->config->item('title'), 'cap' => $cap['image']);
$this->load->view('admin/login', $data);
} else {
header('Location:' . site_url('admin/index'));
}
}
示例9: clear_cache
public function clear_cache()
{
$this->load->helper('file');
delete_files(CACHEPATH);
write_file(CACHEPATH . 'index.html', "<html><head><title>403 Forbidden</title></head><body bgcolor='#ffffff'><p>Directory access is forbidden.<p></body></html>");
$this->session->set_flashdata('msg', 'Cache Files Deleted!');
redirect('admin/actions/view');
}
示例10: change_profile
function change_profile()
{
if (empty($_FILES['avatar']['name']))
{
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'email' => $this->input->post('email'),
'phone_number' => $this->input->post('phone_number')
);
$condition = array('id' => userdata());
return $this->db->update('users',$data,$condition);
}
else
{
$user = $this->user_model->user_data( userdata('email') );
delete_files(base_url("uploads/" . $user->user_avatar));
//echo base_url("uploads/" . $user->user_avatar);
//exit;
$config['upload_path'] = './uploads/';
$config['allowed_types'] = config('allowed_extensions');
$config['max_size'] = config('max_upload_file_size');
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('avatar'))
{
echo $this->upload->display_errors();
}
else
{
$img_data = $this->upload->data();
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'email' => $this->input->post('email'),
'phone_number' => $this->input->post('phone_number'),
'user_avatar' => $img_data['file_name']
);
$condition = array('id' => userdata());
return $this->db->update('users',$data,$condition);
}
}
}
示例11: clear_ci_cache_check
function clear_ci_cache_check()
{
// If we set CI page caching to clear we clear it.
if ($this->data['cms']['cp_clear_ci_page_cache']) {
$this->load->helper('file');
delete_files($this->config->item('cache_path'));
write_file($this->config->item('cache_path') . 'index.html', $this->_get_contents_no_listing());
}
}
示例12: tool
public function tool()
{
$data['title'] = "Data Petugas";
$this->template->display('backup/index');
$this->load->helper('download');
$this->load->dbutil();
$a['page'] = "backup";
$mau_ke = $this->uri->segment(3);
if ($mau_ke == "backup") {
$nama_file = 'bck_perpustakaan_' . date('Y-m-d');
$prefs = array('format' => 'txt', 'filename' => $nama_file . '.sql', 'add_drop' => TRUE, 'add_insert' => TRUE, 'newline' => "\n");
$backup =& $this->dbutil->backup($prefs);
force_download($nama_file . '.sql', $backup);
$this->session->set_flashdata("k", "<div class=\"alert alert-success\">Backup database berhasil</div>");
redirect('backup/tool');
} else {
if ($mau_ke == "optimize") {
$result = $this->dbutil->optimize_database();
if ($result !== FALSE) {
$this->session->set_flashdata("k", "<div class=\"alert alert-success\">Optimize database selesai</div>");
redirect('backup/tool');
} else {
$this->session->set_flashdata("k", "<div class=\"alert alert-error\">Optimize database gagal</div>");
redirect('backup/tool');
}
} else {
if ($mau_ke == "restore") {
$config['upload_path'] = './upload/temp';
$config['allowed_types'] = 'sql';
$config['max_size'] = '8000';
$config['max_width'] = '10000';
$config['max_height'] = '10000';
$this->load->library('upload', $config);
if ($this->upload->do_upload('file_backup')) {
$up_data = $this->upload->data();
$direktori = './upload/temp/' . $up_data['file_name'];
$isi_file = file_get_contents($direktori);
$_satustelu = substr($isi_file, 0, 103);
$string_query = rtrim($isi_file, "\n;");
$array_query = explode(";", $string_query);
foreach ($array_query as $query) {
$this->db->query(trim($query));
}
$path = './upload/temp/';
$this->load->helper("file");
// load the helper
delete_files($path, true);
$this->session->set_flashdata("k", "<div class=\"alert alert-success\" id=\"alert\">Restore data sukses</div>");
redirect('backup/tool');
} else {
$this->session->set_flashdata("k", "<div class=\"alert alert-danger\" id=\"alert\">" . $this->upload->display_errors() . "</div>");
redirect('backup/tool');
}
}
}
}
}
示例13: clean_cache
public function clean_cache()
{
$this->load->helper('file');
$path = config_item('cache_path');
$path = $path == '' ? APPPATH . 'cache/' : $path;
delete_files($path);
$this->cache->clean();
ajax_return('清理成功', 0);
}
示例14: index
/**
* This method is called via AJAX
*/
function index($database, $code_template)
{
$data_path = array();
$data_path['code_template'] = $code_template;
$data_path['app_dir'] = $database;
$this->idb->connect($database);
$manifest = json_decode(file_get_contents('templates' . DS . $code_template . DS . 'manifest.json'), TRUE);
$path_output = $manifest['output_directory'] . DS . $database;
// Load the folder model
$this->load->model('folder_model');
// Get the folder permissions
$folder_info = $this->folder_model->check_permissions($manifest['output_directory']);
// Validate the folder permissions
if ($folder_info['is_writeable'] == true) {
$tables = $this->db->list_tables();
$path_templates = 'templates';
/**
* Create input / output paths for the model_iscaffold.
*/
foreach ($manifest['working_directories'] as $dir) {
if (is_array($dir)) {
list($source, $target) = $dir;
$data_path['input_' . $dir[0]] = $path_templates . DS . $code_template . DS . $manifest['working_root_directory'] . DS . $source . DS;
$data_path['output_' . $dir[0]] = $path_output . DS . $manifest['working_root_directory'] . DS . $target . DS;
} else {
$data_path['input_' . $dir] = $path_templates . DS . $code_template . DS . $manifest['working_root_directory'] . DS . $dir . DS;
$data_path['output_' . $dir] = $path_output . DS . $manifest['working_root_directory'] . DS . $dir . DS;
}
}
/**
* Nuke the output directory if neccessery
*/
if ($manifest['dump_output_directory'] === TRUE) {
delete_files($path_output, TRUE);
}
@mkdir($path_output, 0777);
/**
* Copdy additional resources
*/
foreach ($manifest['copy_directories'] as $dir) {
dircopy($dir, $path_output);
}
/**
* This is wehere the code generation is invoked
* Each table is processed here
*/
foreach ($tables as $table) {
if ($table !== 'sf_config') {
$this->model_iscaffold->Process_Table($table, $data_path, $code_template, $manifest);
}
}
echo '{ "result": "success" }';
} else {
echo '{ "result": "error", "message": "There was a problem generating your application, ther output directory <strong>(' . $manifest['output_directory'] . ')</strong> is not writable." }';
}
}
示例15: eliminar
function eliminar($file = NULL)
{
if (empty($file)) {
return FALSE;
}
$this->load->helper('file');
$string = delete_files("./system/logs/{$file}");
//redirect('prueba/centinelas');
echo $string;
}