예제 #1
0
 /**
  * Translate a given word to the base (english) equivalent.
  * @staticvar string $pqry
  * @staticvar string $id
  * @staticvar string $text
  * @param type $word
  * @param type $table
  * @param type $column
  * @return type
  */
 public static function translateToBase($word, $table = 'kb3_invtypes', $column = 'typeName')
 {
     static $pqry;
     static $keyID;
     static $text;
     static $tcID;
     $text = $word;
     $keyID = 0;
     switch ($table) {
         case "kb3_dgmattributetypes":
             $column = 'description';
             $tcID = 75;
             $type = 'attributeID';
             break;
         case "kb3_dgmeffects":
             if ($column != 'displayName') {
                 $column = 'description';
                 $tcID = 75;
             } else {
                 $tcID = 74;
             }
             $type = 'effectID';
             break;
         case "kb3_invtypes":
         default:
             $table = "kb3_invtypes";
             if ($column != 'typeName') {
                 $column = 'description';
                 $tcID = 33;
             } else {
                 $tcID = 8;
             }
             $type = 'typeID';
             break;
     }
     if (is_null(self::$lang)) {
         self::init();
     }
     if ($language === null) {
         $language = config::get("cfg_language");
     } else {
         $language = preg_replace('/[^a-z-]/', '', strtolower($language));
     }
     if (!isset(self::$pqry)) {
         $pqry = new DBPreparedQuery();
         $sql = "SELECT keyID FROM trntranslations" . " WHERE text LIKE ? AND tcID=? LIMIT 1";
         $keyID = 0;
         $pqry->prepare($sql);
         $pqry->bind_params('si', array($text, $tcID));
         $pqry->bind_result($keyID);
     }
     if ($pqry->execute() && $pqry->recordCount()) {
         $pqry->fetch();
     } else {
         return $word;
     }
     $qry = DBFactory::getDBQuery();
     $qry->execute("SELECT {$column} AS text FROM {$table} WHERE {$type}={$keyID}");
     if (!$qry->recordCount()) {
         return $word;
     } else {
         $row = $qry->getRow();
         return $row['text'];
     }
 }
예제 #2
0
 /**
  * Add a comment to a kill.
  *
  * The kill id is set when the Comments object is constructed.
  * @param string $name The name of the comment poster.
  * @param string $text The text of the comment to post.
  */
 function addComment($name, $text)
 {
     $comment = $this->bbencode(trim($text));
     $name = trim($name);
     $qryP = new DBPreparedQuery();
     $sql = "INSERT INTO kb3_comments (`kll_id`,`site`, `comment`,`name`,`posttime`, `ip`)\n                       VALUES (?, ?, ?, ?, ?, ?)";
     $qryP->prepare($sql);
     $site = KB_SITE;
     $date = kbdate('Y-m-d H:i:s');
     $ip = logger::getip();
     $params = array('isssss', &$this->id_, &$site, &$comment, &$name, &$date, &$ip);
     $qryP->bind_params($params);
     $qryP->execute();
     $id = $qryP->getInsertID();
     $this->comments_[] = array('time' => kbdate('Y-m-d H:i:s'), 'name' => $name, 'comment' => $comment, 'id' => $id);
     // create comment_added event
     event::call('comment_added', $this);
 }
예제 #3
0
 /**
  * Update this kill's CREST hash.
  * @param string $crestHash
  */
 public function updateCrestHash($crestHash)
 {
     $this->execQuery();
     $qry = new DBPreparedQuery();
     $qry->prepare('UPDATE kb3_mails SET kll_crest_hash = ? WHERE kll_id = ?');
     $params = array('si', &$crestHash, &$this->id);
     $qry->bind_params($params);
     if (@$qry->execute()) {
         $this->crestHash = $crestHash;
         $this->putCache();
     }
 }