Exemple #1
0
function combineXML($dir, $id)
{
    $dir .= DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'vqmod' . DIRECTORY_SEPARATOR . 'xml';
    $files = is_dir($dir) ? glob($dir . DIRECTORY_SEPARATOR . '*.xml', GLOB_BRACE) : array();
    if (empty($files)) {
        return;
    }
    $modification = <<<XML
<modification>
\t<id>{$id}</id>
\t<version>2.1.0.2</version>
\t<vqmver>2.4.1</vqmver>
\t<author></author>
</modification>
XML;
    $xml = new DOMDocument('1.0', 'UTF-8');
    $xml->formatOutput = true;
    $xml->preserveWhiteSpace = true;
    $xml->loadXml($modification);
    $modification = $xml->getElementsByTagName('modification')->item(0);
    $author = $modification->getElementsByTagName('author')->item(0);
    foreach ($files as $file) {
        $dom = parseXML($file);
        $fileTags = $dom->getElementsByTagName('modification')->item(0)->getElementsByTagName('file');
        $originAutor = $dom->getElementsByTagName('modification')->item(0)->getElementsByTagName('author');
        $author->textContent = $originAutor->item(0)->textContent;
        for ($i = 0; $i < $fileTags->length; $i++) {
            $fileTag = $fileTags->item($i);
            $fileTag = $xml->importNode($fileTag, true);
            $modification->appendChild($fileTag);
        }
        unlink($file);
    }
    $xml->save($dir . DIRECTORY_SEPARATOR . $id . '.xml');
}
Exemple #2
0
function readConfig($filename)
{
    // read the xml database of aminoacids
    $data = implode("", file($filename));
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $data, $values, $tags);
    xml_parser_free($parser);
    // loop through the structures
    foreach ($tags as $key => $val) {
        if ($key == "node") {
            $noderanges = $val;
            // each contiguous pair of array entries are the
            // lower and upper range for each node definition
            for ($i = 0; $i < count($noderanges); $i += 2) {
                $offset = $noderanges[$i] + 1;
                $len = $noderanges[$i + 1] - $offset;
                $tdb[] = parseXML(array_slice($values, $offset, $len));
            }
        } else {
            continue;
        }
    }
    return $tdb;
}
function import()
{
    global $complete;
    parseXML("sampletr.xml");
    foreach ($complete["JOURNAL"] as $jobjs) {
        // go through each journal
        foreach ($jobjs as $journal) {
            $parms = $journal->cols;
            if ($parms["debitacc"] != "0") {
                $debitacc = clsIncludes::$accounts[$parms["debitacc"]];
            }
            if ($parms["creditacc"] != "0") {
                $creditacc = clsIncludes::$accounts[$parms["creditacc"]];
            }
            switch ($journal->type) {
                case "DEBTOR":
                    $debtor = $complete["DEBTOR"][$parms["iid"]]->cols;
                    break;
                case "CREDITOR":
                    $creditor = $complete["CREDITOR"][$parms["iid"]]->cols;
                    break;
                case "STOCK":
                    $stock = $complete["STOCK"][$parms["iid"]]->cols;
                    break;
                case "JOURNAL":
                    break;
            }
        }
    }
}
$showsToGetFile = 'feeds.txt';
$lastDownloadFile = 'lastDownload.txt';
$downloadLocation = '/Users/ericboehs/Downloads/';
if (file_exists($lastDownloadFile)) {
    $lastDownloadFileContents = file($lastDownloadFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
//Get the Last Downloaded season/episode into an array
if (file_exists($showsToGetFile)) {
    $showsToGetFileContents = file($showsToGetFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
} else {
    die("Failed to open: {$showsToGetFile}.  File doesn't exists.  Please put at least one rss feed in it and try again.");
}
foreach ($lastDownloadFileContents as $lastDownloadThisFeed) {
    //Loop through the last files downloaded for each feed and seperate the season and episode into an array
    $lastDownloadThisFeedArray[] = explode(" ", $lastDownloadThisFeed);
}
foreach ($showsToGetFileContents as $feed => $feedURL) {
    //Loop through each feed and check/update each feed
    $lastDownloadFileThisFeed = checkForUpdate(parseXML(fetchURLContents($feedURL), $lastDownloadThisFeedArray[$feed][0], $lastDownloadThisFeedArray[$feed][1]), $downloadLocation);
    if (!$lastDownloadFileThisFeed) {
        $lastDownloadFileContentsNew .= $lastDownloadFileContents[$feed] . "\n";
    } else {
        if (trim($lastDownloadFileContents[$feed]) == "") {
            $lastDownloadFileContentsNew .= $lastDownloadFileThisFeed['season'] . " " . $lastDownloadFileThisFeed['episode'] . "\n";
        } else {
            $lastDownloadFileContentsNew .= $lastDownloadFileThisFeed['season'] . " " . $lastDownloadFileThisFeed['episode'] . "\n";
        }
    }
}
file_put_contents($lastDownloadFile, $lastDownloadFileContentsNew);
//Update the lastDownload.txt file with the latest season/episode that you just downloaded.
    ?>
 /><i class="glyphicon glyphicon-book" style="padding:1px; margin:1px;color:#8b7765" dir="ltr"></i></span> 
</center>
</div>
<?php 
    $q = "SELECT * FROM `classic_words` where TRIM(word)='" . addslashes($word) . "' or TRIM(word)='" . addslashes($word) . "\n'";
    $res = $con->query($q);
    $morph = array("", "");
    if ($row = $res->fetch_array()) {
        if ($row['morph'] == "Not Found") {
            $morph = array('', '');
        } else {
            if ($row['morph'] == "") {
                $morph = updateTable($row['word']);
            } else {
                $morph = parseXML($row['morph']);
            }
        }
    } else {
        // try to get it from Buck Walter
        $morph = getMorph($row['word']);
    }
    ?>
<br/><br /> <span class="subtitle">Word Stem:<span> <br /> 
<?php 
    echo '<input class="form-control stem" type="text" dir="rtl" id="stem' . $block . '" value="' . $info['stem'] . '" >';
    if ($morph[0] != '') {
        echo $morph[0];
    } else {
        echo '<div class="alert alert-danger" role="alert">Not Found</div>';
    }
function startElement($parser, $name, $attrs)
{
    global $currentdir, $files, $paths, $rankcounts, $status, $pre;
    switch ($name) {
        case "subcollection":
            $pre++;
            $olddir = $currentdir;
            $path = "{$currentdir}/{$attrs['path']}";
            if (!is_file($path)) {
                if (is_dir("{$path}")) {
                    $path .= "/index.xrai";
                }
            }
            if (!is_file($path)) {
                die("Can't find subcollection with path {$path} (search for {$path}{.xrai,index,})\n");
            }
            $currentdir = dirname($path);
            print "Parsing {$path}\n";
            $name = get_name("{$olddir}/{$attrs['path']}");
            array_push($files, array("id" => getFileId($name), "title" => "", "path" => $name, "type" => "xrai", "pre" => $pre));
            parse($path);
            $currentdir = $olddir;
            $status = 1;
            break;
        case "document":
            $pre++;
            $path = "{$currentdir}/{$attrs['path']}.xml";
            print "Parsing {$path}\n";
            array_push($rankcounts, array());
            array_push($paths, "");
            $name = get_name("{$path}");
            array_push($files, array("id" => getFileId($name), "title" => "", "path" => $name, "type" => "xml", "pre" => $pre));
            parseXML($path);
            array_pop($rankcounts);
            array_pop($paths);
            $status = 1;
            break;
        default:
            $status = 0;
    }
}
Exemple #7
0
          <li><a href="index.html">Home</a></li>
          <li class="selected"><a href="Assignment0.php">Assignment0</a></li>
          <li><a href="Assignment1.php">Assignment1</a></li>
          <li><a href="Assignment2.php">Assignment2</a></li>
          <li><a href="FinalP.php">Final Project</a></li>
		  <li><a href="comments.php">Comments</a></li>
        </ul>
      </div>
    </div>
    <div id="site_content">
      <div id="content">
        <!-- insert the page content here -->
        <?php 
echo "<h1><b>Projects</b></h1>";
include 'ParseLog.php';
parseXML();
printInfo("teapot");
//Print files info
echo "<h1><b>Files</b></h1>";
include 'ParseList.php';
parseListXML();
printFileInfo("teapot");
?>
      
      </div>
    </div>
    <div id="footer">
    </div>
  </div>
</body>
</html>
function getMorph($word)
{
    global $con, $textId;
    $url = "http://services.perseids.org/bsp/morphologyservice/analysis/word?engine=aramorph&lang=ara&word=";
    $xml = file_get_contents($url . $word);
    // check oac:body
    $pos = strpos($xml, 'oac:Body');
    $query = "";
    if ($pos === false) {
        $query = "insert into classic_words values ('','" . addslashes($word) . "',0,'Not Found','')";
        $con->query($query);
        return array('', '');
    } else {
        $query = "insert into classic_words values ('','" . addslashes($word) . "',0,'" . addslashes($xml) . "','')";
        $con->query($query);
        return parseXML($xml);
    }
}
function do_trans($_POST)
{
    extract($_POST);
    global $complete;
    #use the perm file we saved in the previous function ...
    $filename_path = $filename_path . "1";
    #now parse it into $complete
    parseXML($filename_path);
    db_connect();
    //print "<pre>";
    //var_dump($complete);
    //print "</pre>";
    pglib_transaction("BEGIN") or errDie("Unable to start transaction.");
    if (isset($complete["DEBTOR"]) and is_array($complete["DEBTOR"])) {
        foreach ($complete["DEBTOR"] as $jobjs) {
            $parms = $jobjs->cols;
            $debtor = $complete["DEBTOR"][$parms["iid"]]->cols;
            if (!isset($debtadd[$parms["accno"]]) or strlen($debtadd[$parms["accno"]]) < 1) {
                continue;
            }
            #this debtor is checked for adding ... so add it
            $ins_sql = "\n\t\t\t\tINSERT INTO customers (\n\t\t\t\t\taccno,surname,title,init,category,class,paddr1,addr1,contname,bustel,tel,cellno,fax,email,saleterm,traddisc,setdisc,pricelist,chrgint,overdue,chrgvat,credterm,odate,credlimit,blocked,deptid,vatnum,div,url,ddiv,intrate,balance,day30,day60,day90,day120,classname,catname,deptname,fbalance,fcid,location,currency,lead_source,comments,del_addr1,sales_rep,bankname,branname,brancode,bankaccno,bankaccname,team_id,registration,bankacctype\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$parms['accno']}','{$parms['surname']}','{$parms['title']}','{$parms['init']}','{$parms['category']}','{$parms['class']}','{$parms['paddr1']}','{$parms['addr1']}','{$parms['contname']}','{$parms['bustel']}','{$parms['tel']}','{$parms['cellno']}','{$parms['fax']}','{$parms['email']}','{$parms['saleterm']}','{$parms['traddisc']}','{$parms['setdisc']}','{$parms['pricelist']}','{$parms['chrgint']}','{$parms['overdue']}','{$parms['chrgvat']}','{$parms['credterm']}','{$parms['odate']}','{$parms['credlimit']}','{$parms['blocked']}','{$parms['deptid']}','{$parms['vatnum']}','{$parms['div']}','{$parms['url']}','{$parms['ddiv']}','{$parms['intrate']}','{$parms['balance']}','{$parms['day30']}','{$parms['day60']}','{$parms['day90']}','{$parms['day120']}','{$parms['classname']}','{$parms['catname']}','{$parms['deptname']}','{$parms['fbalance']}','{$parms['fcid']}','{$parms['location']}','{$parms['currency']}','{$parms['lead_source']}','{$parms['comments']}','{$parms['del_addr1']}','{$parms['sales_rep']}','{$parms['bankname']}','{$parms['branname']}','{$parms['brancode']}','{$parms['bankaccno']}','{$parms['bankaccname']}','{$parms['team_id']}','{$parms['registration']}','{$parms['bankacctype']}'\n\t\t\t\t)";
            $run_ins = db_exec($ins_sql) or errDie("Unable to add debtor information.");
        }
    }
    if (isset($complete["CREDITOR"]) and is_array($complete["CREDITOR"])) {
        foreach ($complete["CREDITOR"] as $jobjs) {
            $parms = $jobjs->cols;
            $creditor = $complete["CREDITOR"][$parms["iid"]]->cols;
            if (!isset($suppadd[$parms["supno"]]) or strlen($suppadd[$parms["supno"]]) < 1) {
                continue;
            }
            #this creditor is checked for adding ... so add it
            $ins_sql = "\n\t\t\t\tINSERT INTO suppliers (\n\t\t\t\t\tsupno,supname,supaddr,contname,tel,fax,email,bankname,branname,brancode,bankaccno,deptid,vatnum,div,url,ddiv,balance,listid,fbalance,fcid,location,currency,lead_source,comments,branch,groupid,reference,bee_status,team_id,registration,bankaccname,bankacctype\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$parms['supno']}','{$parms['supname']}','{$parms['supaddr']}','{$parms['contname']}','{$parms['tel']}','{$parms['fax']}','{$parms['email']}','{$parms['bankname']}','{$parms['branname']}','{$parms['brancode']}','{$parms['bankaccno']}','{$parms['deptid']}','{$parms['vatnum']}','{$parms['div']}','{$parms['url']}','{$parms['ddiv']}','{$parms['balance']}','{$parms['listid']}','{$parms['fbalance']}','{$parms['fcid']}','{$parms['location']}','{$parms['currency']}','{$parms['lead_source']}','{$parms['comments']}','{$parms['branch']}','{$parms['groupid']}','{$parms['reference']}','{$parms['bee_status']}','{$parms['team_id']}','{$parms['registration']}','{$parms['bankaccname']}','{$parms['bankacctype']}'\n\t\t\t\t)";
            $run_ins = db_exec($ins_sql) or errDie("Unable to add supplier information.");
        }
    }
    $sdate = date("Y-m-d");
    if (isset($complete["JOURNAL"]) and is_array($complete["JOURNAL"])) {
        foreach ($complete["JOURNAL"] as $jobjs) {
            $parms = $jobjs->cols;
            $doid = $jobjs->id;
            #check if we should run this transaction
            if (!isset($replay[$doid]) or strlen($replay[$doid]) < 1) {
                continue;
            }
            if (!isset($parms["debitacc"])) {
                $parms["debitacc"] = "0";
            }
            db_connect();
            switch ($jobjs->type) {
                case "DEBTOR":
                    $debtor = $complete["DEBTOR"][$parms["iid"]]->cols;
                    if (!isset($parms['creditacc'])) {
                        $parms['creditacc'] = "0";
                    }
                    if ($parms['debitacc'] == '0' and $parms['creditacc'] == '0') {
                        #its not 1 of the custom saves ... so do generic ...
                        # record the payment on the statement
                        $sql = "\n\t\t\t\t\t\t\tINSERT INTO stmnt (\n\t\t\t\t\t\t\t\tcusnum, invid, amount, date, type, st, div, allocation_date\n\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t'{$parms['iid']}', '0', '{$parms['amount']}', '{$parms['date']}', '{$parms['details']}', 'n', '" . USER_DIV . "', '{$parms['date']}'\n\t\t\t\t\t\t\t)";
                        $stmntRslt = db_exec($sql) or errDie("Unable to Insert statement record in Cubit.", SELF);
                        $sql = "INSERT INTO open_stmnt(cusnum, invid, amount, balance, date, type, st, div) VALUES('{$parms['iid']}', '0', '{$parms['amount']}', '{$parms['amount']}', '{$parms['date']}', '{$parms['details']}', 'n', '" . USER_DIV . "')";
                        $stmntRslt = db_exec($sql) or errDie("Unable to Insert statement record in Cubit.", SELF);
                        # update the customer (make balance more)
                        $sql = "UPDATE customers SET balance = (balance + '{$parms['amount']}') WHERE cusnum = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                        $rslt = db_exec($sql) or errDie("Unable to update customer in Cubit.", SELF);
                    } else {
                        if ($parms['debitacc'] == '0') {
                            if ($parms['creditacc'] == '1') {
                                recordCT($parms['amount'], $parms['iid'], $parms['date']);
                            } else {
                                custledger($parms['iid'], $parms['creditacc'], $parms['date'], $parms['refno'], $parms['details'], $parms['amount'], 'c');
                            }
                        } elseif ($parms['creditacc'] == '0') {
                            if ($parms['debitacc'] == '1') {
                                recordDT($parms['amount'], $parms['iid'], $parms['date']);
                            } else {
                                custledger($parms['iid'], $parms['creditacc'], $parms['date'], $parms['refno'], $parms['details'], $parms['amount'], 'd');
                            }
                        }
                    }
                    break;
                case "CREDITOR":
                    $creditor = $complete["CREDITOR"][$parms["iid"]]->cols;
                    if ($parms['debitacc'] == '0') {
                        if ($parms['creditacc'] == '1') {
                            recordCT(-$parms['amount'], $parms['iid'], $parms['date']);
                        } else {
                            suppledger($parms['iid'], $parms['creditacc'], $parms['date'], $parms['refno'], $parms['details'], $parms['amount'], 'c');
                        }
                    } elseif ($parms['creditacc'] == '0') {
                        if ($parms['debitacc'] == '1') {
                            recordDT($parms['amount'], $parms['iid'], $parms['date']);
                        } else {
                            suppledger($parms['iid'], $parms['debitacc'], $parms['date'], $parms['refno'], $parms['details'], $parms['amount'], 'd');
                        }
                    } elseif ($parms['debitacc'] == "9999" or $parms['creditacc'] == "9999") {
                        # record the payment on the statement
                        $sql = "INSERT INTO sup_stmnt(supid, edate, ref, cacc, descript, amount, div) VALUES('{$parms['iid']}', '{$parms['date']}', '0', '{$parms['refno']}', '{$parms['details']}', '{$parms['amount']}', '" . USER_DIV . "')";
                        $stmntRslt = db_exec($sql) or errDie("Unable to Insert statement record in Cubit.", SELF);
                        # update the supplier (make balance more)
                        $sql = "UPDATE suppliers SET balance = (balance + '{$parms['amount']}') WHERE supid = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                        $rslt = db_exec($sql) or errDie("Unable to update supplier in Cubit.", SELF);
                    } else {
                        #do nothing ?
                        #its not 1 of the custom saves ... so do generic ...
                        //						db_connect();
                        //						$sql = "INSERT INTO sup_stmnt(supid, edate, ref, cacc, descript, amount, div) VALUES('$parms[iid]', '$parms[date]', '0', '$parms[vat]', '$parms[details]', '$parms[amount]', '".USER_DIV."')";
                        //						$stmntRslt = db_exec($sql) or errDie("Unable to Insert statement record in Cubit.",SELF);
                        //						# update the supplier (make balance more)
                        //						$sql = "UPDATE suppliers SET balance = (balance + '$parms[amount]') WHERE supid = '$parms[iid]' AND div = '".USER_DIV."'";
                        //						$rslt = db_exec($sql) or errDie("Unable to update supplier in Cubit.",SELF);
                    }
                    break;
                case "STOCK":
                    $stock = $complete["STOCK"][$parms["iid"]]->cols;
                    if ($parms['debitacc'] == "0" and $parms['creditacc'] == "0") {
                        $sql = "UPDATE stock SET csamt = (csamt - {$parms['amount']}), units = (units - '{$parms['refno']}') WHERE stkid = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                        $rslt = db_exec($sql) or errDie("Unable to insert stock to Cubit.", SELF);
                    } elseif ($parms['debitacc'] == "1" and $parms['creditacc'] == "1") {
                        $sql = "UPDATE stock\n\t\t\t\t\t\t\t\tSET units = (units + '{$parms['refno']}'),\n\t\t\t\t\t\t\t\t\tlcsprice = '{$parms['vat']}',\n\t\t\t\t\t\t\t\t\tcsamt = (csamt + {$parms['amount']}),\n\t\t\t\t\t\t\t\t\tcsprice = (\n\t\t\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t\tCASE WHEN (units != -{$parms['refno']}) THEN (csamt+{$parms['amount']})/(units+{$parms['refno']})\n\t\t\t\t\t\t\t\t\t\t\tELSE 0\n\t\t\t\t\t\t\t\t\t\tEND\n\t\t\t\t\t\t\t\t\t\tFROM cubit.stock\n\t\t\t\t\t\t\t\t\t\tWHERE stkid='{$parms['iid']}' AND div='" . USER_DIV . "'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tWHERE stkid = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                        $rslt = db_exec($sql) or errDie("Unable to insert stock to Cubit.", SELF);
                    } else {
                        if ($parms['debitacc'] == "1" and $parms['creditacc'] == "0") {
                            #first get the stock information
                            $sql = "SELECT * FROM stock WHERE stkid = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                            $stkRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
                            if (pg_numrows($stkRslt) < 1) {
                                return "<li> Invalid Stock ID.</li>";
                            } else {
                                $stk = pg_fetch_array($stkRslt);
                            }
                            stockrec($stk['stkid'], $stk['stkcod'], $stk['stkdes'], 'dt', $parms['date'], $parms['refno'], $parms['amount'], $parms['details']);
                            $sql = "INSERT INTO stockrec (edate, stkid, stkcod, stkdes, trantype, qty, csprice, csamt, details, div)\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$parms['date']}', '{$stk['stkid']}', '{$stk['stkcod']}', '{$stk['stkdes']}', 'inc', '{$parms['refno']}', '{$parms['amount']}', '{$parms['vat']}', '{$parms['details']}', '" . USER_DIV . "')";
                            $recRslt = db_exec($sql);
                        } elseif ($parms['debitacc'] == "0" and $parms['creditacc'] == "1") {
                            $sql = "SELECT * FROM stock WHERE stkid = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                            $stkRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
                            if (pg_numrows($stkRslt) < 1) {
                                return "<li> Invalid Stock ID.</li>";
                            } else {
                                $stk = pg_fetch_array($stkRslt);
                            }
                            stockrec($stk['stkid'], $stk['stkcod'], $stk['stkdes'], 'ct', $parms['date'], $parms['refno'], $parms['amount'], $parms['details']);
                            $parms[vat] += 0;
                            db_connect();
                            $sql = "INSERT INTO stockrec(edate, stkid, stkcod, stkdes, trantype, qty, csprice, csamt, details, div)\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES('{$parms['date']}', '{$stk['stkid']}', '{$stk['stkcod']}', '{$stk['stkdes']}', 'dec', '-{$parms['refno']}', '{$parms['amount']}', '{$parms['vat']}', '{$parms['details']}', '" . USER_DIV . "')";
                            $recRslt = db_exec($sql);
                            # Units
                            if ($stk['units'] != 0) {
                                $sql = "UPDATE stock SET csprice = (csamt/units) WHERE stkid = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                                $rslt = db_exec($sql) or errDie("Unable to insert stock to Cubit.", SELF);
                            } else {
                                $sql = "UPDATE stock SET csprice = '{$parms['vat']}' WHERE stkid = '{$parms['iid']}' AND div = '" . USER_DIV . "'";
                                $rslt = db_exec($sql) or errDie("Unable to insert stock to Cubit.", SELF);
                            }
                        } else {
                            #nothing to do ...
                        }
                    }
                    break;
                case "JOURNAL":
                    #process the writetrans
                    if ($parms['debitacc'] == "0" and $parms['creditacc'] == "0") {
                        print "WROTE JOURNAL: VAT<br>";
                        #we are dealing with vatr .. proceed
                        #get the compressed vars
                        $arrs = explode("|", $parms['details']);
                        vatr($arrs[1], $parms['date'], $arrs[2], $arrs[3], $parms['refno'], $arrs[0], $parms['amount'], $parms['vat']);
                    } else {
                        print "WROTE JOURNAL: TRANSACTION<br>";
                        writetrans($parms['debitacc'], $parms['creditacc'], $parms['date'], $parms['refno'], $parms['amount'], $parms['details']);
                    }
                    break;
            }
        }
    }
    pglib_transaction("COMMIT") or errDie("Unable to commit transactions.");
    $display = "\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Transactions Completed</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>All Selected Replay Transactions Completed.</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t";
    return $display;
}
function updateAddon($curseAddonID)
{
    global $debug, $baseURL, $currentDateTime, $addonName, $ourAddonName, $zipURL, $addonURL, $currentVersion, $currentDownloadID;
    require 'config.php';
    $addonInfo = parseXML(fetchAddonXML($curseAddonID));
    $addonName = $addonInfo[0];
    $addonURL = $addonInfo[1];
    $currentDownloadID = $addonInfo[2];
    $currentVersion = $addonInfo[3];
    $zipURL = $addonInfo[4];
    $currentDateTime = getDateTime();
    $query = "SELECT lastDownloadID from amz_addonsList WHERE curseAddonID=" . $curseAddonID;
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $lastDownloadID = trim($row['lastDownloadID']);
    }
    $query = "UPDATE amz_addonsList SET addonName='{$addonName}', addonURL='{$addonURL}', version='{$currentVersion}', lastUpdateDateTime='{$currentDateTime['0']}', lastUpdateDateTimeHuman='{$currentDateTime['1']}' WHERE curseAddonID={$curseAddonID}";
    if ($debug) {
        echo $query . "<br />";
    }
    $updatesult = mysql_query($query);
    if ($debug && !$updateResult) {
        die('Invalid query: ' . mysql_error());
    }
    if ($currentDownloadID != $lastDownloadID) {
        $updatedNeeded = true;
    }
    if (!file_exists($baseURL . 'cachedZips/' . $addonName . '.zip')) {
        $updatedNeeded = true;
    }
    if (!file_exists($baseURL . 'cachedZips/' . $addonName . '.dir') && !$updatedNeeded) {
        fork('unzip -d "' . $baseURL . 'cachedZips/' . $addonName . '.dir" "' . $baseURL . 'cachedZips/' . $addonName . '.zip"');
    }
    if (!file_exists($baseURL . 'cachedZips/' . $addonName . '.dir/versions/' . $addonName . '.md5') && !$updatedNeeded) {
        md5Addon($addonName);
    }
    if (!$updatedNeeded) {
        return false;
    }
    $_SESSION['addonName'] = $addonName;
    $_SESSION['curseAddonID'] = $curseAddonID;
    $_SESSION['addonSize'] = getContentLength($zipURL);
    touch($baseURL . $curseAddonID . "InProgress");
    fork('wget -O "' . $baseURL . 'cachedZips/' . $addonName . '.zip" ' . $zipURL . ' && rm ' . $baseURL . $curseAddonID . 'InProgress && rm -rf "' . $baseURL . 'cachedZips/' . $addonName . '.dir"; unzip -d "' . $baseURL . 'cachedZips/' . $addonName . '.dir" "' . $baseURL . 'cachedZips/' . $addonName . '.zip" && md5 "' . $baseURL . 'cachedZips/' . $addonName . '.zip" -out "' . $baseURL . 'cachedZips/' . $addonName . '.dir/md5checksum.txt"');
    if (addonExists($curseAddonID)) {
        $query = "UPDATE amz_addonsList SET addonName='{$addonName}', version='{$currentVersion}', addonURL='{$addonURL}', lastDownloadID={$currentDownloadID}, lastDownloadDateTime='{$currentDateTime['0']}', lastDownloadDateTimeHuman='{$currentDateTime['1']}', lastUpdateDateTime='{$currentDateTime['0']}', lastUpdateDateTimeHuman='{$currentDateTime['1']}' WHERE curseAddonID={$curseAddonID}";
    } else {
        $query = "INSERT INTO amz_addonsList (curseAddonID, addonName, version, addonURL, lastDownloadID, lastDownloadDateTime, lastDownloadDateTimeHuman, lastUpdateDateTime, lastUpdateDateTimeHuman) VALUES ({$curseAddonID}, '{$addonName}', '{$currentVersion}', '{$addonURL}', {$currentDownloadID}, '{$currentDateTime['0']}', '{$currentDateTime['1']}', '{$currentDateTime['0']}', '{$currentDateTime['1']}')";
    }
    $result = mysql_query($query);
    if ($debug && !$result) {
        die('Invalid query: ' . mysql_error());
    }
    return true;
}
function importEntriesFromXMLFile( $fileHandle, $umlsCollectionId, $goCollectionId, $hugoCollection, $EC2GoMeaningIdMapping, $keyword2GoMeaningIdMapping, ProgressBar $progressBar ) {
	$languageId = 85;
	bootstrapCollection( "concept mapping", $languageId, "MAPP" );

	$collectionId = bootstrapCollection( "Swiss-Prot", $languageId, "" );
	$classCollectionId = bootstrapCollection( "Swiss-Prot classes", $languageId, "CLAS" );
	$relationTypeCollectionId = bootstrapCollection( "Swiss-Prot relation types", $languageId, "RELT" );
	$textAttibuteCollectionId = bootstrapCollection( "Swiss-Prot text attributes", $languageId, "TATT" );
	$ECCollectionId = bootstrapCollection( "Enzyme Commission numbers", $languageId, "" );
	
	$goCollection = new CachedCollection( $goCollectionId, "GO", $languageId );
	
	$xmlParser = new SwissProtXMLParser();
	$xmlParser->languageId = $languageId;
	$xmlParser->collectionId = $collectionId;
	$xmlParser->classCollectionId = $classCollectionId;
	$xmlParser->relationTypeCollectionId = $relationTypeCollectionId;
	$xmlParser->textAttibuteCollectionId = $textAttibuteCollectionId;
	$xmlParser->ECCollectionId = $ECCollectionId;
	$xmlParser->EC2GoMeaningIdMapping = $EC2GoMeaningIdMapping;
	$xmlParser->keyword2GoMeaningIdMapping = $keyword2GoMeaningIdMapping;
	$xmlParser->goCollection = $goCollection;
	$xmlParser->hugoCollection = $hugoCollection;
	
	// Find some UMLS concepts for cross references from SwissProt:
	if ( $umlsCollectionId != 0 ) {
		// modified from C0033684(protein) to C1254349 
		// UMLS Semantic Type : Amino Acid, Peptide, or Protein 
		$xmlParser->proteinConceptId = getCollectionMemberId( $umlsCollectionId, "C1254349" );
		// UMLS Semantic Type : Gene or Genome
		$xmlParser->geneConceptId = getCollectionMemberId( $umlsCollectionId, "C0017337" );
		// UMLS Semantic Type: Organism
		$xmlParser->organismConceptId = getCollectionMemberId( $umlsCollectionId, "C0029235" );
	}

	$xmlParser->molecularFunctionConceptId = $goCollection->getOrCreateMember( "GO:0003674", "molecular function" );
	$xmlParser->biologicalProcessConceptId = $goCollection->getOrCreateMember( "GO:0008150", "biological process" );
	$xmlParser->cellularComponentConceptId = $goCollection->getOrCreateMember( "GO:0005575", "cellular component" );
	
	$xmlParser->setProgressBar( $progressBar );
	$xmlParser->initialize();
	
	parseXML( $fileHandle, $xmlParser );
}
<?php

$xml = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE test [<!ENTITY xxe SYSTEM "XXE_URI">]>
<foo>&xxe;</foo>
EOT;
$xml = str_replace('XXE_URI', __DIR__ . '/libxml_disable_entity_loader_payload.txt', $xml);
function parseXML($xml)
{
    $doc = new DOMDocument();
    $doc->resolveExternals = true;
    $doc->substituteEntities = true;
    $doc->validateOnParse = false;
    $doc->loadXML($xml, 0);
    return $doc->saveXML();
}
var_dump(strpos(parseXML($xml), 'SECRET_DATA') !== false);
var_dump(libxml_disable_entity_loader(true));
var_dump(strpos(parseXML($xml), 'SECRET_DATA') === false);
echo "Done\n";