summaryrefslogtreecommitdiffstats
path: root/utils/SurveySyncDump.php
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
commit19985dbb8c0aa66dc4bf7905abc1148de909097d (patch)
tree2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /utils/SurveySyncDump.php
download1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip
Diffstat (limited to 'utils/SurveySyncDump.php')
-rw-r--r--utils/SurveySyncDump.php87
1 files changed, 87 insertions, 0 deletions
diff --git a/utils/SurveySyncDump.php b/utils/SurveySyncDump.php
new file mode 100644
index 0000000..7f317f5
--- /dev/null
+++ b/utils/SurveySyncDump.php
@@ -0,0 +1,87 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+include_once ('../function.php');
+include_once ('../admin/survey/definition.php');
+include_once ('../vendor/autoload.php');
+
+// daj to v settings.php za tablice :-)
+
+global $connect_db;
+$data = true;
+
+$ftp_server= $terminal_ftp_server;
+$ftp_user_name = $terminal_ftp_user_name;
+$ftp_user_pass = $terminal_ftp_user_pass;
+
+$dostop = new Dostop();
+?>
+<html>
+ <head>
+ <title>Sinhronizacija podatkov</title>
+ <meta charset="utf-8">
+</head>
+<body>
+<?
+echo 'Pripravljam se na sinhronizacijo podatkov...<br>';
+
+foreach ($terminal_surveys as $anketa) {
+
+ echo 'Preverjam dostop do ankete ' .$anketa .'...';
+ SurveyInfo::getInstance()->SurveyInit($anketa);
+
+ if ($dostop->checkDostop($anketa) == true) {
+
+ echo 'OK<br>';
+
+ SurveyCopy::setSrcSurvey($anketa);
+ SurveyCopy::setSrcConectDb($connect_db);
+ SurveyCopy::setDestSite(0);
+ $dump = SurveyCopy::downloadArrayVar($data);
+
+
+ $nd = array();
+ foreach ($dump as $kljuc=>$vrednost) {
+ $nd[$terminal_id ."||~||" .$terminal_secret][$kljuc] = $vrednost;
+ }
+
+
+ $fn = $terminal_id ."-" .$anketa .'-'.date("YmdHis").'.1ka';
+ $fp = fopen($site_path .'admin/survey/SurveyBackup/' .$fn, 'w');
+ fwrite($fp, serialize($nd));
+ fclose($fp);
+
+ echo 'Anketa je izvožena, pripravljam prenos na strežnik....';
+
+ $file = $fn;
+ $remote_file = $fn;
+
+ // set up basic connection
+ $conn_id = ftp_connect($ftp_server);
+ $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+ ftp_pasv($conn_id, true);
+
+ // upload a file
+ if (ftp_put($conn_id, $remote_file, $site_path .'admin/survey/SurveyBackup/' .$file, FTP_ASCII)) {
+ echo 'OK. <br>Prenos ankete je uspel.<br><br>';
+
+ } else {
+ echo 'NAPAKA. <br>Prenos ankete ni uspel. ALI STE PRIKLOPLJENI NA INTERNET?<br><br>';
+ }
+
+ // close the connection
+ ftp_close($conn_id);
+ }
+
+ else {
+ echo 'nimate dostopa, zato ne izvažam!<br><strong>Ali ste prijavljeni?</strong><br>';
+ }
+}
+?>
+
+ <br><br>Opravljeno. \ No newline at end of file