45 require_once (
'Classes/GetFreshmeatRdf.php');
46 require_once (
'Classes/FreshmeatRdfs.php');
47 require_once (
'Classes/ReadInputFile.php');
66 $usage =
"trac [-h] -i input-file [-o path-to-output] -r path-to-rdf-file\n";
67 $options = getopt(
"hi:o:r:");
75 if (array_key_exists(
"h", $options))
81 if (array_key_exists(
"i", $options))
83 $in_file = $options[
'i'];
86 print
"ERROR, -i is a required parameter\n";
90 if (array_key_exists(
"o", $options))
92 $in_file = $options[
'o'];
99 if (array_key_exists(
"r", $options))
101 $rdf_file = $options[
'r'];
104 print
"ERROR, -r is a required parameter\n";
114 $gRdf->get_rdf($gRdf->rdf_name);
115 if ($gRdf->error_code != 0)
117 print
"ERROR getting the Freshmeat RDF file\n";
118 print
"ERROR code was:$gRdf->error_code\n";
119 print
"command output was:";
120 print_r($gRdf->error_out);
123 $FRdf =
new FreshMeatRdfs($gRdf->rdf_name);
125 if (!$FRdf->Uncompress($gRdf->rdf_name))
127 print
"Could not uncompress the file $gRdf->rdf_name\n";
128 print
"return code from uncompress:$FRdf->error_code\n";
129 print
"Output from uncompress:$FRdf->error_out\n";
132 $FMprojects = $FRdf->XtractProjInfo($FRdf->uncompressed_file);
137 print
"starting read and search\n";
138 while ($line = $INF->GetLine($INF->file_resource))
142 $lc_proj = strtolower($line);
144 $found_it = $FRdf->FindInProjInfo($lc_proj, $FMprojects);
147 if (!is_null($found_it))
150 $found[
"$lc_proj"] = $found_it;
163 print
"DB: Looking for valid download urls\n";
164 $projects = get_proj_url($found);
166 $PF = fopen(
'ol-projects-in-FM',
'w') or die("Can't open file, $php_errormsg\n");
167 foreach($projects as $line)
170 if(fputcsv($PF, $line) ===
false)
172 print
"ERROR: can't write $line\n";
178 $PL = fopen(
'ol-projects-in-FM',
'r') or die("Can't open file, $php_errormsg\n");
179 while ($tokens = fgetcsv($PL, 1024))
181 print
"tokens is:\n";
198 function get_proj_url($pdata)
201 foreach ($pdata as $proj_name=>$aindex)
203 foreach ($aindex as $value)
215 if(preg_match(
'/[0-9.]/', $value))
227 if (preg_match(
'/\/url_zip\/$/', $value))
232 elseif (preg_match(
'/\/url_tgz\/$/', $value))
237 elseif (preg_match(
'/\/url_bz2\/$/', $value))
244 print
"DB:GPU: Testing URL for NULL\n";
247 print
"DB:GPU: Setting URL is NULL\n";
248 $url =
'NO URL FOR THIS PROJECT';
255 $proj_data[0] = $proj_name;
256 $proj_data[1] = $url;
257 $proj_data[2] = $version;
258 $projects[] = $proj_data;