get correct encoding for nfo files external post script

Discussion forum for MOD Writers regarding MOD Development.
Locked
baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

get correct encoding for nfo files external post script

Post by baller1234 »

Hi All,

Im having some problems with parsing NFO files (http://en.wikipedia.org/wiki/.nfo) with a post script i made. Normaly When i go to my forum and i create a new post and paste an nfo file the text is parsed like it should. (with the bbcode [nfo] i created)


How can i make it so that the text from the html $my_text is converted into the correct method to show the nfo with correct encoding? Do i need to use something like http://www.php.net/manual/en/book.iconv.php ?

I tried some different things but cant seem to get it right.. Hope someone can help me!


Here is the script:

Code: Select all

<?PHP

/**
*
* @package phpBB3
* @version $Id: v3_dbal.xml,v 1.6 2007/07/25 11:06:55 smithy_dll Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpbb_admin_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

$username = $_POST['username'];
$password = $_POST['password'];
$remember = false;

// Start session management
$user->session_begin();
$auth->login($username, $password, $remember, 1, 0);
$auth->acl($user->data);
$user->setup('common');

if ($user->data['user_id'] == ANONYMOUS)
{
    login_box('', $user->lang['LOGIN']);
}

$subject = request_var('subject', '');
$message = request_var('message', '');
$subject = "$subject";
$message = "$message";

$my_subject = utf8_normalize_nfc($subject, '', true);
$my_text = utf8_normalize_nfc($message, '', true);

$poll = $uid = $bitfield = $options = '';

generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);

$forum_number = request_var('forum_number', '');
$forum_number = "$forum_number";

$icon = request_var('icon', '');
$icon = "$icon";

$data = array(
  
   'forum_id'      => $forum_number,

   'icon_id'      => $icon,

   'enable_bbcode'      => true,
   'enable_smilies'   => true,
   'enable_urls'      => true,
   'enable_sig'      => true,

   'message'      => $my_text,
   'message_md5'   => md5($my_text),
            
   'bbcode_bitfield'   => $bitfield,
   'bbcode_uid'      => $uid,

   'post_edit_locked'   => 0,
   'topic_title'      => $my_subject,
   'notify_set'      => false,
   'notify'         => false,
   'post_time'       => 0,
   'forum_name'      => 'General',
   'enable_indexing'   => true,
);

submit_post('post', $my_subject, '', POST_NORMAL, $poll, $data);

echo "Post Complete"; 

?>


Locked

Return to “[3.0.x] MOD Writers Discussion”