33 require_once (
'Classes/GetFreshmeatRdf.php');
34 require_once (
'Classes/FreshmeatRdfs.php');
35 require_once (
'Classes/ReadInputFile.php');
54 $usage =
"trac [-h] -i input-file [-o path-to-output] -r path-to-rdf-file\n";
55 $options = getopt(
"hi:o:r:");
63 if (array_key_exists(
"h", $options))
69 if (array_key_exists(
"i", $options))
71 $in_file = $options[
'i'];
74 print
"ERROR, -i is a required parameter\n";
78 if (array_key_exists(
"o", $options))
80 $in_file = $options[
'o'];
87 if (array_key_exists(
"r", $options))
89 $rdf_file = $options[
'r'];
92 print
"ERROR, -r is a required parameter\n";
102 $gRdf->get_rdf($gRdf->rdf_name);
103 if ($gRdf->error_code != 0)
105 print
"ERROR getting the Freshmeat RDF file\n";
106 print
"ERROR code was:$gRdf->error_code\n";
107 print
"command output was:";
108 print_r($gRdf->error_out);
111 $FRdf =
new FreshMeatRdfs($gRdf->rdf_name);
113 if (!$FRdf->Uncompress($gRdf->rdf_name))
115 print
"Could not uncompress the file $gRdf->rdf_name\n";
116 print
"return code from uncompress:$FRdf->error_code\n";
117 print
"Output from uncompress:$FRdf->error_out\n";
120 $FMprojects = $FRdf->XtractProjInfo($FRdf->uncompressed_file);
125 print
"starting read and search\n";
126 while ($line = $INF->GetLine($INF->file_resource))
130 $lc_proj = strtolower($line);
132 $found_it = $FRdf->FindInProjInfo($lc_proj, $FMprojects);
135 if (!is_null($found_it))
138 $found[
"$lc_proj"] = $found_it;
151 print
"DB: Looking for valid download urls\n";
152 $projects = get_proj_url($found);
154 $PF = fopen(
'ol-projects-in-FM',
'w') or die("Can't open file, $php_errormsg\n");
155 foreach($projects as $line)
158 if(fputcsv($PF, $line) ===
false)
160 print
"ERROR: can't write $line\n";
166 $PL = fopen(
'ol-projects-in-FM',
'r') or die("Can't open file, $php_errormsg\n");
167 while ($tokens = fgetcsv($PL, 1024))
169 print
"tokens is:\n";
186 function get_proj_url($pdata)
189 foreach ($pdata as $proj_name=>$aindex)
191 foreach ($aindex as $value)
203 if(preg_match(
'/[0-9.]/', $value))
215 if (preg_match(
'/\/url_zip\/$/', $value))
220 elseif (preg_match(
'/\/url_tgz\/$/', $value))
225 elseif (preg_match(
'/\/url_bz2\/$/', $value))
232 print
"DB:GPU: Testing URL for NULL\n";
235 print
"DB:GPU: Setting URL is NULL\n";
236 $url =
'NO URL FOR THIS PROJECT';
243 $proj_data[0] = $proj_name;
244 $proj_data[1] = $url;
245 $proj_data[2] = $version;
246 $projects[] = $proj_data;