$sql = "SELECT c.code FROM companies c WHERE (true) {$wh}"; $comps = new dbSql($sql); $comps->run(); $companies = array(); while ($row = $comps->fetch_array()) { /* read the companies configuration */ print "Company Read: {$row['code']}\n"; db_con("cubit_{$row['code']}"); $cfg = getTrhConfig(); /* not enabled */ if ($cfg["MANAGEUSER"] <= 0 || empty($cfg["POP3_SERVER"]) || empty($cfg["SMTP_SERVER"])) { continue; } $companies[$row["code"]] = $cfg; } $comps->free(); } /* run the routines */ foreach ($companies as $code => $conf) { routine($code, $conf); if ($smallest_wait < 0 || $smallest_wait > $conf["INTERVAL"]) { $smallest_wait = $conf["INTERVAL"]; } } if ($smallest_wait < 0) { print "\nSleeping for dflt 60\n"; sleep(60); } else { print "\nSleeping for {$smallest_wait}\n"; sleep($smallest_wait); }