28 require_once(
"FIXMETOBERELATIVE/pathinclude.php");
29 require_once(
"$LIBDIR/lib_projxml.h.php");
35 Where: -h optional help, displays
this message
36 <in-file> path to an uncompressed Freshmeat rdf XML file
37 <out-file> path to filename where the xml output will be generated.
38 -n nnn optional parameter to indicate how many projects to
43 The projects are always extracted in priority order.
44 For example, -n 10 will
get the top 10 Freshmeat packages.
45 A range of numbers is not supported.
55 $HowMany_projects = 1000;
57 for ($i = 1; $i < $argc; $i++) {
61 if (isset($argv[$i])) {
65 die(
"ERROR: Must specify an uncompressed filename after -i");
74 if (isset($argv[$i])) {
75 $HowMany_projects = (int) $argv[$i];
78 die(
"ERROR: Must specify a number between 1-1000 after -n");
83 if (isset($argv[$i])) {
84 $out_file = $argv[$i];
87 die(
"ERROR: Must specify an uncompressed filename after -o");
91 die(
"ERROR: Unknown argument: $argv[$i]\n$usage");
96 $F1 = fopen(
"$in_file",
'r') or die("can't open file: $php_errormsg\n");
107 $Output = fopen("$out_file", 'w') or die("Can' open: $php_errormsg\n");
109 echo "Extracting the top $HowMany_projects projects from:\n$in_file\n";
110 echo "\nWriting the top $HowMany_projects projects to: $out_file\n";
115 while(false != ($line = fgets($F1, 1024))) {
116 # echo "Line is:\n$line\n";
118 if (preg_match(
'/<project>/', $line)) {
119 $proj_mark = ftell($F1);
121 elseif (preg_match(
'/<popularity_rank>[0-9].*</', $line)) {
122 $pos = strpos($line,
'>');
123 $rank_pos = $pos + 1;
124 $rank_end = strpos($line,
'</', $rank_pos);
125 $rank_len = $rank_end - $rank_pos;
126 $rank = substr($line, $rank_pos, $rank_len);
127 if ((
int)$rank <= $HowMany_projects){
129 write_entry($F1, $proj_mark, $Output);
char A[MAXCMD]
input for this system
Usage()
Print Usage statement.