Ejemplo n.º 1
0
 function browserUpload()
 {
     if (!igGeneralHelper::authorise('core.igalleryfront.upload', JRequest::getInt('catid', 0))) {
         return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     for ($i = 0; $i < count($_FILES['uploads']['name']); $i++) {
         $fileName = $_FILES['uploads']['name'][$i];
         $tmpPath = $_FILES['uploads']['tmp_name'][$i];
         $uploadError = $_FILES['uploads']['error'][$i];
         if (!($fileData = igFileHelper::processUploadedImage($fileName, $tmpPath, $uploadError, 'igallery_img', true))) {
             $this->setRedirect('index.php?option=com_igallery&controller=igphoto&catid=' . JRequest::getInt('catid'));
             return false;
         }
         $model = $this->getModel();
         $category = $model->getCategory(JRequest::getInt('catid', 0));
         $profile = $model->getProfile($category->profile);
         if (!igFileHelper::makeResizedOnUpload($fileData, $profile, true)) {
             return false;
         }
         if (!$model->store($fileData)) {
             return false;
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_igallery&view=images&catid=' . JRequest::getInt('catid'), false));
 }
Ejemplo n.º 2
0
 function plUpload()
 {
     if (!igGeneralHelper::authorise('core.create', JRequest::getInt('catid', 0))) {
         echo JText::_('JERROR_ALERTNOAUTHOR');
         return false;
     }
     $fileName = $_FILES['file']['name'];
     $tmpPath = $_FILES['file']['tmp_name'];
     $uploadError = $_FILES['file']['error'];
     if (!($fileData = igFileHelper::processUploadedImage($fileName, $tmpPath, $uploadError, 'igallery_img', false))) {
         return false;
     }
     $model = $this->getModel();
     $category = $model->getCategory(JRequest::getInt('catid', 0));
     $profile = $model->getProfile($category->profile);
     if (!igFileHelper::makeResizedOnUpload($fileData, $profile, false)) {
         return false;
     }
     if (!$model->store($fileData)) {
         return false;
     }
     JFactory::getSession()->set('ig_uploaded', 1);
     echo 1;
 }
Ejemplo n.º 3
0
 function save($data)
 {
     $db = $this->getDbo();
     $row = $this->getTable('igallery');
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_igallery');
     $isSite = JFactory::getApplication()->isSite();
     if (!$row->bind($data)) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     if (strlen($_FILES['jform']['name']['upload_image']) > 2) {
         $fileName = $_FILES['jform']['name']['upload_image'];
         $tmpPath = $_FILES['jform']['tmp_name']['upload_image'];
         $uploadError = $_FILES['jform']['error']['upload_image'];
         if (!($fileArray = igFileHelper::processUploadedImage($fileName, $tmpPath, $uploadError, 'igallery', true))) {
             return false;
         }
         $row->menu_image_filename = $fileArray['filename'];
         $params = JComponentHelper::getParams('com_igallery');
     }
     if (empty($row->id)) {
         $firstLast = $params->get('new_cat_ordering', 'last');
         $row->ordering = $firstLast == 'first' ? 0 : $row->getNextOrder('parent = ' . (int) $row->parent);
         $row->profile = empty($row->profile) ? $params->get('default_profile', 1) : $row->profile;
         $row->parent = empty($row->parent) ? $params->get('default_parent', 0) : $row->parent;
     }
     $row->moderate = $params->get('moderate_cat', 0) == 0 || $isSite == false ? 1 : 0;
     $row->user = empty($row->user) ? $user->id : $row->user;
     $row->alias = empty($row->alias) ? JFilterOutput::stringURLSafe($row->name) : JFilterOutput::stringURLSafe($row->alias);
     $row->name = empty($row->name) ? '____' : $row->name;
     $raw = JRequest::getVar('jform', array(), 'post', 'NONE', JREQUEST_ALLOWRAW);
     $row->menu_description = JComponentHelper::filterText($raw['menu_description']);
     $row->gallery_description = JComponentHelper::filterText($raw['gallery_description']);
     if ($data['remove_menu_image'] == 1) {
         $query = 'SELECT menu_image_filename FROM #__igallery WHERE id = ' . (int) $data['id'];
         $db->setQuery($query);
         $category = $db->loadObject();
         $query = 'SELECT menu_image_filename FROM #__igallery WHERE menu_image_filename = ' . $this->_db->Quote($category->menu_image_filename);
         $db->setQuery($query);
         $db->query();
         $numRows = $db->getNumRows();
         $deleteImg = $numRows > 1 ? false : true;
         if ($deleteImg) {
             igFileHelper::deleteImage($category->menu_image_filename, $deleteImg);
         }
         $row->menu_image_filename = '';
     }
     if (!$row->store()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     if (trim(str_replace('-', '', $row->alias)) == '') {
         $row->alias = 'category-' . (int) $row->id;
         if (!$row->store()) {
             $this->setError($db->getErrorMsg());
             return false;
         }
     }
     $query = 'SELECT alias from #__igallery where alias = "' . $db->escape($row->alias) . '"';
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if (count($rows) > 1) {
         $row->alias = $row->alias . '-' . (int) $row->id;
         if (!$row->store()) {
             $this->setError($db->getErrorMsg());
             return false;
         }
     }
     if ($firstLast == 'first') {
         $row->reorder('parent = ' . (int) $row->parent);
     }
     if ($params->get('notify_new_category', 0) == 1 && $isSite == true) {
         $siteConfig = JFactory::getConfig();
         $from = $siteConfig->get('config.mailfrom');
         $fromname = $siteConfig->get('config.fromname');
         $recipient = explode(',', $params->get('notify_emails', ''));
         $subject = $siteConfig->get('config.sitename') . ' : ' . JText::_('NEW_CATEGORY_ADDED');
         $body = JText::_('JGLOBAL_USERNAME') . ': ' . $user->name . " \n\n " . JText::_('JCATEGORY') . ': ' . $row->name . " \n\n " . IG_HOST . 'administrator/index.php?option=com_igallery&view=icategory&id=' . $row->id . " \n\n " . IG_HOST . 'index.php?option=com_igallery&view=category&igid=' . $row->id;
         $mail = JFactory::getMailer();
         for ($i = 0; $i < count($recipient); $i++) {
             $mail->sendMail($from, $fromname, $recipient[$i], $subject, $body);
             if ($i > 5) {
                 break;
             }
         }
     }
     return true;
 }