34 $res = $a[
'copyright_count'] - $b[
'copyright_count'];
46 $res = $a[
'copyright_count'] - $b[
'copyright_count'];
58 return (strnatcasecmp($rowa[
'content'], $rowb[
'content']));
69 return -(strnatcasecmp($rowa[
'content'], $rowb[
'content']));
80 return (strnatcasecmp($rowa[
'ufile_name'], $rowb[
'ufile_name']));
100 $PkgsOnly=
false, $offset=0, $limit=
"ALL",
106 $sql =
"SELECT lft, rgt, upload_fk FROM uploadtree 107 WHERE uploadtree_pk = $uploadtree_pk";
108 $result = pg_query($PG_CONN, $sql);
110 $row = pg_fetch_assoc($result);
113 $upload_pk = $row[
"upload_fk"];
114 pg_free_result($result);
116 $sql =
"select distinct uploadtree_pk, pfile_fk, ufile_name 118 (SELECT pfile_fk as PF, uploadtree_pk, ufile_name from uploadtree 119 where upload_fk=$upload_pk 120 and uploadtree.lft BETWEEN $lft and $rgt) as SS 121 where PF=pfile_fk and agent_fk=$agent_pk 122 and hash='$hash' and type='$type' 123 group by uploadtree_pk, pfile_fk, ufile_name 124 $order limit $limit offset $offset";
125 $result = pg_query($PG_CONN, $sql);
146 $PkgsOnly=
false, $CheckOnly=
false)
151 $sql =
"SELECT lft, rgt, upload_fk FROM uploadtree 152 WHERE uploadtree_pk = $uploadtree_pk";
153 $result = pg_query($PG_CONN, $sql);
155 $row = pg_fetch_assoc($result);
158 $upload_pk = $row[
"upload_fk"];
159 pg_free_result($result);
161 $chkonly = ($CheckOnly) ?
" LIMIT 1" :
"";
163 $sql =
"SELECT count(DISTINCT pfile_fk) as unique from copyright, 164 (SELECT pfile_fk as PF from uploadtree 165 where upload_fk=$upload_pk and uploadtree.lft BETWEEN $lft and $rgt) as SS 166 where PF=pfile_fk and agent_fk=$agent_pk and hash='$hash' and type='$type' 169 $result = pg_query($PG_CONN, $sql);
172 $row = pg_fetch_assoc($result);
173 $FileCount = $row[
'unique'];
174 pg_free_result($result);
214 $OriginalContent = $row[
'content'];
217 $content = preg_replace(
'/[\x0-\x1f]/',
' ', $OriginalContent);
219 if ($row[
'type'] ==
'statement')
222 $content = preg_replace(
'/([\x21-\x27])|([*@])/',
' ', $content);
225 $content = preg_replace(
'/(([0-9]+)-([0-9]+))|([0-9]{2,})|(,)/',
' ', $content);
226 $content = preg_replace(
'/ : /',
' ', $content);
229 if ($row[
'type'] ==
'email')
231 $content = str_replace(
":;<=>()",
" ", $content);
235 $content = preg_replace(
'/\s\s+/',
' ', $content);
238 $content =
trim($content,
"\t \n\r<>./\"\'");
241 if ((strlen($content) > 4) &&
242 (substr_compare($content,
"dnl ", 0, 4,
true) == 0)) {
243 $content = substr($content, 4);
247 if (empty($content)) {
return true;
258 $row[
'content'] = $content;
259 $row[
'copyright_count'] = 1;
260 $row[
'hash'] = md5($row[
'content']);
261 if ($hash && ($row[
'hash'] != $hash)) {
return true;
StmtReorder($content)
rearrange copyright statment to try and put the holder first, followed by the rest of the statement...
hist_rowcmp($rowa, $rowb)
Sort query histogram results (by content), ascend.
hist_rowcmp_count_asc($a, $b)
Sort query histogram results (by content), ascend.
copyright_namecmp($rowa, $rowb)
Sort rows by filename.
GetFilesWithCopyright($agent_pk, $hash, $type, $uploadtree_pk, $PkgsOnly=false, $offset=0, $limit="ALL", $order="")
get files with a given copyright.
hist_rowcmp_desc($rowa, $rowb)
Sort query histogram results (by content), descend.
MassageContent(&$row, $hash)
Input row array contains: pfile, content and type.
hist_rowcmp_count_desc($a, $b)
Sort query histogram results (by content), descend.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
CountFilesWithCopyright($agent_pk, $hash, $type, $uploadtree_pk, $PkgsOnly=false, $CheckOnly=false)
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
char * trim(char *ptext)
Trimming whitespace.