home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / bb98.exe / SOaccess.php < prev    next >
PHP Script  |  2002-06-25  |  3KB  |  102 lines

  1. <?php if (!defined("SOaccess")) { define("SOaccess", 1);
  2.  
  3. include("SOhttp.php");
  4.  
  5. //    Retrieve Access table or query fields over specified row numbers.
  6. //    Inputs:
  7. //        $sAddr: address of BadBlue server (e.g., "127.0.0.1:8080")
  8. //        $sPath: path of shared file in EXT.INI file (e.g., "path11")
  9. //        $sFile: name of Access MDB file to examine (e.g., "mlb2000.mdb")
  10. //        $sTable: name of table (or query) to retrieve
  11. //        $aData: associative/indexed array that is returned with data
  12. //        $nRowStart: numeric zero-based row to start retrieving
  13. //        $nRows: number of rows to retrieve
  14. //        $sUser: (optional) user-name to get access to file
  15. //        $sPassword: (optional) password to get access to file
  16. //    Outputs:
  17. //        $errmsg: empty if no error occurred, otherwise error message
  18. //
  19. function SOAccess($sAddr, $sPath, $sFile, $sTable, &$aData,
  20.                  $nRowStart, $nRows, $sUser = "", $sPassword = "") {
  21.     $aData = array();
  22.     $errmsg = "";
  23.     do {
  24.  
  25.         //    Construct URL and grab page...
  26.         //
  27.         $sURL = "http://".$sAddr."/ext.dll?MfcISAPICommand=LoadPage&".
  28.                 "page=mdb.htx&a0=/get/".$sPath."/".rawurlencode(trim($sFile)).
  29.                 "&a1=".rawurlencode(trim($sTable))."&a2=V&a3=&a4=".
  30.                 $nRowStart."&a8=".$nRows."&a9=";
  31.         $errmsg = SOHTTPGet($sURL, &$sPage, $sUser, $sPassword);
  32.         if (strlen($errmsg)) {
  33.             break;
  34.         }
  35.         $aColumns = array();
  36.         // echo($sPage);
  37.  
  38.         //    Rip through first row of matrix to grab column labels.
  39.         //
  40.         for ($i = 0; $i < 255; $i++) {
  41.             $sTemp = "<td class=fXH align=center>";
  42.             $nCursor = strpos($sPage, $sTemp);
  43.             if ($nCursor === false) {
  44.                 break;
  45.             }
  46.             $nCursor += strlen($sTemp);
  47.             $sColumn = substr($sPage, $nCursor, 255);
  48.             if (($nCursor2 = strpos($sColumn, '<')) > 0) {
  49.                 $sColumn = substr($sColumn, 0, $nCursor2);
  50.             }
  51.             $aColumns[$i] = strtolower($sColumn);
  52.             $sPage = substr($sPage, $nCursor + 2);
  53.         }
  54.         if (strlen($errmsg)) {
  55.             break;
  56.         }
  57.         if (!sizeof($aColumns)) {
  58.             $errmsg = "Invalid template file (1)";
  59.             break;
  60.         }
  61.         // echo("Columns (".sizeof($aColumns).")=".implode(", ", $aColumns)."<BR>");
  62.  
  63.         //    Rip through multiple rows of data...
  64.         //
  65.         for ($i = 0; $i < $nRows; $i++) {
  66.             for ($j = 0; $j < sizeof($aColumns); $j++) {
  67.                 $sTemp = "<td class=fXL";
  68.                 $nCursor = strpos($sPage, $sTemp);
  69.                 if ($nCursor === false) {
  70.                     if (!$i) {
  71.                         $errmsg = "No more data found";
  72.                     }
  73.                     break;
  74.                 }
  75.                 $nCursor += strlen($sTemp);
  76.                 $nCursor = strpos($sPage, ">", $nCursor);
  77.                 if ($nCursor === false) {
  78.                     $errmsg = "Invalid template file (3)";
  79.                     break;
  80.                 }
  81.                 $nCursor++;
  82.                 //
  83.                 $sVal = substr($sPage, $nCursor, 255);
  84.                 if (($nCursor2 = strpos($sVal, '<')) > 0) {
  85.                     $sVal = substr($sVal, 0, $nCursor2);
  86.                 }
  87.                 //
  88.                 $sPage = substr($sPage, $nCursor + $nCursor2);
  89.                 $aData[$nY + $i][$aColumns[$j]] = $sVal;
  90.                 // echo("Val: ".($nY + $i).$aColumns[$j]."= ".$sVal."<BR>");
  91.             }
  92.             if (strlen($errmsg)) {
  93.                 break;
  94.             }
  95.         }
  96.  
  97.     } while (0);
  98.     return ($errmsg);
  99. }
  100.  
  101. } ?>
  102.