/** * @return \Closure */ function isNotIp() { return negate(isIp()); }
function migrateThreads($phorumTable, $forum_id) { global $phorum_db, $e107_threadTable, $e107_db, $memberIdTable; // select parentless messages (= start of a thread) $sql2 = "SELECT * "; $sql2 .= "FROM `" . $phorumTable . "`"; $sql2 .= "WHERE `parent` = 0"; mysql_select_db($phorum_db); $thread_list = mysql_query($sql2); // convert each message from Phorum to e107 while ($thread = mysql_fetch_array($thread_list)) { // get the body of the message (stored in a different table in phorum) $sql3 = "SELECT * "; $sql3 .= "FROM `" . $phorumTable . "_bodies` "; $sql3 .= "WHERE `id` = " . $thread['id']; mysql_select_db($phorum_db); $bodies = mysql_query($sql3); $msg_body = mysql_fetch_array($bodies); // set the thread ownership // TODO: create a function for messages migration ? // TODO: recursive call ? //if($thread['parent'] = 0) { // $msg_parent = 0; //} else { // $msg_parent = $thread['thread']; //} // set the thread moderation status if ($thread['approved'] != 'Y') { $msg_active = 0; } else { $msg_active = 1; } // set the ownership string if ($thread['userid'] == 0) { // get the ip of the anonymous poster not the host name if (isIp($thread['host'])) { $ip = $thread['host']; } else { // try to convert the hostname to ip $ip = gethostbyname($thread['host']); if (!isIp($ip)) { unset($ip); } } if (isset($ip)) { $ip = chr(1) . $ip; } $msg_owner = "0." . addslashes($thread['author']) . $ip; } else { $msg_owner = $memberIdTable[$thread['userid']]; } // array to describe how to migrate every data of the thread $msg_tab = array('thread_name' => addslashes($thread['subject']), 'thread_thread' => str_replace("[%sig%]", "", addslashes($msg_body['body'])), 'thread_forum_id' => $forum_id, 'thread_parent' => 0, 'thread_datestamp' => unix_date($thread['datestamp']), 'thread_active' => $msg_active, 'thread_user' => $msg_owner); // add the message in the e107 forum $e107Thread_id = insertRow($msg_tab, $e107_threadTable, $e107_db); $log .= " New thread \"" . stripslashes($thread['subject']) . "\" added with its first message n°" . $thread['id'] . "<br>"; // TODO: this part of function is the same as above, so we can factorise this part // get all messages sons of the current thread $log .= " Get all messages of the thread...<br>"; $sql3 = "SELECT * "; $sql3 .= "FROM `" . $phorumTable . "`"; $sql3 .= "WHERE `thread` = " . $thread['id'] . " AND `parent` <> 0"; mysql_select_db($phorum_db); $son_list = mysql_query($sql3); // convert each message from Phorum to e107 while ($son = mysql_fetch_array($son_list)) { // get the body of the message (stored in a different table in phorum) $sql4 = "SELECT * "; $sql4 .= "FROM `" . $phorumTable . "_bodies` "; $sql4 .= "WHERE `id` = " . $son['id']; mysql_select_db($phorum_db); $bodies = mysql_query($sql4); $son_body = mysql_fetch_array($bodies); // set the thread moderation status if ($son['approved'] != 'Y') { $son_active = 0; } else { $son_active = 1; } // set the ownership string if ($son['userid'] == 0) { // get the ip of the anonymous poster not the host name if (isIp($son['host'])) { $ip = $son['host']; } else { // try to convert the hostname to ip $ip = gethostbyname($son['host']); if (!isIp($ip)) { unset($ip); } } if (isset($ip)) { $ip = chr(1) . $ip; } $msg_owner = "0." . addslashes($son['author']) . $ip; } else { $msg_owner = $memberIdTable[$son['userid']]; } // array to describe how to migrate every data $son_tab = array('thread_name' => addslashes($son['subject']), 'thread_thread' => str_replace("[%sig%]", "", addslashes($son_body['body'])), 'thread_forum_id' => $forum_id, 'thread_parent' => $e107Thread_id, 'thread_datestamp' => unix_date($son['datestamp']), 'thread_active' => $son_active, 'thread_user' => $msg_owner); // add the message in the thread insertRow($son_tab, $e107_threadTable, $e107_db); $log .= " New son message \"" . stripslashes($son_tab['thread_name']) . "\" added to the thread.<br>"; } } return $log; }
function getHostMask() { $mask = '*!*' . right($this->ident, IDENT_LEN) . '@'; $host = $this->host; if ($this->hasFakehost()) { $host = $this->fakehost; } elseif ($this->isHostHidden()) { $host = $this->getAccountName() . '.' . HIDDEN_HOST; } $levels = explode('.', $host); $num_levels = count($levels); if (isIp($host)) { $host = assemble($levels, 0, 3, '.'); $host .= '.*'; } elseif ($num_levels > 2) { for ($n = $num_levels - 1; $n > 0; $n--) { if (preg_match('/[0-9]/', $levels[$n])) { break; } } $host = '*.'; $host .= assemble($levels, $n + 1, -1, '.'); } $mask = fixHostMask($mask); return $mask . $host; }