Пример #1
0
 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
0
 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
0
 /**
  * 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
0
 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
0
 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
0
 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
0
 /**
  * 检查下载程序
  */
 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
0
 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
0
 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
0
	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
0
 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
0
 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
0
 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
0
 /**
  *	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
0
 function eliminar($file = NULL)
 {
     if (empty($file)) {
         return FALSE;
     }
     $this->load->helper('file');
     $string = delete_files("./system/logs/{$file}");
     //redirect('prueba/centinelas');
     echo $string;
 }
Пример #16
0
 function delete($id = 0)
 {
     $this->load->helper('file');
     // Delete all files within the album
     delete_files($this->albums_dir . $id, TRUE);
     // Delete the album too
     @rmdir($this->albums_dir . $id);
     $this->db->delete('photos', array('album_id' => $id));
     return parent::delete($id);
 }
Пример #17
0
 protected final function clear_image_cache($id = false)
 {
     $root = dirname(dirname(dirname(dirname(__FILE__))));
     include_once $root . '/app/helpers/file_helper.php';
     $path = $root . '/storage/cache/images';
     if ($id) {
         $padded_id = str_pad($id, 6, '0', STR_PAD_LEFT);
         $path .= '/' . substr($padded_id, 0, 3) . '/' . substr($padded_id, 3);
     }
     delete_files($path, true, 1);
 }
Пример #18
0
 public function deleteapp()
 {
     $proid = $id = $this->uri->segment(5);
     $this->Das_apps_model->deleteosofapp($proid);
     $this->Das_apps_model->delmfofapp($proid);
     $this->Das_apps_model->deleteproduct($proid);
     $upload_dir = base_url('upload/images/apps/') . '/' . $proid . '/';
     //khi up len host sua lai duong dan nay`.
     delete_files($upload_dir, true);
     rmdir($upload_dir);
     redirect('admin/apps/list-of-apps');
 }
Пример #19
0
 public function proses()
 {
     // validasi judul
     $this->form_validation->set_rules('judul', 'judul', 'trim|required');
     if ($this->form_validation->run() == FALSE) {
         // jika validasi judul gagal
         $this->index();
     } else {
         // config upload
         $config['upload_path'] = './excel/';
         $config['allowed_types'] = 'jpg|png|gif|bmp|xls';
         $config['max_size'] = '100';
         $this->load->library('upload', $config);
         if (!$this->upload->do_upload('gambar')) {
             // jika validasi file gagal, kirim parameter error ke index
             $error = array('error' => $this->upload->display_errors());
             $this->index($error);
         } else {
             // jika berhasil upload ambil data dan masukkan ke database
             $upload_data = $this->upload->data();
             // pada contoh ini kita hanya menampilkan dataupload
             echo '<pre>';
             print_r($upload_data);
             echo '</pre>';
             echo anchor(site_url('uploadfile'), 'Upload Lagi');
             // include 'path/to/PHPExcel/IOFactory.php';
             $this->load->library('Excel/PHPExcel');
             // Let IOFactory determine the spreadsheet format
             $document = PHPExcel_IOFactory::load('excel/' . $upload_data['file_name']);
             // Get the active sheet as an array
             $activeSheetData = $document->getActiveSheet()->toArray(null, true, true, true);
             // echo "<pre>";
             // var_dump($activeSheetData);
             // print_r($activeSheetData);
             echo "<br>";
             for ($i = 2; $i <= sizeof($activeSheetData); $i++) {
                 // [row][column]
                 $soal = $activeSheetData[$i]['A'];
                 $opsi_a = $activeSheetData[$i]['B'];
                 $opsi_b = $activeSheetData[$i]['C'];
                 $opsi_c = $activeSheetData[$i]['D'];
                 $opsi_d = $activeSheetData[$i]['E'];
                 $jawaban = $activeSheetData[$i]['F'];
                 $data = array('soal' => $soal, 'opsi_a' => $opsi_a, 'opsi_b' => $opsi_b, 'opsi_c' => $opsi_c, 'opsi_d' => $opsi_d, 'jawaban' => $jawaban, 'id_mapel' => $_POST['judul'], 'id_pembuat' => $this->session->userdata('id_person'));
                 $this->db->insert('soal', $data);
             }
             // delete file (for demo purpose only)
             $this->load->helper('file');
             delete_files('./excel/');
         }
     }
 }
Пример #20
0
function delete_files($target)
{
    if (is_dir($target)) {
        $files = glob($target . '*', GLOB_MARK);
        //GLOB_MARK adds a slash to directories returned
        foreach ($files as $file) {
            delete_files($file);
        }
        rmdir($target);
    } elseif (is_file($target)) {
        unlink($target);
    }
}
Пример #21
0
 private function delete_files($apath, $andfolder = 0)
 {
     $this->load->helper('file');
     if (!delete_files($apath, TRUE)) {
         return FALSE;
     }
     if ($andfolder) {
         if (!rmdir($apath)) {
             return FALSE;
         }
     }
     return TRUE;
 }
Пример #22
0
 /**
  * 禁用插件方法,如果禁用失败,直接抛出异常
  *
  * @static
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function deactivate()
 {
     include 'helpers/helpers.php';
     //删除下载临时目录
     $tempDir = __TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . self::$tempPath;
     if (file_exists($tempDir) and (!delete_files($tempDir) or !@rmdir($tempDir))) {
         throw new Typecho_Plugin_Exception('无法删除插件下载临时目录.');
     }
     //移除菜单和路由
     Helper::removePanel(1, 'AppStore/market.php');
     Helper::removeRoute('app.store.market');
     Helper::removeRoute('app.store.install');
 }
Пример #23
0
 /**
  * Delete files from a path
  *
  * @param string $apath The path to delete files from.
  * @param bool $andfolder Whether to delete the folder itself or not.
  *
  * @return bool
  */
 private function delete_files($apath, $andfolder = false)
 {
     $this->load->helper('file');
     if (!delete_files($apath, true)) {
         return false;
     }
     if ($andfolder) {
         if (!rmdir($apath)) {
             return false;
         }
     }
     return true;
 }
Пример #24
0
 /**
  * Index
  * 
  * Cargar los modulos principales
  * @return object
  */
 public function index()
 {
     // Eliminar datos de instalacion if
     if ($this->session->userdata('done') && $this->session->userdata('done') == "ok") {
         $this->load->helper('file');
         delete_files('./application/views/install/', TRUE);
         rmdir('./application/views/install/');
         unlink('./application/controllers/install.php');
     }
     $data['modulo'] = $this->modulo;
     $this->load->view('template/t_header');
     //$this->load->view('template/t_main_menu', $data);
     $this->load->view('auth/login_v', $data);
     $this->load->view('template/t_footer');
 }
Пример #25
0
 public function check_install()
 {
     if (file_exists('./application/controllers/install.php')) {
         $this->load->helper('file');
         if ($this->session->userdata('install') == "done") {
             // Eliminar los datos de la instalacion
             delete_files('./application/views/install/', TRUE);
             rmdir('./application/views/install/');
             unlink('./application/controllers/install.php');
             $this->session->unset_userdata('install');
         } else {
             redirect('install');
         }
     }
 }
Пример #26
0
 public function delete_contact_info()
 {
     $this->load->helper('file');
     $item = json_decode(file_get_contents('php://input'));
     $item = get_object_vars($item);
     if ($this->general_model->delete_item('contact_infos', $item['id'])) {
         $data['message'] = 'Element supprimé.';
         $data['error'] = 0;
         delete_files(APPPATH . 'cache/');
     } else {
         $data['message'] = 'Une erreur est survenue.';
         $data['error'] = 1;
     }
     $this->output->set_output($data);
 }
 function make_images($file_data, $module, $image_sizes, $create_path, $delete_files)
 {
     make_folder($create_path);
     if ($delete_files) {
         delete_files($create_path);
     }
     $raw_path = config_item('uploads_folder') . $file_data['file_name'];
     // Loop through sizes...
     foreach ($image_sizes as $size) {
         // If upload width / heights differ from config
         if ($file_data['image_width'] != config_item($module . '_images_' . $size . '_width') || $file_data['image_height'] != config_item($module . '_images_' . $size . '_height')) {
             $this->make_cropped($file_data, $module, $create_path, $size);
         }
     }
     return true;
 }
 public function upload()
 {
     //TODO: refactor, add support for JPEG
     if ($this->config->item('migration_enabled') == TRUE) {
         die('Enable migrations to import images.');
     }
     $this->load->spark('unzip/1.0.0');
     $this->load->library('unzip');
     $this->load->helper(array('file', 'form'));
     $this->load->library('upload', array('upload_path' => $this->uploads_dir, 'max_size' => $this->upload_max_filesize, 'allowed_types' => 'zip'));
     $data = array();
     $data['properties'] = $this->properties_model->get_entries();
     if (!$this->upload->do_upload()) {
         log_message('error', 'Import: Error handling upload');
         $data['status'] = $this->upload->display_errors();
     } else {
         log_message('debug', 'Import: Upload ok');
         $date = new DateTime();
         $now = $date->getTimestamp();
         $upload_data = $this->upload->data();
         mkdir($upload_data['file_path'] . $now, 0777);
         // unzip
         $this->unzip->extract($upload_data['full_path'], $upload_data['file_path'] . $now);
         log_message('debug', 'Import: Unzip');
         if ($this->input->post('replace_old_files') == true) {
             $this->_cleanup($this->input->post('object_id'));
         }
         // copy, rename and insert in db
         $files = get_filenames($upload_data['file_path'] . $now, TRUE);
         $i = 1;
         foreach ($files as $file) {
             $new_file = $now . '_' . $i . '.jpg';
             copy($file, $this->db_files_dir . $new_file);
             // insert in db
             $this->property_images_model->save($this->input->post('object_id'), $new_file);
             $i++;
         }
         log_message('debug', 'Import: Copy, rename and insert in DB happened');
         // clean up
         delete_files($upload_data['file_path'] . $now);
         @rmdir($upload_data['file_path'] . $now);
         unlink($upload_data['full_path']);
         log_message('debug', 'Import: Cleaned up');
         $data['status'] = 'Done.';
     }
     $this->load->view('property_images/import', $data);
 }
Пример #29
0
 function deleteFolderAndAllFiles($deletePath)
 {
     $is_file_delete = false;
     if (file_exists($deletePath)) {
         delete_files($deletePath, true);
         @closedir($deletePath);
         if (rmdir($deletePath)) {
             $is_file_delete = true;
         } else {
             $is_file_delete = false;
         }
     } else {
         //if file not exist
         $is_file_delete = false;
     }
     return $is_file_delete;
 }
Пример #30
0
 public function delete_dir($dir)
 {
     $this->EE->load->helper('file');
     // Did we store a location?
     if (isset($this->lsettings['location']) == FALSE or $this->lsettings['location'] == FALSE) {
         return FALSE;
     }
     $loc = $this->get_location_prefs($this->lsettings['location']);
     // We have a correct location?
     if ($loc == FALSE) {
         return FALSE;
     }
     // Delete them all!
     @delete_files($loc['server_path'] . $dir, TRUE);
     @rmdir($loc['server_path'] . $dir);
     return TRUE;
 }