Jump to content

Help


wupchurch

Recommended Posts

Below is the code to my Library.php (currently being hosted off of hitchinghope.com)

 

It is drawing it's data from http://semco-ms.semcoinc.com/News.nsf/library.xml

 

Can anyone tell me how I can Automatically Select "Duct and Acoustical Products" and hide the other option dealing with wheel products.  (I'm testing the new script at of hitchinghope.com/library.php

 

If anyone could help that would be great.

 

To see how this script works in action visit http://www.semcoinc.com/library.php

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="htdig-noindex">
<title>SEMCO Library</title>
<style type="text/css">
@import url(http://www.semcoinc.com/css/website.css);
</style>
<script language="JavaScript" type="text/javascript" src="http://www.semcoinc.com/images/form.js">
</script>
</head>

<?php

if ($HTTP_GET_VARS["seq"]){
$seq = $HTTP_GET_VARS["seq"] + 1;
}else{
$seq = 1;
}

if ($HTTP_POST_VARS["__Click"]){ 
$start = $HTTP_POST_VARS["__Click"];
}else{
$start = 0;
}

if (!($HTTP_POST_VARS["unit"])){
$HTTP_POST_VARS["unit"] = -1;
}

if (!($HTTP_POST_VARS["product"])){
$HTTP_POST_VARS["product"] = -1;
}

if (!($HTTP_POST_VARS["type"])){
$HTTP_POST_VARS["type"] = -1;
}

//echo $HTTP_POST_VARS["unit"]."<br>";
//echo $HTTP_POST_VARS["product"]."<br>";
//echo $HTTP_POST_VARS["type"]."<br>";

$a = $HTTP_POST_VARS["unit"]; //1
$b = $HTTP_POST_VARS["product"]; //1.1.1

$this_pos = strpos($b, $a);

$this_url = $HTTP_SERVER_VARS['PHP_SELF'];
$colspan = 2;

?>

<body>
<iframe id="domino_app" name="domino_app" frameborder="1" scrolling="no" src="" height="75" width="750" style="display: none"></iframe>
<form action="<?php echo $this_url?>?seq=<?php echo $seq;?>" method="post" name="_apache" target="_self" id="_apache">
  <p>
  <input type="hidden" name="__Click" value="0">
  <input type="hidden" name="__Refresh" value="0">
  <table width="425" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan="3"><img src="http://www.semcoinc.com/images/sep.gif" width="10" height="10"></td>
    </tr>
<tr bgcolor="#AAAAAA">
	<td height="1" colspan="3"></td>
    </tr>
    <tr>
	<td colspan="3"><h4 style="margin: 5px 0 5px 10px">SEMCO Library</h4></td>
    </tr>
    <tr bgcolor="#AAAAAA">
	<td height="1" colspan="3"></td> 
    </tr>
    <tr>
      <td colspan="3">
        <table width="425" border="0" cellspacing="0" cellpadding="0" bgcolor="#FAFAFA" style="border: 1px solid #DDDDDD">
          <tr><td style="padding: 5px"><p>Choose the appropriate business unit, product, and category from the options below.</p></td></tr>
	  <tr><td><img src="http://www.semcoinc.com/images/sep.gif" width="10" height="10"></td></tr>	  
	  <tr>
          <td>
		<table>
              <tr>
              <td width="250" valign="top"><p><i>Select Business Unit</i></p>
<?php

$file = "http://semco-ms.semcoinc.com/News.nsf/library.xml";

$elements = $stack = array();
$count = $depth = 0;

class notes_entity{

var $name = NULL;
var $attributes = array();
var $depth = 0;
var $data = NULL;

}

function startElementHandler($parser, $name, $attrib) 
{
global $elements;
global $stack;
global $count;
global $depth;

$id = $count;
$element = new notes_entity;
$elements[$id] = $element;
$elements[$id]->name = $name;

while (list ($key, $value) = each ($attrib))
	$elements[$id]->attributes[$key] = $value;

$elements[$id]->depth = $depth;

array_push($stack, $id);

$count++;
$depth++;

} 

function endElementHandler($parser, $name) 
{
global $stack;
global $depth;

array_pop($stack);

$depth--;
} 

function characterDataHandler($parser, $cdata) 
{
global $elements;
global $stack;

$elements[$stack[count($stack)-1]]->data .= $cdata;
} 

$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($xml_parser, "startElementHandler", "endElementHandler");
xml_set_character_data_handler($xml_parser, "characterDataHandler"); 

if (!($fp = fopen($file, "r"))) {
   die("ERROR: Could not open XML input!");
}

while ($data = fread($fp, 4096)) {
   if (!xml_parse($xml_parser, $data, feof($fp))) {
       die(sprintf("ERROR: XML error: %s at line %d.",
                   xml_error_string(xml_get_error_code($xml_parser)),
                   xml_get_current_line_number($xml_parser)));
   }
}

xml_parser_free($xml_parser);

$i = 0;
$value = 0;

while($elements[$i])
{
while($a = each($elements[$i]->attributes))
{
	if($a["key"] == "POSITION") $value = $a["value"];

	if($a["key"] == "NAME" && $a["value"]== "$1")
	{
		if($value == $HTTP_POST_VARS["unit"]){
			$unit = $elements[$i]->data;
			echo "<input type=\"checkbox\" name=\"unit\" value=\"".$value."\" onclick=\"fnGetUnit(this); _doClick('$Refresh', this, '_self', '#_Refresh_next')\" checked>".$elements[$i]->data.chr(13)."<br>";
			$unit = $elements[$i]->data;
		}else{
			echo "<input type=\"checkbox\" name=\"unit\" value=\"".$value."\" onclick=\"fnGetUnit(this); _doClick('$Refresh', this, '_self', '#_Refresh_next')\">".$elements[$i]->data.chr(13)."<br>";
		}
	}
}
$i++;
}

echo "<p> </p><p>Looking for Press Releases? Click <a href=\"http://www.semcoinc.com/corporate/news/\">here</a>.</p></td>";


if ($HTTP_POST_VARS["unit"] != -1)
{

echo "<td width=\"250\" valign=\"top\"><p><i>Select Product</i></p>";

$colspan++;
$i = 0;
$j = 1;
$value = 0;

while($elements[$i]) 
{

$position = $HTTP_POST_VARS["unit"].".".$j;

if (isset($elements[$i]->attributes["POSITION"]) && $elements[$i]->attributes["POSITION"] == $position){

	if(!strcmp($position,$HTTP_POST_VARS["product"]))
	{
		echo "<input type=\"checkbox\" name=\"product\" value=\"".$position."\" onclick=\"fnGetProduct(this); _doClick('\$Refresh', this, '_self', '#_Refresh_next')\" checked>".$elements[$i]->data.chr(13)."<br>";
		$product = $elements[$i]->data;
	}else{
		echo "<input type=\"checkbox\" name=\"product\" value=\"".$position."\" onclick=\"fnGetProduct(this); _doClick('\$Refresh', this, '_self', '#_Refresh_next')\">".$elements[$i]->data.chr(13)."<br>";		
	}

	$j++;

}

$i++;
}

echo "</td>";

}

if ($HTTP_POST_VARS["product"] != -1 && $this_pos === 0)
{

echo "<td width=\"160\" valign=\"top\"><p><i>Select Category</i></p>";

$colspan++;
$i = 0;
$j = 1;
$value = 0;

while($elements[$i])
{

$position = $HTTP_POST_VARS["product"].".".$j;

if (isset($elements[$i]->attributes["POSITION"]) && $elements[$i]->attributes["POSITION"] == $position){

	if ($position == $HTTP_POST_VARS["type"]){
		echo "<input type=\"checkbox\" name=\"type\" value=\"".$position."\" onclick=\"fnGetType(this); _doClick('\$Refresh', this, '_self', '#_Refresh_next')\" checked>".$elements[$i]->data.chr(13)."<br>";
		$category = $elements[$i]->data;
	}else{
		echo "<input type=\"checkbox\" name=\"type\" value=\"".$position."\" onclick=\"fnGetType(this); _doClick('\$Refresh', this, '_self', '#_Refresh_next')\">".$elements[$i]->data.chr(13)."<br>";

	}

	$j++;

}

$i++;
}

echo "</td>";

}

?>

</tr>
</table>
</td>
</tr>
<tr><td><img src="http://www.semcoinc.com/images/sep.gif" width="10" height="10"></td></tr> 
<tr><td> <a href="http://www.hichinghope.com/DWP/library.php" style="font-size: 7pt; color: #AAAAAA">RESET</a></td></tr>
</table>

<?php

if ($HTTP_POST_VARS["product"] != -1 && $this_pos === 0)
{

if ($HTTP_POST_VARS["type"] != -1)
{

?>

<img src="http://www.semcoinc.com/images/sep.gif" width="10" height="10">
<table width="425" border="0" cellspacing="0" cellpadding="0" style="border: 1px dashed #AAAAAA">
<tr valign="top">
<td colspan="5"><p style="margin: 5px"><strong>Results:</strong> <?php echo $unit;?> > <?php echo $product;?> > <?php echo $category;?></p></td>
</tr>
<tr valign="middle">
<td width="250" style="border: 1px dashed #AAAAAA">  Title</td>
<td width="75" style="border: 1px dashed #AAAAAA">  Date</td>
<td width="75" style="border: 1px dashed #AAAAAA">  File Size</td>
<td width="75" style="border: 1px dashed #AAAAAA">  File Type</td>
</tr>


<?php

}

$i=0;
$k=0;

while($elements[$i])
{

if (isset($elements[$i]->attributes["POSITION"]) && $elements[$i]->attributes["POSITION"] == $HTTP_POST_VARS["product"])
	$product = $elements[$i]->data;

if (isset($elements[$i]->attributes["POSITION"]) && $elements[$i]->attributes["POSITION"] == $HTTP_POST_VARS["type"])
	$category = $elements[$i]->data;

if (isset($elements[$i]->attributes["PARENT"]) && $elements[$i]->attributes["PARENT"] == $HTTP_POST_VARS["type"]){

	$article_product = $product;
	$article_category = $category;

	$i++;
	$article_name = $elements[$i]->data;

	$i++;
	$sdate = strtotime($elements[$i]->data);
	$article_date = date("m/d/y",$sdate);
	$i++;
	$article_size = $elements[$i]->data;
	$i++;
	$article_type = $elements[$i]->data;
	$i++;
	$description = $elements[$i]->data;
	$i++;
	$article_url = $elements[$i]->data;
	$i++;
	$article_id = $elements[$i]->data;

	$article_title = "<a href=\"http://".$article_url."\" target=\"_blank\" onclick=\"register('".$article_id ."');\">".$article_name."</a>";

	if (strcmp(trim($article_type),"PDF") == 0)
	$link = "<a href=\"http://".$article_url."\" target=\"_blank\" onclick=\"register('".$article_id ."');\"><img src=\"/images/icons/pdf.gif\" border=\"0\" align=\"middle\" alt=\"PDF\" /></a>";

	if (strcmp(trim($article_type),"DOC") == 0)
	$link = "<a href=\"http://".$article_url."\" target=\"_blank\" onclick=\"register('".$article_id ."');\"><img src=\"/images/icons/doc.gif\" border=\"0\" align=\"middle\" alt=\"DOC\" /></a>";

	if (strcmp(trim($article_type),"EXE") == 0)
	$link = "<a href=\"http://".$article_url."\" target=\"_blank\" onclick=\"register('".$article_id ."');\"><img src=\"/images/icons/exe.gif\" border=\"0\" align=\"middle\" alt=\"EXE\" /></a>";

	if (strcmp(trim($article_type),"ZIP") == 0)
	$link = "<a href=\"http://".$article_url."\" target=\"_blank\" onclick=\"register('".$article_id ."');\"><img src=\"/images/icons/zip.gif\" border=\"0\" align=\"middle\" alt=\"ZIP\" /></a>";

	if($k++ % 2){

		echo "<tr bgcolor=\"#FAFAFA\"><td colspan=\"4\"><img src=\"http://www.semcoinc.com/images/sep.gif\" width=\"3\" height=\"5\"></td></tr>";
		echo "<tr bgcolor=\"#FAFAFA\">";
		echo "<td align=\"left\">  ".$article_title."</td>";
		echo "<td>  ".$article_date."</td>";
		echo "<td>  ".$article_size."</td>";
		echo "<td>  ".$link."</td></tr>";
		echo "<tr bgcolor=\"#FAFAFA\"><td width=\"620\" colspan=\"4\" valign=\"top\" style=\"padding: 10px 0 10px 10px\">".$description."</td></tr>";
		echo "<tr bgcolor=\"#FAFAFA\"><td colspan=\"4\"><img src=\"http://www.semcoinc.com/images/sep.gif\" width=\"3\" height=\"5\"></td></tr>";

	}else{

		echo "<tr><td colspan=\"4\"><img src=\"http://www.semocinc.com/images/sep.gif\" width=\"3\" height=\"5\"></td></tr>";
		echo "<tr>";
		echo "<td align=\"left\">  ".$article_title."</td>";
		echo "<td>  ".$article_date."</td>";
		echo "<td>  ".$article_size."</td>";
		echo "<td>  ".$link."</td></tr>";
		echo "<tr><td width=\"620\" colspan=\"4\" valign=\"top\" style=\"padding: 10px 0 10px 10px\">".$description."</td></tr>";
		echo "<tr><td colspan=\"4\"><img src=\"/images/sep.gif\" width=\"3\" height=\"5\"></td></tr>";

	}
}

$i++;

}

if ($HTTP_POST_VARS["type"] != -1)
{
echo "</table>";
}

}

?>
</form>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> 
</script> 
<script type="text/javascript"> 
_uacct = "UA-2008618-1"; 
urchinTracker(); 
</script>
</body>
</html>

 

EDITED BY WILDTEEN88: Please use code tags (


) when posting code

Link to comment
https://forums.phpfreaks.com/topic/59656-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.