Client client(theserver, 80); is declared in setup() so one cannot reach it inside loop()
=> define Client client global, outside setup and it will be reachable again
Thats a very big setup() consider defining functions to get some overview.
- setupDHCP()
- setupNTP()
- etc
I noticed you use quite a lot of "long" strings, there might be a RAM shortage nearby. MInimizing these strings will help prevent this. (it might not be a problem yet)
Rob