\n"; $done = $_SESSION['sync']['ttl'] - (count($_SESSION['rcv']) + count($_SESSION['snd'])); $perc = intval(($done * 100)/$_SESSION['sync']['ttl']); echo "
\n"; $curRemMod = mysql_query("select NOW() + 0 as curRemMod", $rLink); $curRemMod = mysql_fetch_assoc($curRemMod); $curRemMod = substr($curRemMod['curRemMod'], 0, 14); $ccyls = 175; unset($_SESSION['snd']); while (false and $ccyls and !empty($_SESSION['snd'])) { foreach($_SESSION['snd'] as $idx => $v) break; // gets the first key in the send array $done += 1; $perc = intval(($done * 100)/$_SESSION['sync']['ttl']); echo "\n"; $r = mysql_query("show tables like '{$_SESSION['snd'][$k]['tble']}'", $rLink); if (mysql_num_rows($r)) { $str = ""; $q = "select * from {$_SESSION['snd'][$idx]['tble']} where tid='{$_SESSION['snd'][$idx]['tid']}'"; if (($data = mysql_query($q, $mLink)) !== false) { $data = mysql_fetch_assoc($data); if (is_array($data)) { foreach ($data as $k => $v) { if ($str) $str .=", "; $str .= "$k = '".addslashes($v)."'"; } $q = "replace into {$_SESSION['snd'][$idx]['tble']} set $str"; mysql_query($q, $rLink); $q = "replace into `transaction_mstr_log` set tble='{$_SESSION['snd'][$idx]['tble']}', tid='{$_SESSION['snd'][$idx]['tid']}', lastmod='$curRemMod', chgby = '{$_SESSION['snd'][$idx]['chgby']}'"; mysql_query($q, $rLink); // the info has to be put itno the regular trans-log as well so that it will be relayed to the server if this is a cross sync session $q = "replace into `transaction_log` set tble='{$_SESSION['snd'][$idx]['tble']}', tid='{$_SESSION['snd'][$idx]['tid']}', lastmod='$curRemMod', chgby = '{$_SESSION['snd'][$idx]['chgby']}'"; mysql_query($q, $rLink); // if ($_SESSION['debug']['verbose']) // echo "\n"; mysql_query("delete from `transaction_log` where tid='{$_SESSION['snd'][$idx]['tid']}'", $mLink); // remove from the log $doNotRcvList[] = $tid; } else { //this loop is a "failure to send" because the data doesn't actually exist (that TID is not in that TABLE) // so we will simply remove it from the queue $q = "delete from `transaction_log` where tid='{$_SESSION['snd'][$idx]['tid']}'"; mysql_query($q, $mLink); } } unset($_SESSION['snd'][$idx]); } $ccyls -= 1; } if (!empty($_SESSION['snd'])) { echo " \n"; } else if (array_key_exists("snd", $_SESSION)) unset($_SESSION['snd']); while ($ccyls and !empty($_SESSION['rcv'])) { foreach($_SESSION['rcv'] as $idx => $v) break; // gets the first key in the receive array $done += 1; $perc = intval(($done * 100)/$_SESSION['sync']['ttl']); echo "\n"; $str = ""; $q = "select * from {$_SESSION['rcv'][$idx]['tble']} where tid='{$_SESSION['rcv'][$idx]['tid']}'"; if (($data = mysql_query($q, $rLink)) !== false) { $data = mysql_fetch_assoc($data); if (is_array($data)) { foreach ($data as $k => $v) { if ($str) $str .=", "; $str .= "$k = '".addslashes($v)."'"; } $uStr1 = "replace into {$_SESSION['rcv'][$idx]['tble']} set $str"; mysql_query($uStr1, $mLink); $uStr2 = "replace into `transaction_mstr_log` set tid='{$_SESSION['rcv'][$idx]['tid']}', lastmod = '{$_SESSION['rcv'][$idx]['lastmod']}', tble = '{$_SESSION['rcv'][$idx]['tble']}', chgby = '{$_SESSION['rcv'][$idx]['chgby']}'"; mysql_query($uStr2, $mLink); mysql_query("update system set lastmod ='{$_SESSION['rcv'][$idx]['lastmod']}'", $mLink); } } unset($_SESSION['rcv'][$idx]); $ccyls -= 1; } if (!empty($_SESSION['rcv'])) { echo " \n"; } else { if (array_key_exists("rcv", $_SESSION)) unset($_SESSION['rcv']); echo " \n"; } ?>