Exemple #1
0
function get_tmp_file($id, $nonewver = "")
{
    global $CONF, $DB, $PAGE_ELEMENT;
    $rs = $DB->Execute("SELECT * FROM document WHERE id={$id}");
    if (!($thisfile = $rs->FetchRow())) {
        return false;
    }
    $PAGE_ELEMENT[PAGE][1][0][param] = $thisfile[ref_prat];
    if ($thisfile[ref_id] == 0) {
        $old_ref = $thisfile[id];
        $old_ver = $thisfile[version];
        $old_note = $thisfile[note];
        $old_desc = $thisfile[descr];
        $ref_orig = $thisfile[version];
        $ref_ext = $thisfile[ext];
    } else {
        $rs2 = $DB->Execute("SELECT * FROM document WHERE id=" . $thisfile[ref_id]);
        $thisfile_base = $rs2->FetchRow();
        $old_ref = $thisfile_base[id];
        $old_ver = $thisfile_base[version];
        $old_note = $thisfile_base[note];
        $old_desc = $thisfile_base[descr];
        $ref_orig = $thisfile[version];
        $ref_ext = $thisfile[ext];
    }
    if ($nonewver != 1) {
        //Insert new document
        $rs_insnew = $DB->Execute("INSERT INTO document SET operatore=" . $_SESSION[fw_userid] . ", descr='" . $old_desc . "', note='" . $old_note . "', version=" . ($old_ver + 1) . ", ref_id=0, ref_orig=" . $ref_orig . ", filename='" . $thisfile[filename] . "', data=NOW(), ref_prat=" . $thisfile[ref_prat] . ", ref_pres=" . $thisfile[ref_pres] . ", ext='" . $ref_ext . "'");
        //REMEMBER Change with adodb syntax
        $ret = mysql_insert_id();
    } else {
        $ret = 0;
    }
    //Update other document and unlock user
    $rs_updold = $DB->Execute("UPDATE document SET ref_id={$ret}, `lock`=0, user_lock=0 WHERE ref_id={$old_ref} OR id={$old_ref}");
    $rs_updusr = $DB->Execute("UPDATE " . $CONF[auth_db_table] . " SET  `lock`=0 WHERE id=" . $thisfile[user_lock]);
    if ($nonewver != 1) {
        $filename = $thisfile[filename] . '-' . $thisfile[id] . '-' . $thisfile[version] . '.' . $thisfile[ext];
        $newfilename = $thisfile[filename] . '-' . $ret . '-' . ($old_ver + 1) . '.' . $thisfile[ext];
    } else {
        $filename = $thisfile[filename] . '-' . $thisfile[id] . '-' . $thisfile[version] . '.' . $thisfile[ext];
        $newfilename = $thisfile[filename] . '-' . $thisfile[id] . '-' . $thisfile[version] . '.' . $thisfile[ext];
    }
    if ($thisfile[ext] == "sxw") {
        if (!file_exists($CONF[path_base] . $CONF[dir_upload] . $filename)) {
            return false;
        }
        copy($CONF[path_base] . $CONF[dir_upload] . $filename, $CONF[path_base] . $CONF[dir_upload] . 'document/' . $newfilename);
        unlink($CONF[path_base] . $CONF[dir_upload] . $filename);
        getTextfromSXW($CONF[path_base] . $CONF[dir_upload] . 'document/' . $newfilename);
    } else {
        if (!file_exists($CONF[path_base] . $CONF[dir_upload] . $filename)) {
            return false;
        }
        copy($_FILES["fileupl"]['tmp_name'], $CONF[path_base] . $CONF[dir_upload] . 'document/' . $newfilename);
        unlink($CONF[path_base] . $CONF[dir_upload] . $filename);
    }
    return $newfilename;
    $_SESSION[user][lock] = 0;
}
Exemple #2
0
#!/usr/bin/php

<?php 
include 'functions.php';
getTextfromSXW('/www/htdocs/cw-portal.com/framework/tmp/document/nuovosistema-123-1.sxw');
$ret = searchDocuments('aliquam');
print_r($ret);
?>