function fetchMethodForm($uid, $step, $update = false)
 {
     global $task;
     switch ($step) {
         case 2:
             $lists = array();
             $lists['action'] = _taskLink($task, $uid, array('step' => $step + 1), false);
             return HTML_DMUploadMethod::linkFileForm($lists);
             break;
         case 3:
             $url = stripslashes(JRequest::getString('url', 'http://'));
             $err = DMUploadMethod::linkFileProcess($uid, $step, $url);
             if ($err['_error']) {
                 _returnTo($task, $err['_errmsg'], '', array("method" => 'link', "step" => $step - 1, "localfile" => '', "url" => DOCMAN_Utils::safeEncodeURL($url)));
             }
             $uploaded = DOCMAN_Utils::safeEncodeURL(_DM_DOCUMENT_LINK . $url);
             $catid = $update ? 0 : $uid;
             $docid = $update ? $uid : 0;
             $session = JFactory::getSession();
             $session->set('docman.dmfilename', _DM_DOCUMENT_LINK);
             $session->set('docman.document_url', $url);
             return fetchEditDocumentForm($docid, $uploaded, $catid);
             break;
         default:
             break;
     }
     return true;
 }
 function fetchMethodForm($uid, $step, $update)
 {
     global $task;
     switch ($step) {
         case 2:
             $lists = array();
             $lists['action'] = _taskLink($task, $uid, array('step' => $step + 1), false);
             return HTML_DMUploadMethod::uploadFileForm($lists);
             break;
         case 3:
             //upload file
             $file = JRequest::getVar('upload', array(), 'files', 'array');
             $err = DMUploadMethod::uploadFileProcess($uid, $step, $file);
             if ($err['_error']) {
                 _returnTo($task, $err['_errmsg'], '', array('step' => $step - 1, 'method' => 'http'));
             }
             $catid = $update ? 0 : $uid;
             $docid = $update ? $uid : 0;
             $session = JFactory::getSession();
             $session->set('docman.dmfilename', $file->name);
             $session->set('docman.document_url', null);
             return fetchEditDocumentForm($docid, $file->name, $catid);
             break;
         default:
             break;
     }
     return true;
 }
示例#3
0
 function fetchMethodForm($uid, $step, $update)
 {
     global $task;
     switch ($step) {
         case 2:
             $lists = array();
             $lists['action'] = _taskLink($task, $uid, array('step' => $step + 1), false);
             return HTML_DMUploadMethod::uploadFileForm($lists);
             break;
         case 3:
             //upload file
             //$file = mosGetParam(DOCMAN_Utils::stripslashes($_FILES), 'upload');
             $file_upload = mosGetParam($_FILES, 'upload');
             $err = DMUploadMethod::uploadFileProcess($uid, $step, $file);
             if ($err['_error']) {
                 _returnTo($task, $err['_errmsg'], '', array('step' => $step - 1, 'method' => 'http'));
             }
             $catid = $update ? 0 : $uid;
             $docid = $update ? $uid : 0;
             return fetchEditDocumentForm($docid, $file->name, $catid);
             break;
         default:
             break;
     }
     return true;
 }
 function fetchMethodForm($uid, $step, $update = false)
 {
     global $task;
     switch ($step) {
         case 2:
             $lists = array();
             $lists['action'] = _taskLink($task, $uid, array('step' => $step + 1), false);
             $lists['url'] = '';
             $lists['localfile'] = '';
             return HTML_DMUploadMethod::transferFileForm($lists);
             break;
         case 3:
             $url = stripslashes(mosGetParam($_REQUEST, 'url', 'http://'));
             $file = stripslashes(mosGetParam($_REQUEST, 'localfile', ''));
             $err = DMUploadMethod::transferFileProcess($uid, $step, $url, $file);
             if ($err['_error']) {
                 _returnTo($task, $err['_errmsg'], '', array("method" => 'transfer', "step" => $step - 1, "localfile" => $file, "url" => DOCMAN_Utils::safeEncodeURL($url)));
             }
             $catid = $update ? 0 : $uid;
             $docid = $update ? $uid : 0;
             return fetchEditDocumentForm($docid, $file->name, $catid);
             break;
         default:
             break;
     }
     return true;
 }
示例#5
0
function fetchMethodForm($uid, $step, $method, $update)
{
    global $_DOCMAN, $task;
    $method_file = $_DOCMAN->getPath('includes_f', 'upload.' . $method);
    if (!file_exists($method_file)) {
        _returnTo($task, "Protocol " . $method . " not supported", '', array('step' => 1));
    }
    require_once $method_file;
    return DMUploadMethod::fetchMethodForm($uid, $step, $update);
}
示例#6
0
function fetchCategory($id)
{
    global $_DMUSER;
    $cat = new DOCMAN_Category($id);
    // if the user is not authorized to access this category, redirect
    if (!$_DMUSER->canAccessCategory($cat->getDBObject())) {
        _returnTo('', _DML_NOT_AUTHORIZED);
    }
    // process content mambots
    DOCMAN_Utils::processContentBots($cat, 'description');
    return HTML_DMCategories::displayCategory($cat->getLinkObject(), $cat->getPathObject(), $cat->getDataObject());
}
示例#7
0
function getSearchResult($gid, $itemid)
{
    global $search_mode, $ordering, $invert_search, $reverse_order, $search_where, $search_phrase, $search_catid;
    $search_mode = ($invert_search ? '-' : '') . $search_mode;
    $searchList = array(array('search_mode' => $search_mode, 'search_phrase' => $search_phrase));
    $ordering = ($reverse_order ? '-' : '') . $ordering;
    $rows = DOCMAN_Docs::search($searchList, $ordering, $search_catid, '', $search_where);
    // This acts as the search header - so they can perform search again
    if (count($rows) == 0) {
        $msg = _DML_NOKEYWORD;
    } else {
        $msg = sprintf(_DML_SEARCH . ' ' . _DML_SEARCH_MATCHES, count($rows));
    }
    $items = array();
    if (count($rows) > 0) {
        foreach ($rows as $row) {
            // onFetchDocument event, type = list
            $bot = new DOCMAN_mambot('onFetchDocument');
            $bot->setParm('id', $row->id);
            $bot->copyParm('type', 'list');
            $bot->trigger();
            if ($bot->getError()) {
                _returnTo('cat_view', $bot->getErrorMsg());
            }
            // load doc
            $doc =& DOCMAN_Document::getInstance($row->id);
            // process content mambots
            DOCMAN_Utils::processContentBots($doc, 'dmdescription');
            $item = new StdClass();
            $item->buttons =& $doc->getLinkObject();
            $item->paths =& $doc->getPathObject();
            $item->data =& $doc->getDataObject();
            $item->data->category = $row->section;
            $items[] = $item;
        }
    }
    return $items;
}
示例#8
0
 function _format(&$objDBDoc)
 {
     global $_DOCMAN;
     require_once $_DOCMAN->getPath('classes', 'file');
     require_once $_DOCMAN->getPath('classes', 'params');
     require_once $_DOCMAN->getPath('classes', 'mambots');
     $file = new DOCMAN_file($objDBDoc->dmfilename, $_DOCMAN->getCfg('dmpath'));
     $params = new dmParameters($objDBDoc->attribs, '', 'params');
     // format document data
     $this->objFormatData = DOCMAN_Utils::get_object_vars($objDBDoc);
     $this->objFormatData->owner = $this->_formatUserName($objDBDoc->dmowner);
     $this->objFormatData->submited_by = $this->_formatUserName($objDBDoc->dmsubmitedby);
     $this->objFormatData->maintainedby = $this->_formatUserName($objDBDoc->dmmantainedby);
     $this->objFormatData->lastupdatedby = $this->_formatUserName($objDBDoc->dmlastupdateby);
     $this->objFormatData->checkedoutby = $this->_formatUserName($objDBDoc->checked_out);
     $this->objFormatData->filename = $this->_formatFilename($objDBDoc);
     $this->objFormatData->filesize = $file->getSize();
     $this->objFormatData->filetype = $file->ext;
     $this->objFormatData->mime = $file->mime;
     $this->objFormatData->hot = $this->_formatHot($objDBDoc);
     $this->objFormatData->new = $this->_formatNew($objDBDoc);
     $this->objFormatData->state = $this->objFormatData->new . ' ' . $this->objFormatData->hot;
     //for backwards compat with 1.3
     $this->objFormatData->params = $params;
     $this->objFormatData->dmdescription = $objDBDoc->dmdescription;
     $this->objFormatData->permalink = JRoute::_($this->_formatLink('doc_details'));
     // onFetchButtons event
     // plugins should always return an array of Button objects
     $bot = new DOCMAN_mambot('onFetchButtons');
     $bot->setParm('doc', $this);
     $bot->setParm('file', $file);
     $bot->trigger();
     if ($bot->getError()) {
         _returnTo('cat_view', $bot->getErrorMsg());
     }
     $buttons = array();
     foreach ($bot->getReturn() as $return) {
         if (!is_array($return)) {
             $return = array($return);
         }
         $buttons = array_merge($buttons, $return);
     }
     $this->objFormatLink =& $buttons;
     // format document paths
     $this->objFormatPath->icon = DOCMAN_Utils::pathIcon($file->ext . ".png", 1);
     $this->objFormatPath->thumb = DOCMAN_Utils::pathThumb($objDBDoc->dmthumbnail, 1);
 }
示例#9
0
function deleteDocument($uid)
{
    DOCMAN_token::check() or die('Invalid Token');
    global $database, $_DMUSER;
    $doc = new mosDMDocument($database);
    $doc->load($uid);
    //check user permissions
    $err = $_DMUSER->canPreformTask($doc, 'Delete');
    if ($err) {
        _returnTo('cat_view', $err, $doc->catid);
    }
    //delete the docmument
    $doc->remove(array($uid));
    _returnTo('cat_view', _DML_DOCDELETED, $doc->catid);
}
示例#10
0
function download(&$doc, $inline = false)
{
    global $database, $mosConfig_live_site, $mosConfig_absolute_path, $mosConfig_offset;
    global $_DOCMAN, $_DMUSER;
    // global $HTTP_USER_AGENT;
    require_once $_DOCMAN->getPath('classes', 'file');
    $data =& $doc->getDataObject();
    /* ------------------------------ *
     *   CORE AUTHORIZATIONS          *
     * ------------------------------ */
    // if the user is not authorized to download this document, redirect
    if (!$_DMUSER->canDownload($doc->getDBObject())) {
        _returnTo('cat_view', _DML_NOLOG_DOWNLOAD, $data->catid);
    }
    // If the document is not approved, redirect
    if (!$data->approved and !$_DMUSER->canApprove()) {
        _returnTo('cat_view', _DML_NOAPPROVED_DOWNLOAD, $data->catid);
    }
    // If the document is not published, redirect
    if (!$data->published and !$_DMUSER->canPublish()) {
        _returnTo('cat_view', _DML_NOPUBLISHED_DOWNLOAD, $data->catid);
    }
    // if the document is checked out, redirect
    if ($data->checked_out && $_DMUSER->userid != $data->checked_out) {
        _returnTo('cat_view', _DML_NOTDOWN, $data->catid);
    }
    // If the remote host is not allowed, show anti-leech message and die.
    if (!DOCMAN_Utils::checkDomainAuthorization()) {
        $from_url = parse_url($_SERVER['HTTP_REFERER']);
        $from_host = trim($from_url['host']);
        _returnTo('cat_view', _DML_ANTILEECH_ACTIVE . " (" . $from_host . ")", $data->catid);
        exit;
    }
    /* ------------------------------ *
     *   GET FILE 					  *
     * ------------------------------ */
    $file = new DOCMAN_File($data->dmfilename, $_DOCMAN->getCfg('dmpath'));
    // If the file doesn't exist, redirect
    if (!$file->exists()) {
        _returnTo('cat_view', _DML_FILE_UNAVAILABLE, $data->catid);
    }
    /* ------------------------------ *
     *   MAMBOT - Setup All Mambots   *
     * ------------------------------ */
    $doc_dbo = $doc->getDBObject();
    //Fix for PHP 5
    $logbot = new DOCMAN_mambot('onLog');
    $prebot = new DOCMAN_mambot('onBeforeDownload');
    $postbot = new DOCMAN_mambot('onAfterDownload');
    $logbot->setParm('document', $doc_dbo);
    $logbot->setParm('file', $file);
    $logbot->setParm('user', $_DMUSER);
    $logbot->copyParm('process', 'download');
    $prebot->setParmArray($logbot->getParm());
    // Copy the parms over
    $postbot->setParmArray($logbot->getParm());
    /* ------------------------------ *
     *   MAMBOT - PREDOWNLOAD         *
     * ------------------------------ */
    $prebot->trigger();
    if ($prebot->getError()) {
        $logbot->copyParm('msg', $prebot->getErrorMsg());
        $logbot->copyParm('status', 'LOG_ERROR');
        $logbot->trigger();
        _returnTo('cat_view', $prebot->getErrorMsg());
    }
    // let's increment the counter
    $dbobject = $doc->getDBObject();
    $dbobject->incrementCounter();
    // place an entry in the log
    if ($_DOCMAN->getCfg('log')) {
        require_once $_DOCMAN->getPath('classes', 'jbrowser');
        $browser =& JBrowser::getInstance($_SERVER['HTTP_USER_AGENT']);
        $now = date("Y-m-d H:i:s", time("Y-m-d g:i:s") + $mosConfig_offset * 60 * 60);
        $remote_ip = $_SERVER['REMOTE_ADDR'];
        $row_log = new mosDMLog($database);
        $row_log->log_docid = $data->id;
        $row_log->log_ip = $remote_ip;
        $row_log->log_datetime = $now;
        $row_log->log_user = $_DMUSER->userid;
        $row_log->log_browser = $browser->getBrowser();
        $row_log->log_os = $browser->getPlatform();
        if (!$row_log->store()) {
            exit;
        }
    }
    $logbot->copyParm(array('msg' => 'Download Complete', 'status' => 'LOG_OK'));
    $logbot->trigger();
    $file->download($inline);
    /* ------------------------------ *
     *   MAMBOT - PostDownload        *
     * Currently - we die and no out  *
     * ------------------------------ */
    $postbot->trigger();
    /* if( $postbot->getError() ){
     *		$logbot->copyParm( array(	'msg'	=> $postbot->getErrorMsg() ,
     *			 			  			'status'=> 'LOG_ERROR'
     *								)
     *						);
     *		$logbot->trigger();
     *		_returnTo('cat_view',$postbot->getErrorMsg() );
     *}
     */
    die;
    // REQUIRED
}