ubuntuusers.de

importDatabase

Autor:
Onli
Datum:
25. November 2010 15:04
Code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function importDatabase($importDatabase) {
        global $serendipity;
        foreach ($importDatabase as $importToken) {
            $token = $importToken[0];
            $ham = $importToken[1];
            $spam = $importToken[2];
            $type = $importToken[3];
            
            $sql = "SELECT 
                        token 
                    FROM 
                        {$serendipity['dbPrefix']}spamblock_bayes
                    WHERE 
                         token = '$token' AND type = '$type'";
            
            $tester = serendipity_db_query($sql);
            
            if (empty($tester[0])) {
                $sql = "INSERT INTO 
                        {$serendipity['dbPrefix']}spamblock_bayes 
                            (token, ham, spam, type)
                    VALUES('$token', $ham, $spam, '$type')";
            } else {
                $sql = "UPDATE {$serendipity['dbPrefix']}spamblock_bayes
                    SET 
                        ham = ham + $ham,
                        spam = spam + $spam
                    WHERE token = '$token' AND type = '$type'";
            }
            
            serendipity_db_query($sql);
            $result = mysql_error();
            if ($result != "") {
                return $result;
            }
            $this->set_config("{$type}_ham", $this->get_config("{$type}_ham", 0) + $ham);
            $this->set_config("{$type}_spam", $this->get_config("{$type}_spam", 0) + $spam);
        }
        
        return true;
    }