Example #1
0
 /**
  * Uploads the selected images
  *
  * @return  void
  * @since   1.5.5
  */
 public function upload()
 {
     $this->_mainframe = JFactory::getApplication();
     $type = $this->_mainframe->getUserStateFromRequest('joom.upload.type', 'type', 'single', 'post', 'cmd');
     // If the applet in JAVA upload checks for the serverProtocol,
     // it issues a HEAD request
     // Simply return an empty doc to send a HTTP 200
     if ($type == 'java' && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
         jexit();
     }
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/upload.php';
     $uploader = new JoomUpload();
     if ($uploader->upload($type)) {
         $msg = JText::_('COM_JOOMGALLERY_UPLOAD_MSG_SUCCESSFULL');
         // Set redirect if we are asked for that
         if ($redirect = JRequest::getVar('redirect', '', '', 'base64')) {
             $url = base64_decode($redirect);
             if (JURI::isInternal($url)) {
                 $this->setRedirect(JRoute::_($url, false), $msg);
                 return;
             }
         }
         // Set a redirect according to the correspondent setting in configuration manager
         $model = $this->getModel('upload');
         $url = $model->getRedirectUrlAfterUpload($type);
         if (!empty($url)) {
             $this->setRedirect($url, $msg);
         }
     } else {
         if ($error = $uploader->getError()) {
             $this->setRedirect(JRoute::_('index.php?view=upload&tab=' . $type, false), $error, 'error');
         }
     }
 }
 /**
  * Uploads the selected images
  *
  * @return  void
  * @since   3.0
  */
 public function upload()
 {
     $result = array('error' => false);
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/upload.php';
     $uploader = new JoomUpload();
     if ($image = $uploader->upload(JRequest::getCmd('type', 'ajax'))) {
         $result['success'] = true;
         if (is_object($image)) {
             $result['id'] = $image->id;
             $result['imgtitle'] = $image->imgtitle;
             $result['thumbnailUrl'] = JoomAmbit::getInstance()->getImg('thumb_url', $image);
         }
     } else {
         if ($error = $uploader->getError()) {
             $result['error'] = $error;
         } else {
             $result['error'] = JText::_('COM_JOOMGALLERY_UPLOAD_ERROR_FILE_NOT_UPLOADED');
         }
     }
     if ($debug_output = $uploader->getDebugOutput()) {
         $result['debug_output'] = $debug_output;
     }
     $doc = JFactory::getDocument();
     $doc->setMimeEncoding('text/plain');
     echo json_encode($result);
 }
Example #3
0
 /**
  * Uploads the selected images
  *
  * @return  void
  * @since   1.5.5
  */
 public function upload()
 {
     $this->_mainframe = JFactory::getApplication();
     $type = $this->_mainframe->getUserStateFromRequest('joom.upload.type', 'type', 'single', 'post', 'cmd');
     // If the applet in JAVA upload checks for the serverProtocol,
     // it issues a HEAD request
     // Simply return an empty doc to send a HTTP 200
     if ($type == 'java' && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
         jexit();
     }
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/upload.php';
     $uploader = new JoomUpload();
     if ($uploader->upload($type)) {
         //T.Trung
         $db = JFactory::getDBO();
         $db->setQuery("SELECT MAX(id) FROM #__joomgallery");
         $img_id = $db->loadResult();
         $db->setQuery("INSERT INTO #__joomgallery_image_details (id, details_key, details_value, ordering) VALUES ('" . $img_id . "', 'additional.tags', '" . JRequest::getVar('tags') . "', 4)");
         $db->query();
         $db->setQuery("INSERT INTO #__joomgallery_image_details (id, details_key, details_value, ordering) VALUES ('" . $img_id . "', 'additional.price', '" . JRequest::getVar('price') . "', 1)");
         $db->query();
         $db->setQuery("INSERT INTO #__joomgallery_image_details (id, details_key, details_value, ordering) VALUES ('" . $img_id . "', 'additional.code', '" . $this->generateRandomString() . "', 3)");
         $db->query();
         $db->setQuery("INSERT INTO #__joomgallery_image_details (id, details_key, details_value, ordering) VALUES ('" . $img_id . "', 'additional.like', 0, 2)");
         $db->query();
         //T.Trung end
         $msg = JText::_('COM_JOOMGALLERY_UPLOAD_MSG_SUCCESSFULL');
         // Set redirect if we are asked for that
         if ($redirect = JRequest::getVar('redirect', '', '', 'base64')) {
             $url = base64_decode($redirect);
             if (JURI::isInternal($url)) {
                 $this->setRedirect(JRoute::_($url, false), $msg);
                 return;
             }
         }
         // Set a redirect according to the correspondent setting in configuration manager
         $model = $this->getModel('upload');
         $url = $model->getRedirectUrlAfterUpload($type);
         if (!empty($url)) {
             $this->setRedirect($url, $msg);
         }
     } else {
         if ($error = $uploader->getError()) {
             $this->setRedirect(JRoute::_('index.php?view=upload&tab=' . $type, false), $error, 'error');
         }
     }
 }
Example #4
0
 /**
  * Uploads the selected zip archiv
  *
  * @return  void
  * @since   1.5.5
  */
 public function upload()
 {
     require_once JPATH_COMPONENT . '/helpers/upload.php';
     $uploader = new JoomUpload();
     if ($uploader->upload(JRequest::getCmd('type', 'batch'))) {
         $msg = JText::_('COM_JOOMGALLERY_UPLOAD_MSG_SUCCESSFULL');
         $url = $this->_ambit->getRedirectUrl();
         // Set custom redirect if we are asked for that
         if ($redirect = JRequest::getVar('redirect', '', '', 'base64')) {
             $url_decoded = base64_decode($redirect);
             if (JURI::isInternal($url)) {
                 $url = $url_decoded;
             }
         }
         $this->setRedirect(JRoute::_($url, false), $msg);
     } else {
         if ($error = $uploader->getError()) {
             $this->setRedirect($this->_ambit->getRedirectUrl(), $error, 'error');
         }
     }
 }
Example #5
0
 /**
  * Uploads the passed images
  *
  * @return  void
  * @since   1.5.5
  */
 public function upload()
 {
     require_once JPATH_COMPONENT . '/helpers/upload.php';
     $uploader = new JoomUpload();
     $uploader->upload(JRequest::getCmd('type', 'java'));
 }