39 require_once(
"FIXMETOBERELATIVE/pathinclude.php");
40 require_once(
"$LIBDIR/lib_projxml.h.php");
46 Where: -h optional help, displays
this message
47 <in-file> path to an uncompressed Freshmeat rdf XML file
48 <out-file> path to filename where the xml output will be generated.
49 -n nnn optional parameter to indicate how many projects to
54 The projects are always extracted in priority order.
55 For example, -n 10 will
get the top 10 Freshmeat packages.
56 A range of numbers is not supported.
66 $HowMany_projects = 1000;
68 for ($i = 1; $i < $argc; $i++) {
72 if (isset($argv[$i])) {
76 die(
"ERROR: Must specify an uncompressed filename after -i");
85 if (isset($argv[$i])) {
86 $HowMany_projects = (int) $argv[$i];
89 die(
"ERROR: Must specify a number between 1-1000 after -n");
94 if (isset($argv[$i])) {
95 $out_file = $argv[$i];
98 die(
"ERROR: Must specify an uncompressed filename after -o");
102 die(
"ERROR: Unknown argument: $argv[$i]\n$usage");
107 $F1 = fopen(
"$in_file",
'r') or die("can't open file: $php_errormsg\n");
118 $Output = fopen("$out_file", 'w') or die("Can' open: $php_errormsg\n");
120 echo "Extracting the top $HowMany_projects projects from:\n$in_file\n";
121 echo "\nWriting the top $HowMany_projects projects to: $out_file\n";
126 while(false != ($line = fgets($F1, 1024))) {
127 # echo "Line is:\n$line\n"; 129 if (preg_match(
'/<project>/', $line)) {
130 $proj_mark = ftell($F1);
132 elseif (preg_match(
'/<popularity_rank>[0-9].*</', $line)) {
133 $pos = strpos($line,
'>');
134 $rank_pos = $pos + 1;
135 $rank_end = strpos($line,
'</', $rank_pos);
136 $rank_len = $rank_end - $rank_pos;
137 $rank = substr($line, $rank_pos, $rank_len);
138 if ((
int)$rank <= $HowMany_projects){
140 write_entry($F1, $proj_mark, $Output);
char A[MAXCMD]
input for this system
Usage()
Print Usage statement.