Important alert: (current site time 7/15/2013 10:47:14 AM EDT)
 

VB icon

A PAD File Parser

Email
Submitted on: 12/21/2001 3:27:43 AM
By: Thorsten Sanders 
Level: Intermediate
User Rating: By 2 Users
Compatibility: PHP 4.0
Views: 9264
(About the author)
 
     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!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// 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
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=493&lngWId=8//for details.//**************************************

<?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

7/10/2003 5:55:07 AMNeosis

Execellent, thanks. One small problem though, I can't seem to retrieve the long 2000 character description. It only gives me the short one... I'll figure it out.
(If this comment was disrespectful, please report it.)

 

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.