VB icon

A PAD File Parser

Email
Submitted on: 1/1/2015 8:13:00 AM
By: Thorsten Sanders (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: PHP 4.0
Views: 1785
 
     The script parse an PAD File, and give out the information that you need from it. For all who dont know PAD, it is a standard for Softwareauthors to easily submit there Software Information to software archives.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: A PAD File Parser
// Description:The script parse an PAD File, and give out the information that you need from it. For all who dont know PAD, it is a standard for Softwareauthors to easily submit there Software Information to software archives.
// By: Thorsten Sanders (from psc cd)
//**************************************

<?php
/*
 This is a simple Demo, on how to parse an PAD File,
 and get the Infos you need. When you use this function
 for your own script, leave credits in it for me.
 This Code is written by Thorsten Sanders from
 http://www.php-coding.org
 To test it, just start the script with,
 http://yourdomain.com/parser.php?file=http://www.padfile.com/pad.xml
 for example, you can read local files as well
*/
if ($file==""){
 print "You must enter the URL of the PAD File!";
 die;
}
if(!stristr($file,".xml")){
Print "That file is not an PAD File!";
die;
}
fopen($file,"r") or die("PAD File not found!");
function kriegen($suchwort1,$suchwort2){
global $file;
$fp=fopen($file,"r");
$gefunden=0;
while (!feof($fp)) {
 $buffer = fgets($fp, 4096);
if(@stristr($buffer,"<$suchwort1>")){
$gefunden=1;
 }
 if ($gefunden==1){
if(@stristr($buffer,"<$suchwort2>")){
 $ausgabe = trim(strip_tags($buffer));
 return $ausgabe;
 break;
 }
}
}
fclose($fp);
}
$progname = kriegen("Program_Info","Program_Name");
$downloadurl = kriegen("Download_URLs","Primary_Download_URL");
$progver = kriegen("Program_Info","Program_Version");
$dateigroesse = kriegen("File_Info","File_Size_K");
$hpurl = kriegen("Company_Info","Company_WebSite_URL");
$beschreibung = kriegen("German","Char_Desc_450");
if ($beschreibung == ""){
 $beschreibung = kriegen("German","Char_Desc_250");
if ($beschreibung == ""){
 $beschreibung = kriegen("German","Char_Desc_80");
if ($beschreibung == ""){
 $beschreibung = kriegen("German","Char_Desc_40");
if ($beschreibung == ""){
 $beschreibung = kriegen("German","Char_Desc_2000");
}}}}
if ($beschreibung == ""){
 $beschreibung = kriegen("English","Char_Desc_450");
if ($beschreibung == ""){
 $beschreibung = kriegen("English","Char_Desc_250");
if ($beschreibung == ""){
 $beschreibung = kriegen("English","Char_Desc_80");
if ($beschreibung == ""){
 $beschreibung = kriegen("English","Char_Desc_40");
if ($beschreibung == ""){
 $beschreibung = kriegen("English","Char_Desc_2000");
}}}}}
$progstatus = kriegen("Program_Info","Program_Type");
$progsprache = kriegen("Program_Info","Program_Language");
if ($progsprache == "German"){
 $progsprache = "d";
}elseif($progsprache == "English"){
 $progsprache = "e";
}elseif($progsprache == "English,German" or $progsprache == "German,English"){
 $progsprache = "b";
}else{$progsprache = "";}
$progpreis = kriegen("Program_Info","Program_Cost_Other");
if ($progpreis == ""){
 $progpreis = kriegen("Program_Info","Program_Cost_Dollars"). " $";
}
$email = kriegen("Contact_Info","Author_Email");
if ($email == ""){
 $email = kriegen("Contact_Info","Contact_Email");
}
//Sollten alle variablen leer sein, wird das Script abgebrochen
if ($progname and $downloadurl and $progver and $dateigroesse and $hpurl and $beschreibung and $progstatus and $progsprache and $progpreis and $email == ""){
print "Error";
die;
}
print $progname;
print "<br>";
print $progver;
print "<br>";
print $progstatus;
print "<br>";
print $progpreis;
print "<br>";
print $beschreibung;
print "<br>";
print $progsprache;
print "<br>";
print $dateigroesse;
print "<br>";
print $downloadurl;
print "<br>";
print $hpurl;
print "<br>";
print $email;
?>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.