All pastes #550198 Raw Edit

checkadd.php

public text v1 · immutable
·published 2007-06-08 10:51 UTC
rendered paste body
<?php include("dict.php"); ?>
<?php

  // added in v2.00.03 (OG)
  function _GetParam($Name, $Default = "") {
    if ( isset($_GET[$Name]) )
      return $_GET[$Name];
    else if ( isset($_POST[$Name]) )
      return $_POST[$Name];
    else
      return $Default;
  }
  $padurl = _GetParam("padurl");

  $errmsg ="";

  if (substr(strtolower($padurl),0,7) <> "http://") {
    $errmsg = "<b>Error:</b> PAD URL must begin with http://<br>Press the Back button.<br>";
  }
  elseif (strtolower($padurl) == "http://") {
    $errmsg = "<b>Error:</b> No PAD URL submitted. Press the Back button.<br>";
  }
  else {
    if (!$data = @file($padurl)) {
      $errmsg = "Error opening $padurl . Press back button and check URL";
    }
    else {
      //$data = implode(" ",$data);
      //$data = substr($data, strpos($data,"<?xml"));  // remove any http headers

      //$tag = array("<XML_DIZ_INFO><ASP><ASP_MEMBER_NUMBER>");

      //$category = substr($tagarray["$tag"],0,50);
      $padary = file($padurl);
      $catinpad = "";
      $inpadurl = ""; // added in v2.00.01 (DV)

      // modified in v2.00.04 (OG) BEGIN
      for ($i=1; $i<count($padary); $i++) {
        // the category in PAD file 
        if (strlen(stristr($padary[$i], "<Program_Category_Class>"))>5) { // changed in v2.00.01 (DV)
          $tmp = explode(">", $padary[$i]);   
          $tmp = explode("<", $tmp[1]);    
          $catinpad = $tmp[0];             
        }
        // the PAD URL in PAD file 
        if (strlen(stristr($padary[$i], "<APPLICATION_XML_FILE_URL>"))>1) { // added in v2.00.01 (DV)
          $tmp = explode(">", $padary[$i]);   
          $tmp = explode("<", $tmp[1]);    
          $inpadurl = $tmp[0];             
        }
      }  
	  // modified in v2.00.04 (OG) END
    }

    if($errmsg=="") {
      // scan and build the entry form
      $catary = file($catfile);

      $lastmajor = "xxnone";
      $catenter = "";
      $usecatinpad = 0;

      for ($i=0; $i<count($catary); $i++) {
       $cdisp = rtrim($catary[$i]);
       $cmach = rawurlencode($cdisp);
       $cdisp2 = explode("::", $cdisp);
       $cmach2 = explode("%3A%3A", $cmach);

       $majorcat = $cdisp2[0];
       $fullcat  = $cmach2[0] . "::" . $cmach2[1];
       $pu=urlencode($padurl); // added in v1.50.03 (DV)
       $cl=$cmach2[0] . "%3A%3A" . $cmach2[1]; // added in v2.00.01 (DV)
       $cl=htmlspecialchars($cl); // added in v2.00.01 (DV)
       $fulllink = "<a class=catminor href=addpad.php?padurl=$pu&padcat=$cl>" . $cdisp2[1] ."</a>"; // changed in v1.50.03 (DV)

       if ($cmach2[0] != $lastmajor) { //new major category?
	  $catenter .= "<p> <font class=catmajor>" . $majorcat . "</font>\n, <br>\n" . $fulllink;
        $lastmajor = $cmach2[0];
       } else {
          $catenter .= ", <br>\n" . $fulllink;
       }
       $fullcat=urldecode($fullcat); // added in v2.00.01 (DV)
       $fullcat=htmlspecialchars($fullcat); // added in v2.00.01 (DV)
       if ($catinpad == $fullcat) {
        $usecatinpad = 1;
        break;
       }
      }

      $catenter .= "<br>&nbsp;</td>\n";
      $category=urlencode($catinpad); // added in v2.00.01 (DV)

      if(strcasecmp($inpadurl,htmlspecialchars($padurl))<>0) { // added in v2.00.01 (DV)
        $errmsg = "<b>Error:</b> submitted url ($padurl) does not match url inside PAD file ($inpadurl). Click back button and correct the URL";
      }
      else {
        if ($usecatinpad == 1) {
          $showarg = "padurl=" . $padurl . "&padcat=" . $category;
          header ("Location: $myurlprefix/addpad.php?$showarg\n\n");
          exit;
        } else {
          $errmsg  = "Could not find a category in your PAD file matching those used on this site. ";
          $errmsg .= "Please click on a category below to select closest match.";
          $errmsg .= $catenter;
        }
      }
    }

   }
echo
"
<html>
<head>
<title>PAD Submit Checking</title>
<link rel=stylesheet type=text/css href='styles.css'>
</head>
<body>
"
?>
<?php include("header.php");  ?>
<?php echo"$errmsg"; ?>
<?php include("footer.php") ?>
<?php echo"</body></html>" ?>