Beispiel #1
0
 /**
  * Process before saving to database
  *
  * @access	public
  * @param	array
  * @param	obj
  * @return	string
  */
 public function pre_save($input, $field)
 {
     // If we do not have a file that is being submitted. If we do not,
     // it could be the case that we already have one, in which case just
     // return the numeric file record value.
     if (!isset($_FILES[$field->field_slug . '_file']['name']) or !$_FILES[$field->field_slug . '_file']['name']) {
         if (is_numeric($this->CI->input->post($field->field_slug))) {
             return $this->CI->input->post($field->field_slug);
         } else {
             return null;
         }
     }
     $this->CI->load->library('files/files');
     // Resize options
     $resize_width = isset($field->field_data['resize_width']) ? $field->field_data['resize_width'] : null;
     $resize_height = isset($field->field_data['resize_height']) ? $field->field_data['resize_height'] : null;
     $keep_ratio = (isset($field->field_data['keep_ratio']) and $field->field_data['keep_ratio'] == 'yes') ? true : false;
     // If you don't set allowed types, we'll set it to allow all.
     $allowed_types = isset($field->field_data['allowed_types']) ? $field->field_data['allowed_types'] : '*';
     $return = Files::upload($field->field_data['folder'], null, $field->field_slug . '_file', $resize_width, $resize_height, $keep_ratio, $allowed_types);
     if (!$return['status']) {
         $this->CI->session->set_flashdata('notice', $return['message']);
         return null;
     } else {
         // Return the ID of the file DB entry
         return $return['data']['id'];
     }
 }
 public function actionSave()
 {
     $data_array = $_POST;
     if (!empty($data_array)) {
         $course = new Courses();
         foreach ($data_array as $key => $value) {
             $course->{$key} = $value;
         }
         if (!empty($_FILES)) {
             $course->img = Files::upload($_FILES, 'courses');
         }
         $course->save();
     } else {
         header('Location: ' . ADMIN_PATH);
     }
     header('Location: ' . ADMIN_PATH . '?ctrl=courses&act=edit&id=' . $course->id);
 }
 public function actionSave()
 {
     $data_array = $_POST;
     if (!empty($data_array)) {
         $user = Users::findOneByPK(Auth::checkAuth());
         $user->getProfile();
         foreach ($data_array as $key => $value) {
             $user->{$key} = $value;
         }
         if (!empty($_FILES['img']['name'])) {
             $user->img = Files::upload($_FILES, 'users');
         } else {
             $user->img = 'img/defaults/owl00' . rand(1, 6) . '.png';
         }
         $user->saveProfile();
     } else {
         header('Location: ' . BASE_PATH . 'auth/');
     }
     header('Location: ' . BASE_PATH . 'users/');
 }
Beispiel #4
0
 public function index()
 {
     $this->load->library('form_validation');
     $rules = array(array('field' => 'name', 'label' => 'lang:files:name', 'rules' => 'trim'), array('field' => 'description', 'label' => 'lang:files:description', 'rules' => ''), array('field' => 'folder_id', 'label' => 'lang:files:folder', 'rules' => 'required'));
     $this->form_validation->set_rules($rules);
     if ($this->form_validation->run()) {
         $input = $this->input->post();
         $results = Files::upload($input['folder_id'], $input['name'], 'userfile');
         // if the upload was successful then we'll add the description too
         if ($results['status']) {
             $data = $results['data'];
             $this->file_m->update($data['id'], array('description' => $input['description']));
         }
         // upload has a message to share... good or bad?
         $this->session->set_flashdata($results['status'] ? 'success' : 'notice', $results['message']);
     } else {
         $this->session->set_flashdata('error', validation_errors());
     }
     redirect("admin/wysiwyg/{$this->input->post('redirect_to')}/index/{$this->input->post('folder_id')}");
 }
 public function pre_save($input, $field, $stream, $row_id, $form_data)
 {
     if (!isset($_FILES[$field->field_slug . '_file']['name']) or !$_FILES[$field->field_slug . '_file']['name']) {
         if (isset($form_data[$field->field_slug]) and $form_data[$field->field_slug]) {
             $save["id"] = $form_data[$field->field_slug];
             $save["x"] = $form_data[$field->field_slug . "_x"];
             $save["y"] = $form_data[$field->field_slug . "_y"];
             $save["x2"] = $form_data[$field->field_slug . "_x2"];
             $save["y2"] = $form_data[$field->field_slug . "_y2"];
             return serialize($save);
         } else {
             return "";
         }
     }
     $this->CI->load->library('files/files');
     $allowed_types = isset($field->field_data['allowed_types']) ? $field->field_data['allowed_types'] : '*';
     $return = Files::upload($field->field_data['folder'], null, $field->field_slug . '_file', null, null, null, $allowed_types);
     if (!$return['status']) {
         $this->CI->session->set_flashdata('notice', $return['message']);
         return null;
     } else {
         // Return the ID of the file DB entry
         $save["id"] = $return['data']['id'];
         // Set max. crop (default crop)
         $cw = $field->field_data['crop_width'];
         $ch = $field->field_data['crop_height'];
         $w = $return["data"]["width"];
         $h = $return["data"]["height"];
         $cnx = round($w / 2);
         $cny = round($h / 2);
         $cwh = round($cw / 2);
         $chh = round($ch / 2);
         $save["x"] = max(0, $cnx - $cwh);
         $save["y"] = max(0, $cny - $chh);
         $save["x2"] = min($w, $cnx + $cwh);
         $save["y2"] = min($h, $cny + $chh);
         return serialize($save);
     }
 }
Beispiel #6
0
     // log record creation
     if (!$item['id']) {
         $label = sprintf(i18n::c('New file in %s'), strip_tags($anchor->get_title()));
         $link = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($_REQUEST['id']);
         $description = sprintf(i18n::c('%s at %s'), $_REQUEST['file_name'], '<a href="' . $link . '">' . $link . '</a>');
         Logger::notify('files/edit.php: ' . $label, $description);
     }
     // a file has been uploaded
 } elseif (Files::get_uploaded('upload', 'name')) {
     $file_path = Files::get_path($_REQUEST['anchor']);
     // update an existing file record
     if (isset($item['id'])) {
         Files::set_uploaded('upload', 'id', $item['id']);
     }
     // attach some file
     if ($uploaded = Files::upload(Files::get_uploaded('upload'), $file_path, $anchor->get_reference(), $overlay)) {
         // actually, a new file
         if (!isset($item['id'])) {
             $action = 'file:create';
         } else {
             $action = 'file:upload';
         }
         // several files have been added
         if (is_array($uploaded)) {
             $compact_list = Skin::build_list(Files::list_for_anchor_and_name($anchor->get_reference(), $uploaded, 'compact'), 'compact');
             $context['text'] .= '<p>' . i18n::s('Following files have been added:') . '</p>' . $compact_list;
             // log multiple upload
             $label = sprintf(i18n::c('New files in %s'), strip_tags($anchor->get_title()));
             Logger::notify('files/edit.php: ' . $label, $compact_list);
             // push the list of uploaded files to the notification
             $attributes = array();
 public function upload($id)
 {
     // Get product
     $row = $this->row_m->get_row($id, $this->stream, FALSE);
     $folder = $this->products_m->get_file_folder_by_slug($row->slug);
     // Create folder?
     if (!$folder) {
         $parent = $this->products_m->get_file_folder_by_slug('product-images');
         $folder = Files::create_folder($parent->id, $row->title);
         $folder = (object) $folder['data'];
     }
     // Check for folder
     if (is_object($folder)) {
         // Upload it
         $status = Files::upload($folder->id);
         // Make square?
         $this->products_m->make_square($status);
         // Ajax status
         unset($status['data']);
         echo json_encode($status);
         exit;
     }
     // Seems it was unsuccessful
     echo json_encode(array('status' => FALSE, 'message' => 'Error uploading image'));
     exit;
 }
Beispiel #8
0
 /**
  * Save / Upload gallery images
  * 
  * @param string $type insert|update
  * @param int $gallery_id 
  * @return bool
  */
 private function save_gallery_images($type = 'insert', $gallery_id)
 {
     if (!is_numeric($gallery_id)) {
         return FALSE;
     }
     $folder_id = $this->gallery_m->get($gallery_id)->folder_id;
     $max_images = $this->input->post('max_images');
     $image_name = $this->current_user->username . "Image ";
     $img_data = NULL;
     $img_id = array();
     for ($i = 1; $i <= $max_images; $i++) {
         $img = Files::upload($folder_id, $image_name . $i, $field = 'image' . $i, $width = 800, $height = 800, $ratio = TRUE);
         if ($img['status'] === TRUE) {
             $img_data = array('gallery_id' => $gallery_id, 'file_id' => $img['data']['id']);
             if ($file_id = $this->input->post('image' . $i)) {
                 Files::delete_file($file_id);
                 $img_id[] = $this->gallery_image_m->update_by('file_id', $file_id, $img_data);
             } else {
                 $img_id[] = $this->gallery_image_m->insert($img_data);
             }
         }
     }
     return count($img_id);
 }
Beispiel #9
0
 /**
  * 
  */
 public function executeUploadFile()
 {
     if (Files::upload("file", $_REQUEST["folder"] . "/")) {
         Log::getInstance()->insert(array("action" => "upload", "module" => "projects", "title" => "Envoi de fichier(s)", "message" => "Des fichiers ont été envoyés dans le dossier du projet #" . $data["project_id"]));
         return true;
     } else {
         return false;
     }
 }
 /**
  * Process before saving to database
  *
  * @access	public
  * @param	array
  * @param	obj
  * @return	string
  */
 public function pre_save($input, $field, $stream, $row_id, $form_data)
 {
     // If we do not have a file that is being submitted. If we do not,
     // it could be the case that we already have one, in which case just
     // return the numeric file record value.
     if (!isset($_FILES[$field->field_slug . '_file']) or !$_FILES[$field->field_slug . '_file']) {
         // allow dummy as a reset
         if (isset($form_data[$field->field_slug]) and $form_data[$field->field_slug]) {
             return $form_data[$field->field_slug];
         } else {
             return null;
         }
     }
     $this->CI->load->library('files/files');
     // Resize options
     $resize_width = isset($field->field_data['resize_width']) ? $field->field_data['resize_width'] : null;
     $resize_height = isset($field->field_data['resize_height']) ? $field->field_data['resize_height'] : null;
     $keep_ratio = (isset($field->field_data['keep_ratio']) and $field->field_data['keep_ratio'] == 'yes') ? true : false;
     // If you don't set allowed types, we'll set it to allow all.
     $allowed_types = isset($field->field_data['allowed_types']) ? $field->field_data['allowed_types'] : '*';
     $field_slug = $field->field_slug . '_file';
     $multifiles = $_FILES[$field_slug];
     $_FILES[$field_slug] = null;
     $myfiles = array();
     foreach ($multifiles['name'] as $key => $files) {
         $myfiles[$field_slug . $key]['name'] = $files;
         $myfiles[$field_slug . $key]['type'] = $multifiles['type'][$key];
         $myfiles[$field_slug . $key]['tmp_name'] = $multifiles['tmp_name'][$key];
         $myfiles[$field_slug . $key]['error'] = $multifiles['error'][$key];
         $myfiles[$field_slug . $key]['size'] = $multifiles['size'][$key];
         $_FILES[$field_slug . $key] = $myfiles[$field_slug . $key];
     }
     if (count($myfiles) == 0) {
         return null;
     }
     $returns = array();
     foreach ($myfiles as $file_slug => $file_data) {
         $returns[] = Files::upload($field->field_data['folder'], null, $file_slug, $resize_width, $resize_height, $keep_ratio, $allowed_types);
     }
     $files = null;
     if (count($returns) > 0) {
         foreach ($returns as $return) {
             if ($return['status'] === true) {
                 $files[] = $return['data']['id'];
             }
         }
         //delete unnecessary files and update the selected file to db
         ci()->load->driver('Streams');
         $field_slug = $field->field_slug;
         $entries_files = ci()->streams->entries->get_entry($row_id, $stream->stream_slug, $stream->stream_namespace, false)->{$field_slug};
         $rfiles = $this->filter_images($entries_files, $form_data[$field->field_slug]);
         if ($rfiles) {
             $files = array_merge($rfiles, (array) $files);
         }
         return implode('|', $files);
     } else {
         // Return the ID of the file DB entry
         return null;
     }
 }
Beispiel #11
0
<?php

// helpers and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$FILES = new Files();
$REQUEST = new Request();
if ($REQUEST->avail("admin") && $REQUEST->get("admin")) {
    $RULES = new Rules(5, "files");
    $FILES->upload($REQUEST, '/var/www/html/' . $REQUEST->get("admin_base", "/"));
} else {
    $RULES = new Rules(1, "files");
    $FILES->upload($REQUEST, '/var/www/html/uploads/');
}
?>

Beispiel #12
0
         if (($path = substr($name, strlen($file_path . '/'))) && strpos($path, '/') !== FALSE) {
             Safe::unlink($name);
         } elseif (!($attributes = Safe::GetImageSize($name))) {
             Safe::unlink($name);
         } elseif ($attributes[0] > 5000 || $attributes[1] > 5000) {
             Safe::unlink($name);
         }
     }
     // extract archive components and save them in mentioned directory
     if ($count = $zipfile->explode($_FILES['upload']['tmp_name'], $file_path, '', 'explode_callback')) {
         $exploded = TRUE;
     } else {
         Logger::error(sprintf('Nothing has been extracted from %s.', $_FILES['upload']['name']));
     }
     // attach one file
 } elseif ($file_name = Files::upload($_FILES['upload'], $file_path, array('Image', 'upload'))) {
     $_REQUEST['image_name'] = $file_name;
     // maybe this image has already been uploaded for this anchor
     if (isset($_REQUEST['anchor']) && ($match =& Images::get_by_anchor_and_name($_REQUEST['anchor'], $file_name))) {
         // if yes, switch to the matching record (and forget the record fetched previously, if any)
         $_REQUEST['id'] = $match['id'];
         $item = $match;
     }
     // remember file size
     $_REQUEST['image_size'] = $_FILES['upload']['size'];
     // silently delete the previous file if the name has changed
     if (isset($item['image_name']) && $item['image_name'] && $file_name && $item['image_name'] != $file_name && isset($file_path)) {
         Safe::unlink($file_path . '/' . $item['image_name']);
         Safe::unlink($file_path . '/' . $item['thumbnail_name']);
     }
 }
Beispiel #13
0
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('skins/flexible/upload.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // we need a target directory
} elseif (!isset($_REQUEST['directory']) || !is_dir('./' . basename($_REQUEST['directory']))) {
    Safe::header('Status: 400 Bad Request', TRUE, 400);
    Logger::error(i18n::s('Request is invalid.'));
    // process uploaded file
} elseif (isset($_FILES['upload']['name']) && $_FILES['upload']['name'] && $_FILES['upload']['name'] != 'none') {
    // where to put this file
    $file_path = 'skins/flexible/' . basename($_REQUEST['directory']);
    // attach some file
    if ($file_name = Files::upload($_FILES['upload'], $file_path)) {
        $context['page_title'] = i18n::s('Thank you for your contribution');
        $context['text'] .= '<p><img src="' . $context['url_to_home'] . $context['url_to_root'] . $file_path . '/' . $file_name . '" /></p>';
        if (isset($_REQUEST['referer']) && $_REQUEST['referer']) {
            $link = $_REQUEST['referer'];
        } elseif (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) {
            $link = $_SERVER['HTTP_REFERER'];
        } else {
            $link = 'skins/flexible/configure.php';
        }
        $follow_up = Skin::build_link($link, i18n::s('Done'), 'button');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
    }
    // nothing has been posted
} else {
    $context['page_title'] = i18n::s('Add a file');
Beispiel #14
0
 /**
  * Upload files
  */
 public function upload()
 {
     // this is just a safeguard if they circumvent the JS permissions
     if (!in_array('upload', Files::allowed_actions())) {
         show_error(lang('files:no_permissions'));
     }
     $input = $this->input->post();
     if ($input['folder_id'] and $input['name']) {
         echo json_encode(Files::upload($input['folder_id'], $input['name'], 'file', $input['width'], $input['height'], $input['ratio']));
     }
 }
Beispiel #15
0
 }
 // append to previous comment during 10 secondes
 if (!isset($item['id']) && ($newest = Comments::get_newest_for_anchor($anchor->get_reference())) && $newest['type'] != 'notification' && Surfer::get_id() && (isset($newest['create_id']) && Surfer::get_id() == $newest['create_id']) && $newest['edit_date'] > gmstrftime('%Y-%m-%d %H:%M:%S', time() - 10)) {
     // copy from previous comment record
     $_REQUEST['id'] = $newest['id'];
     $_REQUEST['create_address'] = $newest['create_address'];
     $_REQUEST['create_date'] = $newest['create_date'];
     $_REQUEST['create_id'] = $newest['create_id'];
     $_REQUEST['create_name'] = $newest['create_name'];
     $_REQUEST['description'] = $newest['description'] . BR . $_REQUEST['description'];
     $_REQUEST['previous_id'] = $newest['previous_id'];
     $_REQUEST['type'] = $newest['type'];
 }
 // attach some file
 $file_path = Files::get_path($anchor->get_reference());
 if (isset($_FILES['upload']) && ($uploaded = Files::upload($_FILES['upload'], $file_path, $anchor->get_reference()))) {
     // sanity check
     if (!$_REQUEST['description']) {
         $_REQUEST['description'] = '';
     }
     // several files have been added
     if (is_array($uploaded)) {
         $_REQUEST['description'] .= '<div style="margin-top: 1em;">' . Skin::build_list(Files::list_for_anchor_and_name($anchor->get_reference(), $uploaded, 'compact'), 'compact') . '</div>';
     } elseif ($file =& Files::get_by_anchor_and_name($anchor->get_reference(), $uploaded)) {
         $_REQUEST['description'] .= '<div style="margin-top: 1em;">[file=' . $file['id'] . ',' . $file['file_name'] . ']</div>';
         // silently delete the previous file if the name has changed
         if (isset($file['file_name']) && $file['file_name'] != $uploaded) {
             Safe::unlink($file_path . '/' . $file['file_name']);
         }
     }
 }
Beispiel #16
0
 // the page has been published
 if (isset($_REQUEST['publish_date']) && $_REQUEST['publish_date'] > NULL_DATE) {
     $context['text'] .= '<p>' . i18n::s('The page has been successfully posted. Please review it now to ensure that it reflects your mind.') . '</p>';
 } elseif (Surfer::is_empowered()) {
     $context['text'] .= i18n::s('<p>Don\'t forget to publish the new page someday. Review the page, enhance it and then click on the Publish command to make it publicly available.</p>');
 } elseif (isset($context['users_with_auto_publish']) && $context['users_with_auto_publish'] == 'Y' || is_object($anchor) && $anchor->has_option('auto_publish')) {
     $context['text'] .= i18n::s('<p>Don\'t forget to publish the new page someday. Review the page, enhance it and then click on the Publish command to make it publicly available.</p>');
 } else {
     $context['text'] .= i18n::s('<p>The new page will now be reviewed before its publication. It is likely that this will be done within the next 24 hours at the latest.</p>');
 }
 if (!isset($_REQUEST['first_comment'])) {
     $_REQUEST['first_comment'] = '';
 }
 // attach some file
 $file_path = Files::get_path('article:' . $_REQUEST['id']);
 if (isset($_FILES['upload']) && ($uploaded = Files::upload($_FILES['upload'], $file_path, 'article:' . $_REQUEST['id']))) {
     // several files have been added
     if (is_array($uploaded)) {
         $_REQUEST['first_comment'] .= '<div>' . Skin::build_list(Files::list_for_anchor_and_name('article:' . $_REQUEST['id'], $uploaded, 'compact'), 'compact') . '</div>';
     } elseif ($file =& Files::get_by_anchor_and_name('article:' . $_REQUEST['id'], $uploaded)) {
         $_REQUEST['first_comment'] .= '<div>' . Codes::render_object('file', $file['id']) . '</div>';
         // silently delete the previous file if the name has changed
         if (isset($file['file_name']) && $file['file_name'] != $uploaded) {
             Safe::unlink($file_path . '/' . $file['file_name']);
         }
     }
 }
 // capture first comment too
 if (isset($_REQUEST['first_comment']) && $_REQUEST['first_comment']) {
     include_once $context['path_to_root'] . 'comments/comments.php';
     $fields = array();
Beispiel #17
0
 /**
  * upload a file as a image attach to a given anchor
  * to be used in custom "edit_as" script
  * 
  * @global string $context
  * @param object $anchor
  * @param array $file (from $_FILES)
  * @param bool $set_as_thumb
  * @param bool $put
  */
 public static function upload_to($anchor, $file, $set_as_thumb = false, $put = false)
 {
     global $context;
     // attach some image
     $path = Files::get_path($anchor->get_reference(), 'images');
     // $_REQUEST['action'] = 'set_as_icon'; // instruction for image::upload
     if (isset($file) && ($uploaded = Files::upload($file, $path, array('Image', 'upload')))) {
         // prepare image informations
         $image = array();
         $image['image_name'] = $uploaded;
         $image['image_size'] = $file['size'];
         $image['thumbnail_name'] = 'thumbs/' . $uploaded;
         $image['anchor'] = $anchor->get_reference();
         //$combined = array_merge($image, $_FILES);
         // post the image which was uploaded
         if ($image['id'] = Images::post($image)) {
             // successfull post
             $context['text'] .= '<p>' . i18n::s('Following image has been added:') . '</p>' . Codes::render_object('image', $image['id']) . '<br style="clear:left;" />' . "\n";
             // set image as icon and thumbnail
             if ($set_as_thumb) {
                 // delete former icon if any
                 /*if(isset($anchor->item['icon_url'])
                                                         && $anchor->item['icon_url']
                                                         && $match = Images::get_by_anchor_and_name($anchor->get_reference(), pathinfo($anchor->item['icon_url'],PATHINFO_BASENAME))) {
                 
                 
                                                     if($match['id'] != $image['id'])
                                                         Images::delete($match['id']);
                                                 }*/
                 $fields = array('thumbnail_url' => Images::get_thumbnail_href($image), 'icon_url' => Images::get_icon_href($image));
                 if ($put) {
                     $fields['id'] = $_REQUEST['id'];
                     $class = $anchor->get_static_group_class();
                     $class::put_attributes($fields);
                 } else {
                     $_REQUEST = array_merge($_REQUEST, $fields);
                 }
             }
         }
     }
 }
Beispiel #18
0
 public function edit($id)
 {
     $my_product = $this->product_m->get_by('user', $this->current_user->id);
     $this->data->current_product = $my_product;
     $this->data->all_categories = $this->product_category_m->get_all();
     /* var_dump($this->data->my_all_categories);
        exit();*/
     $my_head_categories = $this->product_category_m->get_all_header();
     $this->data->my_head_categories = $my_head_categories;
     if (!empty($my_head_categories)) {
         foreach ($my_head_categories as $sub_categories) {
             $parent_id = $sub_categories->id;
             $sub_cat_c[] = $this->product_category_m->get_sub_categories($parent_id);
         }
     } else {
         $sub_cat_c = "";
     }
     $this->data->my_sub_categories = $sub_cat_c;
     $user_id = $this->current_user->id;
     if ($this->input->post()) {
         /*if($_SERVER['HTTP_REFERER']!="http://localhost/ezone/sbsupportlink.com.au/solution/create")
           {
                   redirect('product');
               }*/
         //this will check if the form has been submitted from the desired url.
         $this->form_validation->set_rules('subcategory', 'Sub Category', 'required|callback_check');
         $this->form_validation->set_rules('businessname', 'Business Name', 'required');
         $this->form_validation->set_rules('firstname', 'First Name', 'required');
         $this->form_validation->set_rules('lastname', 'Last Name', 'required');
         $this->form_validation->set_rules('telephone', 'Telephone', 'required');
         $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
         $this->form_validation->set_rules('suffix', 'Suffix', 'required');
         $this->form_validation->set_rules('country', 'Country', 'required');
         $this->form_validation->set_rules('area_serviced', 'Do you service all of Australia', 'required');
         $this->form_validation->set_rules('post_code', 'numeric');
         $serialized_category = serialize($this->input->post('subcategory'));
         //echo $serialized_category;
         if ($this->form_validation->run() == TRUE) {
             $data = array();
             $file = $_FILES['attachment']['name'];
             if ($file) {
                 $this->load->library('files/files');
                 $this->load->model('files/file_folders_m');
                 files::delete_file($my_product->business_logo);
                 $folder_id = $this->file_folders_m->get_by('slug', 'attachments')->id;
                 $name = $file . now();
                 $uploaddata = Files::upload($folder_id, $name, 'attachment');
                 if ($uploaddata['status'] == true) {
                     $data['business_logo'] = $uploaddata['data']['id'];
                 }
             }
             $data['user'] = $user_id;
             $data['created'] = strftime("%Y-%m-%d %H:%M:%S", time());
             $data['businessname'] = $this->input->post('businessname');
             $data['firstname'] = $this->input->post('firstname');
             $data['lastname'] = $this->input->post('lastname');
             $data['telephone'] = $this->input->post('telephone');
             $data['mobile'] = $this->input->post('mobile');
             $data['email_address'] = $this->input->post('email');
             $data['website'] = $this->input->post('website');
             $data['unit_no'] = $this->input->post('unit');
             $data['street_address'] = $this->input->post('street');
             $data['suffix'] = $this->input->post('suffix');
             $data['suburb'] = $this->input->post('suburb');
             $data['post_code'] = $this->input->post('postcode');
             $data['state'] = $this->input->post('state');
             $data['country'] = $this->input->post('country');
             $data['area_serviced'] = $this->input->post('area_serviced');
             $data['size_of_business'] = $this->input->post('size_of_business');
             $data['business_description'] = $this->input->post('business_description');
             $data['special_offer'] = $this->input->post('special_offer');
             $data['product_category_select'] = $serialized_category;
             if ($this->product_m->update($id, $data)) {
                 $this->session->set_flashdata('status', 'Your Business Listing Ad has been updated.');
                 redirect('membership/mysb');
             } else {
                 $this->session->set_flashdata('status', 'Your Business Listing Ad could not be updated.');
                 redirect('product/edit/' . $id);
             }
         }
     }
     $this->template->title('Edit Your Ad.')->build('edit', $this->data);
 }
Beispiel #19
0
 public function upload($id)
 {
     $this->forceAdmin();
     $files = new Files($id);
     $files->upload();
     $erlass = Erlass::fromDB($id);
     $this->display($erlass);
     $form = $this->template->addSubtemplate('uploadForm');
     $erlass->assignToTmpl($form);
 }
Beispiel #20
0
 /**
  * Upload files
  */
 public function upload()
 {
     // this is just a safeguard if they circumvent the JS permissions
     if (!in_array('upload', Files::allowed_actions()) and !($this->input->post('replace_id') && !in_array('delete', Files::allowed_actions()))) {
         show_error(lang('files:no_permissions'));
     }
     $result = null;
     $input = $this->input->post();
     if ($input['replace_id'] > 0) {
         $result = Files::replace_file($input['replace_id'], $input['folder_id'], $input['name'], 'file', $input['width'], $input['height'], $input['ratio'], null, $input['alt_attribute']);
         $result['status'] and Events::trigger('file_replaced', $result['data']);
     } elseif ($input['folder_id'] and $input['name']) {
         $result = Files::upload($input['folder_id'], $input['name'], 'file', $input['width'], $input['height'], $input['ratio'], null, $input['alt_attribute']);
         $result['status'] and Events::trigger('file_uploaded', $result['data']);
     }
     echo json_encode($result);
 }
Beispiel #21
0
 // no review is required
 $article['options'] = 'view_as_zic_pm';
 // include some overlay
 $overlay = Overlay::bind('thread');
 $article['overlay'] = $overlay->save();
 $article['overlay_id'] = $overlay->get_id();
 // ensure everything is positioned as expected
 Surfer::empower();
 // post the new thread
 if (!($article['id'] = Articles::post($article))) {
     Logger::error(i18n::s('Impossible to add a page.'));
 } else {
     //get full article
     $article = Articles::get($article['id']);
     // attach some file
     if (isset($_FILES['upload']) && ($file = Files::upload($_FILES['upload'], 'files/article/' . $article['id'], 'article:' . $article['id']))) {
         $_REQUEST['message'] .= $file;
     }
     // make a new comment out of received message, if any
     if (isset($_REQUEST['message']) && trim($_REQUEST['message'])) {
         $comment = array();
         $comment['anchor'] = 'article:' . $article['id'];
         $comment['description'] = strip_tags($_REQUEST['message']);
         Comments::post($comment);
     }
     // page title
     $context['page_title'] = i18n::s('Message sent&nbsp;!');
     // feed-back to surfer
     // $context['text'] .= '<p>'.i18n::s('A new thread has been created, and it will be listed in profiles of the persons that you have involved. You can invite additional people later on if you wish.').'</p>';
     // increment the post counter of the surfer
     Users::increment_posts(Surfer::get_id());