Exemple #1
0
 function sqlQuery($query)
 {
     if (!$query) {
         return false;
     }
     if (bot_DEBUG_LEVEL & bot_DEBUG_SQL) {
         bot_errorLog($query, bot_ERR_NOTICE);
     }
     if (!$this->sqlIsConnected()) {
         bot_errorLog('MySQL NOT CONNECTED', bot_ERR_ERROR);
         return false;
     }
     $result = mysql_query($query, $this->sqllink);
     if (is_bool($result)) {
         return mysql_affected_rows($this->sqllink);
     }
     $num = mysql_num_rows($result);
     if ($num > 0) {
         for ($i = 0; $i < $num; $i++) {
             $row[$i] = mysql_fetch_array($result, MYSQL_ASSOC);
         }
         return $row;
     }
     return true;
 }
Exemple #2
0
 function sockRead()
 {
     $buf = fgets($this->socket, bot_BUFSIZ);
     if (bot_DEBUG_LEVEL & bot_DEBUG_READ) {
         bot_errorLog($buf, bot_ERR_NOTICE);
     }
     return $buf;
 }
Exemple #3
0
 function dataUpdateDb()
 {
     $query = 'SELECT cmd_id, cmd_name FROM command';
     $db_cmd = $this->sqllink->query($query);
     $fields = array('cmd_name', 'cmd_desc', 'cmd_syntax');
     foreach ($ret as $r) {
         if (($web_cmd = $this->dataSearchWeb($r['cmd_name'])) && is_array($web_cmd)) {
             $update_fields = array();
             foreach ($fields as $f) {
                 if (!empty($web_cmd[$f]) && $db_cmd[$f] != $web_cmd[$f]) {
                     $update_fields[] = $f . " = '" . addslashes(trim($web_cmd[$f])) . "'";
                 }
             }
             if (count($update_fields)) {
                 $query = "UPDATE command SET " . implode(", ", $update_fields) . " WHERE cmd_id = '" . $r['cmd_id'] . "'";
                 if (!$this->sqllink->query($query)) {
                     bot_errorLog('Could not update command(' . $r['cmd_id'] . ')', bot_ERR_ERROR);
                 }
             }
         }
     }
     return $this->sqllink->sqlCloseLink();
 }
Exemple #4
0
 function botCheckCommand($buffer)
 {
     if (ereg('^ERROR :Closing Link: ' . bot_IRCNICK, $buffer)) {
         if ($this->dataCountClose() && $this->ircClose()) {
             if (!$this->botRun()) {
                 bot_errorLog('Could not Reconnect.', bot_ERR_ERROR);
                 exit;
             }
         } else {
             bot_errorLog('Could not Close.', bot_ERR_ERROR);
             exit;
         }
     } else {
         return $this->dataCheckCommand($buffer);
     }
 }
Exemple #5
0
 function countClose()
 {
     global $bot_CHANNELS;
     $chan = "(usr_chan IS NULL";
     foreach ($bot_CHANNELS as $c) {
         $chan .= " OR usr_chan = '" . $c . "'";
     }
     $chan .= ")";
     $query = "\n      UPDATE user SET\n        usr_quit_dt = now(),\n        usr_quit_qtt = usr_quit_qtt + 1\n      WHERE\n        usr_join_qtt = (usr_quit_qtt + 1) AND " . $chan;
     if ($ret = $this->sqllink->sqlQuery($query)) {
         $query = "\n        UPDATE user SET\n          usr_max_period = UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(usr_join_dt)\n        WHERE\n          usr_join_qtt = usr_quit_qtt AND \n          usr_max_period < UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(usr_join_dt)\n          " . $chan;
         if ($this->sqllink->sqlQuery($query)) {
             return true;
         } else {
             bot_errorLog('countClose: Could not update (2).', bot_ERR_ERROR);
         }
     } else {
         bot_errorLog('countClose: Could not update (1).', bot_ERR_ERROR);
     }
     return false;
 }