function LoadState() { global $state_path; if (empty($state_path)) { die("ERROR: state.ini path not yet set in server_state.php<br/>"); } // if the state ini exists, parse it $state = new ServerState(); if (file_exists($state_path)) { $state_file = parse_ini_file($state_path, true); $state->ReadBlock($state_file); } // if the update datetime is set, use it reset the bandwidth count if applicable if (!empty($state->state_time->updated_datetime)) { // get the current date and update date $current_datetime = getdate(); $updated_datetime = getdate($state->state_time->updated_datetime); // if if a day has elapsed, reset the bandwidth usage counter to 0 if ($current_datetime['year'] > $updated_datetime['year'] || $current_datetime['month'] > $updated_datetime['month'] || $current_datetime['mday'] > $updated_datetime['mday']) { // reset bandwidth usage for the day $state->server_bandwidth->bandwidth_used = 0; } } else { $state->server_bandwidth->bandwidth_used = 0; } return $state; }
public function CallClients1($func, $v1) { foreach ($this->clients as $client) { call_user_func(array($client, $func), $v1); } } public function CallClients4($func, $v1, $v2, $v3, $v4) { foreach ($this->clients as $client) { call_user_func(array($client, $func), $v1, $v2, $v3, $v4); } } } SetLogFile(dirname($argv[0]) . "/logfile.txt"); LogWrite("############################## Restarted ######################################"); $serverState = ServerState::getInstance(); //LogWrite($serverState->dump()); $LS1 = new LPECListeningSocket($LINN_HOST, $LINN_PORT, 'LPECClientSocket', $serverState, 30000); $LS2 = new LinnDSListeningSocket(0, 9050, 'LinnDSClientSocket', $serverState, 30000); $LS2->setLPECListeningSocket($LS1); //$LS3 = new LinnDSwsListeningSocket(0, 9051, 'LinnDSClientSocket', $serverState, 30000); //$LS3->setLPECListeningSocket($LS1); //$LS1->dump(); //$LS2->dump(); //$LS3->dump(); $SS = new SocketServer(); $SS->addListeningSocket($LS1); $SS->addListeningSocket($LS2); //$SS->addListeningSocket($LS3); LogWrite("LinnDS-jukebox-daemon starts..."); try {