diff options
author | Alexander Kampmann <programmer@nurfuerspam.de> | 2012-03-07 12:06:20 +0100 |
---|---|---|
committer | Alexander Kampmann <programmer@nurfuerspam.de> | 2012-03-07 12:06:20 +0100 |
commit | 4690d00141352db8ca96359cbbf65ce6eb4345c4 (patch) | |
tree | 40347f010a4b15a0eb73f09de3c928258bc9d856 /library | |
parent | b2df1205ef805ab471a73f906d2eda5603a1aa66 (diff) | |
parent | dd2ff7c796302648992835940600c18fd200c388 (diff) | |
download | volse-hubzilla-4690d00141352db8ca96359cbbf65ce6eb4345c4.tar.gz volse-hubzilla-4690d00141352db8ca96359cbbf65ce6eb4345c4.tar.bz2 volse-hubzilla-4690d00141352db8ca96359cbbf65ce6eb4345c4.zip |
Merge branch 'master' of git://github.com/friendica/friendica
Diffstat (limited to 'library')
-rw-r--r-- | library/spam/b8/storage/storage_frndc.php | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/library/spam/b8/storage/storage_frndc.php b/library/spam/b8/storage/storage_frndc.php index 7702c108b..62909d471 100644 --- a/library/spam/b8/storage/storage_frndc.php +++ b/library/spam/b8/storage/storage_frndc.php @@ -174,20 +174,44 @@ class b8_storage_frndc extends b8_storage_base array_push($where, $token); } - $where = 'token IN ("' . implode('", "', $where) . '")'; + $where = 'term IN ("' . implode('", "', $where) . '")'; } else { $token = dbesc($token); - $where = 'token = "' . $token . '"'; + $where = 'term = "' . $token . '"'; } # ... and fetch the data $result = q(' - SELECT * - FROM ' . $this->config['table_name'] . ' - WHERE ' . $where . ' AND uid = ' . $uid ); + SELECT * FROM spam WHERE ' . $where . ' AND uid = ' . $uid ); + + + $returned_tokens = array(); + if(count($result)) { + foreach($result as $rr) + $returned_tokens[] = $rr['term']; + } + $to_create = array(); + + if(count($tokens) > 0) { + foreach($tokens as $token) + if(! in_array($token,$returned_tokens)) + $to_create[] = str_tolower($token); + } + if(count($to_create)) { + $sql = ''; + foreach($to_create as $term) { + if(strlen($sql)) + $sql .= ','; + $sql .= sprintf("(term,datetime,uid) values('%s','%s',%d)", + dbesc(str_tolower($term)) + dbesc(datetime_convert()), + intval($uid) + ); + q("insert into spam " . $sql); + } return $result; |