示例#1
0
 /**
  *	create - use this function to create a new entry in the database.
  *
  *	@param	string	The filename of this document. Can be a URL.
  *	@param	string	The filetype of this document. If filename is URL, this should be 'URL';
  *	@param	string	The contents of this document (should be addslashes()'d before entry).
  *	@param	int	The doc_group id of the doc_groups table.
  *	@param	string	The title of this document.
  *	@param	int	The language id of the supported_languages table.
  *	@param	string	The description of this document.
  *	@return	boolean	success.
  */
 function create($filename, $filetype, $data, $doc_group, $title, $language_id, $description)
 {
     if (strlen($title) < 5) {
         $this->setError(_('Title Must Be At Least 5 Characters'));
         return false;
     }
     if (strlen($description) < 10) {
         $this->setError(_('Document Description Must Be At Least 10 Characters'));
         return false;
     }
     /*
     		$perm =& $this->Group->getPermission( session_get_user() );
     		if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
     			$this->setPermissionDeniedError();
     			return false;
     		}
     */
     $user_id = session_loggedin() ? user_getid() : 100;
     $doc_initstatus = '3';
     // If Editor - uploaded Documents are ACTIVE
     if (session_loggedin()) {
         $perm =& $this->Group->getPermission(session_get_user());
         if ($perm && is_object($perm) && $perm->isDocEditor()) {
             $doc_initstatus = '1';
         }
     }
     // If $filetype is "text/plain", $body convert UTF-8 encoding.
     if (strcasecmp($filetype, "text/plain") === 0 && function_exists('mb_convert_encoding') && function_exists('mb_detect_encoding')) {
         $data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data));
     }
     $data1 = $data;
     // key words for in-document search
     $kw = new Parsedata($this->engine_path);
     $kwords = $kw->get_parse_data(stripslashes($data1), htmlspecialchars($title1), htmlspecialchars($description), $filetype);
     // $kwords = "";
     $filesize = strlen($data);
     $sql = "INSERT INTO doc_data (group_id,title,description,createdate,doc_group,\n\t\t\tstateid,language_id,filename,filetype,filesize,data,data_words,created_by)\n\t\t\tVALUES ('" . $this->Group->getId() . "',\n\t\t\t'" . htmlspecialchars($title) . "',\n\t\t\t'" . htmlspecialchars($description) . "',\n\t\t\t'" . time() . "',\n\t\t\t'{$doc_group}',\n\t\t\t'{$doc_initstatus}',\n\t\t\t'{$language_id}',\n\t\t\t'{$filename}',\n\t\t\t'{$filetype}',\n\t\t\t'{$filesize}',\n\t\t\t'" . base64_encode(stripslashes($data)) . "',\n\t\t\t'{$kwords}',\n\t\t\t'{$user_id}')";
     db_begin();
     $result = db_query($sql);
     if (!$result) {
         $this->setError('Error Adding Document: ' . db_error());
         db_rollback();
         return false;
     }
     $docid = db_insertid($result, 'doc_data', 'docid');
     if (!$this->fetchData($docid)) {
         db_rollback();
         return false;
     }
     $this->sendNotice(true);
     db_commit();
     return true;
 }
示例#2
0
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with FusionForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
require_once $gfwww . 'include/pre.php';
require_once $gfwww . 'docman/include/doc_utils.php';
require_once $gfcommon . 'docman/Parsedata.class.php';
require_once $gfcommon . 'docman/Document.class.php';
require_once $gfcommon . 'docman/DocumentFactory.class.php';
require_once $gfcommon . 'docman/DocumentGroupFactory.class.php';
$p = new Parsedata("{$sys_engine_path}");
// print_debug(print_r($p->get_parser_list (),true));
$timestarttrait = microtime_float();
// documents list
$sql = "SELECT docid, group_id, filename, title, createdate, filename, description, filetype, data FROM doc_data \n";
$resarr = array();
$result = db_query($sql);
if ($result) {
    while ($arr = db_fetch_array($result)) {
        $resarr[] = $arr;
    }
}
$compt = 0;
$rapp = "";
foreach ($resarr as $item) {
    $compt++;