Ejemplo n.º 1
0
 public function syncFolder($folder)
 {
     $syncResult = EventgalleryLibraryFolderLocal::syncFolder($folder);
     if ($syncResult == EventgalleryLibraryManagerFolder::$SYNC_STATUS_NOSYNC) {
         $result = "nosync";
     }
     if ($syncResult == EventgalleryLibraryManagerFolder::$SYNC_STATUS_SYNC) {
         $result = "sync";
     }
     if ($syncResult == EventgalleryLibraryManagerFolder::$SYNC_STATUS_DELTED) {
         $result = "deleted";
     }
     return $result;
 }
Ejemplo n.º 2
0
 function uploadFileByAjax()
 {
     $user = JFactory::getUser();
     @mkdir(COM_EVENTGALLERY_IMAGE_FOLDER_PATH);
     $data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
     $dataHtaccess = "order deny,allow\ndeny from all";
     JFile::write(COM_EVENTGALLERY_IMAGE_FOLDER_PATH . "index.html", $data);
     JFile::write(COM_EVENTGALLERY_IMAGE_FOLDER_PATH . ".htaccess", $dataHtaccess);
     $folder = JRequest::getString('folder');
     $folder = JFile::makeSafe($folder);
     $path = COM_EVENTGALLERY_IMAGE_FOLDER_PATH . $folder . DIRECTORY_SEPARATOR;
     @mkdir($path);
     JFile::write($path . "index.html", $data);
     JFile::write($path . ".htaccess", $dataHtaccess);
     $fn = JRequest::getString('file', false);
     $fn = JFile::makeSafe($fn);
     $allowedExtensions = array('jpg', 'gif', 'png', 'jpeg');
     if (!in_array(strtolower(pathinfo($fn, PATHINFO_EXTENSION)), $allowedExtensions)) {
         echo "Unsopported file extension in {$fn}";
         die;
     }
     $uploadedFiles = array();
     $ajaxMode = JRequest::getString('ajax', false);
     echo $fn . " done";
     if ($fn) {
         // AJAX call
         file_put_contents($path . $fn, file_get_contents('php://input'));
         #echo "$fn uploaded in folder $folder";
         echo '<img alt="Done ' . $fn . '" class="thumbnail" src="' . JURI::base() . ("../components/com_eventgallery/helpers/image.php?view=resizeimage&folder=" . $folder . "&file=" . $fn . "&option=com_eventgallery&width=100&height=50") . '" />';
         array_push($uploadedFiles, $fn);
     } else {
         // form submit
         $files = $_FILES['fileselect'];
         foreach ($files['error'] as $id => $err) {
             if ($err == UPLOAD_ERR_OK) {
                 $fn = $files['name'][$id];
                 $fn = str_replace('..', '', $fn);
                 move_uploaded_file($files['tmp_name'][$id], $path . $fn);
                 array_push($uploadedFiles, $fn);
             }
         }
     }
     $db = JFactory::getDBO();
     foreach ($uploadedFiles as $uploadedFile) {
         if (file_exists($path . $uploadedFile)) {
             @(list($width, $height, $type, $attr) = getimagesize($path . $uploadedFile));
             $query = $db->getQuery(True)->select('count(1)')->from($db->quoteName('#__eventgallery_file'))->where('folder=' . $db->quote($folder))->where('file=' . $db->quote($uploadedFile));
             $db->setQuery($query);
             if ($db->loadResult() == 0) {
                 $query = $db->getQuery(true)->insert($db->quoteName('#__eventgallery_file'))->columns('folder,file,userid,created,modified,ordering')->values($db->Quote($folder) . ',' . $db->Quote($uploadedFile) . ',' . $db->Quote($user->id) . ',' . 'now(),now(),0');
             } else {
                 $query = $db->getQuery(true)->update($db->quoteName('#__eventgallery_file'))->set('userid=' . $db->Quote($user->id))->set('created=now()')->set('modified=now()')->where('folder=' . $db->Quote($folder))->where('file=' . $db->Quote($uploadedFile));
             }
             $db->setQuery($query);
             $db->query();
             EventgalleryLibraryFolderLocal::updateMetadata($path . $uploadedFile, $folder, $uploadedFile);
         }
     }
     if (!$ajaxMode) {
         $msg = JText::_('COM_EVENTGALLERY_EVENT_UPLOAD_COMPLETE');
         $this->setRedirect('index.php?option=com_eventgallery&task=upload', $msg);
     }
     die;
 }