├── .gitignore ├── README.md ├── db ├── db_dump_20160620.sql └── dummy ├── firmware ├── config.h ├── led.cpp ├── led.h ├── log_backup.cpp ├── log_backup.h ├── main.cpp ├── rest_client.cpp ├── rest_client.h ├── wifi_login.cpp └── wifi_login.h ├── pcb ├── MACS7.brd └── MACS7.sch └── website ├── .gitignore ├── css ├── design.css ├── iframe.css └── jquery-ui.css ├── data.php ├── db_con.php ├── helper.php ├── history.php ├── html.php ├── images ├── bg1.jpg ├── bg2.jpg └── bg3.jpg ├── index.php ├── js ├── amcharts.js ├── images │ ├── dragIcon.gif │ ├── dragIconBlack.gif │ ├── dragIconH.gif │ ├── dragIconHBlack.gif │ ├── dragIconRectBig.png │ ├── dragIconRectBig.svg │ ├── dragIconRectBigBlack.png │ ├── dragIconRectBigBlack.svg │ ├── dragIconRectBigBlackH.png │ ├── dragIconRectBigBlackH.svg │ ├── dragIconRectBigH.png │ ├── dragIconRectBigH.svg │ ├── dragIconRectSmall.png │ ├── dragIconRectSmall.svg │ ├── dragIconRectSmallBlack.png │ ├── dragIconRectSmallBlack.svg │ ├── dragIconRectSmallBlackH.png │ ├── dragIconRectSmallBlackH.svg │ ├── dragIconRectSmallH.png │ ├── dragIconRectSmallH.svg │ ├── dragIconRoundBig.png │ ├── dragIconRoundBig.svg │ ├── dragIconRoundBigBlack.png │ ├── dragIconRoundBigBlack.svg │ ├── dragIconRoundBigBlackH.png │ ├── dragIconRoundBigBlackH.svg │ ├── dragIconRoundBigH.png │ ├── dragIconRoundBigH.svg │ ├── dragIconRoundSmall.png │ ├── dragIconRoundSmall.svg │ ├── dragIconRoundSmallBlack.png │ ├── dragIconRoundSmallBlack.svg │ ├── dragIconRoundSmallBlackH.png │ ├── dragIconRoundSmallBlackH.svg │ ├── dragIconRoundSmallH.png │ ├── dragIconRoundSmallH.svg │ ├── eraserIcon.svg │ ├── eraserIconH.svg │ ├── export.png │ ├── exportWhite.png │ ├── lens.png │ ├── lens.svg │ ├── lensWhite.png │ ├── lensWhite.svg │ ├── lensWhite_old.png │ ├── lens_old.png │ ├── pencilIcon.svg │ ├── pencilIconH.svg │ ├── xIcon.svg │ └── xIconH.svg ├── jquery.min.js ├── jstz.min.js ├── log.js ├── md5.js ├── serial.js └── setup_helper.js ├── logview.php ├── m2m.php ├── php_module ├── module_backup.php ├── module_log.php ├── module_log_content.php ├── module_setup.php ├── module_setup_helper_execute.php ├── module_setup_helper_reader.php ├── module_setup_helper_writer.php └── module_usage.php ├── python ├── config.txt └── run.py └── sec.php /.gitignore: -------------------------------------------------------------------------------- 1 | gh-pages/* 2 | website/db_backup/* 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | please refere to http://koljawindeler.github.io/macs 2 | -------------------------------------------------------------------------------- /db/db_dump_20160620.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE access; 2 | 3 | CREATE TABLE `access` ( 4 | `id` int(11) NOT NULL AUTO_INCREMENT, 5 | `user_id` int(11) NOT NULL, 6 | `mach_id` int(11) NOT NULL, 7 | PRIMARY KEY (`id`), 8 | UNIQUE KEY `id` (`id`), 9 | KEY `id_2` (`id`) 10 | ) ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=latin1; 11 | 12 | INSERT INTO access VALUES("11","35","33"); 13 | INSERT INTO access VALUES("12","35","37"); 14 | INSERT INTO access VALUES("13","35","41"); 15 | INSERT INTO access VALUES("14","35","44"); 16 | INSERT INTO access VALUES("15","35","46"); 17 | INSERT INTO access VALUES("16","36","33"); 18 | INSERT INTO access VALUES("17","36","35"); 19 | INSERT INTO access VALUES("18","36","37"); 20 | INSERT INTO access VALUES("19","36","41"); 21 | INSERT INTO access VALUES("20","36","44"); 22 | INSERT INTO access VALUES("21","37","33"); 23 | INSERT INTO access VALUES("22","37","37"); 24 | INSERT INTO access VALUES("23","37","38"); 25 | INSERT INTO access VALUES("24","37","41"); 26 | INSERT INTO access VALUES("25","37","44"); 27 | INSERT INTO access VALUES("26","38","35"); 28 | INSERT INTO access VALUES("27","38","41"); 29 | INSERT INTO access VALUES("28","38","44"); 30 | INSERT INTO access VALUES("29","39","41"); 31 | INSERT INTO access VALUES("30","39","44"); 32 | INSERT INTO access VALUES("31","39","45"); 33 | INSERT INTO access VALUES("38","41","33"); 34 | INSERT INTO access VALUES("39","41","41"); 35 | INSERT INTO access VALUES("40","41","44"); 36 | INSERT INTO access VALUES("41","41","45"); 37 | INSERT INTO access VALUES("42","41","46"); 38 | INSERT INTO access VALUES("43","42","36"); 39 | INSERT INTO access VALUES("44","42","41"); 40 | INSERT INTO access VALUES("45","42","44"); 41 | INSERT INTO access VALUES("46","43","33"); 42 | INSERT INTO access VALUES("47","43","41"); 43 | INSERT INTO access VALUES("48","43","44"); 44 | INSERT INTO access VALUES("49","44","33"); 45 | INSERT INTO access VALUES("50","44","41"); 46 | INSERT INTO access VALUES("51","44","47"); 47 | INSERT INTO access VALUES("52","45","41"); 48 | INSERT INTO access VALUES("53","46","41"); 49 | INSERT INTO access VALUES("54","47","33"); 50 | INSERT INTO access VALUES("55","47","36"); 51 | INSERT INTO access VALUES("56","47","41"); 52 | INSERT INTO access VALUES("57","48","41"); 53 | INSERT INTO access VALUES("58","49","36"); 54 | INSERT INTO access VALUES("59","49","41"); 55 | INSERT INTO access VALUES("60","49","47"); 56 | INSERT INTO access VALUES("61","49","51"); 57 | INSERT INTO access VALUES("62","50","41"); 58 | INSERT INTO access VALUES("63","51","41"); 59 | 60 | 61 | 62 | DROP TABLE log; 63 | 64 | CREATE TABLE `log` ( 65 | `id` int(11) NOT NULL AUTO_INCREMENT, 66 | `timestamp` int(11) NOT NULL, 67 | `user_id` int(11) NOT NULL, 68 | `machine_id` int(11) NOT NULL, 69 | `event` text NOT NULL, 70 | `login_id` int(11) DEFAULT NULL, 71 | `usage` int(11) NOT NULL, 72 | PRIMARY KEY (`id`), 73 | UNIQUE KEY `id` (`id`) 74 | ) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=latin1; 75 | 76 | INSERT INTO log VALUES("1","1455295294","44","47","Unlocked","","0"); 77 | INSERT INTO log VALUES("2","1455295297","44","47","Locked","","2"); 78 | INSERT INTO log VALUES("3","1455295776","44","47","Unlocked","","0"); 79 | INSERT INTO log VALUES("4","1455295782","44","47","Locked","","7"); 80 | INSERT INTO log VALUES("7","1455295786","44","47","Unlocked","","0"); 81 | INSERT INTO log VALUES("8","1455295961","44","47","Locked","","174"); 82 | INSERT INTO log VALUES("9","1455295968","44","47","Unlocked","","0"); 83 | INSERT INTO log VALUES("10","1455295969","44","47","Locked","","2"); 84 | INSERT INTO log VALUES("11","1455295974","0","47","Rejected 8298962","","0"); 85 | INSERT INTO log VALUES("12","1455296696","1","47","Rejected","","0"); 86 | INSERT INTO log VALUES("13","1455296705","1","47","Rejected","","0"); 87 | INSERT INTO log VALUES("14","1455296716","1","47","Rejected","","0"); 88 | INSERT INTO log VALUES("15","1455365038","0","47","Rejected 8298962","","0"); 89 | INSERT INTO log VALUES("16","1455365045","44","47","Unlocked","","0"); 90 | INSERT INTO log VALUES("17","1455365048","44","47","Locked","","3"); 91 | INSERT INTO log VALUES("20","1455365127","44","47","Unlocked","","0"); 92 | INSERT INTO log VALUES("21","1455365343","44","47","Locked","","216"); 93 | INSERT INTO log VALUES("22","1455365348","0","47","Rejected 8298962","","0"); 94 | INSERT INTO log VALUES("23","1455365356","44","47","Unlocked","","0"); 95 | INSERT INTO log VALUES("24","1455365358","44","47","Locked","","2"); 96 | INSERT INTO log VALUES("25","1455380641","0","47","Rejected 8298962","","0"); 97 | INSERT INTO log VALUES("28","1455380646","44","47","Unlocked","","0"); 98 | INSERT INTO log VALUES("29","1455380680","44","47","Locked","","35"); 99 | INSERT INTO log VALUES("30","1455467102","0","47","Rejected 8298962","","0"); 100 | INSERT INTO log VALUES("33","1455467109","44","47","Unlocked","","0"); 101 | INSERT INTO log VALUES("34","1455467401","44","47","Locked","","292"); 102 | INSERT INTO log VALUES("35","1466445799","56","0","User deleted","1","0"); 103 | INSERT INTO log VALUES("36","1466445804","34","0","User deleted","1","0"); 104 | INSERT INTO log VALUES("37","1466445807","40","0","User deleted","1","0"); 105 | INSERT INTO log VALUES("38","1466445811","53","0","User deleted","1","0"); 106 | INSERT INTO log VALUES("39","1466445814","59","0","User deleted","1","0"); 107 | INSERT INTO log VALUES("40","1466445817","58","0","User deleted","1","0"); 108 | INSERT INTO log VALUES("41","1466445821","57","0","User deleted","1","0"); 109 | INSERT INTO log VALUES("42","1466445824","55","0","User deleted","1","0"); 110 | INSERT INTO log VALUES("43","1466445827","54","0","User deleted","1","0"); 111 | INSERT INTO log VALUES("44","1466445898","0","49","Machine deleted","1","0"); 112 | INSERT INTO log VALUES("45","1466445954","1","0","User updated","1","0"); 113 | 114 | 115 | 116 | DROP TABLE mach; 117 | 118 | CREATE TABLE `mach` ( 119 | `id` int(11) NOT NULL AUTO_INCREMENT, 120 | `name` text NOT NULL, 121 | `mach_nr` int(11) NOT NULL, 122 | `desc` text NOT NULL, 123 | `last_seen` int(11) NOT NULL, 124 | `active` int(1) NOT NULL, 125 | `version` int(11) NOT NULL DEFAULT '-1', 126 | PRIMARY KEY (`id`), 127 | UNIQUE KEY `id` (`id`) 128 | ) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=latin1; 129 | 130 | INSERT INTO mach VALUES("3","Band saw 2","905","Fine blade","2","0","-1"); 131 | INSERT INTO mach VALUES("4","Band saw 3","903","Fine blade","1","0","-1"); 132 | INSERT INTO mach VALUES("5","CNC1","914","Gizzmo","1446786040","0","-1"); 133 | INSERT INTO mach VALUES("6","CNC2","901","Gizzmo","1","0","-1"); 134 | INSERT INTO mach VALUES("7","gizzmo","900","Gizzmo","1","0","-1"); 135 | INSERT INTO mach VALUES("8","Locker1","900","Gizzmo2","1","0","-1"); 136 | INSERT INTO mach VALUES("16","SawStop","906","Saw Stop Table Saw","0","0","-1"); 137 | INSERT INTO mach VALUES("17","Panel Saw","907","Safety-Speed Panel Saw","0","0","-1"); 138 | INSERT INTO mach VALUES("18","Miter Saw","915","Dewalt Sliding Compoud Miter Saw","1446784806","0","-1"); 139 | INSERT INTO mach VALUES("19","Lathe","908","11x26 Metal Lathe","0","0","-1"); 140 | INSERT INTO mach VALUES("20","CNC Router","909","CNC Router","1446694286","0","-1"); 141 | INSERT INTO mach VALUES("21","Finger Chopa","910","Very Very Mean Finger Chopper","0","0","-1"); 142 | INSERT INTO mach VALUES("23","Laser 1","911","Laser Engraver #1","0","0","-1"); 143 | INSERT INTO mach VALUES("26","12th test","900","test kolja","0","0","-1"); 144 | INSERT INTO mach VALUES("27","12th test 2","900","new 12er","0","0","-1"); 145 | INSERT INTO mach VALUES("28","asd","902","asdasd","0","0","-1"); 146 | INSERT INTO mach VALUES("29","Fusion Saw","916","Cuts through solid Krell Metal","1446699467","0","-1"); 147 | INSERT INTO mach VALUES("30","Flux Cap","912","Buy one last year","1444442349","0","-1"); 148 | INSERT INTO mach VALUES("31","Test Printer","904","A4 Printer","0","0","-1"); 149 | INSERT INTO mach VALUES("32","Somemachine","913","12345","0","0","-1"); 150 | INSERT INTO mach VALUES("33","Laser1","1","Laser Engraver 1","1449290029","1","-1"); 151 | INSERT INTO mach VALUES("34","Laser2","917","Laser Engraver 2","1448811649","0","-1"); 152 | INSERT INTO mach VALUES("35","Table Saw","17","SawStop Table Saw","1452439506","1","20151231"); 153 | INSERT INTO mach VALUES("36","Metal Lathe1","2","Grizzly 11x26 Lathe","1449291042","1","-1"); 154 | INSERT INTO mach VALUES("37","Wood Lathe","5","14\" Wood Lathe","1452439461","1","20151231"); 155 | INSERT INTO mach VALUES("38","Mill1","6","Bridgeport Mill","0","1","-1"); 156 | INSERT INTO mach VALUES("39","Router Table","7","Router Table","1447449270","1","-1"); 157 | INSERT INTO mach VALUES("40","Zenbot","918","CNC Router","1446907055","0","-1"); 158 | INSERT INTO mach VALUES("41","Panel Saw","88","Safety Saw C4 Panel Saw","1449309236","1","-1"); 159 | INSERT INTO mach VALUES("42","Planer","10","15\" Grizzly Planer","0","1","-1"); 160 | INSERT INTO mach VALUES("43","Jointer","11","Grizzly 8\" Jointer","0","1","-1"); 161 | INSERT INTO mach VALUES("44","Front Door","50","Front Door Access","0","1","-1"); 162 | INSERT INTO mach VALUES("45","Tool Room","51","Tool Room Access","0","1","-1"); 163 | INSERT INTO mach VALUES("46","Miter Saw","12","Dewalt SCMS","0","1","-1"); 164 | INSERT INTO mach VALUES("47","Drill Press","3","Drill Press","1455544028","1","20160213"); 165 | INSERT INTO mach VALUES("48","Hitachi CMS","73","Miter saw","1452439639","1","20151231"); 166 | INSERT INTO mach VALUES("49","new","919","new","1448800952","0","-1"); 167 | INSERT INTO mach VALUES("50","Sander","8","Sanders","1449238451","1","-1"); 168 | INSERT INTO mach VALUES("51","Demo","9","Demonstration Unit","1449238644","1","-1"); 169 | 170 | 171 | 172 | DROP TABLE update_available; 173 | 174 | CREATE TABLE `update_available` ( 175 | `id` int(11) NOT NULL AUTO_INCREMENT, 176 | `mach_id` int(11) NOT NULL, 177 | PRIMARY KEY (`id`) 178 | ) ENGINE=InnoDB AUTO_INCREMENT=1476 DEFAULT CHARSET=latin1; 179 | 180 | INSERT INTO update_available VALUES("1416","3"); 181 | INSERT INTO update_available VALUES("1417","4"); 182 | INSERT INTO update_available VALUES("1418","5"); 183 | INSERT INTO update_available VALUES("1419","6"); 184 | INSERT INTO update_available VALUES("1420","7"); 185 | INSERT INTO update_available VALUES("1421","8"); 186 | INSERT INTO update_available VALUES("1422","16"); 187 | INSERT INTO update_available VALUES("1423","17"); 188 | INSERT INTO update_available VALUES("1424","18"); 189 | INSERT INTO update_available VALUES("1425","19"); 190 | INSERT INTO update_available VALUES("1426","20"); 191 | INSERT INTO update_available VALUES("1427","21"); 192 | INSERT INTO update_available VALUES("1428","23"); 193 | INSERT INTO update_available VALUES("1429","26"); 194 | INSERT INTO update_available VALUES("1430","27"); 195 | INSERT INTO update_available VALUES("1431","28"); 196 | INSERT INTO update_available VALUES("1432","29"); 197 | INSERT INTO update_available VALUES("1433","30"); 198 | INSERT INTO update_available VALUES("1434","31"); 199 | INSERT INTO update_available VALUES("1435","32"); 200 | INSERT INTO update_available VALUES("1437","34"); 201 | INSERT INTO update_available VALUES("1442","39"); 202 | INSERT INTO update_available VALUES("1443","40"); 203 | INSERT INTO update_available VALUES("1445","42"); 204 | INSERT INTO update_available VALUES("1446","43"); 205 | INSERT INTO update_available VALUES("1452","49"); 206 | INSERT INTO update_available VALUES("1454","51"); 207 | INSERT INTO update_available VALUES("1460","38"); 208 | INSERT INTO update_available VALUES("1463","45"); 209 | INSERT INTO update_available VALUES("1464","46"); 210 | INSERT INTO update_available VALUES("1465","48"); 211 | INSERT INTO update_available VALUES("1467","35"); 212 | INSERT INTO update_available VALUES("1469","37"); 213 | INSERT INTO update_available VALUES("1470","41"); 214 | INSERT INTO update_available VALUES("1471","44"); 215 | INSERT INTO update_available VALUES("1472","36"); 216 | INSERT INTO update_available VALUES("1473","47"); 217 | INSERT INTO update_available VALUES("1474","50"); 218 | INSERT INTO update_available VALUES("1475","33"); 219 | 220 | 221 | 222 | DROP TABLE user; 223 | 224 | CREATE TABLE `user` ( 225 | `id` int(11) NOT NULL AUTO_INCREMENT, 226 | `name` text NOT NULL, 227 | `login` text NOT NULL, 228 | `hash` text NOT NULL, 229 | `badge_id` text NOT NULL, 230 | `email` text NOT NULL, 231 | `last_seen` int(11) NOT NULL, 232 | `active` int(11) DEFAULT NULL, 233 | PRIMARY KEY (`id`), 234 | UNIQUE KEY `id` (`id`), 235 | KEY `id_2` (`id`) 236 | ) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=latin1; 237 | 238 | INSERT INTO user VALUES("1","Admin1","admin","21232f297a57a5a743894a0e4a801fc3","1234567890","Admin@internet.com","1443690569","1"); 239 | INSERT INTO user VALUES("35","GregR","","d41d8cd98f00b204e9800998ecf8427e","11842381","unknown@X.com","0","1"); 240 | INSERT INTO user VALUES("36","GlenO","","d41d8cd98f00b204e9800998ecf8427e","11859318","unknown@X.com","0","1"); 241 | INSERT INTO user VALUES("37","BlakeB","","d41d8cd98f00b204e9800998ecf8427e","11848282","unknown@X.com","0","1"); 242 | INSERT INTO user VALUES("38","JohnB","","d41d8cd98f00b204e9800998ecf8427e","11856004","unknown@X.com","0","1"); 243 | INSERT INTO user VALUES("39","EliseEb","","d41d8cd98f00b204e9800998ecf8427e","11843996","unknown@X.com","0","1"); 244 | INSERT INTO user VALUES("41","JeanieJ","","d41d8cd98f00b204e9800998ecf8427e","11858220","unknown@X.com","0","1"); 245 | INSERT INTO user VALUES("42","AndrewJ","","d41d8cd98f00b204e9800998ecf8427e","11854380","unknown@X.com","0","1"); 246 | INSERT INTO user VALUES("43","RudM","","d41d8cd98f00b204e9800998ecf8427e","11852054","unknown@X.com","0","1"); 247 | INSERT INTO user VALUES("44","KoljaW","","d41d8cd98f00b204e9800998ecf8427e","2722341","unknown@x.com","0","1"); 248 | INSERT INTO user VALUES("45","KathrynB","","d41d8cd98f00b204e9800998ecf8427e","2722147","unknown@x.com","0","1"); 249 | INSERT INTO user VALUES("46","JessieJ","","d41d8cd98f00b204e9800998ecf8427e","2724893","unknown@x.com","0","1"); 250 | INSERT INTO user VALUES("47","Guest1","","d41d8cd98f00b204e9800998ecf8427e","2728284","unknown@x.com","0","1"); 251 | INSERT INTO user VALUES("48","Guest2","","d41d8cd98f00b204e9800998ecf8427e","2722221","unknown@x.com","0","1"); 252 | INSERT INTO user VALUES("49","Guest3","","d41d8cd98f00b204e9800998ecf8427e","2722614","unknown@x.com","0","1"); 253 | INSERT INTO user VALUES("50","Guest4","","d41d8cd98f00b204e9800998ecf8427e","2744381","unknown@x.com","0","1"); 254 | INSERT INTO user VALUES("51","Guest5","","d41d8cd98f00b204e9800998ecf8427e","2736279","unknown@x.com","0","1"); 255 | 256 | 257 | 258 | DROP TABLE wifi; 259 | 260 | CREATE TABLE `wifi` ( 261 | `id` int(11) NOT NULL, 262 | `ssid` text NOT NULL, 263 | `pw` text NOT NULL, 264 | `type` int(11) NOT NULL 265 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 266 | 267 | INSERT INTO wifi VALUES("0","macs","6215027094","3"); 268 | INSERT INTO wifi VALUES("1","shop","abcdefgh","3"); 269 | INSERT INTO wifi VALUES("2","ajlokert","qweqweqwe","3"); 270 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /db/dummy: -------------------------------------------------------------------------------- 1 | login: admin 2 | pw: admin 3 | -------------------------------------------------------------------------------- /firmware/config.h: -------------------------------------------------------------------------------- 1 | // hardware 2 | #ifndef AKTORS_H_ 3 | #define AKTORS_H_ 4 | 5 | #include "application.h" 6 | #include "log_backup.h" 7 | #include "stdint.h" 8 | #include "led.h" 9 | #include "wifi_login.h" 10 | #include "rest_client.h" 11 | 12 | #define UPDATECARD 1234567890 13 | 14 | #define MAX_JUMPER_PIN 6 // 2^(6+1)-1=127 15 | 16 | #define DB_LED_AND_UPDATE_PIN D0 17 | #define TAG_IN_RANGE_INPUT D1 18 | #define ANTENNA_PIN D2 19 | #define RELAY_PIN D3 20 | #define RED_LED_PIN D4 21 | #define READ_BACK_PIN D5 22 | #define GREEN_LED_PIN D6 23 | 24 | // storage design: valid adresses are 0-2047 25 | // [0..3] key 1 26 | // [4..7] key 2 27 | // ... 28 | // [1908..1911] key 477 29 | // [1912..1915] key 478 30 | 31 | // [1918] SSID of Macs network, max 20 byte 32 | // [1938] key of Macs network, max 20 byte 33 | // [1958] wifi type of Macs network, max 1 byte 34 | // [1959] checksum for information above 35 | 36 | // [1960] SSID of FIRST update network, max 20 byte 37 | // [1980] key of FIRST update network, max 20 byte 38 | // [2000] wifi type of FIRST update network, max 1 byte 39 | // [2001] checksum for information above 40 | 41 | // [2002] SSID of BACKUP update network, max 20 byte 42 | // [2022] key of BACKUP update network, max 20 byte 43 | // [2042] wifi type of BACKUP update network, max 1 byte 44 | // [2043] checksum for information above 45 | 46 | // [2044,2045] total number of keys 47 | // [2046,2047] key number check (key number+1) 48 | 49 | #define MAX_KEYS 478 // max number of keys, total nr +1 = 479 50 | #define TAGSTRINGSIZE 5 // tag length 51 | #define EEPROM_MAX 2047 // hw limit 52 | #define START_WIFI_MACS 1918 53 | #define START_WIFI_UPDATE_1 1960 54 | #define START_WIFI_UPDATE_2 2002 55 | #define KEY_NUM_EEPROM_HIGH KEY_NUM_EEPROM_LOW-1 56 | #define KEY_NUM_EEPROM_LOW KEY_CHECK_EEPROM_HIGH-1 57 | #define KEY_CHECK_EEPROM_HIGH KEY_CHECK_EEPROM_LOW-1 58 | #define KEY_CHECK_EEPROM_LOW EEPROM_MAX 59 | #define WIFI_MACS 0 60 | #define WIFI_UPDATE_1 1 61 | #define WIFI_UPDATE_2 2 62 | #define UPDATE 1 63 | 64 | // macros 65 | #define RELAY_CONNECTED 1 66 | #define RELAY_DISCONNECTED 0 67 | 68 | #define LOG_RELAY_CONNECTED 1 69 | #define LOG_RELAY_DISCONNECTED 2 70 | #define LOG_LOGIN_REJECTED 3 71 | #define LOG_NOTHING 4 72 | 73 | // debug 74 | //#define DEBUG_JKW 1 75 | //#define DEBUG_JKW_MAIN 1 76 | //#define LOGGING // rest client 77 | //#define DEBUG_JKW_LED 1 78 | //#define DEBUG_JKW_WIFI 1 79 | 80 | // settings 81 | #define DB_UPDATE_TIME 10*60 // seconds between two auto updates from the server 82 | #define MIN_UPDATE_TIME 30 // seconds between two database request, to avoid flooding, remember this has to be smaller then db_update_time 83 | #define RED_LED_DELAY 1000 // ms 84 | #define GREEN_LED_DELAY 1000 // ms 85 | #define DB_LED_DELAY 1000 // ms 86 | #define SEC_WAIT_BOOTUP 5 // 5sec of led toggling to show that we are starting 87 | 88 | // network 89 | #define HOSTPORT 80 90 | 91 | uint8_t get_my_id(); 92 | bool fire_report(uint8_t event,uint32_t badge,uint32_t extrainfo); 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /firmware/led.cpp: -------------------------------------------------------------------------------- 1 | #include "stdint.h" 2 | #include "application.h" 3 | #include "config.h" 4 | 5 | LED::LED(uint8_t pin,uint16_t delay, uint8_t weak, uint8_t inverse){ 6 | m_pin=pin; 7 | m_delay=delay; 8 | m_weak=weak; 9 | m_state=OFF; 10 | m_inverse=inverse; 11 | 12 | m_state=OFF; 13 | m_next_action=0; 14 | 15 | clear(); 16 | }; 17 | 18 | void LED::clear(){ 19 | for(int i=0;i0;i--){ 33 | m_mode[i]=m_mode[i-1]; 34 | } 35 | m_mode[0]=DELAYED_ON; 36 | 37 | hw_on(); 38 | m_next_action=millis()+m_delay; 39 | }; 40 | 41 | // invert LED 42 | void LED::toggle(){ 43 | if(m_state==OFF){ 44 | hw_on(); 45 | } else { 46 | hw_off(); 47 | } 48 | } 49 | 50 | 51 | // standard "on()" should save the old mode of the LED, so call with with remember 52 | void LED::on(){ 53 | #ifdef DEBUG_JKW_LED 54 | Serial.print("Swtich led "); 55 | Serial.print(m_pin); 56 | Serial.println(" on"); 57 | #endif 58 | 59 | // mode saving 60 | for(int i=MAX_MODE_HIST-1;i>0;i--){ 61 | m_mode[i]=m_mode[i-1]; 62 | } 63 | m_mode[0]=ON; 64 | 65 | hw_on(); 66 | m_next_action=0; 67 | } 68 | 69 | 70 | void LED::hw_on(){ 71 | // just change it if we haven't been in that state anyway 72 | if(m_state!=ON){ 73 | if(!m_inverse){ 74 | // not-invertet is tricky, is it pullup or HIGH? 75 | if(m_weak){ 76 | pinMode(m_pin,INPUT_PULLUP); 77 | } else { 78 | pinMode(m_pin,OUTPUT); 79 | digitalWrite(m_pin,1); 80 | }; 81 | } else { 82 | // invertet is straight GND 83 | pinMode(m_pin,OUTPUT); 84 | digitalWrite(m_pin,0); 85 | } 86 | m_state=ON; 87 | }; 88 | } 89 | 90 | void LED::off(){ 91 | #ifdef DEBUG_JKW_LED 92 | Serial.print("Swtich led "); 93 | Serial.print(m_pin); 94 | Serial.println(" to off"); 95 | #endif 96 | 97 | // save the state 98 | for(int i=MAX_MODE_HIST-1;i>0;i--){ 99 | m_mode[i]=m_mode[i-1]; 100 | } 101 | m_mode[0]=OFF; 102 | 103 | hw_off(); 104 | m_next_action=0; 105 | } 106 | 107 | void LED::hw_off(){ 108 | // only call it if needed 109 | if(m_state!=OFF){ 110 | if(!m_inverse){ 111 | // off without inversion is straight GND 112 | pinMode(m_pin,OUTPUT); 113 | digitalWrite(m_pin,0); 114 | } else { 115 | // invertet is tricky, is it pullup or HIGH? 116 | if(m_weak){ 117 | pinMode(m_pin,INPUT_PULLUP); 118 | } else { 119 | pinMode(m_pin,OUTPUT); 120 | digitalWrite(m_pin,1); 121 | }; 122 | } 123 | m_state=OFF; 124 | }; 125 | }; 126 | 127 | 128 | void LED::check(){ 129 | if(m_next_action!=0 && millis()>m_next_action){ 130 | if(m_mode[0]==BLINK){ 131 | toggle(); 132 | m_next_action=millis()+BLINK_DELAY; 133 | } else if(m_mode[0]==DELAYED_ON) { 134 | resume(); 135 | }; 136 | }; 137 | }; 138 | 139 | 140 | void LED::blink(){ 141 | #ifdef DEBUG_JKW_LED 142 | Serial.print("Swtich led "); 143 | Serial.print(m_pin); 144 | Serial.println(" to blink"); 145 | #endif 146 | 147 | for(int i=MAX_MODE_HIST-1;i>0;i--){ 148 | m_mode[i]=m_mode[i-1]; 149 | } 150 | m_mode[0]=BLINK; 151 | 152 | 153 | m_next_action=millis()-1; 154 | check(); 155 | } 156 | 157 | void LED::resume(){ 158 | #ifdef DEBUG_JKW_LED 159 | Serial.print("resume led "); 160 | Serial.println(m_pin); 161 | #endif 162 | 163 | 164 | for(int i=0;i0){ 18 | return true; 19 | } 20 | return false; 21 | } 22 | 23 | uint8_t BACKUP::get(uint8_t *event,uint32_t *badge,uint32_t *extrainfo){ 24 | if(m_position>0){ 25 | *event=m_event[m_position-1]; 26 | *badge=m_badge[m_position-1]; 27 | *extrainfo=m_extrainfo[m_position-1]; 28 | return (m_position-1); 29 | } 30 | return -1; 31 | } 32 | 33 | void BACKUP::rem(uint8_t pos){ 34 | if(pos==m_position-1){ 35 | m_position--; 36 | } else if(pos>m_position){ 37 | return; 38 | } // else move all entries ... 39 | } 40 | 41 | void BACKUP::try_fire(){ 42 | bool run=true; 43 | while(has_backups() && run){ 44 | uint8_t event; 45 | uint32_t badge; 46 | uint32_t extrainfo; 47 | uint8_t pos; 48 | 49 | pos=get(&event,&badge,&extrainfo); 50 | if(fire_report(event, badge, extrainfo)){ 51 | rem(pos); 52 | } else { 53 | run=false; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /firmware/log_backup.h: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #define BACKUP_MAX 50 3 | 4 | 5 | class BACKUP 6 | { 7 | private: 8 | uint8_t m_event[BACKUP_MAX]; 9 | uint32_t m_badge[BACKUP_MAX]; 10 | uint32_t m_extrainfo[BACKUP_MAX]; 11 | uint8_t m_position; 12 | 13 | public: 14 | BACKUP(); 15 | uint8_t add(uint8_t event,uint32_t badge,uint32_t extrainfo); 16 | uint8_t get(uint8_t *event,uint32_t *badge,uint32_t *extrainfo); 17 | bool has_backups(); 18 | void rem(uint8_t pos); 19 | void try_fire(); 20 | }; 21 | -------------------------------------------------------------------------------- /firmware/rest_client.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | static const uint16_t TIMEOUT = 5000; // Allow maximum 5s between data packets. 4 | 5 | /** 6 | * Constructor. 7 | */ 8 | HttpClient::HttpClient() 9 | { 10 | 11 | } 12 | 13 | /** 14 | * Method to send a header, should only be called from within the class. 15 | */ 16 | void HttpClient::sendHeader(const char* aHeaderName, const char* aHeaderValue) 17 | { 18 | client.print(aHeaderName); 19 | client.print(": "); 20 | client.println(aHeaderValue); 21 | 22 | #ifdef LOGGING 23 | Serial1.print(aHeaderName); 24 | Serial1.print(": "); 25 | Serial1.println(aHeaderValue); 26 | #endif 27 | } 28 | 29 | void HttpClient::sendHeader(const char* aHeaderName, const int aHeaderValue) 30 | { 31 | client.print(aHeaderName); 32 | client.print(": "); 33 | client.println(aHeaderValue); 34 | 35 | #ifdef LOGGING 36 | Serial1.print(aHeaderName); 37 | Serial1.print(": "); 38 | Serial1.println(aHeaderValue); 39 | #endif 40 | } 41 | 42 | void HttpClient::sendHeader(const char* aHeaderName) 43 | { 44 | client.println(aHeaderName); 45 | 46 | #ifdef LOGGING 47 | Serial1.println(aHeaderName); 48 | #endif 49 | } 50 | 51 | /** 52 | * Method to send an HTTP Request. Allocate variables in your application code 53 | * in the aResponse struct and set the headers and the options in the aRequest 54 | * struct. 55 | */ 56 | void HttpClient::request(http_request_t &aRequest, http_response_t &aResponse, http_header_t headers[], const char* aHttpMethod) 57 | { 58 | // If a proper response code isn't received it will be set to -1. 59 | aResponse.status = -1; 60 | 61 | // NOTE: The default port tertiary statement is unpredictable if the request structure is not initialised 62 | // http_request_t request = {0} or memset(&request, 0, sizeof(http_request_t)) should be used 63 | // to ensure all fields are zero 64 | bool connected = false; 65 | if(aRequest.hostname!=NULL) { 66 | Serial1.print("HttpClient>\tConnecting to: "); 67 | Serial1.print(aRequest.hostname); 68 | 69 | connected = client.connect(aRequest.hostname.c_str(), (aRequest.port) ? aRequest.port : 80 ); 70 | } else { 71 | 72 | Serial1.print("HttpClient>\tConnecting to ip: "); 73 | Serial1.print(aRequest.ip); 74 | Serial1.print(" port "); 75 | Serial1.println(aRequest.port); 76 | 77 | connected = client.connect(aRequest.ip, aRequest.port); 78 | } 79 | 80 | #ifdef LOGGING 81 | if (connected) { 82 | if(aRequest.hostname!=NULL) { 83 | Serial1.print("HttpClient>\tConnecting to: "); 84 | Serial1.print(aRequest.hostname); 85 | } else { 86 | Serial1.print("HttpClient>\tConnecting to IP: "); 87 | Serial1.print(aRequest.ip); 88 | } 89 | Serial1.print(":"); 90 | Serial1.println(aRequest.port); 91 | } else { 92 | Serial1.println("HttpClient>\tConnection failed."); 93 | } 94 | #endif 95 | 96 | if (!connected) { 97 | client.stop(); 98 | // If TCP Client can't connect to host, exit here. 99 | return; 100 | } 101 | 102 | // 103 | // Send HTTP Headers 104 | // 105 | 106 | // Send initial headers (only HTTP 1.0 is supported for now). 107 | client.print(aHttpMethod); 108 | client.print(" "); 109 | client.print(aRequest.path); 110 | client.print(" HTTP/1.0\r\n"); 111 | 112 | #ifdef LOGGING 113 | Serial1.println("HttpClient>\tStart of HTTP Request."); 114 | Serial1.print(aHttpMethod); 115 | Serial1.print(" "); 116 | Serial1.print(aRequest.path); 117 | Serial1.print(" HTTP/1.0\r\n"); 118 | #endif 119 | 120 | // Send General and Request Headers. 121 | sendHeader("Connection", "close"); // Not supporting keep-alive for now. 122 | if(aRequest.hostname!=NULL) { 123 | sendHeader("HOST", aRequest.hostname.c_str()); 124 | } 125 | 126 | //Send Entity Headers 127 | // TODO: Check the standard, currently sending Content-Length : 0 for empty 128 | // POST requests, and no content-length for other types. 129 | if (aRequest.body != NULL) { 130 | sendHeader("Content-Length", (aRequest.body).length()); 131 | } else if (strcmp(aHttpMethod, HTTP_METHOD_POST) == 0) { //Check to see if its a Post method. 132 | sendHeader("Content-Length", 0); 133 | } 134 | 135 | if (headers != NULL) 136 | { 137 | int i = 0; 138 | while (headers[i].header != NULL) 139 | { 140 | if (headers[i].value != NULL) { 141 | sendHeader(headers[i].header, headers[i].value); 142 | } else { 143 | sendHeader(headers[i].header); 144 | } 145 | i++; 146 | } 147 | } 148 | 149 | // Empty line to finish headers 150 | client.println(); 151 | client.flush(); 152 | 153 | // 154 | // Send HTTP Request Body 155 | // 156 | 157 | if (aRequest.body != NULL) { 158 | client.println(aRequest.body); 159 | 160 | #ifdef LOGGING 161 | Serial1.println(aRequest.body); 162 | #endif 163 | } 164 | 165 | #ifdef LOGGING 166 | Serial1.println("HttpClient>\tEnd of HTTP Request."); 167 | #endif 168 | 169 | // clear response buffer 170 | memset(&buffer[0], 0, sizeof(buffer)); 171 | 172 | 173 | // 174 | // Receive HTTP Response 175 | // 176 | // The first value of client.available() might not represent the 177 | // whole response, so after the first chunk of data is received instead 178 | // of terminating the connection there is a delay and another attempt 179 | // to read data. 180 | // The loop exits when the connection is closed, or if there is a 181 | // timeout or an error. 182 | 183 | unsigned int bufferPosition = 0; 184 | unsigned long lastRead = millis(); 185 | unsigned long firstRead = millis(); 186 | bool error = false; 187 | bool timeout = false; 188 | 189 | do { 190 | #ifdef LOGGING 191 | int bytes = client.available(); 192 | if(bytes) { 193 | Serial1.print("\r\nHttpClient>\tReceiving TCP transaction of "); 194 | Serial1.print(bytes); 195 | Serial1.println(" bytes."); 196 | } 197 | #endif 198 | 199 | while (client.available()) { 200 | char c = client.read(); 201 | #ifdef LOGGING 202 | Serial1.print(c); 203 | #endif 204 | lastRead = millis(); 205 | 206 | if (c == -1) { 207 | error = true; 208 | 209 | #ifdef LOGGING 210 | Serial1.println("HttpClient>\tError: No data available."); 211 | #endif 212 | 213 | break; 214 | } 215 | 216 | // Check that received character fits in buffer before storing. 217 | if (bufferPosition < sizeof(buffer)-1) { 218 | buffer[bufferPosition] = c; 219 | } else if ((bufferPosition == sizeof(buffer)-1)) { 220 | buffer[bufferPosition] = '\0'; // Null-terminate buffer 221 | client.stop(); 222 | error = true; 223 | 224 | #ifdef LOGGING 225 | Serial1.println("HttpClient>\tError: Response body larger than buffer."); 226 | #endif 227 | } 228 | bufferPosition++; 229 | } 230 | buffer[bufferPosition] = '\0'; // Null-terminate buffer 231 | 232 | #ifdef LOGGING 233 | if (bytes) { 234 | Serial1.print("\r\nHttpClient>\tEnd of TCP transaction."); 235 | } 236 | #endif 237 | 238 | // Check that there hasn't been more than 5s since last read. 239 | timeout = millis() - lastRead > TIMEOUT; 240 | 241 | // Unless there has been an error or timeout wait 200ms to allow server 242 | // to respond or close connection. 243 | if (!error && !timeout) { 244 | delay(200); 245 | } 246 | } while (client.connected() && !timeout && !error); 247 | 248 | #ifdef LOGGING 249 | if (timeout) { 250 | Serial1.println("\r\nHttpClient>\tError: Timeout while reading response."); 251 | } 252 | Serial1.print("\r\nHttpClient>\tEnd of HTTP Response ("); 253 | Serial1.print(millis() - firstRead); 254 | Serial1.println("ms)."); 255 | #endif 256 | client.stop(); 257 | 258 | String raw_response(buffer); 259 | 260 | // Not super elegant way of finding the status code, but it works. 261 | String statusCode = raw_response.substring(9,12); 262 | 263 | #ifdef LOGGING 264 | Serial1.print("HttpClient>\tStatus Code: "); 265 | Serial1.println(statusCode); 266 | #endif 267 | 268 | int bodyPos = raw_response.indexOf("\r\n\r\n"); 269 | if (bodyPos == -1) { 270 | #ifdef LOGGING 271 | Serial1.println("HttpClient>\tError: Can't find HTTP response body."); 272 | #endif 273 | 274 | return; 275 | } 276 | // Return the entire message body from bodyPos+4 till end. 277 | aResponse.body = ""; 278 | aResponse.body += raw_response.substring(bodyPos+4); 279 | aResponse.status = atoi(statusCode.c_str()); 280 | } 281 | 282 | -------------------------------------------------------------------------------- /firmware/rest_client.h: -------------------------------------------------------------------------------- 1 | #ifndef __HTTP_CLIENT_H_ 2 | #define __HTTP_CLIENT_H_ 3 | 4 | #include "application.h" 5 | #include "spark_wiring_string.h" 6 | #include "spark_wiring_tcpclient.h" 7 | #include "spark_wiring_usbserial.h" 8 | 9 | /** 10 | * Defines for the HTTP methods. 11 | */ 12 | static const char* HTTP_METHOD_GET = "GET"; 13 | static const char* HTTP_METHOD_POST = "POST"; 14 | static const char* HTTP_METHOD_PUT = "PUT"; 15 | static const char* HTTP_METHOD_DELETE = "DELETE"; 16 | static const char* HTTP_METHOD_PATCH = "PATCH"; 17 | 18 | /** 19 | * This struct is used to pass additional HTTP headers such as API-keys. 20 | * Normally you pass this as an array. The last entry must have NULL as key. 21 | */ 22 | typedef struct 23 | { 24 | const char* header; 25 | const char* value; 26 | } http_header_t; 27 | 28 | /** 29 | * HTTP Request struct. 30 | * hostname request host 31 | * path request path 32 | * port request port 33 | * body request body 34 | */ 35 | typedef struct 36 | { 37 | String hostname; 38 | IPAddress ip; 39 | String path; 40 | // TODO: Look at setting the port by default. 41 | //int port = 80; 42 | int port; 43 | String body; 44 | } http_request_t; 45 | 46 | /** 47 | * HTTP Response struct. 48 | * status response status code. 49 | * body response body 50 | */ 51 | typedef struct 52 | { 53 | int status; 54 | String body; 55 | } http_response_t; 56 | 57 | class HttpClient { 58 | public: 59 | /** 60 | * Public references to variables. 61 | */ 62 | TCPClient client; 63 | char buffer[1024]; 64 | 65 | /** 66 | * Constructor. 67 | */ 68 | HttpClient(void); 69 | 70 | /** 71 | * HTTP request methods. 72 | * Can't use 'delete' as name since it's a C++ keyword. 73 | */ 74 | void get(http_request_t &aRequest, http_response_t &aResponse) 75 | { 76 | request(aRequest, aResponse, (http_header_t*)NULL, HTTP_METHOD_GET); 77 | } 78 | 79 | void post(http_request_t &aRequest, http_response_t &aResponse) 80 | { 81 | request(aRequest, aResponse, (http_header_t*)NULL, HTTP_METHOD_POST); 82 | } 83 | 84 | void put(http_request_t &aRequest, http_response_t &aResponse) 85 | { 86 | request(aRequest, aResponse, (http_header_t*)NULL, HTTP_METHOD_PUT); 87 | } 88 | 89 | void del(http_request_t &aRequest, http_response_t &aResponse) 90 | { 91 | request(aRequest, aResponse, (http_header_t*)NULL, HTTP_METHOD_DELETE); 92 | } 93 | 94 | void get(http_request_t &aRequest, http_response_t &aResponse, http_header_t headers[]) 95 | { 96 | request(aRequest, aResponse, headers, HTTP_METHOD_GET); 97 | } 98 | 99 | void post(http_request_t &aRequest, http_response_t &aResponse, http_header_t headers[]) 100 | { 101 | request(aRequest, aResponse, headers, HTTP_METHOD_POST); 102 | } 103 | 104 | void put(http_request_t &aRequest, http_response_t &aResponse, http_header_t headers[]) 105 | { 106 | request(aRequest, aResponse, headers, HTTP_METHOD_PUT); 107 | } 108 | 109 | void del(http_request_t &aRequest, http_response_t &aResponse, http_header_t headers[]) 110 | { 111 | request(aRequest, aResponse, headers, HTTP_METHOD_DELETE); 112 | } 113 | 114 | void patch(http_request_t &aRequest, http_response_t &aResponse, http_header_t headers[]) 115 | { 116 | request(aRequest, aResponse, headers, HTTP_METHOD_PATCH); 117 | } 118 | 119 | private: 120 | /** 121 | * Underlying HTTP methods. 122 | */ 123 | void request(http_request_t &aRequest, http_response_t &aResponse, http_header_t headers[], const char* aHttpMethod); 124 | void sendHeader(const char* aHeaderName, const char* aHeaderValue); 125 | void sendHeader(const char* aHeaderName, const int aHeaderValue); 126 | void sendHeader(const char* aHeaderName); 127 | }; 128 | 129 | #endif /* __HTTP_CLIENT_H_ */ 130 | 131 | -------------------------------------------------------------------------------- /firmware/wifi_login.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "application.h" 3 | #include "stdint.h" 4 | #include "config.h" 5 | 6 | class FindSSID 7 | { 8 | char *SSID_to_search; 9 | bool found; 10 | LED *m_green; 11 | LED *m_red; 12 | // This is the callback passed to WiFi.scan() 13 | // It makes the call on the `self` instance - to go from a static 14 | // member function to an instance member function. 15 | static void handle_ap(WiFiAccessPoint* wap, FindSSID* self){ 16 | self->next(*wap); 17 | } 18 | 19 | // determine if this AP is stronger than the strongest seen so far 20 | void next(WiFiAccessPoint& ap) 21 | { 22 | m_green->toggle(); 23 | m_red->toggle(); 24 | 25 | #ifdef DEBUG_JKW_WIFI 26 | //Serial.print("found "); 27 | //Serial.println(ap.ssid); 28 | //delay(1000); 29 | #endif 30 | 31 | if(strcmp(ap.ssid,SSID_to_search)==0){ 32 | #ifdef DEBUG_JKW_WIFI 33 | Serial.print("found "); 34 | Serial.println(SSID_to_search); 35 | delay(100); 36 | #endif 37 | found=true; 38 | } 39 | } 40 | 41 | public: 42 | /** 43 | * Scan WiFi Access Points and retrieve the strongest one. 44 | */ 45 | bool check_SSID_in_range(char *SSID, LED *green, LED *red) 46 | { 47 | #ifdef DEBUG_JKW_WIFI 48 | //Serial.print("check SSID for "); 49 | //Serial.println(SSID); 50 | #endif 51 | // initialize data 52 | found = false; 53 | SSID_to_search = SSID; 54 | m_green = green; 55 | m_red = red; 56 | 57 | // avoid scanning for invaid data 58 | if(strlen(SSID)==0){ 59 | return false; 60 | } 61 | 62 | WiFi.scan(handle_ap,this); 63 | // perform the scan# 64 | #ifdef DEBUG_JKW_WIFI 65 | //Serial.println("EOS!!!!"); 66 | #endif 67 | return found; 68 | } 69 | }; 70 | 71 | 72 | // set the config for the update mode 73 | // if the jumper is in position this function will be called in a loop until we return true 74 | // our steps are: 75 | // 1. Clear all old wifi credentials to avoid connecting back to the MACS operational network 76 | // 2. Load data set 1 from EEPROM 77 | // 3. Run the SSID finder for this config, they will return true if SSID in scan results 78 | // 4. set the credentials 79 | // 4.1. if this fails, try config 2 (backup) 80 | // 5. if we don't set any credentials: give the user 10 sec to add some wifis via serial 81 | // 6. assuming we've set credentials, we'll return true, otherwise false and come back in a second 82 | bool set_update_login(LED *green, LED *red){ 83 | return set_login(green, red, UPDATE); 84 | } 85 | 86 | bool set_macs_login(LED *green, LED *red){ 87 | return set_login(green, red, !UPDATE); 88 | } 89 | 90 | bool set_login(LED *green, LED *red, uint8_t mode){ 91 | // ... ok ... complicated 92 | // 93 | // if we have a blank device this will happen: 94 | // 1. Both LEDs will toggle for 10sec (saving WiFi credentials (not applicable here) or waiting for input) 95 | // 96 | // if we have a config that is OUT of reach: 97 | // 1. (MACS=Both LEDs)/(UPDATE1=green LED)/(UPDATE2=red LED) will flash 3x (MACS=simultaneously) to show that the config has been read 98 | // 2. Green off, red on will show the start of the WiFi scanning 99 | // 3. per WiFi that has been found the green and red will toggle, just to show activity 100 | // 4. Both LEDs are switched off 101 | // 5. Both LEDs will toggle for 10sec (saving WiFi credentials (not applicable here) or waiting for input) 20Hz 102 | // 103 | // if we have a config that is IN reach: 104 | // 1. (MACS=Both LEDs)/(UPDATE1=green LED)/(UPDATE2=red LED) will flash 3x (MACS=simultaneously) to show that the config has been read 105 | // 2. Green off, red on will show the start of the WiFi scanning 106 | // 3. per WiFi that has been found the green and red will toggle, just to show activity 107 | // 4. Both LEDs are switched off 108 | // 5. (MACS=Both LEDs)/(UPDATE1=green LED)/(UPDATE2=red LED) will toggle 5x (WiFi found) 10Hz 109 | // 6. Both LEDs will toggle for 10sec or until WiFi data are saved (saving WiFi credentials or waiting for input) 20Hz 110 | // 7. (MACS=Both LEDs)/(UPDATE1=green LED)/(UPDATE2=red LED) will toggle 2x (WiFi connected) 10Hz 111 | // 112 | 113 | String pw; 114 | String SSID; 115 | int type; 116 | char SSID_char[20]; 117 | bool try_backup=true; 118 | uint8_t wifi_offset; 119 | uint8_t max_loop; 120 | LED *visual_indicator[2]={green,red}; 121 | FindSSID ssidFinder; 122 | uint8_t config; 123 | 124 | WiFi.off(); 125 | WiFi.on(); 126 | WiFi.clearCredentials(); 127 | 128 | // start with both LED's off 129 | visual_indicator[0]->off(); 130 | visual_indicator[1]->off(); 131 | 132 | // prepare loop 133 | if(mode==UPDATE){ // in update mode we'll try both configs, WIFI_UPDATE_1 and WIFI_UPDATE_2 134 | max_loop=2; 135 | wifi_offset=WIFI_UPDATE_1; 136 | } else { // in macs mode we'll just try WIFI_MACS 137 | max_loop=1; 138 | wifi_offset=WIFI_MACS; 139 | } 140 | 141 | for(config=0; config < max_loop; config++){ 142 | if(get_wifi_config(wifi_offset+config,&SSID,&pw,&type)){ 143 | // flash 3x green/red to show that I've found a valid WLAN config in EEPROM 144 | for(int i=0;i<2*3; i++){ 145 | if(mode!=UPDATE){ // MACS mode, toggle both 146 | visual_indicator[0]->toggle(); 147 | visual_indicator[1]->toggle(); 148 | } else { // UPDATE mode, toggle just one 149 | visual_indicator[config]->toggle(); 150 | } 151 | delay(100); 152 | } 153 | delay(1000); 154 | 155 | // now switch to a configuration with one LED on, because well toggle both in the ssidFinder 156 | visual_indicator[0]->off(); 157 | visual_indicator[1]->on(); 158 | 159 | SSID.toCharArray(SSID_char,20); 160 | if(ssidFinder.check_SSID_in_range(SSID_char,green,red)){ 161 | // flash 5x green to show that I've found the WLAN and try to connect now 162 | visual_indicator[0]->off(); 163 | visual_indicator[1]->off(); 164 | delay(1000); 165 | for(int i=0;i<2*5; i++){ 166 | if(mode!=UPDATE){ // MACS mode, toggle both 167 | visual_indicator[0]->toggle(); 168 | visual_indicator[1]->toggle(); 169 | } else { // UPDATE mode, toggle just one 170 | visual_indicator[config]->toggle(); 171 | } 172 | delay(100); 173 | } 174 | //try_backup=false; 175 | //Serial.println("setting crededentials"); 176 | //Serial.println(SSID[0]); 177 | WiFi.setCredentials(SSID, pw, type); 178 | break; 179 | }; 180 | delay(1000); 181 | // end with both off, we should have a clean start if we have to loop 182 | visual_indicator[0]->off(); 183 | visual_indicator[1]->off(); 184 | }; 185 | }; 186 | 187 | // start with both off, to show a pattern, different from scanning 188 | visual_indicator[0]->off(); 189 | visual_indicator[1]->off(); 190 | for(int i=0; i<200 && !WiFi.hasCredentials(); i++){ 191 | // take new info 192 | parse_wifi(); 193 | // set info 194 | delay(50); 195 | visual_indicator[0]->toggle(); 196 | visual_indicator[1]->toggle(); 197 | } 198 | 199 | visual_indicator[0]->off(); 200 | visual_indicator[1]->off(); 201 | if(WiFi.hasCredentials()){ 202 | // set IP 203 | if(mode!=UPDATE){ 204 | IPAddress myAddress(192,168,188,100+get_my_id()); 205 | IPAddress netmask(255,255,255,0); 206 | IPAddress gateway(192,168,188,254); 207 | IPAddress dns(192,168,188,254); 208 | WiFi.setStaticIP(myAddress, netmask, gateway, dns); 209 | 210 | // now let's use the configured IP 211 | WiFi.useStaticIP(); 212 | } else { 213 | WiFi.useDynamicIP(); 214 | } 215 | 216 | // finally connect 217 | WiFi.connect(WIFI_CONNECT_SKIP_LISTEN); 218 | int i=0; 219 | while(i<200 && !WiFi.ready()){ 220 | delay(50); // wait 59 221 | i++; 222 | } 223 | 224 | //Serial.println("return true"); 225 | for(int i=0;i<2*2; i++){ 226 | if(mode!=UPDATE){ // MACS mode, toggle both 227 | visual_indicator[0]->toggle(); 228 | visual_indicator[1]->toggle(); 229 | } else { // UPDATE mode, toggle just one 230 | visual_indicator[config]->toggle(); 231 | } 232 | delay(100); 233 | } 234 | visual_indicator[0]->off(); 235 | visual_indicator[1]->off(); 236 | return true; 237 | } 238 | 239 | visual_indicator[0]->off(); 240 | visual_indicator[1]->off(); 241 | return false; 242 | } 243 | 244 | bool is_wifi_connected(){ 245 | IPAddress dns(192,168,188,254); 246 | if(WiFi.ping(dns,1)>0){ 247 | return true; 248 | } else { 249 | if(WiFi.ping(dns,1)>0){ 250 | return true; 251 | } else { 252 | if(WiFi.ping(dns,1)>0){ 253 | return true; 254 | } 255 | } 256 | } 257 | return false; 258 | }; 259 | 260 | 261 | // read data from EEPROM, check them and set them if the check is passed 262 | bool get_wifi_config(uint8_t id, String *_SSID, String *_pw, int *_type){ 263 | Serial1.println("get wifi config!!"); 264 | uint16_t data_start=0; 265 | if(id==WIFI_MACS){ 266 | data_start=START_WIFI_MACS; 267 | } else if(id==WIFI_UPDATE_1){ 268 | data_start=START_WIFI_UPDATE_1; 269 | } else if(id==WIFI_UPDATE_2){ 270 | data_start=START_WIFI_UPDATE_2; 271 | } else { 272 | #ifdef DEBUG_JKW_WIFI 273 | Serial.println("set wifi unknown id"); 274 | #endif 275 | return false; 276 | } 277 | 278 | uint8_t SSID[21]; 279 | uint8_t pw[21]; 280 | uint8_t type=0x00; 281 | uint8_t chk=0x00; 282 | uint8_t read_char=0x00; 283 | uint8_t p=0x00; 284 | 285 | // read ssid 286 | bool all_FF=true; 287 | read_char=0x01; // avoid instand stop 288 | for(uint8_t i=0; i<20 && read_char!=0x00; i++){ 289 | read_char=EEPROM.read(data_start+i); 290 | SSID[i]=read_char; 291 | p=i; 292 | 293 | if(read_char!=0xFF){ 294 | all_FF=false; 295 | } 296 | } 297 | 298 | SSID[p+1]=0x00; 299 | 300 | // read pw 301 | read_char=0x01; // avoid instand stop 302 | for(uint8_t i=0; i<20 && read_char!=0x00; i++){ 303 | read_char=EEPROM.read(data_start+i+20); 304 | pw[i]=read_char; 305 | p=i; 306 | } 307 | pw[p+1]=0x00; 308 | 309 | type=EEPROM.read(data_start+40); 310 | chk=EEPROM.read(data_start+41); 311 | 312 | 313 | // a bug in the system can erase all EEPROM info. 314 | // it is connected to a brown out situation 315 | // in this case the hole eeprom page is 0xFF 316 | // the only thing we can do is to return the default 317 | // wifi config, which we'll do below 318 | if(all_FF){ 319 | //#ifdef DEBUG_JKW_WIFI 320 | //Serial.println("invalid wifi data FF"); 321 | //#endif 322 | Serial1.println("invalid wifi data FF"); 323 | //return false; 324 | 325 | memset(SSID,0x00,21); 326 | memset(pw,0x00,21); 327 | 328 | if(id==WIFI_MACS){ 329 | memcpy(SSID,"macs",4); 330 | memcpy(pw,"6215027094",10); 331 | type=3; // wpa2 332 | chk=0x17; 333 | } else if(id==WIFI_UPDATE_1){ 334 | memcpy(SSID,"ajlokert",8); 335 | memcpy(pw,"qweqweqwe",9); 336 | type=3; // wpa2 337 | chk=0x60; 338 | } else if(id==WIFI_UPDATE_2){ 339 | memcpy(SSID,"shop",4); 340 | memcpy(pw,"abcdefgh",8); 341 | type=2; // WPA 342 | chk=0x0E; 343 | } 344 | } 345 | 346 | //#ifdef DEBUG_JKW_WIFI 347 | //Serial.println("set wifi, data:"); 348 | //Serial.print("SSID:"); 349 | //Serial.print((const char*)SSID); 350 | //Serial.println("."); 351 | //delay(1000); 352 | //Serial.print("PW:"); 353 | //Serial.print((const char*)pw); 354 | //Serial.println("."); 355 | //delay(1000); 356 | //Serial.print("type:"); 357 | //Serial.print(type+'0'); 358 | //Serial.println("."); 359 | //delay(1000); 360 | //Serial.print("chk:"); 361 | //Serial.print(chk); 362 | //Serial.println("."); 363 | //delay(1000); 364 | //#endif 365 | Serial1.println("set wifi, data:"); 366 | Serial1.print("SSID:"); 367 | Serial1.print((const char*)SSID); 368 | Serial1.println("."); 369 | delay(1000); 370 | Serial1.print("PW:"); 371 | Serial1.print((const char*)pw); 372 | Serial1.println("."); 373 | delay(1000); 374 | Serial1.print("type:"); 375 | Serial1.print(type+'0'); 376 | Serial1.println("."); 377 | delay(1000); 378 | Serial1.print("chk:"); 379 | Serial1.print(chk); 380 | Serial1.println("."); 381 | delay(1000); 382 | 383 | if(!check_wifi_config((const char*)SSID,(const char*)pw,type,chk)){ 384 | 385 | //#ifdef DEBUG_JKW_WIFI 386 | //Serial.println("set wifi, data invalid"); 387 | //#endif 388 | Serial1.println("set wifi, data invalid"); 389 | *_SSID=""; 390 | *_pw=""; 391 | *_type=0; 392 | 393 | return false; 394 | } 395 | 396 | *_SSID=(const char*)SSID; 397 | *_pw=(const char*)pw; 398 | *_type=type; 399 | //WiFi.setCredentials((const char*)SSID, (const char*)pw, type); 400 | 401 | return true; 402 | } 403 | 404 | // checks if the data from the given configuration is valid 405 | bool check_wifi_config(String SSID,String pw,uint8_t type,uint8_t chk){ 406 | uint8_t checksum=0x00; 407 | for(uint8_t i=0;i20 || pw.length()>20){ 477 | #ifdef DEBUG_JKW_WIFI 478 | Serial.println("save wifi, data to long"); 479 | #endif 480 | return false; 481 | } 482 | 483 | //save the data 484 | // ssid 485 | FLASH_Unlock(); 486 | for(uint8_t i=0;i+SSID(20)++pw(20)++type(1)++chk(1)+)=48 526 | // e.g. 00 09 6d 61 63 73 09 36 32 31 35 30 32 37 30 39 34 09 03 09 17 09 527 | // e.g. 01 09 61 6a 6c 6f 6b 65 72 74 09 71 77 65 71 77 65 71 77 65 09 03 09 60 09 528 | // e.g. 02 09 73 68 6f 70 09 61 62 63 64 65 66 67 68 09 02 09 0E 09 529 | //Serial.print("available:"); 530 | //Serial.println(Serial.available()); 531 | delay(1000); // give buffer time to fill 532 | 533 | while(Serial.available()){ 534 | in=Serial.read(); 535 | //Serial.print("read "); 536 | //Serial.print(in); 537 | //Serial.println("."); 538 | 539 | 540 | if(in==0x09){ // which is tab, our delimitter 541 | if(tab_count==1){ 542 | SSID[p]=0x00; 543 | } else if(tab_count==2){ 544 | pw[p]=0x00; 545 | } 546 | 547 | p=0x00; 548 | tab_count++; 549 | //Serial.print("tab is now "); 550 | //Serial.println(tab_count); 551 | 552 | 553 | // to identify if a macs unit is present i'll send a "i" and the unit will responde "MACS" 554 | if(tab_count==1 && id=='i'){ 555 | tab_count=0; 556 | Serial.println("MACS"); 557 | } 558 | 559 | if(tab_count==5){ 560 | //Serial.println("try to save"); 561 | if(save_wifi_config(id, (const char*)SSID, (const char*)pw, type, chk)){ 562 | Serial.println("saved"); 563 | return true; 564 | } else { 565 | Serial.println("error"); 566 | return false; 567 | } 568 | tab_count=0; 569 | } 570 | } else if(tab_count==0){ 571 | id=in; 572 | } else if(tab_count==1){ 573 | SSID[p]=in; 574 | if(p<20){ 575 | p++; 576 | }; 577 | } else if(tab_count==2){ 578 | pw[p]=in; 579 | if(p<20){ 580 | 581 | p++; 582 | }; 583 | } else if(tab_count==3){ 584 | type=in; 585 | } else if(tab_count==4){ 586 | chk=in; 587 | } 588 | 589 | } 590 | return false; 591 | //Serial.println("while end"); 592 | } 593 | 594 | 595 | void listen(system_event_t event){ 596 | if (event==wifi_listen_update){ 597 | WiFi.disconnect(); 598 | WiFi.listen(false); 599 | } 600 | /* else if(event==network_status){ 601 | if(param==network_status_disconnecting){ 602 | WiFi.off(); 603 | } 604 | }*/ 605 | } 606 | 607 | -------------------------------------------------------------------------------- /firmware/wifi_login.h: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | bool set_update_login(LED *green, LED *red); 4 | bool set_macs_login(LED *green, LED *red); 5 | bool set_login(LED *green, LED *red, uint8_t mode); 6 | bool get_wifi_config(uint8_t id, String *_SSID, String *_pw, int *_type); 7 | bool check_wifi_config(String SSID,String pw,uint8_t type,uint8_t chk); 8 | bool parse_wifi(); 9 | void listen(system_event_t event); 10 | bool is_wifi_connected(); 11 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | sql_password.php 2 | -------------------------------------------------------------------------------- /website/css/design.css: -------------------------------------------------------------------------------- 1 | /******************************** GENERAL SETUP ***********************************/ 2 | html{ 3 | height:100%; 4 | -webkit-font-smoothing:antialiased; 5 | margin:0; 6 | padding:0; 7 | border:0; 8 | } 9 | 10 | body{ 11 | font-family:Arial,'Helvetica Neue',Helvetica,sans-serif; 12 | margin:0; 13 | padding:0; 14 | border:0; 15 | background-attachment: fixed; 16 | text-align: right; 17 | } 18 | 19 | input,button,select,option{ 20 | font-family:Arial,'Helvetica Neue',Helvetica,sans-serif 21 | } 22 | 23 | table { 24 | border-collapse: collapse; 25 | color:#ffffff; 26 | } 27 | 28 | .maintable{ 29 | text-align: left!important; 30 | color:#eeeeee; 31 | width: 70%; 32 | } 33 | 34 | 35 | table, th, td { 36 | border: 0px solid black; 37 | margin: 0 auto; /* setzt den block mittig */ 38 | } 39 | 40 | .hover { background-color: rgba(0,0,0,0.15)!important } 41 | 42 | .fillme{ 43 | width:98%; 44 | background:rgba(255,255,255,0.65)!important; 45 | color:rgba(0,0,0,0.9); 46 | } 47 | 48 | .header{ 49 | width:100%; 50 | background:#232323; 51 | color:#eeeeee; 52 | font-weight:bold; 53 | font-size:17px; 54 | line-height:40px; 55 | } 56 | a:visited,a:active,a{ 57 | color:#eeeeee; 58 | } 59 | 60 | .subheader{ 61 | width:100%; 62 | background:#333333; 63 | color:#eeeeee; 64 | font-weight:bold; 65 | font-size:15px; 66 | line-height:30px; 67 | } 68 | 69 | th.rotate { 70 | /* Something you can count on */ 71 | height: 120px; 72 | white-space: nowrap; 73 | } 74 | 75 | th.rotate > div { 76 | transform: 77 | /* Magic Numbers */ 78 | translate(-10px, 40px) 79 | /* 45 is really 360 - 45 */ 80 | rotate(270deg); 81 | width: 30px; 82 | } 83 | th.rotate > div > span { 84 | border-bottom: 1px solid #ccc; 85 | padding: 5px 10px; 86 | } 87 | 88 | .spacer{ 89 | line-height:30px; 90 | } 91 | 92 | a.button{ 93 | color:rgba(0,0,0,0.72)!important; 94 | font-size:17px; 95 | font-weight:bold; 96 | font-family:Arial,'Helvetica Neue',Helvetica,sans-serif; 97 | line-height:40px; 98 | text-align:center; 99 | text-decoration:none; 100 | text-shadow:0 1px 1px rgba(255,255,255,0.37); 101 | background:#BABABA; /*6fbbff; /*rgba(190,190,190,1); */ 102 | border:1px solid #2a3f56; 103 | -moz-border-radius:6px; 104 | -webkit-border-radius:6px; 105 | border-radius:6px; 106 | -moz-box-shadow:0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(255,255,255,0.7) inset; 107 | -webkit-box-shadow:0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(255,255,255,0.7) inset; 108 | box-shadow:0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(255,255,255,0.7) inset; 109 | margin:6px auto 0 auto; 110 | padding:0 15px; 111 | cursor:pointer; 112 | display:inline-block; 113 | position:relative; 114 | -moz-background-clip:padding-box; 115 | -webkit-background-clip:padding-box; 116 | background-clip:padding-box; 117 | height:40px; 118 | white-space:nowrap; 119 | outline-width:0; 120 | margin-right: 4px; 121 | margin-left: 4px; 122 | } 123 | 124 | a.button_deactivated{ 125 | color:rgba(150,150,150,0.72)!important; 126 | } 127 | 128 | a.button_active{ 129 | background: #9B2424; 130 | } 131 | 132 | a.button:active{ 133 | -moz-box-shadow:0 1px 0 rgba(255,255,255,0.3),0 1px 3px rgba(0,0,0,0.7) inset; 134 | -webkit-box-shadow:0 1px 0 rgba(255,255,255,0.3),0 1px 3px rgba(0,0,0,0.7) inset; 135 | box-shadow:0 1px 0 rgba(255,255,255,0.3),0 1px 3px rgba(0,0,0,0.7) inset; 136 | opacity:1 137 | } 138 | 139 | div.float_left, img.float_left { 140 | float: left; 141 | } 142 | 143 | div.inline_block { 144 | display: inline-block; 145 | } 146 | 147 | div.clear_both { 148 | clear: both; 149 | } 150 | 151 | div.center, img.center { 152 | margin: 0 auto; /* setzt den block mittig */ 153 | text-align: center!important; 154 | margin-left: auto; 155 | margin-right: auto; 156 | } 157 | 158 | div.center_hor { 159 | position:absolute; 160 | top: 50%; 161 | width: 100%; 162 | } 163 | div.loading { 164 | text-align: center; 165 | margin: 0 auto; /* setzt den block mittig */ 166 | clear: both; 167 | color: #EFEFEF; 168 | } 169 | /******************************************** GENERAL SETUP *******************************************/ 170 | /******************************** floating text "welcome to glubsch ***********************************/ 171 | .logo_l1, .logo_l2{ 172 | color:#EFEFEF; 173 | font-size:18px; 174 | text-shadow:0 1px 4px rgba(0,0,0,0.68); 175 | margin-left:70px; 176 | text-align: left; 177 | } 178 | .logo_l2{ 179 | font-size:75px; 180 | letter-spacing: 6px; 181 | margin-bottom:20px; 182 | } 183 | 184 | .logo_l1{ 185 | margin-top:20px; 186 | } 187 | /**************************** floating text "welcome to glubsch *********************************/ 188 | /******************************** the box that groups the m2m ***********************************/ 189 | div.area_node { 190 | color: #212121; 191 | background-color:rgba(0,0,0,0.7); 192 | padding-bottom: 1%; 193 | padding-top: 0.5%; /*over the "home" */ 194 | margin-bottom: 1%; 195 | 196 | vertical-align: top; 197 | text-align:center; 198 | } 199 | 200 | div.area_header { 201 | padding-top: 20px; 202 | padding-left: 20px; 203 | padding-bottom: 10px; 204 | overflow: hidden; 205 | display: inline-block; 206 | text-align: center; 207 | clear: both; 208 | } 209 | 210 | img.area_header, div.area_header_text { 211 | float: left; 212 | margin-right: 15px; 213 | } 214 | 215 | div.area_header_status{ 216 | text-align: left; 217 | font-size: 13px; 218 | } 219 | 220 | div.area_header_title{ 221 | font-weight: bold; 222 | color: #dddddd; 223 | font-size:25px; 224 | text-align: left; 225 | } 226 | 227 | /******************************* the box that groups the m2m **********************************/ 228 | /******************************** the box that holds an m2m ***********************************/ 229 | div.m2m_header { 230 | padding-top: 20px; 231 | padding-left: 20px; 232 | padding-bottom: 10px; 233 | overflow: hidden; 234 | display: inline-block; 235 | margin: 0 auto; /* setzt den block mittig */ 236 | text-align: center; 237 | clear:left; 238 | } 239 | 240 | div.m2m_header_first_line { 241 | padding-left: 10px; 242 | padding-top: 0px; 243 | } 244 | 245 | img.m2m_header, div.m2m_header_text { 246 | float: left; 247 | margin-right: 15px; 248 | } 249 | 250 | img.m2m_header { 251 | margin-top: 12px; 252 | } 253 | 254 | div.area_m2m { 255 | text-align: left; 256 | background: rgba(143, 152, 162,0.8); 257 | padding-top: 1%; 258 | padding-left: 1%; 259 | padding-bottom: 2%; 260 | margin-left: 2%; 261 | margin-right: 2%; 262 | } 263 | 264 | div.m2m_text, a.m2m_text{ 265 | font-size:12px; 266 | text-align: left; 267 | } 268 | 269 | div.m2m_text_name{ 270 | font-size:20px; 271 | text-align: left; 272 | } 273 | 274 | div.m2m_header_button{ 275 | margin: 0 auto; /* setzt den block mittig */ 276 | text-align: center; 277 | clear:left; 278 | } 279 | 280 | /******************************** the box that holds an m2m ***********************************/ 281 | /**************************************** glowing dot *****************************************/ 282 | div.glow_dot{ 283 | border-radius: 50%; 284 | display: inline-block; 285 | height: 5px; 286 | width: 5px; 287 | 288 | margin-top: 5px; 289 | margin-right: 8px; 290 | margin-left: 3px; 291 | } 292 | 293 | div.glow_red { 294 | -webkit-box-shadow: 0px 0px 6px 3px rgba(255,0,0,1); 295 | -moz-box-shadow: 0px 0px 6px 3px rgba(255,0,0,1); 296 | box-shadow: 0px 0px 6px 3px rgba(255,0,0,1); 297 | background-color: #ff0000; 298 | } 299 | 300 | div.glow_green { 301 | -webkit-box-shadow: 0px 0px 6px 3px rgba(0,255,0,1); 302 | -moz-box-shadow: 0px 0px 6px 3px rgba(0,255,0,1); 303 | box-shadow: 0px 0px 6px 3px rgba(0,255,0,1); 304 | background-color: #00ff00; 305 | } 306 | 307 | div.glow_purple { 308 | -webkit-box-shadow: 0px 0px 6px 3px rgba(255,0,255,1); 309 | -moz-box-shadow: 0px 0px 6px 3px rgba(255,0,255,1); 310 | box-shadow: 0px 0px 6px 3px rgba(255,0,255,1); 311 | background-color: #ff00ff; 312 | } 313 | 314 | div.glow_yellow { 315 | -webkit-box-shadow: 0px 0px 6px 3px rgba(255,255,0,1); 316 | -moz-box-shadow: 0px 0px 6px 3px rgba(255,255,0,1); 317 | box-shadow: 0px 0px 6px 3px rgba(255,255,0,1); 318 | background-color: #ffff00; 319 | } 320 | /**************************************** glowing dot *****************************************/ 321 | /**************************************** m2m icons *****************************************/ 322 | 323 | /**************************************** m2m buttons *****************************************/ 324 | /* TOP section in the area*/ 325 | img.area_sym_protected{ 326 | content:url("../images/ic_place_green_48dp.png"); 327 | height:88px; 328 | width: 57px; 329 | } 330 | .area_sym_protected { 331 | color: #36BF00; 332 | font-weight:bold; 333 | text-shadow: 0 -1px #000000, 1px 0 #000000, 0 1px #000000, -1px 0 #000000; 334 | } 335 | img.area_sym_not_protected{ 336 | content:url("../images/ic_place_red_48dp.png"); 337 | height:88px; 338 | width: 57px; 339 | } 340 | .area_sym_not_protected{ 341 | color: #E94B36; 342 | font-weight:bold; 343 | text-shadow: 0 -1px #000000, 1px 0 #000000, 0 1px #000000, -1px 0 #000000; 344 | } 345 | 346 | /*img.cam_sym{ content:url("../images/ic_camera_black_48dp.png");}*/ 347 | 348 | /* M2M Section */ 349 | .live_sym,.color_sym,.alarm_sym, 350 | .live_sym_not_available,.color_sym_not_available,.alarm_sym_not_available, 351 | .live_sym_active,.color_sym_active,.alarm_sym_active,.alarm_sym_open_alerts{ 352 | cursor:pointer; 353 | display:inline-block; 354 | position:relative; 355 | -moz-background-clip:padding-box; 356 | -webkit-background-clip:padding-box; 357 | background-clip:padding-box; 358 | height:50px; 359 | width:50px; 360 | white-space:nowrap; 361 | outline-width:0; 362 | margin-right: 30px; 363 | margin-left: 30px; 364 | } 365 | 366 | a.live_sym_not_available{ content:url("../images/ic_camera_gray_48dp.png"); } 367 | a.live_sym{ content:url("../images/ic_camera_black_48dp.png"); } 368 | a.live_sym_active{ content:url("../images/ic_camera_red_48dp.png"); } 369 | div.toggle_liveview_text::after { content:'glubsch!'; } 370 | div.toggle_liveview_text_active { color:#d80000; } 371 | 372 | a.color_sym_not_available{ content:url("../images/ic_flare_gray_48dp.png"); } 373 | a.color_sym{ content:url("../images/ic_flare_black_48dp.png"); } 374 | a.color_sym_active{ content:url("../images/ic_flare_red_48dp.png"); } 375 | div.toggle_lightcontrol_text::after { content:'color'; } 376 | div.toggle_lightcontrol_text_active { color:#d80000; } 377 | 378 | a.alarm_sym{ content:url("../images/ic_notifications_black_48dp.png"); } 379 | a.alarm_sym_open_alerts{ content:url("../images/ic_notifications_red_48dp.png"); } 380 | a.alarm_sym_active{ content:url("../images/ic_notifications_red_48dp.png"); } 381 | div.toggle_alarms_text::after { content:'alarms'; } 382 | div.toggle_alarms_text_active { color:#d80000; } 383 | 384 | div.toggle_text { 385 | height:20px; 386 | font-size:12px; 387 | } 388 | 389 | div.sym_text_not_available { color:#555555; } 390 | 391 | div.alarm_button{ 392 | position:relative; 393 | } 394 | 395 | div.alarm_sym_wrap{ 396 | position: absolute; 397 | z-index: 2; 398 | left: 0; 399 | right: 0; 400 | cursor: pointer; 401 | 402 | font-size: 20px; 403 | font-weight: bold; 404 | margin-top: 12px; 405 | color: #dddddd; 406 | } 407 | /**************************************** m2m buttons *****************************************/ 408 | /**************************************** m2m alert navigation *****************************************/ 409 | div.alert_navigation{ 410 | display: inline-block; 411 | float:right; 412 | margin-right:10px; 413 | } 414 | 415 | img.alert_navigation_next,img.alert_navigation_prev, 416 | img.alert_navigation_next_deactivated,img.alert_navigation_prev_deactivated { 417 | width:16px; 418 | height:11px; 419 | margin-left:5px; 420 | margin-right:5px; 421 | color: #fcca04; 422 | cursor: pointer; 423 | } 424 | img.alert_navigation_next{ 425 | content:url("../images/next.png"); 426 | } 427 | img.alert_navigation_prev{ 428 | content:url("../images/prev.png"); 429 | } 430 | img.alert_navigation_next_deactivated{ 431 | content:url("../images/next_d.png"); 432 | } 433 | img.alert_navigation_prev_deactivated{ 434 | content:url("../images/prev_d.png"); 435 | } 436 | 437 | div.alert_side{ 438 | padding-top:20px; 439 | padding-left: 10px; 440 | float: left; 441 | vertical-align:bottom; 442 | } 443 | 444 | img.alert_preview{ 445 | padding-top:10px; 446 | } 447 | /**************************************** m2m alert navigation *****************************************/ 448 | /**************************************** m2m light scroller *****************************************/ 449 | div.light_controll_scroller{ 450 | width: 85%; 451 | margin: 0 auto; /* setzt den block mittig */ 452 | clear: both; 453 | height: 20px; 454 | } 455 | 456 | div.light_controll_color{ 457 | width: 85%; 458 | margin: 0 auto; /* setzt den block mittig */ 459 | height: 30px; 460 | clear: both; 461 | margin-top: 15px; 462 | } 463 | /**************************************** m2m light scroller *****************************************/ 464 | /******************************************** MENU ***************************************************/ 465 | div.menu{ 466 | position:fixed; 467 | background: rgba(143, 152, 162, 1.0); 468 | left: 0px; 469 | top: 0px; 470 | padding: 0 64px; 471 | height: 100%; 472 | box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4); 473 | z-index: 10; 474 | transform: translate(-150%, 0px); 475 | transition: all 0.75s ease-in-out; 476 | } 477 | 478 | div.menu_active { 479 | -webkit-transform: translate(0%, 0px); 480 | transform: translate(0%, 0px); 481 | transition: all 0.75s ease-in-out; 482 | } 483 | 484 | div.hamb { 485 | border: 1px solid #374C77; 486 | border-radius: 3px 3px 3px 3px; 487 | cursor: pointer; 488 | display: block; 489 | height: 24px; 490 | padding: 3px 4px 3px; 491 | position: absolute; 492 | top: 10px; 493 | left: 10px; 494 | width: 25px; 495 | background: #ededed;/*#4569b2;*/ 496 | background: -moz-linear-gradient(top, #4569b2 0%, #4062a5 100%); 497 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #4569b2), color-stop(100%, #4062a5)); 498 | background: -webkit-linear-gradient(top, #4569b2 0%, #4062a5 100%); 499 | background: -o-linear-gradient(top, #4569b2 0%, #4062a5 100%); 500 | background: -ms-linear-gradient(top, #4569b2 0%, #4062a5 100%); 501 | background: linear-gradient(to bottom, #ededed 0%, #e2e2e2 100%); 502 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#4569b2', endColorstr='#4062a5', GradientType=0); 503 | z-index:11; 504 | } 505 | 506 | div.info { 507 | border: 1px solid #222222; 508 | border-radius: 3px 3px 3px 3px; 509 | cursor: pointer; 510 | text-align: center!important; 511 | margin-left: auto; 512 | margin-right: auto; 513 | margin: 0 auto; /* setzt den block mittig */ 514 | display: block; 515 | height: 20px; 516 | padding: 3px 4px 3px; 517 | position: absolute; 518 | top: 10px; 519 | width: 450px; 520 | background: #ebcb00;/*#4569b2;*/ 521 | z-index:11; 522 | } 523 | 524 | /*The white stripes in the hamburger button*/ 525 | div.hamb_l { 526 | background-color: #fff; 527 | border: 1px solid #eee; 528 | border-radius: 2px 2px 2px 2px; 529 | height: 2px; 530 | margin-top: 3px; 531 | width: 90%; 532 | } 533 | -------------------------------------------------------------------------------- /website/css/iframe.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background:rgba(255,255,255,0.65)!important; 3 | color:rgba(0,0,0,0.9); 4 | font-family:Arial,'Helvetica Neue',Helvetica,sans-serif; 5 | margin:0; 6 | padding:0; 7 | border:0; 8 | background-attachment: fixed; 9 | text-align: left; 10 | } 11 | 12 | html{ 13 | height:100%; 14 | -webkit-font-smoothing:antialiased; 15 | margin:0; 16 | padding:0; 17 | border:0; 18 | } 19 | 20 | 21 | input,button,select,option{ 22 | font-family:Arial,'Helvetica Neue',Helvetica,sans-serif 23 | } 24 | 25 | table { 26 | border-collapse: collapse; 27 | color:#ffffff; 28 | } 29 | 30 | .maintable{ 31 | text-align: left!important; 32 | color:#eeeeee; 33 | width: 70%; 34 | } 35 | 36 | 37 | table, th, td { 38 | border: 0px solid black; 39 | margin: 0 auto; /* setzt den block mittig */ 40 | } 41 | 42 | .hover { background-color: rgba(0,0,0,0.15)!important } 43 | 44 | .fillme{ 45 | width:98%; 46 | color:rgba(0,0,0,0.9); 47 | } 48 | 49 | .header{ 50 | width:100%; 51 | background:#232323; 52 | color:#eeeeee; 53 | font-weight:bold; 54 | font-size:17px; 55 | line-height:40px; 56 | } 57 | a:visited,a:active,a{ 58 | color:#eeeeee; 59 | } 60 | 61 | .subheader{ 62 | width:100%; 63 | background:#333333; 64 | color:#eeeeee; 65 | font-weight:bold; 66 | font-size:15px; 67 | line-height:30px; 68 | } 69 | 70 | th.rotate { 71 | /* Something you can count on */ 72 | height: 120px; 73 | white-space: nowrap; 74 | } 75 | 76 | th.rotate > div { 77 | transform: 78 | /* Magic Numbers */ 79 | translate(-10px, 40px) 80 | /* 45 is really 360 - 45 */ 81 | rotate(270deg); 82 | width: 30px; 83 | } 84 | th.rotate > div > span { 85 | border-bottom: 1px solid #ccc; 86 | padding: 5px 10px; 87 | } 88 | 89 | .spacer{ 90 | line-height:30px; 91 | } 92 | 93 | a.button{ 94 | color:rgba(0,0,0,0.72)!important; 95 | font-size:17px; 96 | font-weight:bold; 97 | font-family:Arial,'Helvetica Neue',Helvetica,sans-serif; 98 | line-height:40px; 99 | text-align:center; 100 | text-decoration:none; 101 | text-shadow:0 1px 1px rgba(255,255,255,0.37); 102 | background:#BABABA; /*6fbbff; /*rgba(190,190,190,1); */ 103 | border:1px solid #2a3f56; 104 | -moz-border-radius:6px; 105 | -webkit-border-radius:6px; 106 | border-radius:6px; 107 | -moz-box-shadow:0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(255,255,255,0.7) inset; 108 | -webkit-box-shadow:0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(255,255,255,0.7) inset; 109 | box-shadow:0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(255,255,255,0.7) inset; 110 | margin:6px auto 0 auto; 111 | padding:0 15px; 112 | cursor:pointer; 113 | display:inline-block; 114 | position:relative; 115 | -moz-background-clip:padding-box; 116 | -webkit-background-clip:padding-box; 117 | background-clip:padding-box; 118 | height:40px; 119 | white-space:nowrap; 120 | outline-width:0; 121 | margin-right: 4px; 122 | margin-left: 4px; 123 | } 124 | 125 | a.button_deactivated{ 126 | color:rgba(150,150,150,0.72)!important; 127 | } 128 | 129 | a.button_active{ 130 | background: #9B2424; 131 | } 132 | 133 | a.button:active{ 134 | -moz-box-shadow:0 1px 0 rgba(255,255,255,0.3),0 1px 3px rgba(0,0,0,0.7) inset; 135 | -webkit-box-shadow:0 1px 0 rgba(255,255,255,0.3),0 1px 3px rgba(0,0,0,0.7) inset; 136 | box-shadow:0 1px 0 rgba(255,255,255,0.3),0 1px 3px rgba(0,0,0,0.7) inset; 137 | opacity:1 138 | } 139 | 140 | div.float_left, img.float_left { 141 | float: left; 142 | } 143 | 144 | div.inline_block { 145 | display: inline-block; 146 | } 147 | 148 | div.clear_both { 149 | clear: both; 150 | } 151 | 152 | div.center, img.center { 153 | margin: 0 auto; /* setzt den block mittig */ 154 | text-align: center!important; 155 | margin-left: auto; 156 | margin-right: auto; 157 | } 158 | 159 | div.center_hor { 160 | position:absolute; 161 | top: 50%; 162 | width: 100%; 163 | } 164 | div.loading { 165 | text-align: center; 166 | margin: 0 auto; /* setzt den block mittig */ 167 | clear: both; 168 | color: #EFEFEF; 169 | } 170 | /******************************************** GENERAL SETUP *******************************************/ 171 | /******************************** floating text "welcome to glubsch ***********************************/ 172 | .logo_l1, .logo_l2{ 173 | color:#EFEFEF; 174 | font-size:18px; 175 | text-shadow:0 1px 4px rgba(0,0,0,0.68); 176 | margin-left:70px; 177 | text-align: left; 178 | } 179 | .logo_l2{ 180 | font-size:75px; 181 | letter-spacing: 6px; 182 | margin-bottom:20px; 183 | } 184 | 185 | .logo_l1{ 186 | margin-top:20px; 187 | } 188 | /**************************** floating text "welcome to glubsch *********************************/ 189 | /******************************** the box that groups the m2m ***********************************/ 190 | div.area_node { 191 | color: #212121; 192 | background-color:rgba(0,0,0,0.7); 193 | padding-bottom: 1%; 194 | padding-top: 0.5%; /*over the "home" */ 195 | margin-bottom: 1%; 196 | 197 | vertical-align: top; 198 | text-align:center; 199 | } 200 | 201 | div.area_header { 202 | padding-top: 20px; 203 | padding-left: 20px; 204 | padding-bottom: 10px; 205 | overflow: hidden; 206 | display: inline-block; 207 | text-align: center; 208 | clear: both; 209 | } 210 | 211 | img.area_header, div.area_header_text { 212 | float: left; 213 | margin-right: 15px; 214 | } 215 | 216 | div.area_header_status{ 217 | text-align: left; 218 | font-size: 13px; 219 | } 220 | 221 | div.area_header_title{ 222 | font-weight: bold; 223 | color: #dddddd; 224 | font-size:25px; 225 | text-align: left; 226 | } 227 | 228 | /******************************* the box that groups the m2m **********************************/ 229 | /******************************** the box that holds an m2m ***********************************/ 230 | div.m2m_header { 231 | padding-top: 20px; 232 | padding-left: 20px; 233 | padding-bottom: 10px; 234 | overflow: hidden; 235 | display: inline-block; 236 | margin: 0 auto; /* setzt den block mittig */ 237 | text-align: center; 238 | clear:left; 239 | } 240 | 241 | div.m2m_header_first_line { 242 | padding-left: 10px; 243 | padding-top: 0px; 244 | } 245 | 246 | img.m2m_header, div.m2m_header_text { 247 | float: left; 248 | margin-right: 15px; 249 | } 250 | 251 | img.m2m_header { 252 | margin-top: 12px; 253 | } 254 | 255 | div.area_m2m { 256 | text-align: left; 257 | background: rgba(143, 152, 162,0.8); 258 | padding-top: 1%; 259 | padding-left: 1%; 260 | padding-bottom: 2%; 261 | margin-left: 2%; 262 | margin-right: 2%; 263 | } 264 | 265 | div.m2m_text, a.m2m_text{ 266 | font-size:12px; 267 | text-align: left; 268 | } 269 | 270 | div.m2m_text_name{ 271 | font-size:20px; 272 | text-align: left; 273 | } 274 | 275 | div.m2m_header_button{ 276 | margin: 0 auto; /* setzt den block mittig */ 277 | text-align: center; 278 | clear:left; 279 | } 280 | 281 | /******************************** the box that holds an m2m ***********************************/ 282 | /**************************************** glowing dot *****************************************/ 283 | div.glow_dot{ 284 | border-radius: 50%; 285 | display: inline-block; 286 | height: 5px; 287 | width: 5px; 288 | 289 | margin-top: 5px; 290 | margin-right: 8px; 291 | margin-left: 3px; 292 | } 293 | 294 | div.glow_red { 295 | -webkit-box-shadow: 0px 0px 6px 3px rgba(255,0,0,1); 296 | -moz-box-shadow: 0px 0px 6px 3px rgba(255,0,0,1); 297 | box-shadow: 0px 0px 6px 3px rgba(255,0,0,1); 298 | background-color: #ff0000; 299 | } 300 | 301 | div.glow_green { 302 | -webkit-box-shadow: 0px 0px 6px 3px rgba(0,255,0,1); 303 | -moz-box-shadow: 0px 0px 6px 3px rgba(0,255,0,1); 304 | box-shadow: 0px 0px 6px 3px rgba(0,255,0,1); 305 | background-color: #00ff00; 306 | } 307 | 308 | div.glow_purple { 309 | -webkit-box-shadow: 0px 0px 6px 3px rgba(255,0,255,1); 310 | -moz-box-shadow: 0px 0px 6px 3px rgba(255,0,255,1); 311 | box-shadow: 0px 0px 6px 3px rgba(255,0,255,1); 312 | background-color: #ff00ff; 313 | } 314 | 315 | div.glow_yellow { 316 | -webkit-box-shadow: 0px 0px 6px 3px rgba(255,255,0,1); 317 | -moz-box-shadow: 0px 0px 6px 3px rgba(255,255,0,1); 318 | box-shadow: 0px 0px 6px 3px rgba(255,255,0,1); 319 | background-color: #ffff00; 320 | } 321 | /**************************************** glowing dot *****************************************/ 322 | /**************************************** m2m icons *****************************************/ 323 | 324 | /**************************************** m2m buttons *****************************************/ 325 | /* TOP section in the area*/ 326 | img.area_sym_protected{ 327 | content:url("../images/ic_place_green_48dp.png"); 328 | height:88px; 329 | width: 57px; 330 | } 331 | .area_sym_protected { 332 | color: #36BF00; 333 | font-weight:bold; 334 | text-shadow: 0 -1px #000000, 1px 0 #000000, 0 1px #000000, -1px 0 #000000; 335 | } 336 | img.area_sym_not_protected{ 337 | content:url("../images/ic_place_red_48dp.png"); 338 | height:88px; 339 | width: 57px; 340 | } 341 | .area_sym_not_protected{ 342 | color: #E94B36; 343 | font-weight:bold; 344 | text-shadow: 0 -1px #000000, 1px 0 #000000, 0 1px #000000, -1px 0 #000000; 345 | } 346 | 347 | /*img.cam_sym{ content:url("../images/ic_camera_black_48dp.png");}*/ 348 | 349 | /* M2M Section */ 350 | .live_sym,.color_sym,.alarm_sym, 351 | .live_sym_not_available,.color_sym_not_available,.alarm_sym_not_available, 352 | .live_sym_active,.color_sym_active,.alarm_sym_active,.alarm_sym_open_alerts{ 353 | cursor:pointer; 354 | display:inline-block; 355 | position:relative; 356 | -moz-background-clip:padding-box; 357 | -webkit-background-clip:padding-box; 358 | background-clip:padding-box; 359 | height:50px; 360 | width:50px; 361 | white-space:nowrap; 362 | outline-width:0; 363 | margin-right: 30px; 364 | margin-left: 30px; 365 | } 366 | 367 | a.live_sym_not_available{ content:url("../images/ic_camera_gray_48dp.png"); } 368 | a.live_sym{ content:url("../images/ic_camera_black_48dp.png"); } 369 | a.live_sym_active{ content:url("../images/ic_camera_red_48dp.png"); } 370 | div.toggle_liveview_text::after { content:'glubsch!'; } 371 | div.toggle_liveview_text_active { color:#d80000; } 372 | 373 | a.color_sym_not_available{ content:url("../images/ic_flare_gray_48dp.png"); } 374 | a.color_sym{ content:url("../images/ic_flare_black_48dp.png"); } 375 | a.color_sym_active{ content:url("../images/ic_flare_red_48dp.png"); } 376 | div.toggle_lightcontrol_text::after { content:'color'; } 377 | div.toggle_lightcontrol_text_active { color:#d80000; } 378 | 379 | a.alarm_sym{ content:url("../images/ic_notifications_black_48dp.png"); } 380 | a.alarm_sym_open_alerts{ content:url("../images/ic_notifications_red_48dp.png"); } 381 | a.alarm_sym_active{ content:url("../images/ic_notifications_red_48dp.png"); } 382 | div.toggle_alarms_text::after { content:'alarms'; } 383 | div.toggle_alarms_text_active { color:#d80000; } 384 | 385 | div.toggle_text { 386 | height:20px; 387 | font-size:12px; 388 | } 389 | 390 | div.sym_text_not_available { color:#555555; } 391 | 392 | div.alarm_button{ 393 | position:relative; 394 | } 395 | 396 | div.alarm_sym_wrap{ 397 | position: absolute; 398 | z-index: 2; 399 | left: 0; 400 | right: 0; 401 | cursor: pointer; 402 | 403 | font-size: 20px; 404 | font-weight: bold; 405 | margin-top: 12px; 406 | color: #dddddd; 407 | } 408 | /**************************************** m2m buttons *****************************************/ 409 | /**************************************** m2m alert navigation *****************************************/ 410 | div.alert_navigation{ 411 | display: inline-block; 412 | float:right; 413 | margin-right:10px; 414 | } 415 | 416 | img.alert_navigation_next,img.alert_navigation_prev, 417 | img.alert_navigation_next_deactivated,img.alert_navigation_prev_deactivated { 418 | width:16px; 419 | height:11px; 420 | margin-left:5px; 421 | margin-right:5px; 422 | color: #fcca04; 423 | cursor: pointer; 424 | } 425 | img.alert_navigation_next{ 426 | content:url("../images/next.png"); 427 | } 428 | img.alert_navigation_prev{ 429 | content:url("../images/prev.png"); 430 | } 431 | img.alert_navigation_next_deactivated{ 432 | content:url("../images/next_d.png"); 433 | } 434 | img.alert_navigation_prev_deactivated{ 435 | content:url("../images/prev_d.png"); 436 | } 437 | 438 | div.alert_side{ 439 | padding-top:20px; 440 | padding-left: 10px; 441 | float: left; 442 | vertical-align:bottom; 443 | } 444 | 445 | img.alert_preview{ 446 | padding-top:10px; 447 | } 448 | /**************************************** m2m alert navigation *****************************************/ 449 | /**************************************** m2m light scroller *****************************************/ 450 | div.light_controll_scroller{ 451 | width: 85%; 452 | margin: 0 auto; /* setzt den block mittig */ 453 | clear: both; 454 | height: 20px; 455 | } 456 | 457 | div.light_controll_color{ 458 | width: 85%; 459 | margin: 0 auto; /* setzt den block mittig */ 460 | height: 30px; 461 | clear: both; 462 | margin-top: 15px; 463 | } 464 | /**************************************** m2m light scroller *****************************************/ 465 | /******************************************** MENU ***************************************************/ 466 | div.menu{ 467 | position:fixed; 468 | background: rgba(143, 152, 162, 1.0); 469 | left: 0px; 470 | top: 0px; 471 | padding: 0 64px; 472 | height: 100%; 473 | box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4); 474 | z-index: 10; 475 | transform: translate(-150%, 0px); 476 | transition: all 0.75s ease-in-out; 477 | } 478 | 479 | div.menu_active { 480 | -webkit-transform: translate(0%, 0px); 481 | transform: translate(0%, 0px); 482 | transition: all 0.75s ease-in-out; 483 | } 484 | 485 | div.hamb { 486 | border: 1px solid #374C77; 487 | border-radius: 3px 3px 3px 3px; 488 | cursor: pointer; 489 | display: block; 490 | height: 24px; 491 | padding: 3px 4px 3px; 492 | position: absolute; 493 | top: 10px; 494 | left: 10px; 495 | width: 25px; 496 | background: #ededed;/*#4569b2;*/ 497 | background: -moz-linear-gradient(top, #4569b2 0%, #4062a5 100%); 498 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #4569b2), color-stop(100%, #4062a5)); 499 | background: -webkit-linear-gradient(top, #4569b2 0%, #4062a5 100%); 500 | background: -o-linear-gradient(top, #4569b2 0%, #4062a5 100%); 501 | background: -ms-linear-gradient(top, #4569b2 0%, #4062a5 100%); 502 | background: linear-gradient(to bottom, #ededed 0%, #e2e2e2 100%); 503 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#4569b2', endColorstr='#4062a5', GradientType=0); 504 | z-index:11; 505 | } 506 | 507 | div.info { 508 | border: 1px solid #222222; 509 | border-radius: 3px 3px 3px 3px; 510 | cursor: pointer; 511 | text-align: center!important; 512 | margin-left: auto; 513 | margin-right: auto; 514 | margin: 0 auto; /* setzt den block mittig */ 515 | display: block; 516 | height: 20px; 517 | padding: 3px 4px 3px; 518 | position: absolute; 519 | top: 10px; 520 | width: 450px; 521 | background: #ebcb00;/*#4569b2;*/ 522 | z-index:11; 523 | } 524 | 525 | /*The white stripes in the hamburger button*/ 526 | div.hamb_l { 527 | background-color: #fff; 528 | border: 1px solid #eee; 529 | border-radius: 2px 2px 2px 2px; 530 | height: 2px; 531 | margin-top: 3px; 532 | width: 90%; 533 | } 534 | -------------------------------------------------------------------------------- /website/css/jquery-ui.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.11.4 - 2015-06-02 2 | * http://jqueryui.com 3 | * Includes: core.css, slider.css, theme.css 4 | * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS%2CTahoma%2CVerdana%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=gloss_wave&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=highlight_soft&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=glass&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=glass&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=highlight_soft&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=diagonals_thick&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=diagonals_thick&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=flat&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px 5 | * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ 6 | 7 | /* Layout helpers 8 | ----------------------------------*/ 9 | .ui-helper-hidden { 10 | display: none; 11 | } 12 | .ui-helper-hidden-accessible { 13 | border: 0; 14 | clip: rect(0 0 0 0); 15 | height: 1px; 16 | margin: -1px; 17 | overflow: hidden; 18 | padding: 0; 19 | position: absolute; 20 | width: 1px; 21 | } 22 | .ui-helper-reset { 23 | margin: 0; 24 | padding: 0; 25 | border: 0; 26 | outline: 0; 27 | line-height: 1.3; 28 | text-decoration: none; 29 | font-size: 100%; 30 | list-style: none; 31 | } 32 | .ui-helper-clearfix:before, 33 | .ui-helper-clearfix:after { 34 | content: ""; 35 | display: table; 36 | border-collapse: collapse; 37 | } 38 | .ui-helper-clearfix:after { 39 | clear: both; 40 | } 41 | .ui-helper-clearfix { 42 | min-height: 0; /* support: IE7 */ 43 | } 44 | .ui-helper-zfix { 45 | width: 100%; 46 | height: 100%; 47 | top: 0; 48 | left: 0; 49 | position: absolute; 50 | opacity: 0; 51 | filter:Alpha(Opacity=0); /* support: IE8 */ 52 | } 53 | 54 | .ui-front { 55 | z-index: 100; 56 | } 57 | 58 | 59 | /* Interaction Cues 60 | ----------------------------------*/ 61 | .ui-state-disabled { 62 | cursor: default !important; 63 | } 64 | 65 | 66 | /* Icons 67 | ----------------------------------*/ 68 | 69 | /* states and images */ 70 | .ui-icon { 71 | display: block; 72 | text-indent: -99999px; 73 | overflow: hidden; 74 | background-repeat: no-repeat; 75 | } 76 | 77 | 78 | /* Misc visuals 79 | ----------------------------------*/ 80 | 81 | /* Overlays */ 82 | .ui-widget-overlay { 83 | position: fixed; 84 | top: 0; 85 | left: 0; 86 | width: 100%; 87 | height: 100%; 88 | } 89 | .ui-slider { 90 | position: relative; 91 | text-align: left; 92 | } 93 | .ui-slider .ui-slider-handle { 94 | position: absolute; 95 | z-index: 2; 96 | width: 1.2em; 97 | height: 1.2em; 98 | cursor: default; 99 | -ms-touch-action: none; 100 | touch-action: none; 101 | } 102 | .ui-slider .ui-slider-range { 103 | position: absolute; 104 | z-index: 1; 105 | font-size: .7em; 106 | display: block; 107 | border: 0; 108 | background-position: 0 0; 109 | } 110 | 111 | /* support: IE8 - See #6727 */ 112 | .ui-slider.ui-state-disabled .ui-slider-handle, 113 | .ui-slider.ui-state-disabled .ui-slider-range { 114 | filter: inherit; 115 | } 116 | 117 | .ui-slider-horizontal { 118 | height: .8em; 119 | } 120 | .ui-slider-horizontal .ui-slider-handle { 121 | top: -.3em; 122 | margin-left: -.6em; 123 | } 124 | .ui-slider-horizontal .ui-slider-range { 125 | top: 0; 126 | height: 100%; 127 | } 128 | .ui-slider-horizontal .ui-slider-range-min { 129 | left: 0; 130 | } 131 | .ui-slider-horizontal .ui-slider-range-max { 132 | right: 0; 133 | } 134 | 135 | .ui-slider-vertical { 136 | width: .8em; 137 | height: 100px; 138 | } 139 | .ui-slider-vertical .ui-slider-handle { 140 | left: -.3em; 141 | margin-left: 0; 142 | margin-bottom: -.6em; 143 | } 144 | .ui-slider-vertical .ui-slider-range { 145 | left: 0; 146 | width: 100%; 147 | } 148 | .ui-slider-vertical .ui-slider-range-min { 149 | bottom: 0; 150 | } 151 | .ui-slider-vertical .ui-slider-range-max { 152 | top: 0; 153 | } 154 | 155 | /* Component containers 156 | ----------------------------------*/ 157 | .ui-widget { 158 | font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif; 159 | font-size: 1.1em; 160 | } 161 | .ui-widget .ui-widget { 162 | font-size: 1em; 163 | } 164 | .ui-widget input, 165 | .ui-widget select, 166 | .ui-widget textarea, 167 | .ui-widget button { 168 | font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif; 169 | font-size: 1em; 170 | } 171 | .ui-widget-content { 172 | border: 1px solid #dddddd; 173 | background: #eeeeee url("images/ui-bg_highlight-soft_100_eeeeee_1x100.png") 50% top repeat-x; 174 | color: #333333; 175 | } 176 | .ui-widget-content a { 177 | color: #333333; 178 | } 179 | .ui-widget-header { 180 | border: 1px solid #e78f08; 181 | background: #f6a828 url("images/ui-bg_gloss-wave_35_f6a828_500x100.png") 50% 50% repeat-x; 182 | color: #ffffff; 183 | font-weight: bold; 184 | } 185 | .ui-widget-header a { 186 | color: #ffffff; 187 | } 188 | 189 | /* Interaction states 190 | ----------------------------------*/ 191 | .ui-state-default, 192 | .ui-widget-content .ui-state-default, 193 | .ui-widget-header .ui-state-default { 194 | border: 1px solid #cccccc; 195 | background: #f6f6f6 url("images/ui-bg_glass_100_f6f6f6_1x400.png") 50% 50% repeat-x; 196 | font-weight: bold; 197 | color: #1c94c4; 198 | } 199 | .ui-state-default a, 200 | .ui-state-default a:link, 201 | .ui-state-default a:visited { 202 | color: #1c94c4; 203 | text-decoration: none; 204 | } 205 | .ui-state-hover, 206 | .ui-widget-content .ui-state-hover, 207 | .ui-widget-header .ui-state-hover, 208 | .ui-state-focus, 209 | .ui-widget-content .ui-state-focus, 210 | .ui-widget-header .ui-state-focus { 211 | border: 1px solid #fbcb09; 212 | background: #fdf5ce url("images/ui-bg_glass_100_fdf5ce_1x400.png") 50% 50% repeat-x; 213 | font-weight: bold; 214 | color: #c77405; 215 | } 216 | .ui-state-hover a, 217 | .ui-state-hover a:hover, 218 | .ui-state-hover a:link, 219 | .ui-state-hover a:visited, 220 | .ui-state-focus a, 221 | .ui-state-focus a:hover, 222 | .ui-state-focus a:link, 223 | .ui-state-focus a:visited { 224 | color: #c77405; 225 | text-decoration: none; 226 | } 227 | .ui-state-active, 228 | .ui-widget-content .ui-state-active, 229 | .ui-widget-header .ui-state-active { 230 | border: 1px solid #fbd850; 231 | background: #ffffff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x; 232 | font-weight: bold; 233 | color: #eb8f00; 234 | } 235 | .ui-state-active a, 236 | .ui-state-active a:link, 237 | .ui-state-active a:visited { 238 | color: #eb8f00; 239 | text-decoration: none; 240 | } 241 | 242 | /* Interaction Cues 243 | ----------------------------------*/ 244 | .ui-state-highlight, 245 | .ui-widget-content .ui-state-highlight, 246 | .ui-widget-header .ui-state-highlight { 247 | border: 1px solid #fed22f; 248 | background: #ffe45c url("images/ui-bg_highlight-soft_75_ffe45c_1x100.png") 50% top repeat-x; 249 | color: #363636; 250 | } 251 | .ui-state-highlight a, 252 | .ui-widget-content .ui-state-highlight a, 253 | .ui-widget-header .ui-state-highlight a { 254 | color: #363636; 255 | } 256 | .ui-state-error, 257 | .ui-widget-content .ui-state-error, 258 | .ui-widget-header .ui-state-error { 259 | border: 1px solid #cd0a0a; 260 | background: #b81900 url("images/ui-bg_diagonals-thick_18_b81900_40x40.png") 50% 50% repeat; 261 | color: #ffffff; 262 | } 263 | .ui-state-error a, 264 | .ui-widget-content .ui-state-error a, 265 | .ui-widget-header .ui-state-error a { 266 | color: #ffffff; 267 | } 268 | .ui-state-error-text, 269 | .ui-widget-content .ui-state-error-text, 270 | .ui-widget-header .ui-state-error-text { 271 | color: #ffffff; 272 | } 273 | .ui-priority-primary, 274 | .ui-widget-content .ui-priority-primary, 275 | .ui-widget-header .ui-priority-primary { 276 | font-weight: bold; 277 | } 278 | .ui-priority-secondary, 279 | .ui-widget-content .ui-priority-secondary, 280 | .ui-widget-header .ui-priority-secondary { 281 | opacity: .7; 282 | filter:Alpha(Opacity=70); /* support: IE8 */ 283 | font-weight: normal; 284 | } 285 | .ui-state-disabled, 286 | .ui-widget-content .ui-state-disabled, 287 | .ui-widget-header .ui-state-disabled { 288 | opacity: .35; 289 | filter:Alpha(Opacity=35); /* support: IE8 */ 290 | background-image: none; 291 | } 292 | .ui-state-disabled .ui-icon { 293 | filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */ 294 | } 295 | 296 | /* Icons 297 | ----------------------------------*/ 298 | 299 | /* states and images */ 300 | .ui-icon { 301 | width: 16px; 302 | height: 16px; 303 | } 304 | .ui-icon, 305 | .ui-widget-content .ui-icon { 306 | background-image: url("images/ui-icons_222222_256x240.png"); 307 | } 308 | .ui-widget-header .ui-icon { 309 | background-image: url("images/ui-icons_ffffff_256x240.png"); 310 | } 311 | .ui-state-default .ui-icon { 312 | background-image: url("images/ui-icons_ef8c08_256x240.png"); 313 | } 314 | .ui-state-hover .ui-icon, 315 | .ui-state-focus .ui-icon { 316 | background-image: url("images/ui-icons_ef8c08_256x240.png"); 317 | } 318 | .ui-state-active .ui-icon { 319 | background-image: url("images/ui-icons_ef8c08_256x240.png"); 320 | } 321 | .ui-state-highlight .ui-icon { 322 | background-image: url("images/ui-icons_228ef1_256x240.png"); 323 | } 324 | .ui-state-error .ui-icon, 325 | .ui-state-error-text .ui-icon { 326 | background-image: url("images/ui-icons_ffd27a_256x240.png"); 327 | } 328 | 329 | /* positioning */ 330 | .ui-icon-blank { background-position: 16px 16px; } 331 | .ui-icon-carat-1-n { background-position: 0 0; } 332 | .ui-icon-carat-1-ne { background-position: -16px 0; } 333 | .ui-icon-carat-1-e { background-position: -32px 0; } 334 | .ui-icon-carat-1-se { background-position: -48px 0; } 335 | .ui-icon-carat-1-s { background-position: -64px 0; } 336 | .ui-icon-carat-1-sw { background-position: -80px 0; } 337 | .ui-icon-carat-1-w { background-position: -96px 0; } 338 | .ui-icon-carat-1-nw { background-position: -112px 0; } 339 | .ui-icon-carat-2-n-s { background-position: -128px 0; } 340 | .ui-icon-carat-2-e-w { background-position: -144px 0; } 341 | .ui-icon-triangle-1-n { background-position: 0 -16px; } 342 | .ui-icon-triangle-1-ne { background-position: -16px -16px; } 343 | .ui-icon-triangle-1-e { background-position: -32px -16px; } 344 | .ui-icon-triangle-1-se { background-position: -48px -16px; } 345 | .ui-icon-triangle-1-s { background-position: -64px -16px; } 346 | .ui-icon-triangle-1-sw { background-position: -80px -16px; } 347 | .ui-icon-triangle-1-w { background-position: -96px -16px; } 348 | .ui-icon-triangle-1-nw { background-position: -112px -16px; } 349 | .ui-icon-triangle-2-n-s { background-position: -128px -16px; } 350 | .ui-icon-triangle-2-e-w { background-position: -144px -16px; } 351 | .ui-icon-arrow-1-n { background-position: 0 -32px; } 352 | .ui-icon-arrow-1-ne { background-position: -16px -32px; } 353 | .ui-icon-arrow-1-e { background-position: -32px -32px; } 354 | .ui-icon-arrow-1-se { background-position: -48px -32px; } 355 | .ui-icon-arrow-1-s { background-position: -64px -32px; } 356 | .ui-icon-arrow-1-sw { background-position: -80px -32px; } 357 | .ui-icon-arrow-1-w { background-position: -96px -32px; } 358 | .ui-icon-arrow-1-nw { background-position: -112px -32px; } 359 | .ui-icon-arrow-2-n-s { background-position: -128px -32px; } 360 | .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } 361 | .ui-icon-arrow-2-e-w { background-position: -160px -32px; } 362 | .ui-icon-arrow-2-se-nw { background-position: -176px -32px; } 363 | .ui-icon-arrowstop-1-n { background-position: -192px -32px; } 364 | .ui-icon-arrowstop-1-e { background-position: -208px -32px; } 365 | .ui-icon-arrowstop-1-s { background-position: -224px -32px; } 366 | .ui-icon-arrowstop-1-w { background-position: -240px -32px; } 367 | .ui-icon-arrowthick-1-n { background-position: 0 -48px; } 368 | .ui-icon-arrowthick-1-ne { background-position: -16px -48px; } 369 | .ui-icon-arrowthick-1-e { background-position: -32px -48px; } 370 | .ui-icon-arrowthick-1-se { background-position: -48px -48px; } 371 | .ui-icon-arrowthick-1-s { background-position: -64px -48px; } 372 | .ui-icon-arrowthick-1-sw { background-position: -80px -48px; } 373 | .ui-icon-arrowthick-1-w { background-position: -96px -48px; } 374 | .ui-icon-arrowthick-1-nw { background-position: -112px -48px; } 375 | .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } 376 | .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } 377 | .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } 378 | .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } 379 | .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } 380 | .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } 381 | .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } 382 | .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } 383 | .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } 384 | .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } 385 | .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } 386 | .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } 387 | .ui-icon-arrowreturn-1-w { background-position: -64px -64px; } 388 | .ui-icon-arrowreturn-1-n { background-position: -80px -64px; } 389 | .ui-icon-arrowreturn-1-e { background-position: -96px -64px; } 390 | .ui-icon-arrowreturn-1-s { background-position: -112px -64px; } 391 | .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } 392 | .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } 393 | .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } 394 | .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } 395 | .ui-icon-arrow-4 { background-position: 0 -80px; } 396 | .ui-icon-arrow-4-diag { background-position: -16px -80px; } 397 | .ui-icon-extlink { background-position: -32px -80px; } 398 | .ui-icon-newwin { background-position: -48px -80px; } 399 | .ui-icon-refresh { background-position: -64px -80px; } 400 | .ui-icon-shuffle { background-position: -80px -80px; } 401 | .ui-icon-transfer-e-w { background-position: -96px -80px; } 402 | .ui-icon-transferthick-e-w { background-position: -112px -80px; } 403 | .ui-icon-folder-collapsed { background-position: 0 -96px; } 404 | .ui-icon-folder-open { background-position: -16px -96px; } 405 | .ui-icon-document { background-position: -32px -96px; } 406 | .ui-icon-document-b { background-position: -48px -96px; } 407 | .ui-icon-note { background-position: -64px -96px; } 408 | .ui-icon-mail-closed { background-position: -80px -96px; } 409 | .ui-icon-mail-open { background-position: -96px -96px; } 410 | .ui-icon-suitcase { background-position: -112px -96px; } 411 | .ui-icon-comment { background-position: -128px -96px; } 412 | .ui-icon-person { background-position: -144px -96px; } 413 | .ui-icon-print { background-position: -160px -96px; } 414 | .ui-icon-trash { background-position: -176px -96px; } 415 | .ui-icon-locked { background-position: -192px -96px; } 416 | .ui-icon-unlocked { background-position: -208px -96px; } 417 | .ui-icon-bookmark { background-position: -224px -96px; } 418 | .ui-icon-tag { background-position: -240px -96px; } 419 | .ui-icon-home { background-position: 0 -112px; } 420 | .ui-icon-flag { background-position: -16px -112px; } 421 | .ui-icon-calendar { background-position: -32px -112px; } 422 | .ui-icon-cart { background-position: -48px -112px; } 423 | .ui-icon-pencil { background-position: -64px -112px; } 424 | .ui-icon-clock { background-position: -80px -112px; } 425 | .ui-icon-disk { background-position: -96px -112px; } 426 | .ui-icon-calculator { background-position: -112px -112px; } 427 | .ui-icon-zoomin { background-position: -128px -112px; } 428 | .ui-icon-zoomout { background-position: -144px -112px; } 429 | .ui-icon-search { background-position: -160px -112px; } 430 | .ui-icon-wrench { background-position: -176px -112px; } 431 | .ui-icon-gear { background-position: -192px -112px; } 432 | .ui-icon-heart { background-position: -208px -112px; } 433 | .ui-icon-star { background-position: -224px -112px; } 434 | .ui-icon-link { background-position: -240px -112px; } 435 | .ui-icon-cancel { background-position: 0 -128px; } 436 | .ui-icon-plus { background-position: -16px -128px; } 437 | .ui-icon-plusthick { background-position: -32px -128px; } 438 | .ui-icon-minus { background-position: -48px -128px; } 439 | .ui-icon-minusthick { background-position: -64px -128px; } 440 | .ui-icon-close { background-position: -80px -128px; } 441 | .ui-icon-closethick { background-position: -96px -128px; } 442 | .ui-icon-key { background-position: -112px -128px; } 443 | .ui-icon-lightbulb { background-position: -128px -128px; } 444 | .ui-icon-scissors { background-position: -144px -128px; } 445 | .ui-icon-clipboard { background-position: -160px -128px; } 446 | .ui-icon-copy { background-position: -176px -128px; } 447 | .ui-icon-contact { background-position: -192px -128px; } 448 | .ui-icon-image { background-position: -208px -128px; } 449 | .ui-icon-video { background-position: -224px -128px; } 450 | .ui-icon-script { background-position: -240px -128px; } 451 | .ui-icon-alert { background-position: 0 -144px; } 452 | .ui-icon-info { background-position: -16px -144px; } 453 | .ui-icon-notice { background-position: -32px -144px; } 454 | .ui-icon-help { background-position: -48px -144px; } 455 | .ui-icon-check { background-position: -64px -144px; } 456 | .ui-icon-bullet { background-position: -80px -144px; } 457 | .ui-icon-radio-on { background-position: -96px -144px; } 458 | .ui-icon-radio-off { background-position: -112px -144px; } 459 | .ui-icon-pin-w { background-position: -128px -144px; } 460 | .ui-icon-pin-s { background-position: -144px -144px; } 461 | .ui-icon-play { background-position: 0 -160px; } 462 | .ui-icon-pause { background-position: -16px -160px; } 463 | .ui-icon-seek-next { background-position: -32px -160px; } 464 | .ui-icon-seek-prev { background-position: -48px -160px; } 465 | .ui-icon-seek-end { background-position: -64px -160px; } 466 | .ui-icon-seek-start { background-position: -80px -160px; } 467 | /* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ 468 | .ui-icon-seek-first { background-position: -80px -160px; } 469 | .ui-icon-stop { background-position: -96px -160px; } 470 | .ui-icon-eject { background-position: -112px -160px; } 471 | .ui-icon-volume-off { background-position: -128px -160px; } 472 | .ui-icon-volume-on { background-position: -144px -160px; } 473 | .ui-icon-power { background-position: 0 -176px; } 474 | .ui-icon-signal-diag { background-position: -16px -176px; } 475 | .ui-icon-signal { background-position: -32px -176px; } 476 | .ui-icon-battery-0 { background-position: -48px -176px; } 477 | .ui-icon-battery-1 { background-position: -64px -176px; } 478 | .ui-icon-battery-2 { background-position: -80px -176px; } 479 | .ui-icon-battery-3 { background-position: -96px -176px; } 480 | .ui-icon-circle-plus { background-position: 0 -192px; } 481 | .ui-icon-circle-minus { background-position: -16px -192px; } 482 | .ui-icon-circle-close { background-position: -32px -192px; } 483 | .ui-icon-circle-triangle-e { background-position: -48px -192px; } 484 | .ui-icon-circle-triangle-s { background-position: -64px -192px; } 485 | .ui-icon-circle-triangle-w { background-position: -80px -192px; } 486 | .ui-icon-circle-triangle-n { background-position: -96px -192px; } 487 | .ui-icon-circle-arrow-e { background-position: -112px -192px; } 488 | .ui-icon-circle-arrow-s { background-position: -128px -192px; } 489 | .ui-icon-circle-arrow-w { background-position: -144px -192px; } 490 | .ui-icon-circle-arrow-n { background-position: -160px -192px; } 491 | .ui-icon-circle-zoomin { background-position: -176px -192px; } 492 | .ui-icon-circle-zoomout { background-position: -192px -192px; } 493 | .ui-icon-circle-check { background-position: -208px -192px; } 494 | .ui-icon-circlesmall-plus { background-position: 0 -208px; } 495 | .ui-icon-circlesmall-minus { background-position: -16px -208px; } 496 | .ui-icon-circlesmall-close { background-position: -32px -208px; } 497 | .ui-icon-squaresmall-plus { background-position: -48px -208px; } 498 | .ui-icon-squaresmall-minus { background-position: -64px -208px; } 499 | .ui-icon-squaresmall-close { background-position: -80px -208px; } 500 | .ui-icon-grip-dotted-vertical { background-position: 0 -224px; } 501 | .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } 502 | .ui-icon-grip-solid-vertical { background-position: -32px -224px; } 503 | .ui-icon-grip-solid-horizontal { background-position: -48px -224px; } 504 | .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } 505 | .ui-icon-grip-diagonal-se { background-position: -80px -224px; } 506 | 507 | 508 | /* Misc visuals 509 | ----------------------------------*/ 510 | 511 | /* Corner radius */ 512 | .ui-corner-all, 513 | .ui-corner-top, 514 | .ui-corner-left, 515 | .ui-corner-tl { 516 | border-top-left-radius: 4px; 517 | } 518 | .ui-corner-all, 519 | .ui-corner-top, 520 | .ui-corner-right, 521 | .ui-corner-tr { 522 | border-top-right-radius: 4px; 523 | } 524 | .ui-corner-all, 525 | .ui-corner-bottom, 526 | .ui-corner-left, 527 | .ui-corner-bl { 528 | border-bottom-left-radius: 4px; 529 | } 530 | .ui-corner-all, 531 | .ui-corner-bottom, 532 | .ui-corner-right, 533 | .ui-corner-br { 534 | border-bottom-right-radius: 4px; 535 | } 536 | 537 | /* Overlays */ 538 | .ui-widget-overlay { 539 | background: #666666 url("images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat; 540 | opacity: .5; 541 | filter: Alpha(Opacity=50); /* support: IE8 */ 542 | } 543 | .ui-widget-shadow { 544 | margin: -5px 0 0 -5px; 545 | padding: 5px; 546 | background: #000000 url("images/ui-bg_flat_10_000000_40x100.png") 50% 50% repeat-x; 547 | opacity: .2; 548 | filter: Alpha(Opacity=20); /* support: IE8 */ 549 | border-radius: 5px; 550 | } 551 | -------------------------------------------------------------------------------- /website/data.php: -------------------------------------------------------------------------------- 1 | prepare('SELECT * FROM user'); 12 | $stmt->execute(); 13 | foreach ($stmt as $row) { 14 | $db_user[$row["id"]]=$row; 15 | }; 16 | 17 | // mach 18 | $db_mach=""; 19 | $stmt = $db->prepare('SELECT * FROM mach'); 20 | $stmt->execute(); 21 | foreach ($stmt as $row) { 22 | $db_mach[$row["id"]]=$row; 23 | }; 24 | }; 25 | 26 | 27 | function get_user($i){ 28 | global $db_user; 29 | if(isset($db_user[$i])){ 30 | return $db_user[$i]; 31 | }; 32 | return -1; 33 | } 34 | 35 | function get_user_name($i){ 36 | $u=get_user($i); 37 | if($u!=-1){ 38 | return $u["name"]; 39 | }; 40 | return -1; 41 | }; 42 | 43 | function get_mach($i){ 44 | global $db_mach; 45 | if(isset($db_mach[$i])){ 46 | return $db_mach[$i]; 47 | }; 48 | return -1; 49 | } 50 | 51 | function get_mach_name($i){ 52 | $u=get_mach($i); 53 | if($u!=-1){ 54 | return $u["name"]; 55 | }; 56 | return -1; 57 | }; 58 | 59 | ?> 60 | -------------------------------------------------------------------------------- /website/db_con.php: -------------------------------------------------------------------------------- 1 | setAttribute(PDO::ATTR_EMULATE_PREPARES, false); 6 | $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 7 | ?> 8 | -------------------------------------------------------------------------------- /website/helper.php: -------------------------------------------------------------------------------- 1 | prepare("DELETE FROM `macs`.`update_available` WHERE `mach_id`=:mach_id"); 5 | $stmt3->bindParam(":mach_id",$mach_id,PDO::PARAM_INT); 6 | $stmt3->execute(); 7 | 8 | $stmt2 = $db->prepare("INSERT INTO `macs`.`update_available` (`mach_id`) VALUE (:mach_id)"); 9 | $stmt2->bindParam(":mach_id",$mach_id,PDO::PARAM_INT); 10 | $stmt2->execute(); 11 | }; 12 | 13 | function hide_table($name){ 14 | global $_GET; 15 | $show="hideatstart"; 16 | if(isset($_GET["show"])){ 17 | if($_GET["show"]==$name){ // TODO ARRAY 18 | $show=""; 19 | } 20 | }; 21 | return $show; 22 | }; 23 | 24 | function show_info($txt){ 25 | global $info; 26 | global $info_txt; 27 | if(!empty($info_txt)){ 28 | $info_txt.=",".$txt; 29 | } else { 30 | $info_txt=$txt; 31 | }; 32 | 33 | $info='
'.$info_txt.'
'; 34 | }; 35 | 36 | 37 | 38 | ?> 39 | -------------------------------------------------------------------------------- /website/history.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT `id` FROM `macs`.`mach` WHERE mach_nr=:mach_nr"); 22 | $stmt->bindParam("mach_nr",$_GET["mach_nr"],PDO::PARAM_STR); 23 | $stmt->execute(); 24 | foreach($stmt as $row){ 25 | $mach=$row["id"]; 26 | }; 27 | } 28 | if(!isset($_GET["badge"])){ 29 | $user="-"; 30 | } else { 31 | $user=""; 32 | $stmt = $db->prepare("SELECT `id` FROM `macs`.`user` WHERE badge_id=:badge and active=1"); 33 | $stmt->bindParam("badge",intval($_GET["badge"]),PDO::PARAM_STR); 34 | $stmt->execute(); 35 | foreach($stmt as $row){ 36 | $user=$row["id"]; 37 | }; 38 | if($user==""){ 39 | $event.=" ".$_GET["badge"]; 40 | $user="-"; 41 | }; 42 | } 43 | add_log($mach,$user,$event,$time); 44 | clean_log($mach,$user,$event,time()); 45 | }; 46 | 47 | function add_log($machine,$user,$event,$time){ 48 | global $db; 49 | //echo "adding ".$machine." ".$user." ".$event; 50 | $stmt = $db->prepare("INSERT INTO `macs`.`log` (`timestamp`,`user_id`,`machine_id`,`event`,`login_id`,`usage`) VALUE (".time().",:user,:machine,:event,:login,:time)"); 51 | $stmt->bindParam(":user",$user,PDO::PARAM_STR); 52 | $stmt->bindParam(":machine",$machine,PDO::PARAM_STR); 53 | $stmt->bindParam(":event",$event,PDO::PARAM_STR); 54 | $stmt->bindParam(":login",$_SESSION['ID'],PDO::PARAM_INT); 55 | $stmt->bindParam(":time",$time,PDO::PARAM_INT); 56 | $stmt->execute(); 57 | }; 58 | 59 | function clean_log($machine,$user,$event,$time){ 60 | global $db; 61 | $stmt="SELECT COUNT(*) FROM `macs`.`log` WHERE `timestamp`>=".($time-2)." and `timestamp`<=".($time)." and `user_id`=:user and `machine_id`=:machine"; 62 | $stmt = $db->prepare($stmt); 63 | $stmt->bindParam(":user",$user,PDO::PARAM_STR); 64 | $stmt->bindParam(":machine",$machine,PDO::PARAM_STR); 65 | $stmt->execute(); 66 | foreach($stmt as $row){ 67 | if($row["COUNT(*)"]==3){ 68 | if($event=="Unlocked"){ 69 | $stmt = $db->prepare("DELETE FROM `macs`.`log` WHERE `timestamp`>=".($time-2)." and `timestamp`<=".($time)." and `user_id`=:user and `machine_id`=:machine ORDER BY `id` ASC LIMIT 2"); 70 | $stmt->bindParam(":user",$user,PDO::PARAM_STR); 71 | $stmt->bindParam(":machine",$machine,PDO::PARAM_STR); 72 | $stmt->execute(); 73 | } else if($event=="Locked"){ 74 | $stmt = $db->prepare("DELETE FROM `macs`.`log` WHERE `timestamp`>=".($time-2)." and `timestamp`<=".($time)." and `user_id`=:user and `machine_id`=:machine ORDER BY `id` DESC LIMIT 2"); 75 | $stmt->bindParam(":user",$user,PDO::PARAM_STR); 76 | $stmt->bindParam(":machine",$machine,PDO::PARAM_STR); 77 | $stmt->execute(); 78 | } 79 | } 80 | } 81 | 82 | // delete double reject entries 83 | $stmt="SELECT COUNT(*) FROM `macs`.`log` WHERE `timestamp`>=".($time-2)." and `timestamp`<=".($time)." and `user_id`=:user and `machine_id`=:machine and `event`=:event"; 84 | $stmt = $db->prepare($stmt); 85 | $stmt->bindParam(":event",$event,PDO::PARAM_STR); 86 | $stmt->bindParam(":user",$user,PDO::PARAM_STR); 87 | $stmt->bindParam(":machine",$machine,PDO::PARAM_STR); 88 | $stmt->execute(); 89 | foreach($stmt as $row){ 90 | $stmt = $db->prepare("DELETE FROM `macs`.`log` WHERE `timestamp`>=".($time-2)." and `timestamp`<=".($time)." and `user_id`=:user and `machine_id`=:machine and `event`=:event ORDER BY `id` DESC LIMIT ".($row["COUNT(*)"]-1)); 91 | $stmt->bindParam(":event",$event,PDO::PARAM_STR); 92 | $stmt->bindParam(":user",$user,PDO::PARAM_STR); 93 | $stmt->bindParam(":machine",$machine,PDO::PARAM_STR); 94 | $stmt->execute(); 95 | } 96 | } 97 | ?> 98 | -------------------------------------------------------------------------------- /website/html.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | MACS - Dashboard 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | '; 68 | 69 | if(isset($_SESSION['ID']) && $_SESSION['ID']!=0){ 70 | $header.=''; 71 | } 72 | 73 | $header.='
welcome to
M.A.C.S.

'; 74 | 75 | $footer=''; 76 | 77 | ?> 78 | 79 | -------------------------------------------------------------------------------- /website/images/bg1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/images/bg1.jpg -------------------------------------------------------------------------------- /website/images/bg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/images/bg2.jpg -------------------------------------------------------------------------------- /website/images/bg3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/images/bg3.jpg -------------------------------------------------------------------------------- /website/index.php: -------------------------------------------------------------------------------- 1 | prepare("UPDATE `macs`.`user` SET `active` = 0 WHERE `user`.`id` =:id;"); 27 | $stmt->bindParam(":id",$_POST["eid"],PDO::PARAM_INT); 28 | $stmt->execute(); 29 | 30 | // mark all machines that were affected by this deletation as updateable 31 | $stmt = $db->prepare("SELECT `mach_id` FROM `macs`.`access` WHERE `user_id` =:id;"); 32 | $stmt->bindParam(":id",$_POST["eid"],PDO::PARAM_INT); 33 | $stmt->execute(); 34 | foreach($stmt as $row){ 35 | set_mach_outdated($row["mach_id"],$db); 36 | }; 37 | 38 | // delete all access 39 | $stmt = $db->prepare("DELETE FROM `macs`.`access` WHERE `user_id` =:id;"); 40 | $stmt->bindParam(":id",$_POST["eid"],PDO::PARAM_INT); 41 | $stmt->execute(); 42 | 43 | add_log("-",$_POST["eid"],"User deleted","-"); 44 | show_info("User deleted"); 45 | } 46 | elseif(isset($_POST["submit"]) & ($_POST["submit"]=="Add" || $_POST["submit"]=="Update")){ 47 | $execute=0; 48 | $resume=0; 49 | // 1. check if the data make sense 50 | if($_POST["e_name"]=="-" or empty($_POST["e_name"])){ 51 | $execute=0; 52 | $resume=1; 53 | show_info("You have to provide a name"); 54 | } elseif($_POST["e_badge"]=="-" or empty($_POST["e_badge"]) or !is_numeric($_POST["e_badge"]) or strlen($_POST["e_badge"])>10 or strlen($_POST["e_badge"])<6){ 55 | $execute=0; 56 | $resume=1; 57 | show_info("You have to provide a 6 to 10-digit numeric Badge id"); 58 | } elseif($_POST["e_email"]=="-" or empty($_POST["e_email"]) or !filter_var($_POST["e_email"], FILTER_VALIDATE_EMAIL)){ 59 | $execute=0; 60 | $resume=1; 61 | show_info("You have to provide a valid email"); 62 | } elseif($_POST["e_login"]!="" and $_POST["macs_pw_md5"]=="d41d8cd98f00b204e9800998ecf8427e"){ // d41d8cd98f00b204e9800998ecf8427e = md5("") 63 | $execute=0; 64 | $resume=1; 65 | show_info("No login without pw"); 66 | } else { 67 | // run some checks before we accept the data 68 | // check if there is already the same badge 69 | $stmt = $db->prepare("SELECT COUNT(*) FROM `macs`.`user` WHERE badge_id=:badge_id and `active`=1"); 70 | if($_POST["e_id"]!=0){ // update 71 | $stmt = $db->prepare("SELECT COUNT(*) FROM `macs`.`user` WHERE badge_id=:badge_id and `active`=1 and `user`.`id` !=:id;"); 72 | $stmt->bindParam(":id",$_POST["e_id"],PDO::PARAM_INT); 73 | } 74 | $stmt->bindParam(":badge_id",$_POST["e_badge"],PDO::PARAM_INT); 75 | $stmt->execute(); 76 | foreach($stmt as $row){ 77 | if($row["COUNT(*)"]>0){ 78 | $excute=0; 79 | $resume=1; 80 | add_log("-","-","Badge ID already in db, entry rejected","-"); 81 | show_info("Entry rejected, duplicate badge"); 82 | } 83 | } 84 | 85 | if($resume==0){ 86 | // prepare statements 87 | if($_POST["e_id"]!=0){ // update 88 | $stmt = $db->prepare("UPDATE `macs`.`user` SET `name` = :name,`badge_id` = :badge_id,`email`=:email,`login`=:login,`hash`=:hash WHERE `user`.`id` =:id;"); 89 | $stmt->bindParam(":id",$_POST["e_id"],PDO::PARAM_INT); 90 | $execute=1; 91 | 92 | // mark all machines that were affected by this change as updateable 93 | $stmt2 = $db->prepare("SELECT `mach_id` FROM `macs`.`access` WHERE `user_id` =:id;"); 94 | $stmt2->bindParam(":id",$_POST["e_id"],PDO::PARAM_INT); 95 | $stmt2->execute(); 96 | foreach($stmt2 as $row){ 97 | set_mach_outdated($row["mach_id"],$db); 98 | }; 99 | 100 | } else { 101 | $stmt = $db->prepare("INSERT INTO `macs`.`user` (`name`,`badge_id`,`email`,`active`,`login`,`hash`) VALUE (:name,:badge_id,:email,1,:login,:hash)"); 102 | $execute=1; 103 | } // else 104 | } // resume == 0 105 | } 106 | 107 | if($execute==1){ 108 | $stmt->bindParam(":name",$_POST["e_name"],PDO::PARAM_STR); 109 | $stmt->bindParam(":badge_id",$_POST["e_badge"],PDO::PARAM_STR); 110 | $stmt->bindParam(":email",$_POST["e_email"],PDO::PARAM_STR); 111 | $stmt->bindParam(":login",$_POST["e_login"],PDO::PARAM_STR); 112 | $stmt->bindParam(":hash",$_POST["macs_pw_md5"],PDO::PARAM_STR); 113 | $stmt->execute(); 114 | 115 | load_data(); // reload as user has changed 116 | if($_POST["e_id"]!=0){ 117 | add_log("-",$_POST["e_id"],"User updated","-"); 118 | show_info("User updated"); 119 | 120 | // mark all machines that were affected by this deletation as updateable 121 | $stmt = $db->prepare("SELECT `mach_id` FROM `macs`.`access` WHERE `user_id` =:id;"); 122 | $stmt->bindParam(":id",$_POST["e_id"],PDO::PARAM_INT); 123 | $stmt->execute(); 124 | foreach($stmt as $row){ 125 | set_mach_outdated($row["mach_id"],$db); 126 | }; 127 | 128 | } else { 129 | $stmt = $db->prepare("SELECT ID FROM `macs`.`user` ORDER BY ID desc LIMIT 0,1"); 130 | $stmt->execute(); 131 | foreach($stmt as $row){ 132 | add_log("-",$row["ID"],"User created","-"); 133 | }; 134 | show_info("user created"); 135 | }; // msg 136 | 137 | 138 | 139 | }; // excute ok? 140 | } // edit is handled locally below 141 | } // delete or edit 142 | 143 | 144 | elseif($_POST["edit"]=="mach"){ 145 | if(isset($_POST["submit"]) & $_POST["submit"]=="delete"){ // delete 146 | // we are going to rename the machine id to the next freee nr above 900, get free nr 147 | $request = $db->prepare('SELECT MAX(mach_nr) FROM mach'); 148 | $request->execute(); 149 | foreach ($request as $row) { 150 | $new_mach_nr=$row["MAX(mach_nr)"]+1; 151 | }; 152 | if($new_mach_nr<900){ 153 | $new_mach_nr=900; 154 | }; 155 | 156 | // now, relabel machine 157 | $stmt = $db->prepare("UPDATE `macs`.`mach` SET `active` = 0, `mach_nr`=".$new_mach_nr." WHERE `mach`.`id` =:id;"); 158 | $stmt->bindParam(":id",$_POST["eid"],PDO::PARAM_INT); 159 | $stmt->execute(); 160 | 161 | 162 | add_log($_POST["eid"],"-","Machine deleted","-"); 163 | show_info("Machine deleted"); 164 | } 165 | elseif(isset($_POST["submit"]) & ($_POST["submit"]=="Add" || $_POST["submit"]=="Update")){ 166 | $execute=0; 167 | $resume=0; 168 | // check if the data make sense 169 | if($_POST["e_name"]=="-" or empty($_POST["e_name"])){ 170 | $execute=0; 171 | $resume=1; 172 | show_info("You have to provide a name"); 173 | } elseif($_POST["e_mach_nr"]=="-" or empty($_POST["e_mach_nr"])){ 174 | $execute=0; 175 | $resume=1; 176 | show_info("You have to provide a Mach id"); 177 | } elseif(!($_POST["e_mach_nr"]<128 && $_POST["e_mach_nr"]>0)){ 178 | $execute=0; 179 | $resume=1; 180 | show_info("Valid range for Mach Nr 1-127"); 181 | } elseif($_POST["e_desc"]=="-" or empty($_POST["e_desc"])){ 182 | $execute=0; 183 | $resume=1; 184 | show_info("You have to provide a description"); 185 | } elseif(strlen($_POST["e_name"])>12){ 186 | $execute=0; 187 | $resume=1; 188 | show_info("Please limit name to 12 chars"); 189 | } else { 190 | // is machine id already used? 191 | $stmt = $db->prepare("SELECT COUNT(*) FROM `macs`.`mach` WHERE mach_nr=:machine_id"); 192 | if($_POST["e_id"]!=0){ // update 193 | $stmt = $db->prepare("SELECT COUNT(*) FROM `macs`.`mach` WHERE mach_nr=:machine_id and `mach`.`id` !=:id;"); 194 | $stmt->bindParam(":id",$_POST["e_id"],PDO::PARAM_INT); 195 | }; 196 | $stmt->bindParam(":machine_id",$_POST["e_mach_nr"],PDO::PARAM_INT); 197 | $stmt->execute(); 198 | foreach($stmt as $row){ 199 | if($row["COUNT(*)"]>0){ 200 | $excute=0; 201 | $resume=1; 202 | add_log("-","-","Mach ID already in db, entry rejected","-"); 203 | show_info("Entry rejected, duplicate id"); 204 | } 205 | } 206 | 207 | if($resume==0){ 208 | if($_POST["e_id"]!=0){ // update 209 | $stmt = $db->prepare("UPDATE `macs`.`mach` SET `name` = :name,`mach_nr` = :mach_nr,`desc`=:desc WHERE `mach`.`id` =:id;"); 210 | $stmt->bindParam(":id",$_POST["e_id"],PDO::PARAM_INT); 211 | $execute=1; 212 | 213 | // insert entry that this machine might need an update 214 | set_mach_outdated($_POST["e_id"],$db); 215 | 216 | } else { 217 | $stmt = $db->prepare("INSERT INTO `macs`.`mach` (`name`,`mach_nr`,`desc`,`active`) VALUE (:name,:mach_nr,:desc,1)"); 218 | $execute=1; 219 | } // insert 220 | }; 221 | } // if check ok 222 | 223 | if($execute==1){ 224 | $stmt->bindParam(":name",$_POST["e_name"],PDO::PARAM_STR); 225 | $stmt->bindParam(":mach_nr",$_POST["e_mach_nr"],PDO::PARAM_STR); 226 | $stmt->bindParam(":desc",$_POST["e_desc"],PDO::PARAM_STR); 227 | $stmt->execute(); 228 | 229 | load_data(); // reload as user has changed 230 | if($_POST["e_id"]!=0){ 231 | add_log($_POST["e_id"],"-","Machine updated","-"); 232 | show_info("machine updated"); 233 | } else { 234 | $stmt = $db->prepare("SELECT ID FROM `macs`.`mach` ORDER BY ID desc LIMIT 0,1"); 235 | $stmt->execute(); 236 | foreach($stmt as $row){ 237 | add_log($row["ID"],"-","Machine created","-"); 238 | }; 239 | show_info("machine created"); 240 | }; 241 | } 242 | } // add update 243 | } 244 | elseif($_POST["edit"]=="eaccess"){ 245 | $stmt = $db->prepare("TRUNCATE TABLE `access`"); 246 | $stmt->execute(); 247 | foreach($_POST as $post => $value){ 248 | $post_ex=explode("_",$post); 249 | if($post_ex[0]=="c" and count($post_ex)==3){ 250 | $stmt=$db->prepare("INSERT INTO `macs`.`access` (`user_id`, `mach_id`) VALUES (:uid, :mid);"); 251 | $stmt->bindParam(":uid",$post_ex[2],PDO::PARAM_INT); 252 | $stmt->bindParam(":mid",$post_ex[1],PDO::PARAM_INT); 253 | $stmt->execute(); 254 | } 255 | }; 256 | 257 | // mark all machines as updateable 258 | $stmt = $db->prepare("SELECT `id` FROM `macs`.`mach`"); 259 | $stmt->execute(); 260 | foreach($stmt as $row){ 261 | set_mach_outdated($row["id"],$db); 262 | }; 263 | 264 | 265 | add_log("-","-","access right updated","-"); 266 | show_info("access right updated"); 267 | }; 268 | }; 269 | ////////////////// USER /////////////// 270 | ////////////////// DB CHANGES /////////////// 271 | 272 | 273 | $o=$header.' 274 |
+ Add/Edit User
275 | '; 276 | 277 | 278 | ///////////////// GET USER /////////////// 279 | $o_user=""; 280 | $stmt = $db->prepare('SELECT * FROM user where active=1'); 281 | $stmt->execute(); 282 | foreach ($stmt as $row) { 283 | $last_seen=date("Y/m/d H:i",$row["last_seen"]); 284 | if($row["last_seen"]==0){ 285 | $last_seen="-"; 286 | }; 287 | $admin_access='no'; 288 | if(!empty($row["login"]) and !empty($row["hash"])){ 289 | $admin_access='yes'; 290 | }; 291 | 292 | $o_user.=' 293 | 294 | 295 | 296 | 297 | 298 | '; 306 | }; 307 | $o.=$o_user; 308 | ///////////////// GET USER /////////////// 309 | 310 | ///////////////// EDIT USER /////////////// 311 | $e_name="-"; 312 | $e_badge="-"; 313 | $e_email="-"; 314 | $e_login=""; 315 | $e_hash=""; 316 | $e_id=0; 317 | $btn="Add"; 318 | 319 | if(isset($_POST["edit"])){ 320 | if($_POST["edit"]=="user" AND !empty($_POST["eid"]) AND $_POST["submit"]=="edit"){ 321 | $stmt = $db->prepare('SELECT * FROM user where id=:id'); 322 | $stmt->execute(array('id' => $_POST["eid"])); 323 | foreach ($stmt as $row){ 324 | $e_name=$row["name"]; 325 | $e_badge=$row["badge_id"]; 326 | $e_id=$row["id"]; 327 | $e_email=$row["email"]; 328 | $e_login=$row["login"]; 329 | }; 330 | $btn="Update"; 331 | } elseif($_POST["edit"]=="user" AND ($_POST["submit"]=="Add" || $_POST["submit"]=="Update") AND $resume==1){ 332 | $e_name=$_POST["e_name"]; 333 | $e_email=$_POST["e_email"]; 334 | $e_badge=$_POST["e_badge"]; 335 | $e_login=$_POST["e_login"]; 336 | $e_id=$_POST["e_id"]; 337 | if($_POST["submit"]=="Update"){ 338 | $btn="Update"; 339 | }; 340 | }; 341 | }; 342 | 343 | 344 | $o.=' 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 |
NameeMailBadge-IDAdmin accesslast usededit
'.$row["name"].''.$row["email"].''.$row["badge_id"].''.$admin_access.''.$last_seen.' 299 |
300 | 301 | 302 | 303 | 304 |
305 |
 
NameeMailProvid login/pw for admin accessBadge-ID
'; 354 | ///////////////// EDIT USER /////////////// 355 | 356 | $o.='
 
+ Add/Edit Stations
'; 357 | 358 | /////////////// GET MACHINE //////////////// 359 | $o.=' 360 | '; 361 | 362 | $o_mach=""; 363 | $stmt = $db->prepare('SELECT * FROM mach WHERE `active`=1'); 364 | $stmt->execute(); 365 | foreach ($stmt as $row) { 366 | $last_seen=date("Y/m/d H:i",$row["last_seen"]); 367 | if($row["last_seen"]==0){ 368 | $last_seen="-"; 369 | }; 370 | 371 | $o_mach.=' 372 | 373 | 374 | 375 | 376 | 377 | 385 | 386 | '; 387 | }; 388 | $o.=$o_mach; 389 | 390 | /////////////// GET MACHINE //////////////// 391 | /////////////// EDIT MACHINE //////////////// 392 | $e_name="-"; 393 | $e_mach_nr="-"; 394 | $e_desc="-"; 395 | $e_id=0; 396 | $btn="Add"; 397 | if(isset($_POST["edit"])){ 398 | if($_POST["edit"]=="mach" AND !empty($_POST["eid"]) AND $_POST["submit"]=="edit"){ 399 | $stmt = $db->prepare('SELECT * FROM mach where id=:id'); 400 | $stmt->execute(array('id' => $_POST["eid"])); 401 | foreach ($stmt as $row){ 402 | $e_name=$row["name"]; 403 | $e_mach_nr=$row["mach_nr"]; 404 | $e_id=$row["id"]; 405 | $e_desc=$row["desc"]; 406 | }; 407 | $btn="Update"; 408 | } elseif($_POST["edit"]=="mach" AND ($_POST["submit"]=="Add" || $_POST["submit"]=="Update") AND $resume==1){ 409 | $e_name=$_POST["e_name"]; 410 | $e_mach_nr=$_POST["e_mach_nr"]; 411 | $e_desc=$_POST["e_desc"]; 412 | $e_id=$_POST["e_id"]; 413 | if($_POST["submit"]=="Update"){ 414 | $btn="Update"; 415 | }; 416 | 417 | }; 418 | }; 419 | $o.=' 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 |
NameMachine-NrDescriptionlast usedversion 
'.$row["name"].''.$row["mach_nr"].''.$row["desc"].''.$last_seen.''.$row["version"].' 378 |
379 | 380 | 381 | 382 | 383 |
384 |
 
NameMachine-NrDescription 
-
'; 429 | /////////////// EDIT MACHINE //////////////// 430 | 431 | /////////////// GET CONNECTION ////////////// 432 | $o.='
 
+ Connect User to Station
433 | '; 466 | $marray[$i]=$mrow; 467 | if($DEBUG) "marray[".$i."][id]=".$marray[$i]["id"]."
"; 468 | $i++; 469 | } 470 | $o_conn.=''; 471 | 472 | // user 473 | $user = $db->prepare('SELECT * FROM user WHERE `active`=1 order by id asc'); 474 | $user->execute(); 475 | 476 | // generate access matrix 477 | if($DEBUG) "generate access matrix (".$matrix_dimx."/".$matrix_dimy.")
"; 478 | for($x=0;$x<=$matrix_dimx;$x++){ 479 | for($y=0;$y<=$matrix_dimy;$y++){ 480 | $access[$x][$y]=0; // x=machine , y=user 481 | } 482 | }; 483 | 484 | $db_a = $db->prepare('SELECT * FROM access order by id asc'); 485 | $db_a->execute(); 486 | foreach ($db_a as $arow) { 487 | $access[$arow['mach_id']][$arow['user_id']]=1; 488 | } 489 | 490 | if($DEBUG) "matrix:
"; 491 | for($x=0;$x<=$matrix_dimx;$x++){ 492 | for($y=0;$y<=$matrix_dimy;$y++){ 493 | if($DEBUG) $access[$x][$y].','; 494 | } 495 | if($DEBUG) '
'; 496 | }; 497 | 498 | // output 499 | $i=0; 500 | $o_conn.=''; 501 | foreach ($user as $row) { 502 | $o_conn.=''; 503 | for($x=0;$x<$dimx;$x++){ 504 | $checked=""; 505 | if($DEBUG) "searching in access[".$marray[$x]["id"]."][".$row["id"]."]
"; 506 | if($access[$marray[$x]["id"]][$row["id"]]==1){ 507 | $checked="checked"; 508 | }; 509 | $o_conn.=''; 510 | } 511 | $i++; 512 | }; 513 | 514 | $o_conn.=' 515 |
 '; 434 | 435 | $o_conn=""; 436 | 437 | // generate dimensions 438 | $request = $db->prepare('SELECT MAX(ID) FROM mach order by id asc'); 439 | $request->execute(); 440 | foreach ($request as $row) { 441 | $matrix_dimx=$row["MAX(ID)"]; 442 | }; 443 | $request = $db->prepare('SELECT MAX(ID) FROM user order by id asc'); 444 | $request->execute(); 445 | foreach ($request as $row) { 446 | $matrix_dimy=$row["MAX(ID)"]; 447 | }; 448 | 449 | $request = $db->prepare('SELECT COUNT(*) FROM mach WHERE `active`=1 order by id asc '); 450 | $request->execute(); 451 | foreach ($request as $row) { 452 | $dimx=$row["COUNT(*)"]; 453 | }; 454 | $request = $db->prepare('SELECT COUNT(*) FROM user WHERE `active`=1 order by id asc'); 455 | $request->execute(); 456 | foreach ($request as $row) { 457 | $dimy=$row["COUNT(*)"]; 458 | }; 459 | 460 | // machines 461 | $i=0; 462 | $mach = $db->prepare('SELECT * FROM mach WHERE `active`=1 order by id asc'); 463 | $mach->execute(); 464 | foreach ($mach as $mrow) { 465 | $o_conn.='
'.$mrow['name'].'
'.$row["name"].'
 
'; 516 | 517 | $o.=$o_conn; 518 | 519 | 520 | //////////////// LOG ///////////////// 521 | include("php_module/module_log.php"); 522 | 523 | $o.='
 
+ Log '.$title.'
'; 524 | $o.='
'; 525 | 526 | $o.=$o_log; 527 | //////////////// LOG ///////////////// 528 | 529 | //////////////// LOG ///////////////// 530 | include("php_module/module_usage.php"); 531 | 532 | $o.='
 
+ Usage
'; 533 | $o.='
'; 534 | 535 | $o.=$o_usage; 536 | //////////////// LOG ///////////////// 537 | 538 | //////////////// setup ///////////////// 539 | $o.='
 
+ Setup
'; 540 | $o.='
'; 541 | 542 | $o.=''; 543 | //////////////// setup ///////////////// 544 | 545 | //////////////// backup ///////////////// 546 | $o.='
 
+ Backup DB
'; 547 | $o.='
'; 548 | $o.=''; 549 | //////////////// backup ///////////////// 550 | 551 | $o.='



'; 552 | 553 | 554 | if(!empty($info)){ 555 | $o.=$info; 556 | }; 557 | 558 | $o.=$footer; 559 | echo $o; 560 | 561 | ?> 562 | -------------------------------------------------------------------------------- /website/js/images/dragIcon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIcon.gif -------------------------------------------------------------------------------- /website/js/images/dragIconBlack.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconBlack.gif -------------------------------------------------------------------------------- /website/js/images/dragIconH.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconH.gif -------------------------------------------------------------------------------- /website/js/images/dragIconHBlack.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconHBlack.gif -------------------------------------------------------------------------------- /website/js/images/dragIconRectBig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectBig.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectBig.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRectBigBlack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectBigBlack.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectBigBlack.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /website/js/images/dragIconRectBigBlackH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectBigBlackH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectBigBlackH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /website/js/images/dragIconRectBigH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectBigH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectBigH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectSmall.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmall.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmallBlack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectSmallBlack.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmallBlack.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmallBlackH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectSmallBlackH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmallBlackH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmallH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRectSmallH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRectSmallH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundBig.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBig.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBigBlack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundBigBlack.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBigBlack.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBigBlackH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundBigBlackH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBigBlackH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBigH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundBigH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundBigH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundSmall.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmall.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmallBlack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundSmallBlack.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmallBlack.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmallBlackH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundSmallBlackH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmallBlackH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmallH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/dragIconRoundSmallH.png -------------------------------------------------------------------------------- /website/js/images/dragIconRoundSmallH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/eraserIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/eraserIconH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /website/js/images/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/export.png -------------------------------------------------------------------------------- /website/js/images/exportWhite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/exportWhite.png -------------------------------------------------------------------------------- /website/js/images/lens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/lens.png -------------------------------------------------------------------------------- /website/js/images/lens.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /website/js/images/lensWhite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/lensWhite.png -------------------------------------------------------------------------------- /website/js/images/lensWhite.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /website/js/images/lensWhite_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/lensWhite_old.png -------------------------------------------------------------------------------- /website/js/images/lens_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoljaWindeler/macs/f500a70e3164f127ab1c58baaed7efb61e5e1ab9/website/js/images/lens_old.png -------------------------------------------------------------------------------- /website/js/images/pencilIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 23 | -------------------------------------------------------------------------------- /website/js/images/pencilIconH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 23 | -------------------------------------------------------------------------------- /website/js/images/xIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /website/js/images/xIconH.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /website/js/jstz.min.js: -------------------------------------------------------------------------------- 1 | /*! jstz - v1.0.4 - 2012-12-18 */ 2 | (function(e){var t=function(){"use strict";var e="s",n=function(e){var t=-e.getTimezoneOffset();return t!==null?t:0},r=function(e,t,n){var r=new Date;return e!==undefined&&r.setFullYear(e),r.setDate(n),r.setMonth(t),r},i=function(e){return n(r(e,0,2))},s=function(e){return n(r(e,5,2))},o=function(e){var t=e.getMonth()>7?s(e.getFullYear()):i(e.getFullYear()),r=n(e);return t-r!==0},u=function(){var t=i(),n=s(),r=i()-s();return r<0?t+",1":r>0?n+",1,"+e:t+",0"},a=function(){var e=u();return new t.TimeZone(t.olson.timezones[e])},f=function(e){var t=new Date(2010,6,15,1,0,0,0),n={"America/Denver":new Date(2011,2,13,3,0,0,0),"America/Mazatlan":new Date(2011,3,3,3,0,0,0),"America/Chicago":new Date(2011,2,13,3,0,0,0),"America/Mexico_City":new Date(2011,3,3,3,0,0,0),"America/Asuncion":new Date(2012,9,7,3,0,0,0),"America/Santiago":new Date(2012,9,3,3,0,0,0),"America/Campo_Grande":new Date(2012,9,21,5,0,0,0),"America/Montevideo":new Date(2011,9,2,3,0,0,0),"America/Sao_Paulo":new Date(2011,9,16,5,0,0,0),"America/Los_Angeles":new Date(2011,2,13,8,0,0,0),"America/Santa_Isabel":new Date(2011,3,5,8,0,0,0),"America/Havana":new Date(2012,2,10,2,0,0,0),"America/New_York":new Date(2012,2,10,7,0,0,0),"Asia/Beirut":new Date(2011,2,27,1,0,0,0),"Europe/Helsinki":new Date(2011,2,27,4,0,0,0),"Europe/Istanbul":new Date(2011,2,28,5,0,0,0),"Asia/Damascus":new Date(2011,3,1,2,0,0,0),"Asia/Jerusalem":new Date(2011,3,1,6,0,0,0),"Asia/Gaza":new Date(2009,2,28,0,30,0,0),"Africa/Cairo":new Date(2009,3,25,0,30,0,0),"Pacific/Auckland":new Date(2011,8,26,7,0,0,0),"Pacific/Fiji":new Date(2010,11,29,23,0,0,0),"America/Halifax":new Date(2011,2,13,6,0,0,0),"America/Goose_Bay":new Date(2011,2,13,2,1,0,0),"America/Miquelon":new Date(2011,2,13,5,0,0,0),"America/Godthab":new Date(2011,2,27,1,0,0,0),"Europe/Moscow":t,"Asia/Yekaterinburg":t,"Asia/Omsk":t,"Asia/Krasnoyarsk":t,"Asia/Irkutsk":t,"Asia/Yakutsk":t,"Asia/Vladivostok":t,"Asia/Kamchatka":t,"Europe/Minsk":t,"Australia/Perth":new Date(2008,10,1,1,0,0,0)};return n[e]};return{determine:a,date_is_dst:o,dst_start_for:f}}();t.TimeZone=function(e){"use strict";var n={"America/Denver":["America/Denver","America/Mazatlan"],"America/Chicago":["America/Chicago","America/Mexico_City"],"America/Santiago":["America/Santiago","America/Asuncion","America/Campo_Grande"],"America/Montevideo":["America/Montevideo","America/Sao_Paulo"],"Asia/Beirut":["Asia/Beirut","Europe/Helsinki","Europe/Istanbul","Asia/Damascus","Asia/Jerusalem","Asia/Gaza"],"Pacific/Auckland":["Pacific/Auckland","Pacific/Fiji"],"America/Los_Angeles":["America/Los_Angeles","America/Santa_Isabel"],"America/New_York":["America/Havana","America/New_York"],"America/Halifax":["America/Goose_Bay","America/Halifax"],"America/Godthab":["America/Miquelon","America/Godthab"],"Asia/Dubai":["Europe/Moscow"],"Asia/Dhaka":["Asia/Yekaterinburg"],"Asia/Jakarta":["Asia/Omsk"],"Asia/Shanghai":["Asia/Krasnoyarsk","Australia/Perth"],"Asia/Tokyo":["Asia/Irkutsk"],"Australia/Brisbane":["Asia/Yakutsk"],"Pacific/Noumea":["Asia/Vladivostok"],"Pacific/Tarawa":["Asia/Kamchatka"],"Africa/Johannesburg":["Asia/Gaza","Africa/Cairo"],"Asia/Baghdad":["Europe/Minsk"]},r=e,i=function(){var e=n[r],i=e.length,s=0,o=e[0];for(;s'+col[0]+''+col[1]+''+col[2]+''+col[3]+''+col[4]+''); 20 | //console.log("line "+i+" has "+col.length+" data, first "+col[0]); 21 | }; 22 | old=data; 23 | }; 24 | } // success 25 | }); 26 | }; 27 | 28 | setInterval(function(){get_data();}, 1000); 29 | 30 | 31 | }); 32 | -------------------------------------------------------------------------------- /website/js/md5.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.0.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2012 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | var CryptoJS=CryptoJS||function(o,q){var l={},m=l.lib={},n=m.Base=function(){function a(){}return{extend:function(e){a.prototype=this;var c=new a;e&&c.mixIn(e);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),j=m.WordArray=n.extend({init:function(a,e){a= 8 | this.words=a||[];this.sigBytes=e!=q?e:4*a.length},toString:function(a){return(a||r).stringify(this)},concat:function(a){var e=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b>>2]|=(c[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535>>2]=c[b>>>2];else e.push.apply(e,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,e=this.sigBytes;a[e>>>2]&=4294967295<<32-8*(e%4);a.length=o.ceil(e/4)},clone:function(){var a= 9 | n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var e=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((b>>>4).toString(16));c.push((b&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return j.create(c,b/2)}},p=k.Latin1={stringify:function(a){for(var b= 10 | a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return j.create(c,b)}},h=k.Utf8={stringify:function(a){try{return decodeURIComponent(escape(p.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return p.parse(unescape(encodeURIComponent(a)))}},b=m.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=j.create(); 11 | this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=h.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,i=d/(4*f),i=a?o.ceil(i):o.max((i|0)-this._minBufferSize,0),a=i*f,d=o.min(4*a,d);if(a){for(var h=0;h>>32-d)+f}function l(b,f,a,e,c,d,g){b=b+(f&e|a&~e)+c+g;return(b<>>32-d)+f}function m(b,f,a,e,c,d,g){b=b+(f^a^e)+c+g;return(b<>>32-d)+f}function n(b,f,a,e,c,d,g){b=b+(a^(f|~e))+c+g;return(b<>>32-d)+f}var j=CryptoJS,k=j.lib,r=k.WordArray,k=k.Hasher,p=j.algo,h=[];(function(){for(var b=0;64>b;b++)h[b]=4294967296*o.abs(o.sin(b+1))|0})();p=p.MD5=k.extend({_doReset:function(){this._hash=r.create([1732584193,4023233417, 14 | 2562383102,271733878])},_doProcessBlock:function(b,f){for(var a=0;16>a;a++){var e=f+a,c=b[e];b[e]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360}for(var e=this._hash.words,c=e[0],d=e[1],g=e[2],i=e[3],a=0;64>a;a+=4)16>a?(c=q(c,d,g,i,b[f+a],7,h[a]),i=q(i,c,d,g,b[f+a+1],12,h[a+1]),g=q(g,i,c,d,b[f+a+2],17,h[a+2]),d=q(d,g,i,c,b[f+a+3],22,h[a+3])):32>a?(c=l(c,d,g,i,b[f+(a+1)%16],5,h[a]),i=l(i,c,d,g,b[f+(a+6)%16],9,h[a+1]),g=l(g,i,c,d,b[f+(a+11)%16],14,h[a+2]),d=l(d,g,i,c,b[f+a%16],20,h[a+3])):48>a?(c= 15 | m(c,d,g,i,b[f+(3*a+5)%16],4,h[a]),i=m(i,c,d,g,b[f+(3*a+8)%16],11,h[a+1]),g=m(g,i,c,d,b[f+(3*a+11)%16],16,h[a+2]),d=m(d,g,i,c,b[f+(3*a+14)%16],23,h[a+3])):(c=n(c,d,g,i,b[f+3*a%16],6,h[a]),i=n(i,c,d,g,b[f+(3*a+7)%16],10,h[a+1]),g=n(g,i,c,d,b[f+(3*a+14)%16],15,h[a+2]),d=n(d,g,i,c,b[f+(3*a+5)%16],21,h[a+3]));e[0]=e[0]+c|0;e[1]=e[1]+d|0;e[2]=e[2]+g|0;e[3]=e[3]+i|0},_doFinalize:function(){var b=this._data,f=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;f[e>>>5]|=128<<24-e%32;f[(e+64>>>9<<4)+14]=(a<<8|a>>> 16 | 24)&16711935|(a<<24|a>>>8)&4278255360;b.sigBytes=4*(f.length+1);this._process();b=this._hash.words;for(f=0;4>f;f++)a=b[f],b[f]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360}});j.MD5=k._createHelper(p);j.HmacMD5=k._createHmacHelper(p)})(Math); 17 | -------------------------------------------------------------------------------- /website/js/setup_helper.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | var setup_old=""; 3 | var setup_same_content=0; 4 | //alert("und los"); 5 | function get_data_setup_helper() { 6 | $.ajax({ 7 | type: "GET", 8 | url: "module_setup_helper_reader.php", 9 | success: function(data){ 10 | if(data!=setup_old){ 11 | //alert(data); 12 | var a=$("#setup_log"); 13 | if(a.length){ 14 | a.html("Output:
"+data); 15 | }; 16 | setup_old=data; 17 | setup_same_content=0; 18 | } else { 19 | setup_same_content=setup_same_content+1; 20 | } 21 | } // success 22 | }); 23 | }; 24 | // call it for 50 sec 25 | if(setup_same_content<100){ 26 | setInterval(function(){get_data_setup_helper();}, 500); 27 | }; 28 | 29 | 30 | }); 31 | -------------------------------------------------------------------------------- /website/logview.php: -------------------------------------------------------------------------------- 1 | '; 21 | $o.=' + Log '.$title.''; 22 | $o.=''; 23 | 24 | $o.=$o_log; 25 | 26 | $o.=''; 27 | 28 | 29 | 30 | $o.=$footer; 31 | echo $o; 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /website/m2m.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT COUNT(*) FROM mach where mach_nr=:id"); 6 | $stmt->bindParam(":id",$_GET["mach_nr"],PDO::PARAM_INT); 7 | $stmt->execute(); 8 | foreach($stmt as $row){ 9 | if($row["COUNT(*)"]>0){ 10 | $machine_known=1; 11 | } 12 | } 13 | 14 | if($machine_known==1){ 15 | $stmt = $db->prepare("SELECT badge_id FROM `user` WHERE active=1 and id in (select user_id from access where mach_id=(select id from mach where mach_nr=:id))"); 16 | $stmt->bindParam(":id",$_GET["mach_nr"],PDO::PARAM_INT); 17 | $stmt->execute(); 18 | $csv=""; 19 | foreach($stmt as $row){ 20 | $csv.=intval($row["badge_id"],10).","; 21 | }; 22 | 23 | //echo $csv; 24 | 25 | 26 | // update last seen 27 | $stmt = $db->prepare("UPDATE `mach` SET `last_seen`=".time().", `version`=:v WHERE mach_nr=:id"); 28 | $stmt->bindParam(":id",$_GET["mach_nr"],PDO::PARAM_INT); 29 | $stmt->bindParam(":v",$_GET["v"],PDO::PARAM_INT); 30 | $stmt->execute(); 31 | 32 | // check if we should create a log entry for this 33 | $stmt = $db->prepare("SELECT COUNT(*) FROM `update_available` WHERE mach_id in (select id from mach where mach_nr=:id)"); 34 | $stmt->bindParam(":id",$_GET["mach_nr"],PDO::PARAM_INT); 35 | $stmt->execute(); 36 | 37 | $updated=0; 38 | foreach($stmt as $row){ 39 | if($row["COUNT(*)"]>0){ 40 | $stmt2 = $db->prepare("INSERT INTO `macs`.`log` (`id`, `timestamp`, `user_id`, `machine_id`, `event`) VALUES ('', '".time()."', '0', (SELECT `id` FROM `mach` WHERE mach_nr=:id), 'Station updated')"); 41 | $stmt2->bindParam(":id",$_GET["mach_nr"],PDO::PARAM_INT); 42 | $stmt2->execute(); 43 | 44 | $stmt3 = $db->prepare("DELETE FROM `update_available` WHERE mach_id in (select id from mach where mach_nr=:id)"); 45 | $stmt3->bindParam(":id",$_GET["mach_nr"],PDO::PARAM_INT); 46 | $stmt3->execute(); 47 | 48 | echo $csv; 49 | $updated=1; 50 | break; 51 | }; 52 | }; 53 | 54 | if(isset($_GET['forced'])){ 55 | if($_GET['forced']=='1'){ 56 | echo $csv; 57 | $updated=1; 58 | } 59 | } 60 | 61 | if($updated==0){ 62 | echo "nu"; 63 | }; 64 | 65 | } else { 66 | // unknown machine 67 | if(!is_numeric($_GET["mach_nr"])){ 68 | $_GET["mach_nr"]=999; 69 | }; 70 | $stmt2 = $db->prepare("INSERT INTO `macs`.`log` (`id`, `timestamp`, `user_id`, `machine_id`, `event`) VALUES ('', '".time()."', '0', '', 'Unknown Station ".$_GET["mach_nr"]." connected')"); 71 | $stmt2->execute(); 72 | }; 73 | }; 74 | 75 | ?> 76 | -------------------------------------------------------------------------------- /website/php_module/module_backup.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | MACS - Dashboard 17 | 18 | '; 19 | 20 | $dbhost = 'localhost'; 21 | $dbuser = 'root'; 22 | $dbpass = $sql_pw; 23 | $dbname = 'macs'; 24 | 25 | function backup_tables($host,$user,$pass,$name,$tables = '*') 26 | { 27 | 28 | $link = mysql_connect($host,$user,$pass); 29 | mysql_select_db($name,$link); 30 | mysql_query("SET NAMES 'utf8'"); 31 | 32 | //get all of the tables 33 | if($tables == '*') 34 | { 35 | $tables = array(); 36 | $result = mysql_query('SHOW TABLES'); 37 | while($row = mysql_fetch_row($result)) 38 | { 39 | $tables[] = $row[0]; 40 | } 41 | } 42 | else 43 | { 44 | $tables = is_array($tables) ? $tables : explode(',',$tables); 45 | } 46 | $return=''; 47 | //cycle through 48 | foreach($tables as $table) 49 | { 50 | $result = mysql_query('SELECT * FROM '.$table); 51 | $num_fields = mysql_num_fields($result); 52 | 53 | $return.= 'DROP TABLE '.$table.';'; 54 | $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table)); 55 | $return.= "\n\n".$row2[1].";\n\n"; 56 | 57 | for ($i = 0; $i < $num_fields; $i++) 58 | { 59 | while($row = mysql_fetch_row($result)) 60 | { 61 | $return.= 'INSERT INTO '.$table.' VALUES('; 62 | for($j=0; $j<$num_fields; $j++) 63 | { 64 | $row[$j] = addslashes($row[$j]); 65 | $row[$j] = str_replace("\n","\\n",$row[$j]); 66 | if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; } 67 | if ($j<($num_fields-1)) { $return.= ','; } 68 | } 69 | $return.= ");\n"; 70 | } 71 | } 72 | $return.="\n\n\n"; 73 | } 74 | 75 | //save file 76 | $fn = '../db_backup/db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql'; 77 | $handle = fopen($fn,'w+'); 78 | fwrite($handle,$return); 79 | fclose($handle); 80 | return 'click to download database'; 81 | } 82 | 83 | if (isset($_GET['restore'])) { 84 | if (is_uploaded_file($_FILES['filename']['tmp_name'])) { 85 | if (move_uploaded_file($_FILES['filename']['tmp_name'], "../db_backup/".$_FILES['filename']['name'])) { 86 | $command = "mysql -uroot -p123 -hlocalhost -D macs < ".$_FILES['filename']['name']."; rm ".$_FILES['filename']['name']; 87 | $output = shell_exec($command); 88 | $result = "Import done"; 89 | } 90 | } 91 | } else if(isset($_GET["generate"])){ 92 | $result = backup_tables($dbhost,$dbuser,$dbpass,$dbname); 93 | } else { 94 | $result=""; 95 | } 96 | 97 | echo $header.' 107 |
98 |
99 | 100 |
101 |
102 |
103 | 104 | 105 |
106 |
'.$result.'
'; 108 | 109 | ?> 110 | -------------------------------------------------------------------------------- /website/php_module/module_log.php: -------------------------------------------------------------------------------- 1 | show all)"; 9 | $sql_limit="LIMIT 0,50"; 10 | if(isset($_GET["loglimited"])){ 11 | $_SESSION["sql_limit"]="yes"; 12 | } elseif(isset($_GET["logall"]) or (isset($_SESSION["sql_limit"]) && $_SESSION["sql_limit"]=="none")){ 13 | $title="(all) - show only 50 entries"; 14 | $sql_limit=""; 15 | $_SESSION["sql_limit"]="none"; 16 | }; 17 | 18 | // prepare new links 19 | $link[0][0]="timestamp"; 20 | $link[0][1]="desc"; 21 | $link[0][2]="Time"; 22 | 23 | $link[1][0]="event"; 24 | $link[1][1]="desc"; 25 | $link[1][2]="Event"; 26 | 27 | $link[2][0]="machine_id"; 28 | $link[2][1]="desc"; 29 | $link[2][2]="Machine"; 30 | 31 | $link[3][0]="user_id"; 32 | $link[3][1]="desc"; 33 | $link[3][2]="User"; 34 | 35 | //// sorting 36 | $log_sort_column=$link[0][0]; 37 | $log_sort_dir=$link[0][1]; 38 | 39 | $MACRO_LOG_SORT_COLUMN="LOG_SORT_COLUMN"; 40 | $MACRO_LOG_SORT_DIR="LOG_SORT_DIR"; 41 | 42 | 43 | // accept incoming parameter 44 | if(isset($_GET[$MACRO_LOG_SORT_COLUMN])){ 45 | for($i=0;$i'.$link[$i][2].''; 73 | }; 74 | 75 | $o_log=''; 76 | $o_log.=''; 77 | 78 | //////////////// LOG ///////////////// 79 | 80 | $o_log.='
'.$link[0][3].''.$link[1][3].''.$link[2][3].''.$link[3][3].'Info
loading
'; 81 | 82 | ?> 83 | -------------------------------------------------------------------------------- /website/php_module/module_log_content.php: -------------------------------------------------------------------------------- 1 | '.$link[$i][2].''; 60 | }; 61 | 62 | $o_log=""; 63 | $stmt = $db->prepare('SELECT * FROM log ORDER BY `'.$log_sort_column.'` '.$log_sort_dir.' '.$sql_limit); 64 | $stmt->execute(); 65 | foreach ($stmt as $row) { 66 | $u_out="-"; 67 | $m_out="-"; 68 | $l_out="-"; 69 | $extra="-"; 70 | 71 | if($row["machine_id"]>0){ 72 | $m=get_mach($row["machine_id"]); 73 | if($m!=-1){ 74 | $m_out=$m["name"]; 75 | } else { 76 | $m_out="db hickup"; 77 | }; 78 | } 79 | 80 | if($row["user_id"]>0){ 81 | $u=get_user($row["user_id"]); 82 | if($u!=-1){ 83 | $u_out=$u["name"]; 84 | } else { 85 | $u_out="db hickup"; 86 | }; 87 | }; 88 | 89 | // extra info 90 | 91 | if($row["login_id"]>0){ 92 | $l=get_user($row["login_id"]); 93 | if($l!=-1){ 94 | $extra='by '.$l["name"]; 95 | } else { 96 | $extra="by "."db hickup"; 97 | }; 98 | } else if($row["usage"]!="-" && !empty($row["usage"]) && $extra=="-"){ 99 | $d[0]=floor($row["usage"]/3600); 100 | $d[1]=floor(($row["usage"]%3600)/60); 101 | $d[2]=$row["usage"]%60; 102 | for($i=0; $i<3; $i++){ 103 | $ii=0; 104 | while(strlen($d[$i])<2 && $ii<5){ 105 | $d[$i]="0".$d[$i]; 106 | $ii++; 107 | } 108 | } 109 | $extra="Usage ".$d[0].":".$d[1].":".$d[2]; 110 | }; 111 | 112 | $row["event"]=str_replace(";",",",$row["event"]); 113 | $m_out=str_replace(";",",",$m_out); 114 | $u_out=str_replace(";",",",$u_out); 115 | $extra=str_replace(";",",",$extra); 116 | 117 | $o_log.=date("Y/m/d H:i",$row["timestamp"]).';'.$row["event"].';'.$m_out.';'.$u_out.';'.$extra."\r\n"; 118 | 119 | }; 120 | //////////////// LOG ///////////////// 121 | 122 | echo $o_log; 123 | 124 | ?> 125 | -------------------------------------------------------------------------------- /website/php_module/module_setup.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | MACS - Dashboard 17 | 18 | '; 19 | 20 | $o_setup.=$header; 21 | 22 | //var_dump($_POST); 23 | 24 | 25 | if(isset($_POST["save_wifi"])){ 26 | $stmt = $db->prepare("TRUNCATE wifi"); 27 | $stmt->execute(); 28 | $all_ok=1; 29 | 30 | for($i=0;$i<3;$i++){ 31 | $stmt = $db->prepare("INSERT INTO `macs`.`wifi` (`id`,`ssid`,`pw`,`type`) VALUE (".$i.",:ssid,:pw,:type)"); 32 | $stmt->bindParam(":ssid",$_POST["ssid_".$i],PDO::PARAM_STR); 33 | $stmt->bindParam(":pw",$_POST["pw_".$i],PDO::PARAM_STR); 34 | $stmt->bindParam(":type",$_POST["type_".$i],PDO::PARAM_STR); 35 | $stmt->execute(); 36 | // save it but check if after wards to keep the input in the database 37 | if(strlen($_POST["ssid_".$i])>20){ 38 | $msg="SSID length is limited to 20 chars"; 39 | $all_ok=0; 40 | }; 41 | if(strlen($_POST["pw_".$i])>20){ 42 | $msg="PW length is limited to 20 chars"; 43 | $all_ok=0; 44 | }; 45 | 46 | }; 47 | 48 | if($all_ok==1){ 49 | $o_setup_below.=''; 50 | $o_setup_below.=''; 51 | $o_setup_below.=''; 52 | $status="Loading"; 53 | } else { 54 | $o_setup_below.=$msg; 55 | }; 56 | }; 57 | 58 | // grab all wifi from db 59 | $stmt = $db->prepare('SELECT * FROM wifi'); 60 | $stmt->execute(); 61 | foreach ($stmt as $row) { 62 | if($row["id"]>=0 && $row["id"]<=2){ 63 | $i=$row["id"]; 64 | $db_wifi[$i]["ssid"]=$row["ssid"]; 65 | $db_wifi[$i]["pw"]=$row["pw"]; 66 | $db_wifi[$i]["type"]=$row["type"]; 67 | } 68 | }; 69 | 70 | $o_setup.='
'; 71 | 72 | for($i=0; $i<3; $i++){ 73 | if(empty($db_wifi[$i])){ 74 | $db_wifi[$i]["ssid"]=""; 75 | $db_wifi[$i]["pw"]=""; 76 | $db_wifi[$i]["type"]=""; 77 | } 78 | 79 | $title=""; 80 | if($i==0){ 81 | $title="MACS"; 82 | } else if($i==1){ 83 | $title="Primary update"; 84 | } else { 85 | $title="Backup update"; 86 | }; 87 | 88 | $o_setup.=' 89 | 90 | 91 | '; 103 | }; 104 | 105 | $o_setup.=''; 106 | $o_setup.=''; 107 | $o_setup.='
WiFiSSIDpasswordtype
'.$title.'


'.$status.'
'; 108 | 109 | $o_setup.=$o_setup_below; 110 | echo $o_setup; 111 | ?> 112 | -------------------------------------------------------------------------------- /website/php_module/module_setup_helper_execute.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /website/php_module/module_setup_helper_reader.php: -------------------------------------------------------------------------------- 1 | ",$data); 6 | fclose($myfile); 7 | ?> 8 | -------------------------------------------------------------------------------- /website/php_module/module_setup_helper_writer.php: -------------------------------------------------------------------------------- 1 | prepare('SELECT * FROM wifi'); 9 | $stmt->execute(); 10 | foreach ($stmt as $row) { 11 | if($row["id"]>=0 && $row["id"]<=2){ 12 | $i=$row["id"]; 13 | $db_wifi[$i]["ssid"]=$row["ssid"]; 14 | $db_wifi[$i]["pw"]=$row["pw"]; 15 | $db_wifi[$i]["type"]=$row["type"]; 16 | } 17 | }; 18 | 19 | for($i=0; $i<3; $i++){ 20 | if(isset($db_wifi[$i]["ssid"]) && isset($db_wifi[$i]["pw"]) && isset($db_wifi[$i]["type"])){ 21 | if(!empty($db_wifi[$i]["ssid"]) && !empty($db_wifi[$i]["pw"])){ 22 | $line=$i." ".$db_wifi[$i]["ssid"]." ".$db_wifi[$i]["pw"]." ".$db_wifi[$i]["type"]."\r\n"; 23 | fwrite($myfile,$line); 24 | }; 25 | }; 26 | }; 27 | 28 | fclose($myfile); 29 | ?> 30 | -------------------------------------------------------------------------------- /website/php_module/module_usage.php: -------------------------------------------------------------------------------- 1 | prepare($req); 28 | $stmt->execute(); 29 | $i=0; 30 | foreach($stmt as $row){ 31 | $user_on_machine[$i]["id"]=$row["user_id"]; 32 | //failsafe 33 | if(!isset($db_user[$row["user_id"]])){ 34 | $db_user[$row["user_id"]]["name"]="user not found"; 35 | } 36 | $user_on_machine[$i]["title"]=$db_user[$row["user_id"]]["name"]; 37 | $i++; 38 | }; 39 | 40 | // now get all log entries, summed per day 41 | $req='SELECT sum(`usage`) as used_time, `user_id`, FLOOR(`timestamp`/86400)*86400 as date '; 42 | $req.='FROM `log` where `usage`>0 and `machine_id`='.$machine_id.' '; 43 | $req.='group by FLOOR(`timestamp`/86400), `user_id` ORDER BY `date` asc'; 44 | 45 | //echo '
'.$req.'
'; 46 | 47 | $stmt = $db->prepare($req); 48 | $stmt->execute(); 49 | $collector=array(); 50 | $log_entries=0; 51 | 52 | foreach ($stmt as $row) { 53 | $log_entries++; 54 | //echo "Time:".$row["used_time"]." user id=".$row["user_id"]." date=".$row["date"]." / ".date("Y-m-d",$row["date"])."
"; 55 | 56 | // find the right index in the collector 57 | $found=-1; 58 | for($i=0;$i"; 69 | $found=count($collector); 70 | for($i=0;$i"; 75 | }; 76 | 77 | // fill data 78 | for($i=0;$i"; 80 | if($row["user_id"]==$user_on_machine[$i]["id"]){ 81 | $collector[$found]["user"][$i]=floor($row["used_time"]/60); 82 | //echo "set
"; 83 | break; 84 | }; 85 | 86 | //echo "found ".$found.",date:".$collector[$found]["date"]." data:".$collector[$found]["user"][$i]."
"; 87 | 88 | }; 89 | 90 | }; 91 | 92 | 93 | // sum up the data as string 94 | $data=""; 95 | //echo "

".$db_mach[$row2["id"]]["name"]."
"; 96 | for($i=0;$i1){ 106 | $data=substr($data,0,strlen($data)-1); 107 | }; 108 | 109 | // generate config section (which user are on this graph) 110 | $g_config=gen_config($user_on_machine); 111 | 112 | $ret[0]=gen_chart($g_config,$data,$db_mach[$machine_id]["name"]); 113 | $ret[1]='
'; 114 | $ret[2]=$log_entries; 115 | 116 | return $ret; 117 | 118 | }; 119 | 120 | 121 | function gen_config($graph_config){ 122 | $g_config=""; 123 | for($i=0; $i'; 178 | return $ret; 179 | }; 180 | 181 | 182 | 183 | echo ''; 184 | 185 | 186 | $o_usage=""; 187 | $o_data=""; 188 | $o_show=""; 189 | $req2 = 'SELECT `id` FROM `mach` where active=1'; 190 | $stmt2 = $db->prepare($req2); 191 | $stmt2->execute(); 192 | foreach($stmt2 as $row2){ 193 | //echo "
taking a look at this machine ".$db_mach[$row2["id"]]["name"]."
"; 194 | $data=get_graph($row2["id"]); 195 | if($data[2]>0){ 196 | $o_data.=$data[0]; 197 | $o_show.=$data[1]; 198 | }; 199 | 200 | }; 201 | 202 | $o_usage=$o_data.$o_show; 203 | 204 | 205 | 206 | ?> 207 | -------------------------------------------------------------------------------- /website/python/config.txt: -------------------------------------------------------------------------------- 1 | 0 macs 6215027094 3 2 | 1 ajlokert qweqweqwe 3 3 | 2 shop abcdefgh 3 4 | -------------------------------------------------------------------------------- /website/python/run.py: -------------------------------------------------------------------------------- 1 | #sudo apt-get install python-serial 2 | import os, sys 3 | import glob, time 4 | import serial 5 | 6 | 7 | def log(inp,reset=0): 8 | if(reset==1): 9 | log_f=open("/tmp/macs_log.txt", "w") 10 | else: 11 | log_f=open("/tmp/macs_log.txt", "a") 12 | out="["+time.strftime("%H:%M:%S")+"] "+str(inp) 13 | log_f.write(out+"\r\n") 14 | log_f.close() 15 | print(out) 16 | 17 | try: 18 | log("Reading WiFi config file",1) 19 | except: 20 | exit("could not start logging") 21 | 22 | 23 | 24 | # open file 25 | try: 26 | dirname, filename = os.path.split(os.path.abspath(sys.argv[0])) 27 | fileh = open("/tmp/macs_config.txt", 'r') 28 | except: 29 | exit("file not found") 30 | 31 | data=fileh.readlines() 32 | 33 | 34 | # try to get all serial ports starting with /dev/ttyACM 35 | ports = glob.glob('/dev/ttyACM*') 36 | result = [] 37 | for port in ports: 38 | try: 39 | s = serial.Serial(port) 40 | s.close() 41 | result.append(port) 42 | except (OSError, serial.SerialException): 43 | pass 44 | 45 | 46 | if(len(result)==0): 47 | log("no connection found") 48 | 49 | for port in result: 50 | for a in range(0,len(data)): 51 | # read and prepare data 52 | data_line=data[a] 53 | data_ar=data_line.split(" ") 54 | 55 | # check length 56 | if(len(data_ar)!=4): 57 | log("config invalid") 58 | exit("config invalid") 59 | 60 | # generate msg 61 | chk=0x00 62 | msg=bytearray() 63 | 64 | # array to loop over field (the fields are separated by tabs in the file 65 | for i in range(0,len(data_ar)): 66 | b = bytearray() 67 | b.extend(map(ord, data_ar[i])) 68 | # field 0 (id) and 3 (wifi type) are asci nr, convert them to nr only 69 | if((i==3 or i==0) and b[0]>=ord('0') and b[0]<=ord('4')): 70 | #print("converted type") 71 | b[0]-=ord('0') 72 | # loop over all chars in the current field 73 | for ii in range(0,len(b)): 74 | if(b[ii]!=10 and b[ii]!=13): 75 | # id field is not part of checksum 76 | if(i>0): 77 | chk^=b[ii] 78 | msg.append(b[ii]) 79 | msg.append(0x09) 80 | msg.append(chk) 81 | msg.append(0x09) 82 | 83 | for i in range(0,len(msg)): 84 | print(hex(msg[i])) 85 | 86 | if(a==0): 87 | log("Port "+port+" found") 88 | 89 | try: 90 | s = serial.Serial(port, baudrate=115200, timeout=2.0) 91 | if(a==0): 92 | send=bytearray() 93 | send.append(ord('i')); 94 | send.append(0x09); 95 | s.write(send) 96 | recv=s.read(4) # waits up to 3 sec 97 | if(recv.decode()=="MACS"): 98 | log("MACS unit found on port "+port) 99 | send=1 100 | 101 | if(send==1 or a>0): 102 | s.write(msg) 103 | recv=s.read(20) 104 | recv=recv.decode() 105 | #recv=recv[0:5] 106 | if(recv.find("saved")>-1): 107 | log("Stored WiFi-config #"+str(a)+" '"+data_ar[1]+"' to unit") 108 | else: 109 | log("Resp: '"+recv+"'!='saved'") 110 | log("Please try again") 111 | break 112 | 113 | else: 114 | log("No MACS found on port "+port+" - resp ("+str(len(recv))+") '"+recv.decode()+"'!='MACS'") 115 | log("Please try again") 116 | break 117 | except: 118 | log("Exception") 119 | log("Please try again") 120 | 121 | log("Thanks for using MACS") 122 | 123 | 124 | -------------------------------------------------------------------------------- /website/sec.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT `hash`,`id` FROM `macs`.`user` where login=:login and active=1"); 14 | $stmt->bindParam(":login",$_POST["macs_login"],PDO::PARAM_STR); 15 | $stmt->execute(); 16 | 17 | foreach($stmt as $row){ 18 | //echo "
given ".$_POST["macs_pw_md5"]." vs ".$row["hash"]; 19 | if($row["hash"]==$_POST["macs_pw_md5"]){ 20 | //echo "i guess you are in"; 21 | $_SESSION['ID']=$row["id"]; 22 | $login=1; 23 | //show_info("Good to see you again, ".$_POST["macs_login"]); 24 | echo ""; 25 | break; 26 | } 27 | }; 28 | } 29 | 30 | if(!$login){ 31 | include_once("html.php"); 32 | $o='
'; 33 | $o.=''; 34 | $o.=''; 35 | $o.='
'; 36 | echo $header.$o.$footer; 37 | exit(0); 38 | }; 39 | } else if(isset($_GET['msg'])) { 40 | show_info($_GET['msg']); 41 | }; 42 | ?> 43 | --------------------------------------------------------------------------------