Avatar billede fire-fox Nybegynder
17. juni 2009 - 22:01 Der er 1 løsning

phpbb2 announce script

Hejsa

Jeg har fundet et script, der gør det muligt at når man poster, i phpbb forummet så poster den også på irc. men den fungere ikke helt.

På irc ser udfaldet sådan her ud : /viewtopic.php?p=# men den skulle gerne være /viewtopic.php?p=20#20 Og ved ikke lige hvorfor den ikke lige sætter det sidste på..


her er koden...

//Bot Mod Start
if($mode=='newtopic' || $mode=='reply')
{
$url = 'http://' . $board_config['server_name'] . (($board_config['server_port']==80) ? '' : ':' . $board_config['server_port']) . $board_config['script_path']. 'viewtopic.' . $phpEx . '?' .POST_POST_URL . '=' . $post_id . '#' . $post_id;
if(function_exists('replace_for_mod_rewrite'))
{
$url = replace_for_mod_rewrite($url);
}
include($phpbb_root_path . 'includes/eggdrop.class.' . $phpEx);
$tmp = new eggdrop_class;
$tmp->send_msg($board_config['eggdrop_server'],$board_config['eggdrop_port'],$board_config['eggdrop_username'],$board_config['eggdrop_password'],$board_config['eggdrop_channel'],str_replace(array('{POSTER}','{SUBJECT}','{LINK}'),array($userdata['username'],$post_subject,$url),$board_config['eggdrop_message' . (($mode=='newtopic') ? '' : '2')]));
unset($tmp);
}
//Bot Mod Slut

Her er kildekoden ned til det øverste :

<?php
/***************************************************************************
*                            functions_post.php
*                            -------------------
*  begin                : Saturday, Feb 13, 2001
*  copyright            : (C) 2001 The phpBB Group
*  email                : support@phpbb.com
*
*  $Id: functions_post.php 5886 2006-05-06 13:38:55Z grahamje $
*
*
***************************************************************************/

/***************************************************************************
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
***************************************************************************/

if (!defined('IN_PHPBB'))
{
    die('Hacking attempt');
}

$html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#');
$html_entities_replace = array('&', '<', '>', '"');

$unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#');
$unhtml_specialchars_replace = array('>', '<', '"', '&');

//
// This function will prepare a posted message for
// entry into the database.
//
function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0)
{
    global $board_config, $html_entities_match, $html_entities_replace;

    //
    // Clean up the message
    //
    $message = trim($message);

    if ($html_on)
    {
        // If HTML is on, we try to make it safe
        // This approach is quite agressive and anything that does not look like a valid tag
        // is going to get converted to HTML entities
        $message = stripslashes($message);
        $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#';
        $matches = array();

        $message_split = preg_split($html_match, $message);
        preg_match_all($html_match, $message, $matches);

        $message = '';

        foreach ($message_split as $part)
        {
            $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2]));
            $message .= preg_replace($html_entities_match, $html_entities_replace, $part) . clean_html($tag);
        }

        $message = addslashes($message);
        $message = str_replace('"', '\"', $message);
    }
    else
    {
        $message = preg_replace($html_entities_match, $html_entities_replace, $message);
    }

    if($bbcode_on && $bbcode_uid != '')
    {
        $message = bbencode_first_pass($message, $bbcode_uid);
    }

    return $message;
}

function unprepare_message($message)
{
    global $unhtml_specialchars_match, $unhtml_specialchars_replace;

    return preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, $message);
}

//
// Prepare a message for posting
//
function prepare_post(&$mode, &$post_data, &$bbcode_on, &$html_on, &$smilies_on, &$error_msg, &$username, &$bbcode_uid, &$subject, &$message, &$poll_title, &$poll_options, &$poll_length)
{
    global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path;

    // Check username
    if (!empty($username))
    {
        $username = phpbb_clean_username($username);

        if (!$userdata['session_logged_in'] || ($userdata['session_logged_in'] && $username != $userdata['username']))
        {
            include($phpbb_root_path . 'includes/functions_validate.'.$phpEx);

            $result = validate_username($username);
            if ($result['error'])
            {
                $error_msg .= (!empty($error_msg)) ? '<br />' . $result['error_msg'] : $result['error_msg'];
            }
        }
        else
        {
            $username = '';
        }
    }

    // Check subject
    if (!empty($subject))
    {
        $subject = htmlspecialchars(trim($subject));
    }
    else if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post']))
    {
        $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Empty_subject'] : $lang['Empty_subject'];
    }

    // Check message
    if (!empty($message))
    {
        $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : '';
        $message = prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
    }
    else if ($mode != 'delete' && $mode != 'poll_delete')
    {
        $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Empty_message'] : $lang['Empty_message'];
    }

    //
    // Handle poll stuff
    //
    if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post']))
    {
        $poll_length = (isset($poll_length)) ? max(0, intval($poll_length)) : 0;

        if (!empty($poll_title))
        {
            $poll_title = htmlspecialchars(trim($poll_title));
        }

        if(!empty($poll_options))
        {
            $temp_option_text = array();
            while(list($option_id, $option_text) = @each($poll_options))
            {
                $option_text = trim($option_text);
                if (!empty($option_text))
                {
                    $temp_option_text[intval($option_id)] = htmlspecialchars($option_text);
                }
            }
            $option_text = $temp_option_text;

            if (count($poll_options) < 2)
            {
                $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['To_few_poll_options'] : $lang['To_few_poll_options'];
            }
            else if (count($poll_options) > $board_config['max_poll_options'])
            {
                $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['To_many_poll_options'] : $lang['To_many_poll_options'];
            }
            else if ($poll_title == '')
            {
                $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Empty_poll_title'] : $lang['Empty_poll_title'];
            }
        }
    }

    return;
}

//
// Post a new topic/reply/poll or edit existing post/poll
//
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, $post_username, $post_subject, $post_message, $poll_title, &$poll_options, &$poll_length)
{
    global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
    global $userdata, $user_ip;

    include($phpbb_root_path . 'includes/functions_search.'.$phpEx);

    $current_time = time();

    if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost')
    {
        //
        // Flood control
        //
        $where_sql = ($userdata['user_id'] == ANONYMOUS) ? "poster_ip = '$user_ip'" : 'poster_id = ' . $userdata['user_id'];
        $sql = "SELECT MAX(post_time) AS last_post_time
            FROM " . POSTS_TABLE . "
            WHERE $where_sql";
        if ($result = $db->sql_query($sql))
        {
            if ($row = $db->sql_fetchrow($result))
            {
                if (intval($row['last_post_time']) > 0 && ($current_time - intval($row['last_post_time'])) < intval($board_config['flood_interval']))
                {
                    message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
                }
            }
        }
    }

    if ($mode == 'editpost')
    {
        remove_search_post($post_id);
    }

    if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post']))
    {
        $topic_vote = (!empty($poll_title) && count($poll_options) >= 2) ? 1 : 0;

        $sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = $topic_id";
        if (!$db->sql_query($sql))
        {
            message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }

        if ($mode == 'newtopic')
        {
            $topic_id = $db->sql_nextid();
        }
    }

    $edited_sql = ($mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post']) ? ", post_edit_time = $current_time, post_edit_count = post_edit_count + 1 " : "";
    $sql = ($mode != "editpost") ? "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ($topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '$user_ip', $bbcode_on, $html_on, $smilies_on, $attach_sig)" : "UPDATE " . POSTS_TABLE . " SET post_username = '$post_username', enable_bbcode = $bbcode_on, enable_html = $html_on, enable_smilies = $smilies_on, enable_sig = $attach_sig" . $edited_sql . " WHERE post_id = $post_id";
    if (!$db->sql_query($sql, BEGIN_TRANSACTION))
    {
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
   
//Bot Mod Start
if($mode=='newtopic' || $mode=='reply')
{
$url = 'http://' . $board_config['server_name'] . (($board_config['server_port']==80) ? '' : ':' . $board_config['server_port']) . $board_config['script_path']. 'viewtopic.' . $phpEx . '?' .POST_POST_URL . '=' . $post_id . '#' . $post_id;
if(function_exists('replace_for_mod_rewrite'))
{
$url = replace_for_mod_rewrite($url);
}
include($phpbb_root_path . 'includes/eggdrop.class.' . $phpEx);
$tmp = new eggdrop_class;
$tmp->send_msg($board_config['eggdrop_server'],$board_config['eggdrop_port'],$board_config['eggdrop_username'],$board_config['eggdrop_password'],$board_config['eggdrop_channel'],str_replace(array('{POSTER}','{SUBJECT}','{LINK}'),array($userdata['username'],$post_subject,$url),$board_config['eggdrop_message' . (($mode=='newtopic') ? '' : '2')]));
unset($tmp);
}
//Bot Mod Slut
Avatar billede fire-fox Nybegynder
17. juni 2009 - 22:31 #1
Fik det til at virke :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester