| | 375 | outn("creating cronmanager table.."); |
|---|
| | 376 | $sql = " CREATE TABLE IF NOT EXISTS `cronmanager` ( |
|---|
| | 377 | `module` varchar(24) NOT NULL default '', |
|---|
| | 378 | `id` varchar(24) NOT NULL default '', |
|---|
| | 379 | `time` varchar(5) default NULL, |
|---|
| | 380 | `freq` int(11) NOT NULL default '0', |
|---|
| | 381 | `lasttime` int(11) NOT NULL default '0', |
|---|
| | 382 | `command` varchar(255) NOT NULL default '', |
|---|
| | 383 | PRIMARY KEY (`module`,`id`) |
|---|
| | 384 | ) |
|---|
| | 385 | "; |
|---|
| | 386 | $check = $db->query($sql); |
|---|
| | 387 | if(DB::IsError($check)) { |
|---|
| | 388 | out("ERROR: Can not create cronmanager table"); |
|---|
| | 389 | } |
|---|
| | 390 | out("Done"); |
|---|
| | 391 | |
|---|
| | 392 | outn("enabling online update checking.."); |
|---|
| | 393 | $sql = "SELECT * FROM cronmanager WHERE module = 'module_admin' AND id = 'UPDATES'"; |
|---|
| | 394 | $result = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 395 | if (DB::IsError($result)) { // error - table must not be there |
|---|
| | 396 | out("can't update cronmanager table"); |
|---|
| | 397 | } else { |
|---|
| | 398 | if (count($result)) { |
|---|
| | 399 | out("already enabled"); |
|---|
| | 400 | } else { |
|---|
| | 401 | $freq = 24; |
|---|
| | 402 | $night_time = array(19,20,21,22,23,0,1,2,3,4,5); |
|---|
| | 403 | $run_time = $night_time[rand(0,10)]; |
|---|
| | 404 | $command = $amp_conf['AMPBIN']."/module_admin listonline"; |
|---|
| | 405 | |
|---|
| | 406 | $sql = "INSERT INTO cronmanager |
|---|
| | 407 | (module, id, time, freq, lasttime, command) |
|---|
| | 408 | VALUES |
|---|
| | 409 | ('module_admin', 'UPDATES', '$run_time', $freq, 0, '$command') |
|---|
| | 410 | "; |
|---|
| | 411 | $check = $db->query($sql); |
|---|
| | 412 | if(DB::IsError($check)) { |
|---|
| | 413 | out("ERROR: can not insert update information in cronmanager"); |
|---|
| | 414 | } else { |
|---|
| | 415 | out("Done"); |
|---|
| | 416 | } |
|---|
| | 417 | } |
|---|
| | 418 | } |
|---|
| | 419 | |
|---|