Changes made:
1. Use the $recharges variable to hold the query results to clarify the context.
2. Use the ternary operator to determine whether the application is running in a CLI environment or not
3. Simplify the logic by combining several redundant code blocks.
4. Unify Mikrotik client retrieval logic based on type (Hotspot or PPPOE) to reduce code duplication.
5. Tidy up the indents to make them consistent and easier to read.