function fetchMethodsForm($uid, $step, $method) { global $task; // Prompt with a list of upload methods $lists = array(); $lists['methods'] = dmHTML::uploadSelectList(); $lists['action'] = _taskLink($task, $uid, array('step' => $step + 1), false); return HTML_DMUpload::uploadMethodsForm($lists); }
function uploadWizard($step = 1, $method = 'http', $old_filename) { global $_DOCMAN; $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); switch ($step) { case 1: $lists['methods'] = dmHTML::uploadSelectList($method); HTML_DMFiles::uploadWizard($lists); break; case 2: switch ($method) { case 'http': HTML_DMFiles::uploadWizard_http($old_filename); break; case 'ftp': HTML_DMFiles::uploadWizard_ftp(); break; case 'link': $mainframe->redirect("index.php?option=com_docman§ion=documents&task=new&makelink=1", _DML_CREATEALINK); // HTML_DMFiles::uploadWizard_link(); break; case 'transfer': HTML_DMFiles::uploadWizard_transfer(); break; default: $mainframe->redirect("index.php?option=com_docman§ion=files", _DML_SELECTMETHODFIRST); } break; case 3: DOCMAN_token::check() or die('Invalid Token'); switch ($method) { case 'http': $path = $_DOCMAN->getCfg('dmpath'); $upload = new DOCMAN_FileUpload(); $file_upload = JRequest::getVar('upload', '', 'files', 'array'); $result =& $upload->uploadHTTP($file_upload, $path, _DM_VALIDATE_ADMIN); if (!$result) { $mainframe->redirect("index.php?option=com_docman§ion=files", _DML_ERROR_UPLOADING . " - " . $upload->_err); } else { $batch = JRequest::getCmd('batch', null); if ($batch && $old_filename != null) { require_once JPATH_ADMINISTRATOR . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php'; if (!extension_loaded('zlib')) { $mainframe->redirect("index.php?option=com_docman§ion=files", _DML_ZLIB_ERROR); } $target_directory = $_DOCMAN->getCfg('dmpath'); $zip = new PclZip($target_directory . DS . $result->name); $file_to_unzip = preg_replace('/(.+)\\..*$/', '$1', $target_directory . DS . $result->name); if (!$zip->extract($target_directory)) { $mainframe->redirect("index.php?option=com_docman§ion=files", _DML_UNZIP_ERROR); } @unlink($target_directory . DS . $result->name); } if ($old_filename && $old_filename != $file_upload['name']) { $file = $_DOCMAN->getCfg('dmpath') . DS . $old_filename; @unlink($file); $database->setQuery("UPDATE #__docman SET dmfilename='" . $database->getEscaped($result->name) . "' WHERE dmfilename='" . $database->getEscaped($old_filename) . "'"); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1);</script>\n"; exit; } } //HTML_DMFiles::uploadWizard_sucess($result, $batch, $old_filename); $mainframe->redirect("index.php?option=com_docman§ion=files&task=upload&step=4" . "&result=" . urlencode($result->name) . "&batch=" . (0 + $batch) . "&old_filename=" . $old_filename, _DML_SUCCESS . ' "' . $result->name . '" - ' . _DML_FILEUPLOADED); } break; case 'ftp': break; case 'link': break; case 'transfer': $url = stripslashes(JRequest::getString('url', null, 'post')); $name = stripslashes(JRequest::getString('localfile', null, 'post')); $path = $_DOCMAN->getCfg('dmpath') . DS; $upload = new DOCMAN_FileUpload(); $result = $upload->uploadURL($url, $path, _DM_VALIDATE_ADMIN, $name); if ($result) { // HTML_DMFiles::uploadWizard_sucess($result, 0, 1); $mainframe->redirect("index.php?option=com_docman§ion=files&task=upload&step=4" . "&result=" . urlencode($result->name) . "&batch=0&old_filename=1", _DML_SUCCESS . ' "' . $result->name . '" - ' . _DML_FILEUPLOADED); } else { $mainframe->redirect("index.php?option=com_docman§ion=files", $upload->_err); } break; } break; case '4': /* New step that gives us a header completion message rather than "in body" completion. For uniformity */ $file = new StdClass(); $file->name = urlencode(stripslashes(JRequest::getString('result', 'INTERNAL ERROR'))); $batch = JRequest::getInt('batch', 0); $old_filename = JRequest::getString('old_filename', null); HTML_DMFiles::uploadWizard_sucess($file, $batch, $old_filename, 0); break; } //End switch($step) }