├── README.md └── config.php /README.md: -------------------------------------------------------------------------------- 1 | # FluxBB configuration used for Textpattern support forum 2 | 3 | ## Install 4 | 5 | Install as if a normal FluxBB install from the *feature-textpattern-forum* branch. 6 | 7 | After which you would follow the standard [FluxBB installation steps](https://fluxbb.org/docs/v1.5/installing). 8 | 9 | ## Development 10 | 11 | Development happens in the *feature-textpattern-forum* branch: 12 | 13 | ```ShellSession 14 | $ git clone --branch feature-textpattern-forum git@github.com:textpattern/fluxbb.git 15 | ``` 16 | 17 | To create a patch: 18 | 19 | ```ShellSession 20 | $ git diff master feature-textpattern-forum > feature-textpattern-forum.patch 21 | ``` 22 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 55 | 56 | // Fetch user details. 57 | 58 | if ($action === 'login') 59 | { 60 | $sth = $pdo->prepare("SELECT group_id, email FROM {$db_prefix}users WHERE username = :username"); 61 | $sth->execute(array(':username' => $user)); 62 | $r = $sth->fetch(); 63 | 64 | if (!$r || $r['group_id'] != 0) 65 | { 66 | return; 67 | } 68 | 69 | $email = $r['email']; 70 | } 71 | 72 | // Check if the user is already banned. 73 | 74 | $sth = $pdo->prepare("SELECT ip FROM {$db_prefix}bans WHERE ((ip != '' and ip = :ip) or (email != '' and email = :email)) and IFNULL(expire, :expires) >= :expires limit 1"); 75 | 76 | $sth->execute(array( 77 | ':ip' => $ip, 78 | ':email' => $email, 79 | ':expires' => time(), 80 | )); 81 | 82 | if ($sth->rowCount()) 83 | { 84 | return; 85 | } 86 | 87 | // Get records from StopForumSpam database. 88 | 89 | $data = file_get_contents('http://www.stopforumspam.com/api?f=json&unix&ip='.urlencode($ip).'&email='.urlencode($email).'&username='.urlencode($user), false, stream_context_create(array('http' => array('timeout' => 15)))); 90 | 91 | if (!$data) 92 | { 93 | return; 94 | } 95 | 96 | $data = json_decode($data); 97 | 98 | if (!$data || empty($data->success)) 99 | { 100 | return; 101 | } 102 | 103 | // Add new bans to the database. 104 | 105 | if ($ip && isset($data->ip) && $data->ip->appears && $data->ip->lastseen >= $since) 106 | { 107 | $pdo->prepare("INSERT INTO {$db_prefix}bans SET ip = :ip, message = :message, expire = :expires")->execute(array( 108 | ':ip' => $ip, 109 | ':message' => 'IP address found in StopForumSpam database.', 110 | ':expires' => strtotime('+2 month'), 111 | )); 112 | 113 | @unlink(__DIR__ . '/cache/cache_bans.php'); 114 | } 115 | 116 | if ($email && isset($data->email) && $data->email->appears && $data->email->lastseen > $since) 117 | { 118 | $pdo->prepare("INSERT INTO {$db_prefix}bans SET email = :email, message = :message")->execute(array( 119 | ':email' => $email, 120 | ':message' => 'Email address found in StopForumSpam database.', 121 | )); 122 | 123 | @unlink(__DIR__ . '/cache/cache_bans.php'); 124 | } 125 | } 126 | 127 | try 128 | { 129 | TextpatternForumSfs(); 130 | } 131 | catch (Exception $e) 132 | { 133 | } 134 | --------------------------------------------------------------------------------