Пример #1
0
 public function storestl()
 {
     $template_data = array();
     $error = NULL;
     $response = 0;
     $button_goto_slice = NULL;
     $f1 = NULL;
     $f2 = NULL;
     $name = NULL;
     $this->load->library('parser');
     $this->lang->load('printerstoring/storestl', $this->config->item('language'));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $array_model = array();
         $upload_config = array('upload_path' => $this->config->item('temp'), 'allowed_types' => '*', 'overwrite' => FALSE, 'remove_spaces' => TRUE, 'encrypt_name' => TRUE);
         $this->load->library('upload', $upload_config);
         if ($this->upload->do_upload('file') && ($name = $this->input->post('name'))) {
             $f1 = $this->upload->data();
         } else {
             if ($this->upload->do_upload('file_c1') && ($name = $this->input->post('name'))) {
                 $first_combine = TRUE;
                 $f1 = $this->upload->data();
                 foreach (array('file_c2') as $file_key) {
                     if ($this->upload->do_upload($file_key)) {
                         $first_combine = FALSE;
                         $f2 = $this->upload->data();
                     } else {
                         if ($first_combine == TRUE) {
                             $error = t('fail_message');
                             break;
                         }
                     }
                 }
             } else {
                 // treat error - missing gcode file
                 $error = t('fail_message');
                 //TODO get error detail by $this->upload->display_errors()
             }
         }
         if ($f1 && ($name = $this->input->post('name'))) {
             $this->load->helper('printerstoring');
             $cr = PrinterStoring_storeStl($name, $f1, $f2);
             if ($cr === ERROR_OK) {
                 header('Location: ' . '/printerstoring/liststl?uploaded=uploaded');
             }
             if ($cr === ERROR_DISK_FULL) {
                 $error = t('fail_disk_full');
             } else {
                 $error = t('fail_message');
             }
         }
     }
     // parse the main body
     $template_data = array('back' => t('back'), 'home' => t('home'), 'select_hint' => t('select_hint'), 'select_hint_multi' => t('select_hint_multi'), 'header_single' => t('header_single'), 'header_multi' => t('header_multi'), 'upload_button' => t('upload_button'), 'error' => $error, 'name' => t('name'));
     // parse all page
     $this->_parseBaseTemplate(t('printerstoring_storestl_pagetitle'), $this->parser->parse('printerstoring/storestl', $template_data, TRUE));
     return;
 }
Пример #2
0
 public function libstorestl()
 {
     $cr = ERROR_OK;
     $f1 = NULL;
     $f2 = NULL;
     $name = NULL;
     $this->load->helper('printerstoring');
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $upload_config = array('upload_path' => $this->config->item('temp'), 'allowed_types' => '*', 'overwrite' => TRUE, 'remove_spaces' => TRUE, 'encrypt_name' => TRUE);
         $this->load->library('upload', $upload_config);
         if ($this->upload->do_upload('f1') and $name = $this->input->post('name')) {
             $f1 = $this->upload->data();
             if ($this->upload->do_upload('f2')) {
                 $f2 = $this->upload->data();
             }
             if ($f1['file_size'] < 100000 && ($f2 === NULL || $f2 && $f2['file_size'] < 100000)) {
                 $cr = PrinterStoring_storeStl($name, $f1, $f2);
             } else {
                 $cr = ERROR_TOOBIG_FILE;
             }
         } else {
             // treat error - missing file or name
             $cr = ERROR_MISS_PRM;
         }
         $this->_return_cr($cr);
     } else {
         $this->load->view('template/rest/libstorestl_form');
     }
     return;
 }