Example #1
0
    function uploadWizard_sucess(&$file, $batch = 0, $old_filename = null, $show_completion = 1)
    {
        global $mosConfig_live_site;
        if ($old_filename != '1') {
            mosredirect("index2.php?option=com_docman&section=files", """ . $old_filename . "" - " . _DML_DOCUPDATED);
        }
        ?>

        <?php 
        dmHTML::adminHeading(_DML_UPLOADWIZARD, 'files');
        ?>


        <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
  		<?php 
        if ($show_completion) {
            /* backwards compatible */
            ?>
        <tr>
          <td width="38%" align="center">
          	<div align="right">
          		<img src="<?php 
            echo $mosConfig_live_site;
            ?>
/administrator/components/com_docman/images/dm_upload_48.png" />
          	</div>
          </td>
          <td colspan="2"><div align="left">'<?php 
            echo $file->name;
            ?>
' -<?php 
            echo _DML_FILEUPLOADED;
            ?>
</div></td>
        </tr>
	<tr>
	  <td colspan=2><div align="center"><hr /></td>
	<tr>
	<?php 
        }
        ?>

	<!-- Give them a nice sub menu -->
  	<?php 
        if (!$batch && $old_filename == '1') {
            /* Can't create docs from a batch or existing file */
            ?>
    	<tr>
    		<td>
    		<div align="right">
    			<a href="index2.php?option=com_docman&section=documents&task=new&uploaded_file=<?php 
            echo $file->name;
            ?>
">
    			<img src="<?php 
            echo $mosConfig_live_site;
            ?>
/administrator/images/edit_f2.png" border="0">
    			</a>
    		</div>
    		</td>

    		<td>
    		<div align="left"><?php 
            echo _DML_MAKENEWENTRY;
            ?>
</div>
    		</td>
    	</tr>
    	<?php 
        }
        ?>

    <tr>

	<td>
		<div align="right">
			<a href="index2.php?option=com_docman&section=files&task=upload">
			<img src="<?php 
        echo $mosConfig_live_site;
        ?>
/administrator/images/upload_f2.png" border="0">
			</a>
		</div>
	</td>
	<td><div align="left"><?php 
        echo _DML_UPLOADMORE;
        ?>
</div></td>
	</tr>
	<tr>
		<td>
			<div align="right">
				<a href="index2.php?option=com_docman&section=files">
					<img src="<?php 
        echo $mosConfig_live_site;
        ?>
/administrator/images/next_f2.png" border="0">
				</a>
			</div>
		</td>
		<td>
			<div align="left"><?php 
        echo _DML_DISPLAYFILES;
        ?>
</div>
		</td>
	</tr>
	</table>

	<form action="index2.php" method="post" name="adminForm">
        <input type="hidden" name="option" value="com_docman" />
        <input type="hidden" name="section" value="files" />
        <input type="hidden" name="task" value="" />
        <input type="hidden" name="boxchecked" value="0" />
    </form>
	<?php 
    }
Example #2
0
function uploadWizard($step = 1, $method = 'http', $old_filename)
{
    global $_DOCMAN, $database;
    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':
                    mosRedirect("index2.php?option=com_docman&section=documents&task=new&makelink=1", _DML_CREATEALINK);
                    // HTML_DMFiles::uploadWizard_link();
                    break;
                case 'transfer':
                    HTML_DMFiles::uploadWizard_transfer();
                    break;
                default:
                    mosRedirect("index2.php?option=com_docman&section=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 = mosGetParam(DOCMAN_Utils::stripslashes($_FILES), 'upload');
                    $file_upload = mosGetParam($_FILES, 'upload');
                    $result =& $upload->uploadHTTP($file_upload, $path, _DM_VALIDATE_ADMIN);
                    if (!$result) {
                        mosRedirect("index2.php?option=com_docman&section=files", _DML_ERROR_UPLOADING . " - " . $upload->_err);
                    } else {
                        $batch = mosGetParam($_POST, 'batch', null);
                        if ($batch && $old_filename != null) {
                            require_once "includes/pcl/pclzip.lib.php";
                            if (!extension_loaded('zlib')) {
                                mosRedirect("index2.php?option=com_docman&section=files", _DML_ZLIB_ERROR);
                            }
                            $target_directory = $_DOCMAN->getCfg('dmpath');
                            $zip = new PclZip($target_directory . "/" . $result->name);
                            $file_to_unzip = preg_replace('/(.+)\\..*$/', '$1', $target_directory . "/" . $result->name);
                            if (!$zip->extract($target_directory)) {
                                mosRedirect("index2.php?option=com_docman&section=files", _DML_UNZIP_ERROR);
                            }
                            @unlink($target_directory . "/" . $result->name);
                        }
                        if ($old_filename) {
                            $file = $_DOCMAN->getCfg('dmpath') . "/" . $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);
                        mosRedirect("index2.php?option=com_docman&section=files&task=upload&step=4" . "&result=" . urlencode($result->name) . "&batch=" . (0 + $batch) . "&old_filename=" . $old_filename, _DML_SUCCESS . ' &quot;' . $result->name . '&quot; - ' . _DML_FILEUPLOADED);
                    }
                    break;
                case 'ftp':
                    break;
                case 'link':
                    break;
                case 'transfer':
                    $url = stripslashes(mosGetParam($_POST, 'url', null));
                    $name = stripslashes(mosGetParam($_POST, 'localfile', null));
                    $path = $_DOCMAN->getCfg('dmpath') . "/";
                    $upload = new DOCMAN_FileUpload();
                    $result = $upload->uploadURL($url, $path, _DM_VALIDATE_ADMIN, $name);
                    if ($result) {
                        // HTML_DMFiles::uploadWizard_sucess($result, 0, 1);
                        mosredirect("index2.php?option=com_docman&section=files&task=upload&step=4" . "&result=" . urlencode($result->name) . "&batch=0&old_filename=1", _DML_SUCCESS . ' &quot;' . $result->name . '&quot; - ' . _DML_FILEUPLOADED);
                    } else {
                        mosredirect("index2.php?option=com_docman&section=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(mosGetParam($_REQUEST, 'result', 'INTERNAL ERROR')));
            $batch = mosGetParam($_REQUEST, 'batch', 0);
            $old_filename = mosGetParam($_REQUEST, 'old_filename', null);
            HTML_DMFiles::uploadWizard_sucess($file, $batch, $old_filename, 0);
            break;
    }
    //End switch($step)
}