Commit Graph
76 Commits
Author SHA1 Message Date
Jash 245179d093 fix: ignore stale Server_Stats rows when reading server stats refs #5900 2026-11-14 22:49:59 +05:30
Nic BoetandClaude Opus 5.5 49ab7682ea fix: keep the auth relay out of PHP warnings on failed remote requests
When the other server of a multi-server install did not answer,
file_get_contents() raised a PHP warning whose text is the call and its
URL, ?auth=<hash> or user=/pass= included, and PHP wrote it to the web
server's error log (Event.php, Filter.php). The same happened with the
image proxy's digest retry (camera user:password@) and the X-Frame
check of a website monitor (get_headers()), which also took the false
it returns on failure for an array.

Fetch with @ and log lastErrorForLog(), the reason without the call
and its URL, next to urlForLog() of the URL. Server::SendToApi()
already used @ and now logs the reason too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Nic BoetandClaude Opus 5.5 b9e20c84a4 fix: stop logging the auth relay in multi-server request URLs
Event.php, Server.php and Filter.php call the API or index.php of
another server with the auth relay appended (?auth=<hash>, or with
ZM_AUTH_RELAY=plain the user's username and password) and logged that
URL, at debug level before the call and at Error level when the other
server did not answer. Error reaches the Logs table at the default
database log level. Log it through urlForLog(), without the query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Isaac Connor 112a5da852 fix: match single-server ServerId=0 in Server::ReadStats
06801955a bound $this->Id() directly in the stats lookup. On a
single-server install the Server object's Id() is empty/undef and
zmstats.pl writes the rows under ServerId=0 (ZM_SERVER_ID ? ZM_SERVER_ID
: 0), so the query matched nothing and CpuLoad/load reported as -1.

Coerce a falsy id to 0 so the reader mirrors the writer; a real
(multi-server) id still passes through unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-07-27 08:12:51 -04:00
Isaac ConnorandClaude Sonnet 5 06801955a8 fix: add ServerId index to Server_Stats to speed up per-server stats lookup
Server.php's ReadStats() query (SELECT ... WHERE ServerId=? ORDER BY
TimeStamp DESC LIMIT 1) had no supporting index, forcing a full table
scan on every page load that shows server stats. Add a composite
(ServerId, TimeStamp) index via zm_update-1.39.18.sql (idempotent,
checked against INFORMATION_SCHEMA.STATISTICS) and zm_create.sql.in
for fresh installs. Keep the existing TimeStamp-only index, since
zmstats.pl's prune DELETE filters by TimeStamp alone.

Also query ReadStats() with the server's actual Id() instead of
coercing Id() <= 1 to 0.

Bump version.txt and the redhat spec Version to 1.39.18.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q7jeoG8ptXRpXxif2JqkD7
2026-07-23 14:01:24 -04:00
Simpler1 e922b9e16d Update Server.php
Don't require a database entry for Server.
Use ZM_BASE_URL.
2026-01-31 21:01:00 -05:00
Isaac Connor 6e9c69300b Handle no rows return from Server_Stats 2024-06-02 16:04:15 -04:00
Isaac Connor 7bfd94b9d2 Merge branch 'patch-6' of github.com:IgorA100/zoneminder into IgorA100-patch-6 2024-05-15 11:45:49 -04:00
IgorA100 4f60769413 Fix: Now a single server is recorded in the database as 0, not NULL 2024-03-23 00:56:53 +03:00
IgorA100 f89b7461b1 Temp solution: If server ID is "1" we assume that it is NULL in DB
To display Stats in Options->Server
2024-02-27 22:06:24 +03:00
IgorA100 72674fd0d4 Add function ReadStats()
Reading Stats from DB
2024-02-27 18:14:02 +03:00
Isaac Connor ebad97038e Implement CpuLoad in Server object 2024-02-22 12:52:49 -05:00
Isaac Connor f54f10df72 Add server stats fields 2024-02-20 13:14:23 -05:00
Isaac Connor 6e93e3df4c Allow untrsuted ssl certs when sending commands to other servers 2023-12-24 12:17:08 -05:00
Isaac Connor 4e2dd31cdc Use ZM_PATH_API instead of hard coded /zm/api 2023-12-15 09:18:04 -05:00
adhamiamirhossein 27977acdd4 fix: php 8.3 deprecated get_class method call without argument 2023-11-22 10:48:04 +03:30
Isaac Connor a1693c34b9 Add HTTP_FRONT_END_HTTPS as a signal to use https in urls. Mainly for when using a reverse proxy 2023-11-16 10:34:44 -05:00
Isaac Connor ebb37ebc98 Don't output errors from remote commands as it breaks ui 2023-02-09 18:46:01 -05:00
Isaac Connor 359c0c1b27 Don't know why we are turning off display errors in Server.php. Let's not. 2023-01-03 13:17:00 -05:00
Isaac Connor bce8c6195a Don't display errors in Server.php 2022-10-20 16:45:52 -04:00
Isaac Connor 2a9576371b Introduce Server::SendToApi to reduce duplicated code. 2022-09-28 17:40:08 -04:00
Isaac Connor 855dd6ac93 Use HTTP_X_FORWARDED_HOST or HTTP_X_FORWARDED_SERVER if present to get correct hostname to use when behind a reverse proxy. 2022-08-26 14:12:25 -04:00
Isaac Connor a465403c72 Handle when SERVER['HTTP_HOST'] is not set 2021-10-05 19:49:42 -04:00
Isaac Connor 8a170f2841 Remove Debug 2020-08-15 17:49:26 -04:00
Isaac Connor 25426d5fdd Don't add 442 for https and 80 for http. Just cleaner 2020-08-09 22:18:35 -04:00
Isaac Connor cc6d40d67e Missing -> 2019-12-07 10:38:51 -05:00
Isaac Connor 1dc83700c0 Do a better job of handling the non-server, non-multiport case. Put the code in Url so that it works for other functions that call Url() 2019-11-21 13:32:27 -05:00
Isaac Connor 59b9220ddd if doing multiport still call Url(), as it requires a hostname 2019-11-11 13:33:54 -05:00
Isaac Connor d218d2ee9f If the default server case, don't add the Url component. So this will return just the path, using whatever servername/port combo is currently in use. Fixes #2750 2019-11-04 12:04:23 -05:00
Isaac Connor b15f7ad47d handle ipv6 in Server->Hostname. Fixes #2713 2019-10-09 10:00:13 -04:00
Isaac Connor a05c513643 Revert change breaking multiport when servers not defined. 2019-09-23 12:03:19 -04:00
Isaac Connor 0a0bb1b326 Update Frame and Server Objects to use common methods 2019-09-19 16:24:05 -04:00
Isaac Connor 60cf4586da Don't return a hostname when not in multi-server. Should prevent problems with reverse proxies 2019-09-15 17:54:23 -04:00
Isaac Connor c0ae7820bb add zmeventnotification to Server object 2019-02-27 09:28:36 -05:00
Isaac Connor 8dd8888975 Php namespace (#2537)
* experiment with namespaces on the Server class

* experiment with namespaces on the Server class

* Implement the ZM namespace on objects

* Implement the ZM namespace on objects

* Implement the ZM namespace on objects
2019-02-22 09:19:07 -05:00
Matthew Noorenberghe a97711de89 Replace or sanitize remaining uses of PHP_SELF. Fixes #2446 2019-02-09 22:12:36 -08:00
Isaac Connor eee1d871e0 get rid of default value for PathToIndex so that it will use PHP_SELF instead 2019-01-16 12:09:26 -05:00
Isaac Connor 3182d8bab7 implement to_json method so that defaults get included 2019-01-15 11:36:56 -05:00
Mike Rosack 567b60ffa7 support for forwarded proto/port in Server.php (#2343) 2018-12-13 10:24:32 -05:00
Isaac Connor a1141d2dc4 remove second use of HTTP_HOST and use a better method of stripping off port from HTTP_HOST 2018-12-07 08:39:23 -05:00
Isaac Connor 757e538550 strip port from HTTP_HOST 2018-12-06 17:12:03 -05:00
Andrew Bauer cae6ffd5a3 use HTTP_HOST instead of SERVER_NAME 2018-12-01 13:27:08 -06:00
Isaac Connor 8c626c984b Need to pass port through all Url functions 2018-11-30 14:45:58 -05:00
Isaac Connor 3bd5774ea1 Default to PathToIndex should have the index.php in it 2018-11-29 15:53:19 -05:00
Isaac Connor 1c17f334d3 fix missing bits. Implement UrlToIndex in Monitor and fix use of Url(). Implement PathToApi as well 2018-11-29 14:26:30 -05:00
Isaac Connor f8b2ff5c77 rework from Url() to PathToIndex(), PathToZMS(), UrlToIndex() and UrlToZMS() 2018-11-27 17:35:25 -05:00
Isaac Connor c5f7fb7b18 Merge branch 'master' into server_path_prefix 2018-11-22 10:04:33 -05:00
Isaac Connor f9b1453705 Include SERVER_PORT when not doing multi-server or multi-port but are running on a port other than 80. 2018-10-19 10:59:16 -04:00
Isaac Connor 52b1439d51 fix the lack of /zm/index.php in url in Server->Url() and multiport 2018-10-08 09:55:47 -04:00
Isaac Connor 1eb8e9ed9e Include PHP_SELF in url to Server. This will assume that all servers in a multi-server setup use the same path 2018-10-08 09:45:03 -04:00