function index()
 {
     $max_size = 10240 * 20000;
     $extensions = array('jpeg', 'jpg', 'png');
     $dir = ltrim(assets_server_path('property_listing/', 'images'), '/');
     $count = 0;
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['files'])) {
         // loop all files
         foreach ($_FILES['files']['name'] as $i => $name) {
             // if file not uploaded then skip it
             if (!is_uploaded_file($_FILES['files']['tmp_name'][$i])) {
                 die("file is not uploaded");
             }
             // skip large files
             if ($_FILES['files']['size'][$i] >= $max_size) {
                 die("file size is too big");
             }
             // skip unprotected files
             if (!in_array(pathinfo($name, PATHINFO_EXTENSION), $extensions)) {
                 die("invalid image file type");
             }
             // now we can move uploaded files
             if (move_uploaded_file($_FILES["files"]["tmp_name"][$i], $dir . $name)) {
                 $count++;
             }
         }
         echo json_encode(array('count' => $count));
     } else {
         echo "missing files!!!";
     }
 }
 function form_fields($values = array())
 {
     $fields = parent::form_fields();
     $upload_path = assets_server_path('authors/', 'images');
     $fields['avatar_upload'] = array('type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE);
     $fields['published']['order'] = 1000;
     return $fields;
 }
 function form_fields($values = array())
 {
     $fields = parent::form_fields();
     //$fields['published']['order'] = 1000;
     $upload_path = ltrim(assets_server_path('i_property/', 'images'), "/");
     $fields['Property_info_image'] = array('type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE, 'xss_clean' => TRUE, 'allowed_types' => 'jpg|jpeg|bmp|png|gif');
     return $fields;
 }
 function form_fields($values = array())
 {
     $fields = parent::form_fields();
     $upload_path = assets_server_path('i_property/', 'images');
     $fields['category']['required'] = TRUE;
     $fields['category_path']['required'] = TRUE;
     $fields['category_icon'] = array('required' => TRUE, 'type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE, 'xss_clean' => TRUE, 'is_image' => TRUE, 'allowed_types' => 'jpg|jpeg|bmp|png|gif');
     $fields['category_mo_icon'] = array('required' => TRUE, 'type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE, 'xss_clean' => TRUE, 'is_image' => TRUE, 'allowed_types' => 'jpg|jpeg|bmp|png|gif');
     return $fields;
 }
Esempio n. 5
0
 /**
  * Create CAPTCHA image to verify user as a human
  *
  * @return	string
  */
 public function get_create_captcha()
 {
     $this->CI->load->helper('captcha');
     $cap = create_captcha(array('img_path' => assets_server_path('captcha/', 'images'), 'img_url' => base_url() . "assets/images/captcha/", 'font_path' => './' . $this->CI->config->item('captcha_fonts_path', 'tank_auth'), 'font_size' => $this->CI->config->item('captcha_font_size', 'tank_auth'), 'img_width' => $this->CI->config->item('captcha_width', 'tank_auth'), 'img_height' => $this->CI->config->item('captcha_height', 'tank_auth'), 'show_grid' => $this->CI->config->item('captcha_grid', 'tank_auth'), 'expiration' => $this->CI->config->item('captcha_expire', 'tank_auth')));
     // Save captcha params in session
     /*$this->CI->session->set_userdata(array(
     				'captcha_word' => $cap['word'],
     				'captcha_time' => $cap['time'],
     		));*/
     $img_path = str_replace("\"", "'", $cap['image']);
     return array($img_path, $cap['word'], $cap['time']);
 }
Esempio n. 6
0
 function index()
 {
     $this->_validate_user('tools/backup');
     $backup_config = $this->config->item('backup');
     $download_path = $backup_config['db_backup_path'];
     $is_writable = is_writable($download_path);
     if ($post = $this->input->post('action')) {
         // Load the DB utility class
         $this->load->dbutil();
         // Backup your entire database and assign it to a variable
         //$config = array('newline' => "\r", 'format' => 'zip');
         // need to do text here to make some fixes
         $db_back_prefs = $backup_config['db_backup_prefs'];
         $db_back_prefs['format'] = 'txt';
         $backup =& $this->dbutil->backup($db_back_prefs);
         //fixes to work with PHPMYAdmin
         $backup = str_replace('\\\\t', "\t", $backup);
         $backup = str_replace('\\\\n', '\\n', $backup);
         $backup = str_replace("\\'", "''", $backup);
         $backup = str_replace('\\\\', '', $backup);
         // load the file helper and write the file to your server
         $this->load->helper('file');
         $this->load->library('zip');
         if ($backup_config['backup_file_prefix'] == 'AUTO') {
             $this->load->helper('url');
             $backup_config['backup_file_prefix'] = url_title($this->config->item('site_name', FUEL_FOLDER), '_', TRUE);
         }
         $filename = $backup_config['backup_file_prefix'] . '_' . date('Y-m-d');
         $this->zip->add_data($filename . '.sql', $backup);
         // include assets folder
         if (!empty($_POST['include_assets'])) {
             $this->zip->read_dir(assets_server_path());
         }
         // write the zip file to a folder on your server.
         $this->zip->archive($download_path . $filename . '.zip');
         // download the file to your desktop.
         $this->zip->download($filename . '.zip');
         $msg = lang('data_backup');
         $this->logs_model->logit($msg);
     } else {
         $vars['download_path'] = $download_path;
         $vars['is_writable'] = $is_writable;
         $vars['backup_assets'] = $backup_config['backup_assets'];
         $this->_render('backup', $vars);
     }
 }
 function form_fields($values = array())
 {
     $fields = parent::form_fields();
     $CI =& get_instance();
     $CI->load->module_model(FUEL_FOLDER, 'users_model');
     $CI->load->module_library(BLOG_FOLDER, 'fuel_blog');
     $options = $CI->users_model->options_list();
     $upload_image_path = assets_server_path($CI->fuel_blog->settings('asset_upload_path'));
     $fields['fuel_user_id'] = array('label' => 'User', 'type' => 'select', 'options' => $options);
     // put all project images into a projects suboflder.
     $fields['avatar_image_upload']['upload_path'] = assets_server_path($CI->fuel_blog->settings('asset_upload_path'));
     // fix the preview by adding projects in front of the image path since we are saving it in a subfolder
     if (!empty($values['avatar_image'])) {
         $fields['avatar_image_upload']['before_html'] = '<img src="' . assets_path($CI->fuel_blog->settings('asset_upload_path') . $values['avatar_image']) . '" style="float: right;"/>';
     }
     return $fields;
 }
Esempio n. 8
0
 function form_fields($values = array(), $related_fields = array())
 {
     $fields = parent::form_fields($values, $related_fields);
     $CI =& get_instance();
     $CI->load->module_model(FUEL_FOLDER, 'fuel_users_model');
     $CI->load->module_library(BLOG_FOLDER, 'fuel_blog');
     //use only fuel users not already chosen
     $where = !empty($values['fuel_user_id']) ? array('fuel_user_id !=' => $values['fuel_user_id']) : array();
     $already_used = array_keys($this->options_list('fuel_user_id', 'display_name', $where));
     if (!empty($already_used)) {
         $CI->fuel_users_model->db()->where_not_in('id', $already_used);
     }
     $options = $CI->fuel_users_model->options_list();
     $upload_image_path = assets_server_path($CI->fuel->blog->settings('asset_upload_path'));
     $fields['fuel_user_id'] = array('label' => 'User', 'type' => 'select', 'options' => $options, 'module' => 'users');
     return $fields;
 }
 function form_fields($values = array())
 {
     $fields = parent::form_fields();
     $CI =& get_instance();
     $CI->load->module_library(BLOG_FOLDER, 'fuel_blog');
     $CI->load->module_model(BLOG_FOLDER, 'blog_users_model');
     $CI->load->module_model(BLOG_FOLDER, 'blog_categories_model');
     $CI->load->module_model(BLOG_FOLDER, 'blog_posts_to_categories_model');
     $blog_config = $CI->config->item('blog');
     $category_options = $CI->blog_categories_model->options_list('id', 'name', array('published' => 'yes'), 'name');
     $category_values = !empty($values['id']) ? array_keys($CI->blog_posts_to_categories_model->find_all_array_assoc('category_id', array('post_id' => $values['id'], $this->_tables['blog_categories'] . '.published' => 'yes'))) : array();
     $fields['categories'] = array('label' => 'Categories', 'type' => 'array', 'options' => $category_options, 'class' => 'add_edit blog/categories combo', 'value' => $category_values, 'mode' => 'multi');
     $user_options = $CI->blog_users_model->options_list();
     $user = $this->fuel_auth->user_data();
     $user_value = !empty($values['author_id']) ? $values['author_id'] : $user['id'];
     $author_comment = $fields['author_id']['comment'];
     $fields['author_id'] = array('label' => 'Author', 'type' => 'select', 'options' => $user_options, 'first_option' => 'Select an author...', 'value' => $user_value, 'comment' => $author_comment);
     if (!isset($values['allow_comments'])) {
         $fields['allow_comments']['value'] = $CI->fuel_blog->settings('allow_comments') ? 'yes' : 'no';
     }
     if (!empty($blog_config['formatting'])) {
         $blog_config['formatting'] = (array) $blog_config['formatting'];
         if (count($blog_config['formatting']) == 1) {
             $fields['formatting'] = array('type' => 'hidden', 'options' => current($blog_config['formatting']), 'default' => $fields['formatting']['default']);
         } else {
             $fields['formatting'] = array('type' => 'select', 'options' => $blog_config['formatting'], 'default' => $fields['formatting']['default']);
         }
     }
     $fields['published']['order'] = 10000;
     if (!is_true_val($CI->fuel_blog->settings('allow_comments'))) {
         unset($fields['allow_comments']);
     }
     $fields['upload_images'] = array('type' => 'file', 'class' => 'multifile', 'order' => 6, 'upload_path' => assets_server_path($CI->fuel_blog->settings('asset_upload_path')), 'comment' => 'Upload images to be used with your blog posts');
     unset($fields['content_filtered']);
     //$fields['date_added']['type'] = 'hidden'; // so it will auto add
     $fields['date_added']['type'] = 'datetime';
     // so it will auto add
     $fields['last_modified']['type'] = 'hidden';
     // so it will auto add
     return $fields;
 }
Esempio n. 10
0
 function cache()
 {
     $this->_validate_user('manage/cache');
     $this->nav_selected = 'manage/cache';
     if ($post = $this->input->post('action')) {
         $this->load->library('cache');
         $cache_group = $this->config->item('page_cache_group', 'fuel');
         $this->cache->remove_group($cache_group);
         // also delete DWOO compiled files
         $this->load->helper('file');
         $dwoo_path = APPPATH . 'cache/dwoo/compiled/';
         if (is_dir($dwoo_path) and is_writable($dwoo_path)) {
             @delete_files($dwoo_path);
         }
         // remove asset cache files if exist
         $modules = $this->config->item('modules_allowed', 'fuel');
         $modules[] = FUEL_FOLDER;
         // fuel
         $modules[] = '';
         // main application assets
         foreach ($modules as $module) {
             // check if there is a css module assets file and load it so it will be ready when the page is ajaxed in
             $cache_folder = assets_server_path($this->asset->assets_cache_folder, 'cache', $module);
             if (is_dir($cache_folder) and is_writable($cache_folder)) {
                 @delete_files($cache_folder);
             }
         }
         $msg = lang('cache_cleared');
         $this->logs_model->logit($msg);
         $this->session->set_flashdata('success', 'The cache has been cleared.');
         redirect('fuel/manage/cache');
     } else {
         $vars['notifications'] = $this->load->view('_blocks/notifications', array(), TRUE);
         $this->_render('manage/cache', $vars);
     }
 }
Esempio n. 11
0
 private function _get_excluded_asset_server_folders()
 {
     $CI =& get_instance();
     $excluded = $CI->config->item('assets_excluded_dirs', 'fuel');
     $return = array();
     foreach ($excluded as $folder) {
         $return[] = assets_server_path($folder) . '/';
     }
     return $return;
 }
Esempio n. 12
0
 /**
  * Add FUEL specific changes to the form_fields method
  *
  * @access	public
  * @param	string
  * @param	int
  * @return	boolean
  */
 function form_fields($values = array(), $related = array())
 {
     $fields = parent::form_fields($values, $related);
     $order = 1;
     // create default images
     $upload_path = assets_server_path('', 'images');
     $order = 1;
     foreach ($fields as $key => $field) {
         $fields[$key]['order'] = $order;
         // get field names that end with _image
         if ($fields[$key]['type'] == 'string' and substr($key, -5) == 'image' or substr($key, -3) == 'img') {
             $img = '';
             if (!empty($values['id'])) {
                 if (!empty($values[$key])) {
                     $img = '<div class="img_display"><img src="' . img_path($values[$key]) . '" style="float: right;"/></div>';
                 }
             }
             $fields[$key]['class'] = 'asset_select';
             $order++;
             $fields[$key . '_upload'] = array('order' => $order, 'before_html' => $img, 'label' => '... OR upload an image', 'upload_path' => $upload_path, 'type' => 'file', 'overwrite' => TRUE);
         }
         $order++;
     }
     $yes = lang('form_enum_option_yes');
     $no = lang('form_enum_option_no');
     if (isset($fields['published'])) {
         $fields['published']['order'] = 9999;
         $fields['published']['options'] = array('yes' => $yes, 'no' => $no);
     }
     if (isset($fields['active'])) {
         $fields['active']['order'] = 9999;
         $fields['active']['options'] = array('yes' => $yes, 'no' => $no);
     }
     return $fields;
 }
Esempio n. 13
0
 function do_code_edit($code_id)
 {
     $module_uri = base_url() . $this->module_uri;
     if (!empty($code_id)) {
         $post_arr = $this->input->post();
         $post_arr['lang_code'] = 'zh-TW';
         $root_path = assets_server_path('code_img/' . $post_arr['code_key'] . "/" . $post_arr['lang_code'] . "/");
         if (!file_exists($root_path)) {
             mkdir($root_path, 0777, true);
         }
         $config['upload_path'] = $root_path;
         $config['allowed_types'] = 'png';
         $config['max_size'] = '9999';
         $config['max_width'] = '1024';
         $config['max_height'] = '768';
         $this->load->library('upload', $config);
         // $name = 'news_img/'.$post_arr['type']."/".$post_arr['title'].".png";
         $redirect_uri = base_url() . "fuel/code/lists?codekind_key=" . $post_arr['codekind_key'] . "&code_id=" . $post_arr['parent_id'];
         if ($this->upload->do_upload('img')) {
             $data = array('upload_data' => $this->upload->data());
             $post_arr["img"] = 'code_img/' . $post_arr['code_key'] . '/' . $post_arr['lang_code'] . '/' . $data["upload_data"]["file_name"];
         } else {
             $post_arr["img"] = $post_arr["exist_img"];
         }
         // $update_data = array();
         // $update_data['code_name'] 		= $this->input->get_post("code_name");
         // $update_data['code_key'] 		= $this->input->get_post("code_key");
         // $update_data['code_value1'] 	= $this->input->get_post("code_value1");
         // $update_data['code_value2'] 	= $this->input->get_post("code_value2");
         // $update_data['code_value3'] 	= $this->input->get_post("code_value3");
         // $update_data['lang_code'] 		= $this->input->get_post("lang_code");
         // $update_data['codekind_key'] 	= $this->input->get_post("codekind_key");
         // $update_data['parent_id'] 		= $this->input->get_post("parent_id");
         $success = $this->codekind_manage_model->code_update($code_id, $post_arr);
         if ($success) {
             $this->comm->plu_redirect($redirect_uri, 0, "更新成功");
             die;
         } else {
             $this->comm->plu_redirect($redirect_uri, 0, "更新失敗");
             die;
         }
     } else {
         $this->comm->plu_redirect($module_uri, 0, "更新失敗");
         die;
     }
     return;
 }
Esempio n. 14
0
 /**
  * Returns an image based on the assets upload path
  *
  * @access	public
  * @param	string
  * @param	string
  * @param	boolean
  * @return	string
  */
 function image_path($image, $variable = NULL, $is_server = FALSE)
 {
     $base_path = $this->fuel->blog->config('asset_upload_path');
     $base_path = preg_replace('#(\\{.+\\})#U', $variable, $base_path);
     if ($is_server) {
         $folder = assets_server_path($base_path);
     } else {
         $folder = assets_path($base_path);
     }
     return $folder . $image;
 }
Esempio n. 15
0
 /**
 * Returns the file size of an asset
 *
 	<code>
 	echo $this->asset->asset_filesize('banner.jpg');
 	// 20500
 
 	echo $this->asset->assets_path('banner.jpg', 'images', '', TRUE);
 	// 20.5 KB 
 	</code>
 
 * @access	public
 * @param	string	asset file name including extension
  	 * @param	string	subfolder to asset file (e.g. images, js, css... etc)
  	 * @param	string	module folder if any
  	 * @param	boolean	format
 * @return	string
 */
 public function asset_filesize($file = NULL, $path = NULL, $module = NULL, $format = TRUE)
 {
     $asset_file = assets_server_path($file, $path, $module);
     $filesize = 0;
     if (file_exists($asset_file)) {
         $filesize = filesize($asset_file);
     }
     if ($format) {
         if (!function_exists('byte_format')) {
             $CI = $this->_get_assets_config();
             $CI->load->helper('number');
         }
         $filesize = byte_format($filesize);
     }
     return $filesize;
 }
Esempio n. 16
0
 protected function _process_uploads($posted = NULL)
 {
     if (empty($posted)) {
         $posted = $_POST;
     }
     $this->lang->load('upload');
     $errors = FALSE;
     if (!empty($_FILES)) {
         $this->load->model('assets_model');
         $this->load->library('upload');
         $this->load->helper('directory');
         $config['max_size'] = $this->config->item('assets_upload_max_size', 'fuel');
         $config['max_width'] = $this->config->item('assets_upload_max_width', 'fuel');
         $config['max_height'] = $this->config->item('assets_upload_max_height', 'fuel');
         // loop through all asset types
         foreach ($_FILES as $file => $file_info) {
             if ($file_info['error'] == 0) {
                 // continue processing
                 $filename = $file_info['name'];
                 $filename_arr = explode('.', $filename);
                 $filename_no_ext = $filename_arr[0];
                 $ext = end($filename_arr);
                 $test_multi = explode('___', $file);
                 $is_multi = count($test_multi) > 1;
                 $multi_root = $test_multi[0];
                 foreach ($this->assets_model->get_dir_filetypes() as $key => $val) {
                     $file_types = explode('|', strtolower($val));
                     if (in_array(strtolower($ext), $file_types)) {
                         $asset_dir = $key;
                         break;
                     }
                 }
                 if (!empty($asset_dir)) {
                     // upload path
                     if (!empty($posted[$file . '_path'])) {
                         $config['upload_path'] = $posted[$file . '_path'];
                     } else {
                         if (!empty($posted[$multi_root . '_path'])) {
                             $config['upload_path'] = $posted[$multi_root . '_path'];
                         } else {
                             $config['upload_path'] = isset($upload_path) ? $upload_path : assets_server_path() . $asset_dir . '/';
                         }
                     }
                     if (!is_dir($config['upload_path']) and $this->config->item('assets_allow_subfolder_creation', 'fuel')) {
                         // will recursively create folder
                         //$old = umask(0)
                         @mkdir($config['upload_path'], 0777, TRUE);
                         if (!file_exists($config['upload_path'])) {
                             $errors = TRUE;
                             add_error(lang('upload_not_writable'));
                             $this->session->set_flashdata('error', lang('upload_not_writable'));
                         } else {
                             chmodr($config['upload_path'], 0777);
                         }
                         //umask($old);
                     }
                     // overwrite
                     if (!empty($posted[$file . '_overwrite'])) {
                         $config['overwrite'] = !empty($posted[$file . '_overwrite']);
                     } else {
                         if (!empty($posted[$multi_root . '_overwrite'])) {
                             $config['overwrite'] = !empty($posted[$multi_root . '_overwrite']);
                         } else {
                             $config['overwrite'] = TRUE;
                         }
                     }
                     // filename... lower case it for consistency
                     $config['file_name'] = url_title($filename, 'underscore', TRUE);
                     if (!empty($posted[$file . '_filename'])) {
                         $config['file_name'] = $posted[$file . '_filename'] . '.' . $ext;
                     } else {
                         if (!empty($posted[$multi_root . '_filename'])) {
                             $config['file_name'] = $posted[$multi_root . '_filename'] . '.' . $ext;
                         }
                     }
                     $config['allowed_types'] = $this->assets_model->get_dir_filetype($asset_dir) ? $this->assets_model->get_dir_filetype($asset_dir) : 'jpg|jpeg|png|gif';
                     $config['remove_spaces'] = TRUE;
                     //$config['xss_clean'] = TRUE; // causes problem with image if true... so we use the below method
                     $tmp_file = file_get_contents($file_info['tmp_name']);
                     if ($this->sanitize_images and $this->input->xss_clean($tmp_file, TRUE) === FALSE) {
                         $errors = TRUE;
                         add_error(lang('upload_invalid_filetype'));
                         $this->session->set_flashdata('error', lang('upload_invalid_filetype'));
                     }
                     if (!$errors) {
                         $this->upload->initialize($config);
                         if (!$this->upload->do_upload($file)) {
                             $errors = TRUE;
                             add_error(lang('upload_invalid_filetype'));
                             $this->session->set_flashdata('error', $this->upload->display_errors('', ''));
                         }
                     }
                 }
             }
         }
     }
     return !$errors;
 }
 /**
  * Add FUEL specific changes to the form_fields method
  *
  * @access	public
  * @param	array Values of the form fields (optional)
  * @param	array An array of related fields. This has been deprecated in favor of using has_many and belongs to relationships (deprecated)
  * @return	array An array to be used with the Form_builder class
  */
 public function form_fields($values = array(), $related = array())
 {
     $fields = parent::form_fields($values, $related);
     $order = 1;
     // create default images
     $upload_path = assets_server_path('', 'images');
     $order = 1;
     foreach ($fields as $key => $field) {
         $fields[$key]['order'] = $order;
         $order++;
     }
     $yes = lang('form_enum_option_yes');
     $no = lang('form_enum_option_no');
     if (isset($fields['published'])) {
         $fields['published']['order'] = 9999;
         $fields['published']['options'] = array('yes' => $yes, 'no' => $no);
     }
     if (isset($fields['active'])) {
         $fields['active']['order'] = 9999;
         $fields['active']['options'] = array('yes' => $yes, 'no' => $no);
     }
     return $fields;
 }
Esempio n. 18
0
 function optimize_css()
 {
     $css = array('jqmodal', 'jquery.tooltip', 'jquery.treeview', 'jquery.supercomboselect', 'markitup', 'jquery-ui-1.8.17.custom', 'fuel');
     // set the folder in which to place the file
     $output_params['type'] = 'css';
     $output_params['whitespace'] = TRUE;
     $output_params['destination'] = assets_server_path('fuel.min.css', 'css', FUEL_FOLDER);
     $output_params['module'] = FUEL_FOLDER;
     $output = $this->asset->optimize($css, $output_params);
     echo lang('module_build_asset', 'CSS', $output_params['destination']);
 }
Esempio n. 19
0
 function _remap($method)
 {
     if (defined('CRON')) {
         $this->load->library('email');
         $this->load->helper('string');
         $this->load->module_model(FUEL_FOLDER, 'logs_model');
         $backup_config = $this->config->item('backup');
         $include_assets = ($method == '1' or $method == 'index' and $backup_config['backup_assets']);
         $download_path = $backup_config['db_backup_path'];
         if (!is_writable($download_path)) {
             $this->output->set_output(lang('cron_db_folder_not_writable', $download_path));
             return;
         }
         // Load the DB utility class
         $this->load->dbutil();
         // Backup your entire database and assign it to a variable
         //$config = array('newline' => "\r", 'format' => 'zip');
         // need to do text here to make some fixes
         $db_back_prefs = $backup_config['db_backup_prefs'];
         $db_back_prefs['format'] = 'txt';
         $backup =& $this->dbutil->backup($db_back_prefs);
         //fixes to work with PHPMYAdmin
         $backup = str_replace('\\\\t', "\t", $backup);
         $backup = str_replace('\\\\n', '\\n', $backup);
         $backup = str_replace("\\'", "''", $backup);
         $backup = str_replace('\\\\', '', $backup);
         // load the file helper and write the file to your server
         $this->load->helper('file');
         $this->load->library('zip');
         $backup_date = date('Y-m-d');
         $filename = $backup_config['backup_file_prefix'] . '_' . $backup_date . '.sql';
         $this->zip->add_data($filename, $backup);
         // include assets folder
         if ($include_assets) {
             $this->zip->read_dir(assets_server_path());
         }
         $download_file = $download_path . $filename . '.zip';
         // write the zip file to a folder on your server.
         if (!file_exists($download_file)) {
             $this->zip->archive($download_file);
             $output = $include_assets ? lang('cron_db_backup_asset', $filename) : lang('cron_db_backup', $filename);
             $this->logs_model->logit($output, 0);
             // the 0 is for the system as the user
             // send email if set in config
             if (!empty($backup_config['backup_cron_email'])) {
                 $this->email->to($backup_config['backup_cron_email']);
                 $this->email->from($this->config->item('from_email', 'fuel'), $this->config->item('site_name', 'fuel'));
                 $this->email->message($output);
                 $this->email->subject(lang('cron_email_subject', $this->config->item('site_name', 'fuel')));
                 if ($backup_config['backup_cron_email_file']) {
                     $this->email->attach($download_file);
                 }
                 if ($this->email->send()) {
                     $output .= "\n" . lang('cron_email', $backup_config['backup_cron_email']);
                 } else {
                     $output .= "\n" . lang('cron_email_error', $backup_config['backup_cron_email']);
                 }
             }
         } else {
             $output = lang('cron_db_backed_up_already');
         }
         $this->output->set_output($output);
     }
 }
Esempio n. 20
0
	private function _get_excluded_asset_server_folders()
	{
		$CI =& get_instance();
		$excluded = array_merge($CI->config->item('assets_excluded_dirs', 'fuel'), $CI->asset->assets_folders);
		$return = array();
		foreach($excluded as $folder)
		{
			$folder_path = assets_server_path($folder);
			if (substr($folder_path, -1, 1) != '/')
			{
				$folder_path = $folder_path.'/';
			}
			
			if (!in_array($folder_path, $return))
			{
				$return[] = $folder_path;
			}
		}
		return $return;
	}
Esempio n. 21
0
 function do_edit($id)
 {
     $post_arr = $this->input->post();
     $news_kind = $post_arr['news_kind'];
     $root_path = assets_server_path("news_img/{$news_kind}/");
     if (!file_exists($root_path)) {
         mkdir($root_path, 0777, true);
     }
     $post_arr["content"] = htmlspecialchars($post_arr["content"]);
     $post_arr = $this->input->post();
     $config['upload_path'] = $root_path;
     $config['allowed_types'] = 'png|jpg';
     $config['max_size'] = '9999';
     $config['max_width'] = '*';
     $config['max_height'] = '*';
     $this->load->library('upload', $config);
     // $name = 'news_img/'.$post_arr['type']."/".$post_arr['title'].".png";
     if ($this->upload->do_upload('img')) {
         $data = array('upload_data' => $this->upload->data());
         $post_arr["img"] = "news_img/{$news_kind}/" . $data["upload_data"]["file_name"];
     } else {
         $post_arr["img"] = $post_arr["exist_img"];
     }
     $post_arr["id"] = $id;
     $module_uri = base_url() . 'fuel/news/edit/' . $id;
     //調整順序
     // if ($post_arr['news_ori_order'] != $post_arr['news_order']) {
     // 	$ori_obj = $this->news_manage_model->get_order($post_arr);
     // 	if (isset($ori_obj)) {
     // 		$ori_id = $ori_obj->id;
     // 		$this->news_manage_model->update_order($post_arr['news_order'],$id);
     // 		$this->news_manage_model->update_order($post_arr['news_ori_order'],$ori_id);
     // 	}
     // }
     // print_r($post_arr);
     $success = $this->news_manage_model->update($post_arr);
     if ($success) {
         $this->plu_redirect($module_uri, 0, "更新成功");
         die;
     } else {
         $this->plu_redirect($module_uri, 0, "更新失敗");
         die;
     }
     return;
 }
Esempio n. 22
0
 /**
  * Set Writer for css
  *
  * @author Kondratenko Alexander (Xander)
  */
 public function writeStaticCssLinks()
 {
     $writer = new AssetWriter(assets_server_path('static'));
     $writer->writeManagerAssets($this->am_css);
 }
Esempio n. 23
0
echo is_really_writable(BASEPATH . 'cache/') ? 'success' : 'error';
?>
">
				<?php 
echo BASEPATH . 'cache/';
?>
			</li>
			<li class="<?php 
echo is_really_writable(BASEPATH . 'cache/dwoo/compiled') ? 'success' : 'error';
?>
">
				<?php 
echo BASEPATH . 'cache/dwoo/compiled';
?>
			</li>
			<li class="<?php 
echo is_really_writable(assets_server_path('', 'images')) ? 'success' : 'error';
?>
">
				<?php 
echo WEB_ROOT . 'assets/images';
?>
			</li>
		</ul>
	</li>
</ol>

<p>That's it!</p>

<p class="important">Certain modules may require their own configuration and database SQL files to be run. Please reference their own documentation in the user guide for additional
install information.</p>
Esempio n. 24
0
 function do_edit()
 {
     $base_url = base_url();
     $id = $this->input->get("id");
     $user_info = $this->fuel_users_model->get_login_user_info();
     // $module_uri = $base_url.'fuel/event/edit?id='.$id;
     $post_arr = $this->input->post();
     $post_arr['create_by'] = $user_info['user_name'];
     if (!array_key_exists("can_vote", $post_arr)) {
         $post_arr['can_vote'] = 0;
     }
     if (!array_key_exists("can_like", $post_arr)) {
         $post_arr['can_like'] = 0;
     }
     if (!array_key_exists("can_share", $post_arr)) {
         $post_arr['can_share'] = 0;
     }
     if (!array_key_exists("allow_email", $post_arr)) {
         $post_arr['allow_email'] = 0;
     }
     if (!array_key_exists("allow_fb", $post_arr)) {
         $post_arr['allow_fb'] = 0;
     }
     $root_path = assets_server_path("event/");
     if (!file_exists($root_path)) {
         mkdir($root_path, 0777, true);
     }
     $config['upload_path'] = $root_path;
     $config['allowed_types'] = 'png|jpg';
     $config['max_size'] = '9999';
     $config['max_width'] = '*';
     $config['max_height'] = '*';
     $this->load->library('upload', $config);
     // $name = 'news_img/'.$post_arr['type']."/".$post_arr['title'].".png";
     if ($this->upload->do_upload('file')) {
         $data = array('upload_data' => $this->upload->data());
         $post_arr["photo"] = "event/" . $data["upload_data"]["file_name"];
     } else {
         $post_arr["photo"] = $post_arr["exist_img"];
     }
     if ($this->upload->do_upload('spilt_file')) {
         $data = array('upload_data' => $this->upload->data());
         $post_arr["spilt_file"] = "event/" . $data["upload_data"]["file_name"];
     } else {
         $post_arr["spilt_file"] = $post_arr["exist_spilt_file"];
     }
     // print_r($post_arr);
     // die;
     $success = $this->event_manage_model->modify($post_arr, $id);
     $module_uri = $base_url . 'fuel/event/item/' . $id;
     if ($success) {
         $this->comm->plu_redirect($module_uri, 0, "修改成功");
         die;
     } else {
         $this->comm->plu_redirect($module_uri, 0, "修改失敗");
         die;
     }
     return;
 }
Esempio n. 25
0
 /**
  * Creates the file input for the form
  *
  * @access	public
  * @param	array fields parameters
  * @return	string
  */
 public function create_file($params)
 {
     $defaults = array('overwrite' => NULL, 'display_overwrite' => TRUE, 'accept' => 'gif|jpg|jpeg|png|pdf', 'upload_path' => NULL, 'folder' => NULL, 'file_name' => NULL, 'encrypt_name' => NULL);
     $params = $this->normalize_params($params, $defaults);
     $attrs = array('id' => $params['id'], 'class' => $params['class'], 'readonly' => $params['readonly'], 'disabled' => $params['disabled'], 'required' => !empty($params['required']) ? TRUE : NULL, 'accept' => str_replace('|', ',', $params['accept']), 'tabindex' => $params['tabindex'], 'attributes' => $params['attributes']);
     if (is_array($this->form_attrs)) {
         $this->form_attrs['enctype'] = 'multipart/form-data';
     } else {
         if (is_string($this->form_attrs) and strpos($this->form_attrs, 'enctype') === FALSE) {
             $this->form_attrs .= ' enctype="multipart/form-data"';
         }
     }
     $file = $this->form->file($params['name'], $attrs);
     if (isset($params['overwrite'])) {
         $overwrite = ($params['overwrite'] == 1 or $params['overwrite'] === TRUE or $params['overwrite'] === 'yes' or $params['overwrite'] === 'y') ? '1' : '0';
         if (!empty($params['display_overwrite'])) {
             $file .= ' &nbsp; <span class="overwrite_field">' . $this->form->checkbox($params['name'] . '_overwrite', 1, Form::do_checked($overwrite));
             $file .= ' ' . $this->create_label($this->label_lang('overwrite')) . '</span>';
         } else {
             $file .= $this->form->hidden($params['name'] . '_overwrite', $overwrite);
         }
     }
     if (isset($params['upload_path']) or isset($params['folder'])) {
         if (isset($params['folder'])) {
             $upload_path = $this->CI->encrypt->encode(assets_server_path($params['folder']));
         } else {
             $upload_path = $this->CI->encrypt->encode($params['upload_path']);
         }
         $file .= $this->form->hidden($params['name'] . '_upload_path', $upload_path);
     }
     if (isset($params['file_name']) or isset($params['filename'])) {
         $file_name = isset($params['file_name']) ? $params['file_name'] : $params['filename'];
         $file .= $this->form->hidden($params['name'] . '_file_name', $file_name);
     }
     if (isset($params['encrypt']) or isset($params['encrypt_name'])) {
         $encrypt_name = isset($params['encrypt_name']) ? $params['encrypt_name'] : $params['encrypt'];
         $file .= $this->form->hidden($params['name'] . '_encrypt_name', $encrypt_name);
     }
     return $file;
 }
Esempio n. 26
0
 /**
  * Unzips a zip file
  *
  * @access	public
  * @param	string	The path to the zip file to unzip relative to the assets folder
  * @param	string	The destination path
  * @return	array 	An array of unzipped file names
  */
 public function unzip($zip_file, $destination = NULL)
 {
     $this->CI->load->library('unzip');
     // the assets server path
     $assets_dir = assets_server_path();
     //Only take out these files, anything else is ignored
     $path_parts = pathinfo($zip_file);
     $filetype_folder = rtrim(str_replace($assets_dir, '', $path_parts['dirname']), '/');
     $allowed = $this->dir_filetype($filetype_folder);
     if (!$allowed) {
         $this->_add_error(lang('error_invalid_folder'));
         return FALSE;
     }
     // normalize file path
     $zip_file = rtrim(str_replace($assets_dir, '', $zip_file), '/');
     $this->CI->unzip->allow($allowed);
     $zip_file = $assets_dir . $zip_file;
     // or specify a destination directory
     $unzipped = $this->CI->unzip->extract($zip_file, $destination);
     $errors = $this->CI->unzip->error_string('', '');
     if (!$unzipped or !empty($errors)) {
         $this->_add_error($this->CI->unzip->error_string('', ' '));
         return FALSE;
     }
     return $unzipped;
 }
Esempio n. 27
0
 /**
  * Clears the assets cache
  * 
  * Will look in module asset folders if the <dfn>fuel/{module}/assets/cache/</dfn> directory exist for that module
  * 
  * <code>
  * $this->fuel->cache->clear_assets();
  * </code>
  *
  * @access	public
  * @return	void
  */
 public function clear_assets()
 {
     // remove asset cache files if exist
     $modules = $this->fuel->config('modules_allowed');
     $modules[] = FUEL_FOLDER;
     // fuel
     $modules[] = '';
     // main application assets
     foreach ($modules as $module) {
         // check if there is a css module assets file and load it so it will be ready when the page is ajaxed in
         $cache_folder = assets_server_path($this->CI->asset->assets_cache_folder, 'cache', $module);
         if (is_dir($cache_folder) and is_writable($cache_folder)) {
             $this->_delete_files($cache_folder);
         }
     }
 }
Esempio n. 28
0
 public function create($dir = NULL, $inline = FALSE)
 {
     $id = NULL;
     if (!empty($dir)) {
         $dir = uri_safe_decode($dir);
     }
     if ($inline !== FALSE) {
         $this->fuel->admin->set_inline(TRUE);
     }
     $inline = $this->fuel->admin->is_inline();
     if (!empty($_POST)) {
         if (!empty($_FILES['userfile']) and $_FILES['userfile']['error'] != 4 or !empty($_FILES['userfile___0']) and $_FILES['userfile___0']['error'] != 4) {
             $this->model->on_before_post();
             if ($this->input->post('asset_folder')) {
                 $dir = $this->input->get_post('asset_folder', TRUE);
                 if (!in_array($dir, array_keys($this->fuel->assets->dirs()))) {
                     show_404();
                 }
             }
             $subfolder = $this->config->item('assets_allow_subfolder_creation', 'fuel') ? str_replace('..' . DIRECTORY_SEPARATOR, '', $this->input->get_post('subfolder', TRUE)) : '';
             // remove any going down the folder structure for protections
             $upload_path = $this->config->item('assets_server_path') . $this->fuel->assets->dir($dir) . DIRECTORY_SEPARATOR . $subfolder;
             //assets_server_path is in assets config
             $posted['upload_path'] = $upload_path;
             $posted['overwrite'] = $this->input->get_post('overwrite') ? TRUE : FALSE;
             $posted['create_thumb'] = $this->input->get_post('create_thumb') ? TRUE : FALSE;
             $posted['resize_method'] = $this->input->get_post('resize_method') ? $this->input->get_post('resize_method', TRUE) : 'maintain_ratio';
             $posted['resize_and_crop'] = $this->input->get_post('resize_and_crop', TRUE);
             $posted['width'] = $this->input->get_post('width', TRUE);
             $posted['height'] = $this->input->get_post('height', TRUE);
             $posted['master_dim'] = $this->input->get_post('master_dim', TRUE);
             $posted['file_name'] = $this->input->get_post('userfile_file_name', TRUE);
             $posted['unzip'] = $this->input->get_post('unzip') ? TRUE : FALSE;
             $posted['remove_subfolder'] = $this->input->get_post('remove_subfolder', TRUE);
             $redirect_to = uri_safe_decode($this->input->get_post('redirect_to'));
             $id = $posted['file_name'];
             // run before_create hook
             $this->_run_hook('before_create', $posted);
             // run before_save hook
             $this->_run_hook('before_save', $posted);
             if ($this->fuel->assets->upload($posted)) {
                 foreach ($_FILES as $filename => $fileinfo) {
                     $msg = lang('module_edited', $this->module_name, $fileinfo['name']);
                     $this->fuel->logs->write($msg);
                 }
                 // explicitly set the flash values to save cookie space
                 $flashdata['asset_folder'] = $this->input->post('asset_folder', TRUE);
                 $flashdata['userfile_file_name'] = $this->input->post('userfile_file_name', TRUE);
                 $flashdata['subfolder'] = $this->input->post('subfolder', TRUE);
                 $flashdata['overwrite'] = $this->input->post('overwrite', TRUE);
                 $flashdata['resize_method'] = $this->input->post('resize_method', TRUE);
                 $flashdata['width'] = $this->input->post('width', TRUE);
                 $flashdata['height'] = $this->input->post('height', TRUE);
                 $flashdata['resize_method'] = $this->input->post('resize_method', TRUE);
                 $flashdata['master_dim'] = $this->input->post('master_dim', TRUE);
                 $flashdata['resize_method'] = $this->input->post('resize_method', TRUE);
                 $uploaded_data = $this->fuel->assets->uploaded_data();
                 $first_file = current($uploaded_data);
                 $uploaded_file_name_arr = array();
                 $uploaded_file_webpath_arr = array();
                 foreach ($uploaded_data as $ud) {
                     $uploaded_path = assets_server_path() . $dir;
                     if (is_true_val($posted['remove_subfolder'])) {
                         $uploaded_path = $uploaded_path . '/' . $subfolder;
                     }
                     $uploaded_file_name_arr[] = trim(str_replace($uploaded_path, '', $ud['full_path']), '/');
                     $uploaded_file_webpath_arr[] = assets_server_to_web_path($ud['full_path']);
                 }
                 // set the uploaded file name to a concatenated string separated by commas
                 $uploaded_file_name = implode(', ', $uploaded_file_name_arr);
                 $flashdata['uploaded_file_name'] = $uploaded_file_name;
                 $flashdata['uploaded_file_webpath'] = $uploaded_file_webpath_arr;
                 $this->session->set_flashdata('uploaded_post', $flashdata);
                 $this->fuel->admin->set_notification(lang('data_saved'), Fuel_admin::NOTIFICATION_SUCCESS);
                 $this->model->on_after_post($posted);
                 $inline = $this->fuel->admin->is_inline();
                 $query_str = query_str(array(), TRUE);
                 if (!empty($redirect_to)) {
                     $url = $redirect_to;
                 } else {
                     if ($inline === TRUE) {
                         $url = fuel_uri($this->module . '/inline_create/' . uri_safe_encode($dir) . $query_str, FALSE);
                     } else {
                         $url = fuel_uri($this->module . '/create/' . uri_safe_encode($dir) . $query_str, FALSE);
                     }
                 }
                 redirect($url);
             } else {
                 add_errors($this->fuel->assets->errors());
             }
         } else {
             add_errors(lang('error_upload'));
         }
     }
     $form_vars = $this->input->get(NULL, TRUE);
     if (!empty($dir)) {
         $form_vars['asset_folder'] = $dir;
     }
     $form_vars['asset_folder'] = !empty($form_vars['asset_folder']) ? trim($form_vars['asset_folder'], '/') : '';
     $vars = $this->_form($form_vars, $inline);
     $vars['related_items'] = $this->model->related_items($vars);
     $list_view = $inline ? $this->module_uri . '/inline_items/' : $this->module_uri;
     $crumbs = array($list_view => $this->module_name, lang('assets_upload_action'));
     $this->fuel->admin->set_titlebar($crumbs);
     $this->fuel->admin->set_inline($inline === TRUE);
     if ($inline === TRUE) {
         $this->fuel->admin->set_display_mode(Fuel_admin::DISPLAY_COMPACT_TITLEBAR);
     } else {
         $vars['actions'] = $this->load->module_view(FUEL_FOLDER, '_blocks/module_create_edit_actions', $vars, TRUE);
     }
     $this->fuel->admin->render($this->views['create_edit'], $vars, '', FUEL_FOLDER);
     return $id;
 }