enveetee Posted February 20, 2015 Share Posted February 20, 2015 Looking for some guidance on this... I have two applications, A windows desktop application written in VB6/VB.NET and my new (and learning) PHP/MYSQL app. I am mirroring records between them. Records can be added to both systems and I synchronise them. I am currently dealing with downloading the PHP/MYSQL records to my desktop and was wondering if I was going about it in the right way. This is how I have designed it... I have a common form which deals with three actions (POLL, DOWNLOAD and CONFIRM) using POST. I can return the number of records to be downloaded (using the POLL) paramater, the actual record (using a DOWNLOAD parameter along with a record ID) and finally a CONFIRM parameter to mark the MYSQL record as having been downloaded and is in the desktop database. I am ECHO'ing out values from the PHP form which is being received by the desktop component. This does work, but was wondering if the way I was doing it is ok - it seems too simple which scares me! Comments/advice/bullet-between-the-eyes - please here's the code if you are interested... <?php require_once('../includes/cs_functions.php'); require_once('../includes/cs_password.php'); require_once('../includes/meekrodb.2.3.class.php'); require_once('../classes/cUser.php'); FN_MeekroDBSetup(); //Call as POLL first to return id's of records needed to be downloaded TAB separated //Whitelist the POST values into WhiteListParameter array $WLP = allowed_post_params(['cs_name', 'cs_password', 'cs_mode', 'cs_id', 'cs_serialno', 'cs_downloadtime']); //Declare the user class for user name and password validation later $cUser = new clsUser; //These are debug settings so form can be executed in Netbeans $WLP['cs_name'] = 'Admin'; $WLP['cs_password'] = 'a'; $WLP['cs_mode'] = 'POLL'; $WLP['cs_mode'] = 'DOWNLOAD'; $WLP['cs_mode'] = 'CONFIRM'; //Validate user, returns NULL if user not valid $cUser = FN_Validate_User($WLP['cs_name'], $WLP['cs_password'], TRUE); if ($cUser == NULL) { } else { //Detect mode POLL, CONFIRM, DOWNLOAD switch ($WLP['cs_mode']) { case "POLL": //Check if any records to be downloaded and return a TAB delimited list of record ID's $resultsArray = db::query("SELECT * FROM bk WHERE bkwebbooking=%s AND bkwebbooking_downloadedtime=%s", '1', NULL); $tmp = ''; foreach ($resultsArray as $row) { $tmp = $tmp . $row['id'] . chr(9); } //Loose trailing TAB $tmp = FN_Shorten($tmp, 1); break; case "DOWNLOAD": //Return the record for import into desktop system $resultsArray = db::query("SELECT * FROM bk WHERE id=%s", $WLP['cs_id'], NULL); $tmp = ''; foreach ($resultsArray as $row) { $tmp = $tmp . $row['id'] . chr(9) . $row['bkaccount'] . $row['bkservice']; } break; case "CONFIRM": //Update MYSQL record with time and serial number from desktop system $cs_serialno, $cs_downloadtime default: $tmp = 'Call with POLL or DOWNLOAD or CONFIRM'; break; } echo $tmp; } Link to comment https://forums.phpfreaks.com/topic/294755-polling-a-server-downloading-data-uploading-confirmation/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.