23 return $a[
'copyright_count'] - $b[
'copyright_count'];
34 $res = $a[
'copyright_count'] - $b[
'copyright_count'];
46 return (strnatcasecmp($rowa[
'content'], $rowb[
'content']));
57 return -(strnatcasecmp($rowa[
'content'], $rowb[
'content']));
68 return (strnatcasecmp($rowa[
'ufile_name'], $rowb[
'ufile_name']));
88 $PkgsOnly=
false, $offset=0, $limit=
"ALL",
94 $sql =
"SELECT lft, rgt, upload_fk FROM uploadtree
95 WHERE uploadtree_pk = $uploadtree_pk";
98 $row = pg_fetch_assoc($result);
101 $upload_pk = $row[
"upload_fk"];
102 pg_free_result($result);
104 $sql =
"select distinct uploadtree_pk, pfile_fk, ufile_name
106 (SELECT pfile_fk as PF, uploadtree_pk, ufile_name from uploadtree
107 where upload_fk=$upload_pk
108 and uploadtree.lft BETWEEN $lft and $rgt) as SS
109 where PF=pfile_fk and agent_fk=$agent_pk
110 and hash='$hash' and type='$type'
111 group by uploadtree_pk, pfile_fk, ufile_name
112 $order limit $limit offset $offset";
134 $PkgsOnly=
false, $CheckOnly=
false)
139 $sql =
"SELECT lft, rgt, upload_fk FROM uploadtree
140 WHERE uploadtree_pk = $uploadtree_pk";
143 $row = pg_fetch_assoc($result);
146 $upload_pk = $row[
"upload_fk"];
147 pg_free_result($result);
149 $chkonly = ($CheckOnly) ?
" LIMIT 1" :
"";
151 $sql =
"SELECT count(DISTINCT pfile_fk) as unique from copyright,
152 (SELECT pfile_fk as PF from uploadtree
153 where upload_fk=$upload_pk and uploadtree.lft BETWEEN $lft and $rgt) as SS
154 where PF=pfile_fk and agent_fk=$agent_pk and hash='$hash' and type='$type'
160 $row = pg_fetch_assoc($result);
161 $FileCount = $row[
'unique'];
162 pg_free_result($result);
202 $OriginalContent = $row[
'content'];
205 $content = preg_replace(
'/[\x0-\x1f]/',
' ', $OriginalContent);
207 if ($row[
'type'] ==
'statement') {
209 $content = preg_replace(
'/([\x21-\x27])|([*@])/',
' ', $content);
212 $content = preg_replace(
'/(([0-9]+)-([0-9]+))|([0-9]{2,})|(,)/',
' ', $content);
213 $content = preg_replace(
'/ : /',
' ', $content);
214 } elseif ($row[
'type'] ==
'email') {
215 $content = str_replace(
":;<=>()",
" ", $content);
219 $content = preg_replace(
'/\s\s+/',
' ', $content);
222 $content =
trim($content,
"\t \n\r<>./\"\'");
225 if ((strlen($content) > 4) &&
226 (substr_compare($content,
"dnl ", 0, 4,
true) == 0)) {
227 $content = substr($content, 4);
231 if (empty($content)) {
243 $row[
'content'] = $content;
244 $row[
'copyright_count'] = 1;
245 $row[
'hash'] = md5($row[
'content']);
246 if ($hash && ($row[
'hash'] != $hash)) {
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
char * trim(char *ptext)
Trimming whitespace.
copyright_namecmp($rowa, $rowb)
Sort rows by filename.
hist_rowcmp_count_asc($a, $b)
Sort query histogram results (by content), ascend.
MassageContent(&$row, $hash)
Input row array contains: pfile, content and type.
hist_rowcmp_desc($rowa, $rowb)
Sort query histogram results (by content), descend.
StmtReorder($content)
rearrange copyright statment to try and put the holder first, followed by the rest of the statement.
GetFilesWithCopyright($agent_pk, $hash, $type, $uploadtree_pk, $PkgsOnly=false, $offset=0, $limit="ALL", $order="")
get files with a given copyright.
hist_rowcmp($rowa, $rowb)
Sort query histogram results (by content), ascend.
hist_rowcmp_count_desc($a, $b)
Sort query histogram results (by content), descend.
CountFilesWithCopyright($agent_pk, $hash, $type, $uploadtree_pk, $PkgsOnly=false, $CheckOnly=false)
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN