<commit_before><?php
/**
 * Export Vault Files
 *
 * @author <NAME> 
 * @version $Id: exportfile.php,v 1.21 2008/05/20 15:26:48 eric Exp $
 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
 * @package FREEDOM
 * @subpackage 
 */
 /**
 */



include_once("FDL/Class.Doc.php");
include_once("FDL/Class.DocAttr.php");
include_once("FDL/Lib.Vault.php");
include_once("VAULT/Class.VaultFile.php");

define("RESIZEDIR",DEFAULT_PUBDIR."/.img-resize/");
// --------------------------------------------------------------------
function exportfile(&$action) {
  $dbaccess = $action->GetParam("FREEDOM_DB");
  $docid = GetHttpVars("docid", GetHttpVars("id",0)); // same docid id
  $attrid = GetHttpVars("attrid",0);
  $vaultid = GetHttpVars("vaultid",0); // only for public file
  $index = GetHttpVars("index");
  //  $imgheight = GetHttpVars("height");
  $imgwidth = GetHttpVars("width");
  $inline = (GetHttpVars("inline")=="yes");
  $cache = (GetHttpVars("cache","yes")=="yes");
  $latest = GetHttpVars("latest");
  $state = GetHttpVars("state"); // search doc in this state
  $type = GetHttpVars("type"); // [pdf|png] 
  $pngwidth = GetHttpVars("width"); // [pdf|png] 
  $pngpage = GetHttpVars("page"); // [pdf|png] 

  $isControled=false;

  if ($vaultid == 0) {

    $doc= new_Doc($dbaccess,$docid);
    if ($state != "") {
      $docid=$doc->getRevisionState($state,true);
      if ($docid==0) {
	$action->exitError(sprintf(_("Document %s in %s state not found"),
				   $doc->title,_($state)));
      } 
      $doc= new_Doc($dbaccess,$docid);
    } else {
      if (($latest == "Y") && ($doc->locked == -1)) {
	// get latest revision
	$docid=$doc->latestId();
	$doc= new_Doc($dbaccess,$docid);
      } 
    }

    // ADD CONTROL ACCESS HERE
    $err = $doc->control("view");
    if ($err != "") $action->exiterror($err);
    $isControled=true;;
    if ($doc->doctype=="C") $ovalue=$doc->getDefValue($attrid);
    else $ovalue = $doc->getValue($attrid);
    if (($index !== "") && ($index >= 0)) {
      $tvalue = explode("\n",$ovalue);
      $ovalue= $tvalue[$index];
    }
    $oa=$doc->getAttribute($attrid);
    if (!$oa) $action->exitError(sprintf(_("attribute %s not found"),$attrid));
    if ($oa->getOption("preventfilechange")=="yes") {
      if (preg_match(PREGEXPFILE, $ovalue, $reg)) {
	$vaultid= $reg[2];
	$mimetype=$reg[1];
	$info=vault_properties($vaultid);
	$othername=vault_uniqname($vaultid);
      }
    }

    if ($ovalue == "") {
      print(sprintf(_("no file referenced for %s document"),$doc->title));
      exit;<commit_msg>file upload in parameters family (refs #1767)<commit_after><?php
/**
 * Export Vault Files
 *
 * @author Anakeen 2000 
 * @version $Id: exportfile.php,v 1.21 2008/05/20 15:26:48 eric Exp $
 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
 * @package FREEDOM
 * @subpackage 
 */
 /**
 */



include_once("FDL/Class.Doc.php");
include_once("FDL/Class.DocAttr.php");
include_once("FDL/Lib.Vault.php");
include_once("VAULT/Class.VaultFile.php");

define("RESIZEDIR",DEFAULT_PUBDIR."/.img-resize/");
// --------------------------------------------------------------------
function exportfile(&$action) {
  $dbaccess = $action->GetParam("FREEDOM_DB");
  $docid = GetHttpVars("docid", GetHttpVars("id",0)); // same docid id
  $attrid = GetHttpVars("attrid",0);
  $vaultid = GetHttpVars("vaultid",0); // only for public file
  $index = GetHttpVars("index");
  //  $imgheight = GetHttpVars("height");
  $imgwidth = GetHttpVars("width");
  $inline = (GetHttpVars("inline")=="yes");
  $cache = (GetHttpVars("cache","yes")=="yes");
  $latest = GetHttpVars("latest");
  $state = GetHttpVars("state"); // search doc in this state
  $type = GetHttpVars("type"); // [pdf|png] 
  $pngwidth = GetHttpVars("width"); // [pdf|png] 
  $pngpage = GetHttpVars("page"); // [pdf|png] 

  $isControled=false;

  if ($vaultid == 0) {

    $doc= new_Doc($dbaccess,$docid);
    if ($state != "") {
      $docid=$doc->getRevisionState($state,true);
      if ($docid==0) {
	$action->exitError(sprintf(_("Document %s in %s state not found"),
				   $doc->title,_($state)));
      } 
      $doc= new_Doc($dbaccess,$docid);
    } else {
      if (($latest == "Y") && ($doc->locked == -1)) {
	// get latest revision
	$docid=$doc->latestId();
	$doc= new_Doc($dbaccess,$docid);
      } 
    }

    // ADD CONTROL ACCESS HERE
    $err = $doc->control("view");
    if ($err != "") $action->exiterror($err);
    $isControled=true;
    if ($doc->doctype=="C") {
        $ovalue=$doc->getParamValue($attrid);
        if (!$ovalue)  $ovalue=$doc->getDefValue($attrid);
    } else $ovalue = $doc->getValue($attrid);
    if (($index !== "") && ($index >= 0)) {
      $tvalue = explode("\n",$ovalue);
      $ovalue= $tvalue[$index];
    }
    $oa=$doc->getAttribute($attrid);
    if (!$oa) $action->exitError(sprintf(_("attribute %s not found"),$attrid));
    if ($oa->getOption("preventfilechange")=="yes") {
      if (preg_match(PREGEXPFILE, $ovalue, $reg)) {
	$vaultid= $reg[2];
	$mimetype=$reg[1];
	$info=vault_properties($vaultid);
	$othername=vault_uniqname($vaultid);
      }
    }

    if ($ovalue == "") {
      print(sprintf(_("no file referenced for %s document"),$doc->title));
      exit;
{'fraction_non_alphanumeric': 0.23848187311178248, 'fraction_numerical': 0.012084592145015106, 'mean_word_length': 3.4252297410192147, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5597235', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1909, 'n_words': 327}