46 function write_entry($in_handle, $marker, $out_handle){
50 $start = fseek($in_handle, $marker);
51 fwrite($out_handle,
" <project>\n");
52 while(
false != ($line = fgets($in_handle, 1024))){
54 if (preg_match(
'|</project>|', $line)){
55 fwrite($out_handle, $line);
58 fwrite($out_handle, $line);
77 function get_entry($in_handle, $marker){
83 $start = fseek($in_handle, $marker);
84 $project[] =
" <project>\n";
85 while(
false != ($line = fgets($in_handle, 1024))){
87 if (preg_match(
'|</project>|', $line)){
88 array_push(&$project, $line);
91 array_push(&$project, $line);
106 function close_tag($handle){
108 $tag =
"</project-listing>\n";
109 fwrite($handle, $tag);
123 function parse_fm_input($fm_string){
125 (
'/([\'|\"])+?/', $fm_string);
129 $acnt = count($parms);
130 for ($ai=0; $ai<=$acnt; $ai++){
131 $len = strlen($parms[$ai]);
136 elseif (!(isset($parms[$ai]))){
140 elseif ((isset($parms[$ai]))){
141 if(ereg(
'^ +', $parms[$ai])){
148 $lparms = array_values($parms);
169 function pdbg($message, $dump=
''){
171 $dbg_msg =
'DBG->' . $message .
"\n";
195 function write_hdr($handle){
198 <?xml version=
"1.0" encoding=
"ISO-8859-1"?>
199 <!DOCTYPE project-listing SYSTEM
"http://freshmeat.net/backend/fm-projects-0.4.dtd">
204 fwrite($handle, $xml_hdr);
221 function write_pxml($file_handle, $pxml){
223 for ($i=0; $i < count($pxml); $i++){
224 fwrite($file_handle, $pxml[$i]);
241 function save_Yupdated($file_handle, $Updata){
243 fwrite($file_handle, $Updata);
260 function xtract($string){
262 $pos = strpos($string,
'>');
263 $val_start = $pos + 1;
264 $val_end = strpos($string,
'</', $val_start);
265 if(!(is_numeric($val_end))){
268 $val_len = $val_end - $val_start;
269 $value = substr($string, $val_start, $val_len);
288 function read_pfile($xml_file) {
299 $meatdoc= simplexml_load_file(
"$xml_file");
300 # echo "read_pfile: Read XML file\n"; 302 foreach ($meatdoc->project as $project) {
303 $fmprojs[
"$project->popularity_rank"] [
"$project->projectname_short"] =
304 array (
"$project->url_tgz",
307 "$project->url_homepage",
308 "$project->desc_short" 310 foreach($project->latest_release as $verdata){
312 &$fmprojs[
"$project->popularity_rank"] [
"$project->projectname_short"],
313 $verdata->latest_release_version,
314 $verdata->latest_release_id,
315 $verdata->latest_release_date