function validate_username($username)
{
    global $db, $lang, $userdata;
    // Remove doubled up spaces
    $username = preg_replace('#\\s+#', ' ', $username);
    // Limit username length
    $username = substr(str_replace("\\'", "'", $username), 0, 25);
    $username = str_replace("'", "''", $username);
    $sql = "SELECT username\n        FROM " . USERS_TABLE . "\n        WHERE LOWER(username) = '" . strtolower($username) . "'";
    if ($result = $db->sql_query($sql)) {
        if ($row = $db->sql_fetchrow($result)) {
            if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
                $db->sql_freeresult($result);
                return array('error' => true, 'error_msg' => $lang['Username_taken']);
            }
        }
    }
    $db->sql_freeresult($result);
    $sql = "SELECT group_name\n        FROM " . GROUPS_TABLE . "\n        WHERE LOWER(group_name) = '" . strtolower($username) . "'";
    if ($result = $db->sql_query($sql)) {
        if ($row = $db->sql_fetchrow($result)) {
            $db->sql_freeresult($result);
            return array('error' => true, 'error_msg' => $lang['Username_taken']);
        }
    }
    $db->sql_freeresult($result);
    $sql = "SELECT disallow_username\n        FROM " . DISALLOW_TABLE;
    if ($result = $db->sql_query($sql)) {
        if ($row = $db->sql_fetchrow($result)) {
            do {
                if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['disallow_username'], '#')) . ")\\b#i", $username)) {
                    $db->sql_freeresult($result);
                    return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
                }
            } while ($row = $db->sql_fetchrow($result));
        }
    }
    $db->sql_freeresult($result);
    $sql = "SELECT word\n        FROM  " . WORDS_TABLE;
    if ($result = $db->sql_query($sql)) {
        if ($row = $db->sql_fetchrow($result)) {
            do {
                if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\\b#i", $username)) {
                    $db->sql_freeresult($result);
                    return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
                }
            } while ($row = $db->sql_fetchrow($result));
        }
    }
    $db->sql_freeresult($result);
    // Don't allow " and ALT-255 in username.
    if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160))) {
        return array('error' => true, 'error_msg' => $lang['Username_invalid']);
    }
    return array('error' => false, 'error_msg' => '');
}
function validate_username($username)
{
    global $db, $lang, $userdata;
    $username = str_replace("\\'", "''", $username);
    $sql = "SELECT username \r\n\t\tFROM " . USERS_TABLE . " \r\n\t\tWHERE LOWER(username) = '" . strtolower($username) . "'";
    if ($result = $db->sql_query($sql)) {
        if ($row = $db->sql_fetchrow($result)) {
            if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
                return array('error' => true, 'error_msg' => $lang['Username_taken']);
            }
        }
    }
    $sql = "SELECT group_name\r\n\t\tFROM " . GROUPS_TABLE . " \r\n\t\tWHERE LOWER(group_name) = '" . strtolower($username) . "'";
    if ($result = $db->sql_query($sql)) {
        if ($row = $db->sql_fetchrow($result)) {
            return array('error' => true, 'error_msg' => $lang['Username_taken']);
        }
    }
    $sql = "SELECT disallow_username\r\n\t\tFROM " . DISALLOW_TABLE;
    if ($result = $db->sql_query($sql)) {
        while ($row = $db->sql_fetchrow($result)) {
            if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['disallow_username'], '#')) . ")\\b#i", $username)) {
                return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
            }
        }
    }
    $sql = "SELECT word \r\n\t\tFROM  " . WORDS_TABLE;
    if ($result = $db->sql_query($sql)) {
        while ($row = $db->sql_fetchrow($result)) {
            if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\\b#i", $username)) {
                return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
            }
        }
    }
    // Don't allow " in username.
    if (strstr($username, '"')) {
        return array('error' => true, 'error_msg' => $lang['Username_invalid']);
    }
    return array('error' => false, 'error_msg' => '');
}
        /**
         * Obtain list of acronyms and build preg style replacement arrays for use by the calling script
         */
        function obtain_acronym_list()
        {
            global $k_config, $user, $db;
            //Fix ref: http://www.stargate-portal.com/forum/viewtopic.php?f=29&t=591&p=6857 syntron //
            if (!class_exists('acm')) {
                global $phpbb_root, $phpEx;
                require $phpbb_root_path . 'includes/acm/acm_file.' . $phpEx;
            }
            if (($acronyms = $this->get('_word_acronyms')) === false) {
                $sql = 'SELECT acronym, meaning
					FROM ' . K_ACRONYMS_TABLE . "\n\t\t\t\t\tWHERE lang = '" . $user->data['user_lang'] . "'\n\t\t\t\t\tORDER BY LENGTH(TRIM(acronym))\tDESC";
                $result = $db->sql_query($sql, 600);
                $acronyms = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $acronyms['match'][] = '#(' . phpbb_preg_quote($row['acronym'], '#') . ')#';
                    $acronyms['replace'][] = '<acronym title="' . $row['meaning'] . '">\\1</acronym>';
                }
                $db->sql_freeresult($result);
                $this->put('_word_acronyms', $acronyms);
            }
            return $acronyms;
        }
function smilies_news($message)
{
    static $orig, $repl;
    if (!isset($orig)) {
        global $db, $config;
        $orig = $repl = array();
        //$sql = "SELECT * FROM " . SMILIES_TABLE;
        $sql = "SELECT code, smile_url FROM " . SMILIES_TABLE . " ORDER BY smilies_order";
        $result = $db->sql_query($sql, 0, 'smileys_');
        $host = extract_current_hostname();
        $orig = array();
        $repl = array();
        while ($row = $db->sql_fetchrow($result)) {
            $orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($row['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
            $repl[] = '<img src="http://' . $host . $config['script_path'] . $config['smilies_path'] . '/' . $row['smile_url'] . '" alt="" />';
        }
    }
    if (sizeof($orig)) {
        $message = preg_replace($orig, $repl, ' ' . $message . ' ');
        $message = substr($message, 1, -1);
    }
    return $message;
}
Beispiel #5
0
 }
 $hasil4 = mysql_query("SELECT `mod_download`.*,`mod_cat_download`.`kategori`,\n\t\t \t\tMATCH(`mod_download`.`judul`,`mod_download`.`keterangan`,`mod_download`.`url`) AGAINST ('{$search}'  IN BOOLEAN MODE) AS score \n\t  \t\t\tFROM `mod_download` LEFT JOIN `mod_cat_download` ON `mod_cat_download`.`kid`=`mod_download`.`kid` where MATCH(`mod_download`.`judul`,`mod_download`.`keterangan`,`mod_download`.`url`) AGAINST ('{$search}'  IN BOOLEAN MODE) \n\t  \t\t\t ORDER BY score DESC\n\t \t\t\tLIMIT {$offset}, {$limit}");
 if ($jumlah > 0) {
     $open['finds'] = true;
     $open['caption'] = 'Ditemukan <b>' . $jumlah . '</b> Download Dengan Kata Kunci : <b>' . $search . '</b>';
     while ($data = mysql_fetch_assoc($hasil4)) {
         ///// fungsi hightlight
         //////////////////////////////////////////////////////////////////////////////////////////////////////////
         $highlight = $search;
         if (isset($search)) {
             // Split words and phrases
             $words = explode(' ', trim(htmlspecialchars(urldecode($search))));
             $highlight_match = '';
             for ($i = 0; $i < sizeof($words); $i++) {
                 if (trim($words[$i]) != '') {
                     $highlight_match .= ($highlight_match != '' ? '|' : '') . str_replace('*', '\\w*', phpbb_preg_quote($words[$i], '#'));
                 }
             }
             unset($words);
         }
         $JUDUL = str_replace('\\"', '"', substr(preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "preg_replace('#(" . $highlight_match . ")#i', '<span style=\"color:orange\">\\\\1</span>', '\\0')", '>' . $data['judul'] . '<'), 1, -1));
         $KETERANGAN = str_replace('\\"', '"', substr(preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "preg_replace('#(" . $highlight_match . ")#i', '<span style=\"color:orange\">\\\\1</span>', '\\0')", '>' . $data['keterangan'] . '<'), 1, -1));
         $ceknew = empty($ceknew) ? '' : $ceknew;
         $open['List'][] = array('judul' => $JUDUL, 'keterangan' => $KETERANGAN, 'url' => $data['url'], 'hit' => $data['hit'], 'date' => date('Y-m-d H:i:s', $data['date']), 'id' => $data['id'], 'kid' => $data['kid'], 'kategori' => $data['kategori'], 'size' => $data['size'], 'newlinks' => cek_baru($data['id'], 1209600, 'id', 'mod_link'));
     }
 } else {
     $open['finds'] = false;
     $open['caption'] = 'Tidak Ditemukan  Dengan Kata Kunci : <b>' . $search . '</b>';
 }
 $j = new JSON_obj();
 echo $j->encode($open);
Beispiel #6
0
 function encode($str)
 {
     if ($this->encoding == '') {
         return $str;
     }
     // define start delimimter, end delimiter and spacer
     $end = "?=";
     $start = "=?{$this->encoding}?B?";
     $spacer = "{$end}\r\n {$start}";
     // determine length of encoded text within chunks and ensure length is even
     $length = 75 - strlen($start) - strlen($end);
     $length = floor($length / 2) * 2;
     // encode the string and split it into chunks with spacers after each chunk
     $str = chunk_split(base64_encode($str), $length, $spacer);
     // remove trailing spacer and add start and end delimiters
     $str = preg_replace('#' . phpbb_preg_quote($spacer, '#') . '$#', '', $str);
     return $start . $str . $end;
 }
function obtain_word_list(&$orig_word, &$replacement_word)
{
    global $db, $cache;
    if ($cache->exists('word_censors')) {
        $censors = $cache->get('word_censors');
        $orig_word = $censors['orig_word'];
        $replacement_word = $censors['replacement_word'];
        unset($censors);
    } else {
        //
        // Define censored word matches
        //
        $sql = "SELECT word, replacement\n            FROM  " . WORDS_TABLE;
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
        }
        if ($row = $db->sql_fetchrow($result)) {
            do {
                // Intellicensor © 2004 Jonathan Motta < *****@*****.** >
                $ic_word = '';
                $ic_first = 0;
                $ic_chars = preg_split('//', $row['word'], -1, PREG_SPLIT_NO_EMPTY);
                foreach ($ic_chars as $char) {
                    if ($ic_first == 1 && $char != '*') {
                        $ic_word .= '_';
                    }
                    $ic_word .= $char;
                    $ic_first = 1;
                }
                $ic_search = array('\\*', 's', 'a', 'b', 'l', 'i', 'o', 'p', '_');
                $ic_replace = array('\\w*?', '(?:s|\\$)', '(?:a|\\@)', '(?:b|8|3)', '(?:l|1|i|\\!)', '(?:i|1|l|\\!)', '(?:o|0)', '(?:p|\\?)', '(?:_|\\W)*');
                $orig_word[] = '#(?<=^|\\W)(' . str_replace($ic_search, $ic_replace, phpbb_preg_quote($ic_word, '#')) . ')(?=\\W|$)#i';
                //	$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
                $replacement_word[] = $row['replacement'];
            } while ($row = $db->sql_fetchrow($result));
        }
        $db->sql_freeresult($result);
        $cache->put('word_censors', array('orig_word' => $orig_word, 'replacement_word' => $replacement_word));
    }
    return true;
}
Beispiel #8
0
function smilies_pass($message)
{
    global $db, $board_config;
    static $smilies;
    if (empty($smilies)) {
        $sql = "SELECT code, smile_url\r\n\t\t\tFROM " . SMILIES_TABLE;
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
        }
        if (!$db->sql_numrows($result)) {
            return $message;
        }
        $smilies = $db->sql_fetchrowset($result);
    }
    usort($smilies, 'smiley_sort');
    for ($i = 0; $i < count($smilies); $i++) {
        $orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
        $repl[] = '<img src="' . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['smile_url'] . '" border="0" />';
    }
    if ($i > 0) {
        $message = preg_replace($orig, $repl, ' ' . $message . ' ');
        $message = substr($message, 1, -1);
    }
    return $message;
}
 function smilies_pass($message)
 {
     static $orig, $repl;
     if (!isset($orig)) {
         global $db, $images, $portal_config, $var_cache, $phpbb_root_path, $config;
         $orig = $repl = array();
         if (!$orig) {
             $sql = 'SELECT * FROM ' . SMILIES_TABLE;
             if (!($result = $db->sql_query($sql))) {
                 trigger_error($user->lang['ERROR_SMILIES_DATA'], __LINE__, __FILE__, $sql);
             }
             $smilies = $db->sql_fetchrowset($result);
             if (count($smilies)) {
                 usort($smilies, "smiley_sort");
             }
             for ($i = 0; $i < count($smilies); $i++) {
                 $orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
                 $repl[] = '<img src="' . $phpbb_root_path . $config['smilies_path'] . '/' . $smilies[$i]['smiley_url'] . '" alt="' . $smilies[$i]['emotion'] . '" border="0" />';
             }
             if ($portal_config['cache_enabled']) {
                 $var_cache->save($orig, 'orig2', 'smilies');
                 $var_cache->save($repl, 'repl2', 'smilies');
             }
         }
     }
     if (count($orig)) {
         $message = preg_replace($orig, $repl, ' ' . $message . ' ');
         $message = substr($message, 1, -1);
     }
     return $message;
 }
Beispiel #10
0
 function obtain_autolinks_list($forum_id)
 {
     global $db;
     $where = $forum_id ? ' WHERE link_forum = 0 OR link_forum IN (' . $forum_id . ')' : ' WHERE link_forum = -1';
     $sql = "SELECT * FROM " . AUTOLINKS . $where;
     $result = $db->sql_query($sql, 0, 'autolinks_', TOPICS_CACHE_FOLDER);
     $autolinks = array();
     while ($row = $db->sql_fetchrow($result)) {
         // Munge word boundaries to stop autolinks from linking to
         // themselves or other autolinks in step 2 in the function below.
         $row['link_url'] = preg_replace('/(\\b)/', '\\1ALSPACEHOLDER', $row['link_url']);
         $row['link_comment'] = preg_replace('/(\\b)/', '\\1ALSPACEHOLDER', $row['link_comment']);
         if ($row['link_style']) {
             $row['link_style'] = preg_replace('/(\\b)/', '\\1ALSPACEHOLDER', $row['link_style']);
             $style = ' style="' . htmlspecialchars($row['link_style']) . '" ';
         } else {
             $style = ' ';
         }
         $autolinks['match'][] = '/(?<![\\/\\w@\\.:-])(?!\\.\\w)(' . phpbb_preg_quote($row['link_keyword'], '/') . ')(?![\\/\\w@:-])(?!\\.\\w)/i';
         if ($row['link_int']) {
             $autolinks['replace'][] = '<a href="' . append_sid(htmlspecialchars($row['link_url'])) . '" target="_self"' . $style . 'title="' . htmlspecialchars($row['link_comment']) . '">' . htmlspecialchars($row['link_title']) . '</a>';
         } else {
             $autolinks['replace'][] = '<a href="' . htmlspecialchars($row['link_url']) . '" target="_blank"' . $style . 'title="' . htmlspecialchars($row['link_comment']) . '">' . htmlspecialchars($row['link_title']) . '</a>';
         }
     }
     $db->sql_freeresult($result);
     return $autolinks;
 }
 function execute(&$observer)
 {
     $username = $observer->get('default.validation.username');
     // length check
     if (strlen(trim($username)) > 25) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username must be no more than 25 characters long.');
         $observer->set('default.validation.status', 'LONG');
         $observer->set('login.request.status', 'LONG');
         return FALSE;
     }
     //get the entire list of disallowed words. In the future we might have
     //more specific queries eg. get only swear words, get only NPC, etc.
     $filterList = UsernameFilter::filterList(1);
     if (count($filterList) <= 0) {
         return TRUE;
     }
     //nothing to filter against lol
     // are they logged in -- Jakob
     // if so, we don't bother doing the NPC check
     // rxes defines the array of regular expressions
     $rxes = array();
     // MATCH 1.  Variants of [NPC] using nonword characters
     $delim = "[\\W\\s_]";
     // Nonword, whitespace, underscore
     $rx = "^(.*?)" . "{$delim} *?" . "[N]" . "{$delim} *?" . "[P]" . "{$delim} *?" . "[C]" . "{$delim} +" . "(.*)";
     // match as much as possible to end of string
     $rx = "/" . $rx . "/xi";
     $rxes[] = $rx;
     // MATCH 2,  inpci, lnpcl, l_n-p_c and word variants.  Much stricter so as not
     // to break actual words
     $delim = "[il\\|]";
     // i, l, pipe
     $rx = "^(.*?)" . "{$delim}" . "[\\s\\-_]*" . "n[\\s\\-_]*" . "p[\\s\\-_]*" . "c[\\s\\-_]*" . "{$delim} ?" . "(.*)";
     // grab the rest by being greedy
     $rx = "/" . $rx . "/xi";
     $rxes[] = $rx;
     $matched = false;
     foreach ($rxes as $rx) {
         if (preg_match($rx, $username)) {
             $matched = true;
         }
     }
     if ($matched) {
         /// name found, logged in?
         if (SC::get("userdata.user_level") <= 0) {
             $observer->set('error.title', 'Username Error');
             $observer->set('error.message', 'Your username is in conflict because it is the name of a NPC (Non-Playable Character). For storyline purposes, we kindly ask you to choose another username. Thank you!');
             $observer->set('default.validation.status', 'NPC');
             $observer->set('login.request.status', 'NPC');
             return FALSE;
         }
     }
     //-------------------------------------------------------------------------------------
     //this is pretty ghetto but we don't have a consesus for handling all the names in the database
     //so there is some hack-ish stuff going on eg. with checking ElfTech names it is extra
     //strict that previous NPC names
     //do a case insensitive check against each of the NPC names.
     foreach ($filterList['NPC'] as $f) {
         //in the future if we want to do other checks like against l33t names we can modify this.
         $pattern = "/\\b{$f}\\b/i";
         //this is more lenient than below
         if ($f == 'ElfTech') {
             $pattern = "/.*Elf.*Tech.*/i";
             //nothing allowed!!! omg:O
         }
         $result = preg_match($pattern, $username);
         if (!empty($result)) {
             $observer->set('error.title', 'Username Error');
             $observer->set('error.message', 'Your username is in conflict because it is the name of a NPC (Non-Playable Character). For storyline purposes, we kindly ask you to choose another username. Thank you!');
             $observer->set('default.validation.status', 'NPC');
             $observer->set('login.request.status', 'NPC');
             return FALSE;
         }
     }
     //----------------------------------------------------------------------------------------
     //do a case insensitive check against each of the Admin names.
     foreach ($filterList['Admin'] as $f) {
         //in the future if we want to do other checks like against l33t names we can modify this.
         $pattern = "/{$f}/i";
         $result = preg_match($pattern, $username);
         if (!empty($result)) {
             $observer->set('error.title', 'Username Error');
             $observer->set('error.message', 'Your username is in conflict with administration names. We kindly ask you to choose another username that will not confuse other user.');
             $observer->set('default.validation.status', 'Admin');
             $observer->set('login.request.status', 'Admin');
             return FALSE;
         }
     }
     //----------------------------------------------------------------------------------------
     //do a case insensitive check against each of the Swear names.
     foreach ($filterList['Swear'] as $f) {
         //in the future if we want to do other checks like against l33t names we can modify this.
         $pattern = "/{$f}/i";
         $result = preg_match($pattern, $username);
         if (!empty($result)) {
             $observer->set('error.title', 'Username Error');
             $observer->set('error.message', 'Your username is in conflict with PG-13 guidelines! We kindly ask you to choose another username that is more appropriate.');
             $observer->set('default.validation.status', 'Swear');
             $observer->set('login.request.status', 'Swear');
             return FALSE;
         }
     }
     //----------------------------------------------------------------------------------------
     // username approximate matching
     // we need to munge the name now and attempt to standardize the lookups
     $userdata =& SC::get('userdata');
     $username = str_replace("\\'", "''", $username);
     $checkname = strtolower(preg_replace("/^[_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\'\\s\\.]+/", '', $username));
     $checkname = preg_replace("/[_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\'\\s\\.]+\$/", '', $checkname);
     $checkname = preg_replace("/[\\-\\+\\=\\^\\#\\!\\~\\s\\.]/", '_', $checkname);
     // compressed length check
     if (strlen(trim($username)) <= 2) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username must be at least 3 characters.');
         return FALSE;
     }
     // invalid character check
     if (!preg_match('/^[a-zA-z0-9_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\s\\.]+$/', $username)) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username contains invalid characters.');
         return FALSE;
     }
     // check for at least one letter
     if (!preg_match("/[a-zA-Z]/", $username)) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username must have at least one letter.');
         return FALSE;
     }
     // check for double spaces
     if (preg_match("/  /", $username)) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username cannot have 2 spaces in a row.');
         return FALSE;
     }
     // Don't allow " in username.
     if (strstr($username, '"') || strstr($username, ',')) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username cannot contain quotations or commas.');
         return FALSE;
     }
     // check for exact username
     $dao =& DaoFactory::create('users');
     $dao->byExactUsername(strtolower($username));
     $rs =& $dao->execute();
     if (!$rs->isSuccess()) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Unable to validate username.');
         $observer->set('error.line', __LINE__);
         $observer->set('error.file', __FILE__);
         $observer->set('error.debug', $rs);
         return FALSE;
     }
     while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
         if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
             if (strtolower($row['username']) == strtolower($username)) {
                 $observer->set('error.title', 'Username Error');
                 $observer->set('error.message', 'That username is already taken.');
                 return FALSE;
             } else {
                 $observer->set('error.title', 'Username Error');
                 $observer->set('error.message', 'Your username is too similar to the username of ' . $row['username']);
                 return FALSE;
             }
         }
     }
     // perform a wildcard search for special character matching
     if (strtolower($username) != $checkname) {
         $dao =& DaoFactory::create('users');
         $dao->byUsername(preg_replace('/_/', '\\_', $checkname));
         $rs =& $dao->execute();
         while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
             if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
                 if (strtolower($row['username']) == strtolower($username)) {
                     $observer->set('error.title', 'Username Error');
                     $observer->set('error.message', 'That username is already taken.');
                     return FALSE;
                 } else {
                     $observer->set('error.title', 'Username Error');
                     $observer->set('error.message', 'Your username is too similar to the username of ' . $row['username']);
                     return FALSE;
                 }
             }
         }
     }
     // check wordlist filter
     $dao =& DaoFactory::create('words');
     $dao->setWhat('word');
     $rs =& $dao->execute();
     while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
         if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\\b#i", $username)) {
             $observer->set('error.title', 'Username Error');
             $observer->set('error.message', 'Your username contains invalid characters.');
             return FALSE;
         }
     }
     return TRUE;
 }
Beispiel #12
0
function obtain_word_list(&$orig_word, &$replacement_word)
{
    global $db;
    //
    // Define censored word matches
    //
    $result = $db->sql_query("SELECT word, replacement FROM\t " . WORDS_TABLE);
    if ($row = $db->sql_fetchrow($result)) {
        do {
            $orig_word[] = '#\\b(' . str_replace('\\*', '\\w*?', phpbb_preg_quote($row['word'], '#')) . ')\\b#i';
            $replacement_word[] = $row['replacement'];
        } while ($row = $db->sql_fetchrow($result));
    }
    return true;
}
Beispiel #13
0
function smilies_pass($message) 
{ 
   static $orig, $repl; 

   if (!isset($orig)) 
   { 
      global $db, $board_config; 
      $orig = $repl = array(); 

      $sql = 'SELECT code, smile_url FROM ' . SMILIES_TABLE; 
      if( !$result = $db->sql_query($sql) ) 
      { 
         message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql); 
      } 
      $smilies = $db->sql_fetchrowset($result); 

      usort($smilies, 'smiley_sort'); 
      for($i = 0; $i < count($smilies); $i++) 
      { 
         $orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/"; 
         $smile_file_path = get_file_path($smilies[$i]['smile_url'], $board_config['smilies_path'] . '/');
         $repl[] = '<img src="'. $smile_file_path . '" alt="' . $smilies[$i]['smile_url'] . '" border="0" />'; 
      } 
   } 

   if (count($orig)) 
   { 
      $message = preg_replace($orig, $repl, ' ' . $message . ' '); 
      $message = substr($message, 1, -1); 
   } 
   return $message; 
}
Beispiel #14
0
function smart_pass($message)
{
    static $orig, $repl;
    if (!isset($orig)) {
        global $db, $board_config;
        $orig = $repl = array();
        $sql = 'SELECT * FROM ' . SMART_TABLE;
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, "Couldn't obtain smart tag data", "", __LINE__, __FILE__, $sql);
        }
        $smart_tags = $db->sql_fetchrowset($result);
        if (count($smart_tags)) {
            usort($smart_tags, 'smart_sort');
        }
        for ($i = 0, $max = count($smart_tags); $i < $max; $i++) {
            $orig[] = '#\\b(' . phpbb_preg_quote($smart_tags[$i]['smart'], "/") . ')\\b#';
            //$orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($acronyms[$i]['acronym'], "/") . "(?=.\W|\W.|\W$)/";
            $repl[] = '<a href="' . $smart_tags[$i]['url'] . '" target="_blank">' . $smart_tags[$i]['smart'] . '</a>';
        }
    }
    if (count($orig)) {
        $segments = preg_split('#(<a href=.+?>.+?</a>|<.+?>)#s', $message, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
        $message = '';
        foreach ($segments as $seg) {
            if ($seg[0] != '<' && $seg[0] != '[') {
                $message .= str_replace('\\"', '"', substr(preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "preg_replace(\$orig, \$repl, '\\0')", '>' . $seg . '<'), 1, -1));
            } else {
                $message .= $seg;
            }
        }
    }
    return $message;
}
Beispiel #15
0
/**
* smilies_pass processing
*/
function smilies_pass($message)
{
    static $orig, $repl;
    if (!isset($orig)) {
        global $db, $images, $portal_config;
        $orig = $repl = array();
        if (!$orig) {
            $sql = 'SELECT * FROM ' . SMILIES_TABLE;
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
            }
            $smilies = $db->sql_fetchrowset($result);
            if (count($smilies)) {
                usort($smilies, "smiley_sort");
            }
            for ($i = 0; $i < count($smilies); $i++) {
                $orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
                $repl[] = '<img src="images/smilies/' . $images['smilies'] . '/' . $smilies[$i]['smiley_url'] . '" alt="' . $smilies[$i]['emotion'] . '" border="0" />';
            }
        }
    }
    if (count($orig)) {
        $message = preg_replace($orig, $repl, ' ' . $message . ' ');
        $message = substr($message, 1, -1);
    }
    return $message;
}
Beispiel #16
0
function smiley_replace($text = '')
{
    global $db;
    static $search, $replace;
    // Did we get the smiley info in a previous call?
    if (!is_array($search)) {
        $sql = "SELECT code, smile_url\n\t\t\tFROM smiles";
        $result = query($sql, "Unable to get list of smilies from the DB");
        $smilies = $db->sql_fetchrowset($result);
        @usort($smilies, 'smiley_sort');
        $search = array();
        $replace = array();
        for ($i = 0; $i < count($smilies); $i++) {
            $search[] = '/<IMG SRC=".*?\\/' . phpbb_preg_quote($smilies[$i]['smile_url'], '/') . '">/i';
            $replace[] = $smilies[$i]['code'];
        }
    }
    return $text != '' ? preg_replace($search, $replace, $text) : '';
}
Beispiel #17
0
function obtain_word_list(&$orig_word, &$replacement_word)
{
	global $db;

	//
	// Define censored word matches
	//
	$sql = "SELECT word, replacement
		FROM  " . WORDS_TABLE;
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
	}

	if ( $row = $db->sql_fetchrow($result) )
	{
		do
		{
			$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
			$replacement_word[] = $row['replacement'];
		}
		while ( $row = $db->sql_fetchrow($result) );
	}

	return true;
}
Beispiel #18
0
 public function send()
 {
     global $board_config, $lang, $phpbb_root_path, $db;
     foreach ($this->vars as $key => $val) {
         $this->msg = str_replace('{' . $key . '}', $val, $this->msg);
     }
     //		$this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#ise', '$this->vars[\'$1\']', $this->msg);
     /*
     		// Escape all quotes, else the eval will fail.
     		$this->msg = str_replace ("'", "\'", $this->msg);
     		$this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "'.$\\1.'", $this->msg);
     		// Set vars
     		foreach ($this->vars AS $key => $val) { $$key = $val; }
     		eval("\$this->msg = '$this->msg';");
     		// Clear vars
     		foreach ($this->vars AS $key => $val) { unset($$key); }
     */
     // We now try and pull a subject from the email body ... if it exists,
     // do this here because the subject may contain a variable
     $drop_header = '';
     $match = array();
     if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) {
         $this->subject = trim($match[2]) != '' ? trim($match[2]) : ($this->subject != '' ? $this->subject : 'No Subject');
         $drop_header .= '[\\r\\n]*?' . phpbb_preg_quote($match[1], '#');
     } else {
         $this->subject = $this->subject != '' ? $this->subject : 'No Subject';
     }
     if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match)) {
         $this->encoding = trim($match[2]) != '' ? trim($match[2]) : trim($lang['ENCODING']);
         $drop_header .= '[\\r\\n]*?' . phpbb_preg_quote($match[1], '#');
     } else {
         $this->encoding = trim($lang['ENCODING']);
     }
     if ($drop_header != '') {
         $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
     }
     // use Dragonfly mailer
     if (isset($this->addresses['cc']) && count($this->addresses['cc']) || isset($this->addresses['bcc']) && count($this->addresses['bcc'])) {
         $to = array();
         // bcc array($to_email => $to_name);
         if ($this->addresses['to']) {
             $to[$this->addresses['to']] = '';
         }
         if (isset($this->addresses['cc']) && count($this->addresses['cc'])) {
             foreach ($this->addresses['cc'] as $cc) {
                 $to[$cc] = '';
             }
         }
         if (isset($this->addresses['bcc']) && count($this->addresses['bcc'])) {
             foreach ($this->addresses['bcc'] as $cc) {
                 $to[$cc] = '';
             }
         }
     } else {
         $to = $this->addresses['to'];
     }
     $email_headers = empty($this->extra_headers) ? false : explode("\n", $this->extra_headers);
     $to_name = $from_name = $mailer_message = '';
     $result = send_mail($mailer_message, $this->msg, false, $this->subject, $to, $to_name, $this->from, $from_name, $email_headers);
     // Did it work?
     if (!$result) {
         message_die(GENERAL_ERROR, 'Failed sending email :: ' . ($this->use_smtp ? 'SMTP' : 'PHP') . ' :: ' . $mailer_message, '', __LINE__, __FILE__);
     }
     return true;
 }