Пример #1
0
echo "<tr><td>strdbsyncnr</td><td> : " . $strdbsyncnr . "</td></tr>";
echo "</table>";
echo "</div>";
echo "<form class='form-horizontal' method='post' action='" . $callbackurl . "&onlyshow=" . $onlyshow . "'>";
echo "<input type='hidden' name='status' value='einspielen' />";
//echo "<input type='submit' value='Daten einspielen' />";
echo "<br>";
$db = new SQLite3('../data/' . $database);
echo "<table class='table table-hover'>";
echo "<tr><th>Table</th><th>Index</th><th>Bezeichnung</th><th>NOSYNC</th></tr>";
$arranzds = array();
$arrtblstatus = array();
$arridxds = array();
$arrdaten = array();
for ($tablecount = 0; $tablecount < $anztables; $tablecount++) {
    $dbnchopen = dbopentyp($arrnchdbtyp[$tablecount], $arrnchdbname[$tablecount], $arrnchdbuser[$tablecount], $arrnchdbpassword[$tablecount]);
    $column = getdbcolumn($arrnchdbtyp[$tablecount], $arrnchdbname[$tablecount], $arrnchtables[$tablecount], $arrnchdbuser[$tablecount], $arrnchdbpassword[$tablecount]);
    if ($arrcolsel[$tablecount] == $column) {
        array_push($arrtblstatus, "OK");
        $query = "SELECT * FROM tblsyncstatus WHERE fldtable='" . $arrnchtables[$tablecount] . "' AND flddbsyncnr=" . $arrdbsyncnr[$tablecount];
        //echo $query."<br>";
        $resst = $db->query($query);
        if ($linst = $resst->fetchArray()) {
            $timestamp = $linst['fldtimestamp'];
        } else {
            $timestamp = '2015-01-01 00:00:00';
        }
        $qryval = "SELECT " . $arrcolsel[$tablecount] . " FROM " . $arrnchtables[$tablecount] . " WHERE flddbsyncstatus='SYNC' AND fldtimestamp>'" . $timestamp . "'";
        echo $qryval . "<br>";
        $resval = dbquerytyp($arrnchdbtyp[$tablecount], $dbnchopen, $qryval);
        //echo $arrnchdbtyp[$tablecount]."<br>";
Пример #2
0
function einspielen($menu, $onlyshow)
{
    $anztables = $_POST["anztables"];
    $arrvontables = json_decode($_POST["strvontables"]);
    $arrnchtables = json_decode($_POST["strnchtables"]);
    $arrvonindex = json_decode($_POST["strvonindex"]);
    $arrvondbtyp = json_decode($_POST["strvondbtyp"]);
    $arrvondbname = json_decode($_POST["strvondbname"]);
    $arrvondbuser = json_decode($_POST["strvondbuser"]);
    $arrvondbpassword = json_decode($_POST["strvondbpassword"]);
    $arrtblstatus = json_decode($_POST["strtblstatus"]);
    $arrdbsyncnr = json_decode($_POST["strdbsyncnr"]);
    $arranzds = json_decode($_POST["stranzds"]);
    $arridxds = json_decode($_POST["stridxds"]);
    $arrdaten = json_decode($_POST["strdaten"]);
    $arrnchwebsite = json_decode($_POST["strnchwebsite"]);
    echo "<div class='alert alert-info'>";
    echo "einspielen<br>";
    echo "<table>";
    echo "<tr><td>onlyshow</td><td> : " . $onlyshow . "</td></tr>";
    echo "<tr><td>anztables</td><td> : " . $anztables . "</td></tr>";
    echo "</table>";
    $idxcnt = 0;
    $idxcol = 0;
    for ($tablecount = 0; $tablecount < $anztables; $tablecount++) {
        if ($arrtblstatus[$tablecount] == "OK") {
            $dbvonopen = dbopentyp($arrvondbtyp[$tablecount], $arrvondbname[$tablecount], $arrvondbuser[$tablecount], $arrvondbpassword[$tablecount]);
            $column = getdbcolumn($arrvondbtyp[$tablecount], $arrvondbname[$tablecount], $arrvontables[$tablecount], $arrvondbuser[$tablecount], $arrvondbpassword[$tablecount]);
            $arrcolumn = explode(",", $column);
            echo $arranzds[$tablecount] . "=anzds<br>";
            for ($i = 1; $i <= $arranzds[$tablecount]; $i++) {
                $qryval = "SELECT * FROM " . $arrvontables[$tablecount] . " WHERE " . $arrvonindex[$tablecount] . "=" . $arridxds[$idxcnt];
                echo $qryval . "<br>";
                $resval = dbquerytyp($arrvondbtyp[$tablecount], $dbvonopen, $qryval);
                if ($linval = dbfetchtyp($arrvondbtyp[$tablecount], $resval)) {
                    $upd = $arrcolumn[0] . "='" . str_replace("#", " ", $arrdaten[$idxcol]) . "'";
                    //$upd=$arrcolumn[0]."=''";
                    for ($colidx = 1; $colidx < count($arrcolumn); $colidx++) {
                        $idxcol = $idxcol + 1;
                        $upd = $upd . ", " . $arrcolumn[$colidx] . "='" . str_replace("#", " ", $arrdaten[$idxcol]) . "'";
                        //$upd=$upd.", ".$arrcolumn[$colidx]."=''";
                    }
                    $sql = "UPDATE " . $arrvontables[$tablecount] . " SET " . $upd . " WHERE " . $arrvonindex[$tablecount] . "=" . $arridxds[$idxcnt];
                } else {
                    for ($colidx = 0; $colidx < count($arrcolumn); $colidx++) {
                        if ($colidx == 0) {
                            $ins = "'" . str_replace("#", " ", $arrdaten[$colidx]) . "'";
                        } else {
                            $ins = $ins . ", '" . str_replace("#", " ", $arrdaten[$colidx]) . "'";
                        }
                    }
                    $sql = "INSERT INTO " . $arrvontables[$tablecount] . " (" . $column . ") VALUES(" . $ins . ")";
                }
                echo $sql . "<br>";
                dbexecutetyp($arrvondbtyp[$tablecount], $dbvonopen, $sql);
                $idxcol = $idxcol + 1;
                $idxcnt = $idxcnt + 1;
            }
        }
    }
    echo "</div>";
    //$website="http://localhost:8080/own/phpmysync/classes/syncfertig.php?menu=".$menu;
    $website = $arrnchwebsite[0] . "syncfertig.php?menu=" . $menu;
    $aktpfad = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
    $callbackurl = "http://" . $aktpfad . "?menu=" . $menu;
    $onlyshow = "";
    echo "<form class='form-horizontal' method='post' action='" . $website . "'>";
    echo "<input type='hidden' name='callbackurl' value='" . $callbackurl . "' />";
    echo "<input type='hidden' name='strnchtables' value='" . json_encode($arrnchtables) . "' />";
    echo "<input type='hidden' name='strtblstatus' value='" . json_encode($arrtblstatus) . "' />";
    echo "<input type='hidden' name='strdbsyncnr' value='" . json_encode($arrdbsyncnr) . "' />";
    echo "<input type='submit' value='Daten abschließen' />";
    echo "</form>";
}
Пример #3
0
$fldindex = $_POST['fldindex'];
$fldindexrmt = $_GET['fldindexremote'];
$fldindexloc = $_GET['fldindexloc'];
$nuranzeigen = $_GET['nuranzeigen'];
$urladr = $_GET['urladr'];
bootstraphead();
bootstrapbegin("Datenaustausch");
$database = "/var/www/html/own/joorgsqlite/data/joorgsqlite.db";
//$database=$_POST['database'];
//$database="dbjoorgportal";
echo $database . "=database<br>";
//$db = new SQLite3($database);
$dbtyp = "SQLITE3";
$dbuser = "";
$dbpassword = "";
$db = dbopentyp($dbtyp, $database, $dbuser, $dbpassword);
$showsync = $_GET['showsync'];
$dbsyncnr = 8;
echo "<a href='http://" . $pfad . "showtab.php?menu=" . $menu . "'  class='btn btn-primary btn-sm active' role='button'>Zurück</a> ";
if ($showsync == "J") {
    $fldindex = "fldindex";
    $timestamp = "2015-01-01 06:00:00";
    $website = "allnosync.php?menu=" . $menu;
    echo "<form class='form-horizontal' method='post' action='" . $website . "'>";
    echo "<input type='submit' value='All NoSync' />";
    echo "<input type='hidden' name='pfad' value='" . $pfad . "' />";
    echo "<input type='hidden' name='dbtyp' value='" . $dbtyp . "' />";
    echo "<input type='hidden' name='dbtable' value='" . $dbtable . "' />";
    echo "<input type='hidden' name='database' value='" . $database . "' />";
    echo "<input type='hidden' name='dbsyncnr' value='" . $dbsyncnr . "' />";
    echo "<input type='hidden' name='timestamp' value='" . $timestamp . "' />";
Пример #4
0
function syncempfangen($database, $nuranzeigen, $datcntremote, $dbtable, $fldindex, $timestamp)
{
    $db = new SQLite3('../data/' . $database);
    $dbtyp = "MYSQL";
    $dbase = "dbjoorgportal";
    $dbuser = "******";
    $dbpassword = "******";
    $dbremote = dbopentyp($dbtyp, $dbase, $dbuser, $dbpassword);
    echo "<div class='alert alert-success'>";
    echo $datcntremote . " Datensätze empfangen am " . $timestamp . "<br>";
    for ($i = 1; $i <= $datcntremote; $i++) {
        echo "<div class='alert alert-success'>";
        $index = $_POST['index' . $i];
        $qryval = "SELECT * FROM " . $dbtable . " WHERE " . $fldindex . "=" . $index;
        echo $qryval . "<br>";
        //    $results = $db->query($qryval);
        $results = dbquerytyp($dbtyp, $dbase, $qryval);
        if ($linval = dbfetchtyp($dbtyp, $results)) {
            $sql = $_POST['updsql' . $i];
        } else {
            $sql = $_POST['inssql' . $i];
        }
        $sql = str_replace("#", "'", $sql);
        echo $sql . "<br>";
        echo "</div>";
        if ($nuranzeigen != "anzeigen") {
            //$query = $db->exec($sql);
            dbexecutetyp($dbtyp, $dbremote, $sql);
        }
    }
    echo "</div>";
    syncfertig($database, $nuranzeigen, $dbtable, $timestamp);
}
Пример #5
0
function getdbcolumn($dbtyp, $dbname, $dbtable, $dbuser, $dbpassword)
{
    switch ($dbtyp) {
        case 'SQLITE3':
            $dbopen = dbopentyp($dbtyp, $dbname, "", "");
            $col = "";
            $lincnt = 1;
            $count = 0;
            $query = "PRAGMA table_info(" . $dbtable . ")";
            $results = dbquerytyp($dbtyp, $dbopen, $query);
            while ($row = dbfetchtyp($dbtyp, $results)) {
                $colstr = $row['name'];
                $lincnt = $lincnt + 1;
                if ($col == "") {
                    $col = $colstr;
                } else {
                    $col = $col . "," . $colstr;
                }
            }
            return $col;
            break;
        case 'MYSQL':
            $dbopen = dbopentyp($dbtyp, $dbname, $dbuser, $dbpassword);
            //$col="*";
            $col = "";
            //$query="describe ".$dbtable;
            $query = "SHOW COLUMNS FROM " . $dbtable;
            $results = dbquerytyp($dbtyp, $dbopen, $query);
            while ($row = dbfetchtyp($dbtyp, $results)) {
                $colstr = $row['Field'];
                //$lincnt = $lincnt + 1;
                if ($col == "") {
                    $col = $colstr;
                } else {
                    $col = $col . "," . $colstr;
                }
            }
            return $col;
            break;
        default:
            echo 'Unbekannter dbtyp ' . $dbtyp;
            break;
    }
}