diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
commit | 19985dbb8c0aa66dc4bf7905abc1148de909097d (patch) | |
tree | 2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /utils/Fieldwork | |
download | 1ka-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/Fieldwork')
-rw-r--r-- | utils/Fieldwork/1ka-128.png | bin | 0 -> 8067 bytes | |||
-rw-r--r-- | utils/Fieldwork/1ka-192.png | bin | 0 -> 14999 bytes | |||
-rw-r--r-- | utils/Fieldwork/import_db.php | 87 | ||||
-rw-r--r-- | utils/Fieldwork/index.php | 98 |
4 files changed, 185 insertions, 0 deletions
diff --git a/utils/Fieldwork/1ka-128.png b/utils/Fieldwork/1ka-128.png Binary files differnew file mode 100644 index 0000000..5115e5a --- /dev/null +++ b/utils/Fieldwork/1ka-128.png diff --git a/utils/Fieldwork/1ka-192.png b/utils/Fieldwork/1ka-192.png Binary files differnew file mode 100644 index 0000000..3fdacbe --- /dev/null +++ b/utils/Fieldwork/1ka-192.png diff --git a/utils/Fieldwork/import_db.php b/utils/Fieldwork/import_db.php new file mode 100644 index 0000000..232cf71 --- /dev/null +++ b/utils/Fieldwork/import_db.php @@ -0,0 +1,87 @@ +<?php
+
+$filename = '1ka_offline.sql';
+$dbHost = 'localhost';
+$dbUser = 'root';
+$dbPass = '';
+$dbName = '1ka';
+$maxRuntime = 8; // less then your max script execution limit
+
+$deadline = time()+$maxRuntime;
+$progressFilename = $filename.'_filepointer'; // tmp file for progress
+$errorFilename = $filename.'_error'; // tmp file for erro
+
+mysql_connect($dbHost, $dbUser, $dbPass);
+mysql_select_db($dbName);
+mysql_query ("SET foreign_key_checks = 0");
+mysql_query ("DROP database 1ka");
+mysql_query ("CREATE database 1ka");
+
+
+$fp = fopen($filename, 'r');
+
+// check for previous error
+ if( file_exists($errorFilename) ){
+ die('<pre> prejsnja napaka: '.file_get_contents($errorFilename));
+ }
+
+ // activate automatic reload in browser
+ echo '<html><head> <meta http-equiv="refresh" content="'.($maxRuntime+2).'"><pre>';
+
+ // go to previous file position
+ $filePosition = 0;
+ if( file_exists($progressFilename) ){
+ $filePosition = file_get_contents($progressFilename);
+ fseek($fp, $filePosition);
+ }
+
+ $queryCount = 0;
+ $query = '';
+ while( $deadline>time() AND ($line=fgets($fp, 1024000)) ) {
+ if(substr($line,0,2)=='--' OR trim($line)=='' ){
+ continue;
+ }
+
+ $query .= $line;
+ if( substr(trim($query),-1)==';' ){
+ if( !mysql_query($query) ){
+ $error = 'Napaka pri uvozu podatkov: ' . mysql_error();
+ file_put_contents($errorFilename, $error."\n");
+ exit;
+ }
+ $query = '';
+ file_put_contents($progressFilename, ftell($fp)); // save the current file position for
+ $queryCount++;
+ }
+ }
+
+ if(feof($fp) ){
+
+ // Zdaj pa še triggerji!
+ mysql_query ("DROP TRIGGER IF EXISTS srv_anketa_zero");
+ mysql_query ("CREATE TRIGGER srv_anketa_zero BEFORE DELETE ON srv_anketa FOR EACH ROW BEGIN DECLARE dummy INTEGER; IF OLD.id <= 0 THEN SELECT Cannot_delete_IDs_smaller_than_zero INTO dummy FROM srv_anketa; END IF; END");
+
+ mysql_query ("DROP TRIGGER IF EXISTS srv_grupa_zero");
+ mysql_query ("CREATE TRIGGER srv_grupa_zero BEFORE DELETE ON srv_grupa FOR EACH ROW BEGIN DECLARE dummy INTEGER; IF OLD.id <= 0 THEN SELECT Cannot_delete_IDs_smaller_than_zero INTO dummy FROM srv_grupa; END IF; END;");
+
+ mysql_query ("DROP TRIGGER IF EXISTS srv_if_zero");
+ mysql_query ("CREATE TRIGGER srv_if_zero BEFORE DELETE ON srv_if FOR EACH ROW BEGIN DECLARE dummy INTEGER; IF OLD.id <= 0 THEN SELECT Cannot_delete_IDs_smaller_than_zero INTO dummy FROM srv_if; END IF; END;");
+
+ mysql_query ("DROP TRIGGER IF EXISTS srv_spremenljivka_zero");
+ mysql_query ("CREATE TRIGGER srv_spremenljivka_zero BEFORE DELETE ON srv_spremenljivka FOR EACH ROW BEGIN DECLARE dummy INTEGER; IF OLD.id <= 0 THEN SELECT Cannot_delete_IDs_smaller_than_zero INTO dummy FROM srv_spremenljivka; END IF; END;");
+
+ mysql_query ("DROP TRIGGER IF EXISTS srv_vrednost_zero");
+ mysql_query ("CREATE TRIGGER srv_vrednost_zero BEFORE DELETE ON srv_vrednost FOR EACH ROW BEGIN DECLARE dummy INTEGER; IF OLD.id <= 0 THEN SELECT Cannot_delete_IDs_smaller_than_zero INTO dummy FROM srv_vrednost; END IF; END;");
+
+ mysql_query ("DROP FUNCTION IF EXISTS MAX_RECNUM");
+ mysql_query ("CREATE FUNCTION MAX_RECNUM (aid INT(11)) RETURNS INT(11) BEGIN DECLARE max INT(11); SELECT MAX(recnum) INTO max FROM srv_user WHERE ank_id = aid AND preview='0'; IF max IS NULL THEN SET max = '0' ; END IF; RETURN max+1; END;");
+
+
+
+
+
+ echo 'Podatki uspesno uvozeni!';
+ }else {
+ echo ftell($fp).'/'.filesize($filename).' '.(round(ftell($fp)/filesize($filename), 2)*100).'%'."\n";
+ echo $queryCount.' zahtevkov obdelanih! Prosimo, cakajte, podatki se uvazajo...';
+ }
\ No newline at end of file diff --git a/utils/Fieldwork/index.php b/utils/Fieldwork/index.php new file mode 100644 index 0000000..15d5d59 --- /dev/null +++ b/utils/Fieldwork/index.php @@ -0,0 +1,98 @@ +<html>
+ <head>
+ <title>1KA</title>
+ <meta charset="utf-8">
+ <link rel="shortcut icon" sizes="192x192" href="1ka-192.png">
+ <link rel="shortcut icon" sizes="128x128" href="1ka-128.png">
+ <style type="text/css">
+ html, body {
+ font-family: Arial;
+ }
+ span.veliki {
+ display: block;
+ width: 50px;
+ height: 50px;
+ margin-left: auto;
+ margin-right: auto;
+ text-align: center;
+ padding: 7px 6px 4px 6px;
+ font: bold 38px helvetica;
+ color: #black;
+ background-color: #9a9add;
+ border: 1px solid #9a9add;
+ border-radius: 10px;
+ }
+ span.veliki.rdeci {
+ background-color: #dd9a9a;
+ }
+ span.veliki.zeleni {
+ background-color: #9aff9a;
+ padding-bottom: 10px;
+ padding-top: 2px;
+ }
+ div.blok {
+ displaY: block;
+ float: left;
+ width: 200px;
+ height: 200px;
+
+ text-align: center;
+ text-transform: uppercase;
+ }
+
+ div.spodaj {
+ cleaR: both;
+ width: 900px;
+ margin-top: 25px;
+ margin-left: auto;
+ margin-right: auto;
+ }
+ div.zgoraj {
+ clear: both;
+ width: 900px;
+ margin-top: 25px;
+ margin-left: auto;
+ margin-right: auto;
+ }
+ a, a:visited {
+ text-decoration: none;
+ color: black;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div class="zgoraj">
+<?php
+ include_once ('../../settings.php');
+ include_once ('../../function.php');
+ $result = sisplet_query ("SELECT naslov, id FROM srv_anketa WHERE id IN (" .implode (",", $terminal_surveys) .")");
+ while ($r = mysqli_fetch_row ($result)) {
+?>
+ <div class="blok">
+ <a href="/a/<?=$r[1]?>" target="_blank"><span class="veliki"><?=$r[0][0]?></span><br>
+ <?=$r[0]?></a>
+
+ </div>
+<?
+ }
+?>
+ </div>
+ <br><br><br>
+ <div class="spodaj">
+ <div class="blok">
+ <a href="/utils/SurveySyncDump.php" target="_blank"><span class="veliki zeleni">⇄</span><br>
+ Sihnroniziraj</a>
+
+ </div>
+ <div class="blok">
+ <a href="/admin/" target="_blank"><span class="veliki rdeci">A</span><br>
+ Admin</a>
+
+ </div>
+ </div>
+
+ </body>
+</html>
+<?php
+?>
\ No newline at end of file |