Forum AI 0.2.0 mod help (unreconized commands)

Wondering why that MOD you have won't install correctly? Let's take a look
Forum rules
DO NOT give out any FTP passwords to anyone! There is no reason to do so! If you need help badly enough, create a temporary FTP account that is restricted to only the files that you need help with and give the information for that. Giving out FTP information can be very dangerous!
Locked
xkevinx
Registered User
Posts: 26
Joined: Tue Jun 24, 2003 8:44 pm
Location: California
Contact:

Forum AI 0.2.0 mod help (unreconized commands)

Post by xkevinx »

what should i do let it process the commands that were reconized and do the others by hand. thanks


MOD Title: Forum AI 0.2.0
Author: zemaj zemaj@palgn.com James Gay http://www.palgn.com/" target="_blank
Processed Themes: subSilver; subSilver
Processed Languages: english
Files Edited: 4
Commands Processed: 9
Unprocessed Commands: 4



The following commands were not recognized by EasyMOD and were ignored. The MOD script line number is displayed.

Unprocessed Commands ADD AFTER line #87
//
// Begin IAI system
//

// Note: the switch statements here can be quite complicated, so I've used
// some weird setting out. This helps to show exactly what is going on and
// allows me to bear down on the problems that were occuring before.

// Do seed for random replies
list($usec, $sec) = explode(' ', microtime());
mt_srand((float) $sec + ((float) $usec * 100000));
$iai_rand = mt_rand(0, 100);

// Initial should IAI run check
$run_iai =
(
(
$mode == 'newtopic'
||
$mode == 'reply'
)
&&
(
$iai_rand <= $board_config['iai_percentage_all']
)
&&
(
$board_config['iai_percentage_all'] != 0
)
&&
(
$board_config['iai_active_all']
)
) ? TRUE : FALSE;

// Check if forum has settings which overide this
if($post_info['iai_override'])
{
$run_iai = (($iai_rand <= $post_info['iai_percentage']) && ($post_info['iai_percentage'] != 0)) ? TRUE : FALSE;
}

// If IAI is not currently set to run, then it should find any call words
// in the post which might overide this.
// Not in the usual set out, but it allows you to actually understand what's going on.
if(
(
!($run_iai)
)
&&
(
(
$post_info['iai_override']
&&
$post_info['iai_stop_words']
)
||
(
!($post_info['iai_override'])
&&
$board_config['iai_active_all']
)
)
)
{
// See if there is any match in the respond words array.
// I know this system is pretty bad (there must be a faster way), but I haven't had much experience with it, so any help would be greatly appreciated
$res_words = str_replace(", ", ",", $board_config['iai_respond_words']);
$res_words = str_replace("!", "", $res_words);
$res_words = str_replace("?", "", $res_words);
$res_words = str_replace("'", "", $res_words);
$res_words = str_replace('"', '', $res_words);
$res_words = explode(",", $res_words);
$words = str_replace(".", "", $HTTP_POST_VARS['message']);
$words = str_replace("!", "", $words);
$words = str_replace("?", "", $words);
$words = str_replace(",", "", $words);
$words = str_replace("'", "", $words);
$words = str_replace('"', '', $words);
$words = explode(" ", $words);
for($i = 0; $i < count($res_words); $i++)
{
$words = str_replace($res_words[$i] . " ", " " . $res_words[$i] . " ", $words);
$words = str_replace(" " . $res_words[$i], " " . $res_words[$i] . " ", $words);
for($g = 0; $g < count($words); $g++)
{
if($res_words[$i] == $words[$g])
{
$run_iai = TRUE;
}
}
}
}

// START IAI response and entry to db (if active)
if ($run_iai)
{
$iai_root_path = $phpbb_root_path . "mods/iai/";
include($iai_root_path . 'includes/iai_functions.'.$phpEx);

// Initialise variables
$iai_mode = 'reply';
$iai_post_id = '';
$iai_id = $board_config['iai_userid'];
$iai_subject = '';
$iai_username = $board_config['iai_username'];
$iai_topic_type = POST_NORMAL;
$numselects = 0;
$user_id = ($userdata['session_logged_in']) ? $userdata['user_id'] : 0;
// $topic_id should be set already
$sesh_id = $userdata['session_id']; // should NOT be null in any situation
$iai_reply_to = str_replace("is " . $iai_username, "are you", $HTTP_POST_VARS['message']);
$iai_reply_to = str_replace( $iai_username, "you", $iai_reply_to);

// Get IAI reply
$iai_reply = reply($iai_reply_to,$user_id,$topic_id,$sesh_id);
$iai_message = $iai_reply->response;

// prepare IAI message(IAI may have used html, smilies etc...)
$bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
$iai_message = str_replace("'", "''", $iai_message);
$iai_message = prepare_message(trim($iai_message), 0, 1, 1, $bbcode_uid);

if ( $error_msg == '' && !empty($iai_message) )
{
// Submit IAI's response to DB & update stats
iai_submit_post($iai_mode, $iai_id, $forum_id, $topic_id, $iai_post_id, $iai_topic_type, 1, 1, 1, 1, $bbcode_uid, str_replace("\'", "''", $iai_username), str_replace("\'", "''", $iai_subject), str_replace("\'", "''", $iai_message));
iai_update_post_stats($forum_id, $topic_id, $iai_post_id, $iai_id);
}
}
// END IAI response and entry to db

//
// END IAI system
//



ADD BEFORE line #238
//
// Post IAI's response to database
//
function iai_submit_post($mode, &$iai_id, &$forum_id, &$topic_id, &$iai_post_id, &$topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, &$bbcode_uid, &$iai_username, &$iai_subject, &$iai_message)
{
global $board_config, $lang, $db, $phpbb_root_path, $phpEx;

//Stores user's IP since IAI has none. Can be changed as wished.
global $user_ip;

$current_time = time();

$sql = "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, $iai_id, '$iai_username', $current_time, '$user_ip', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}

$iai_post_id = $db->sql_nextid();

$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ($iai_post_id, '$iai_subject', '$bbcode_uid', '$iai_message')";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}

add_search_words($iai_post_id, stripslashes($iai_message), stripslashes($iai_subject));

return false;
}
//
// Update Stats for IAI: must be run AFTER update_post_stats() for original post
//
function iai_update_post_stats(&$forum_id, &$topic_id, &$iai_post_id, &$iai_id)
{
global $db;

//This simply runs the 3 db updating functions (only used for IAI replies).

$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_posts = forum_posts + 1, forum_last_post_id = $iai_post_id
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}

$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_last_post_id = $iai_post_id, topic_replies = topic_replies + 1
WHERE topic_id = $topic_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}

// Comment out the next 7 lines if you don't want user posts to be updated (it will annoy some users otherwise).
$sql = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts + 1
WHERE user_id = $iai_id";
if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}

return;
}
//
// Allows bot to send pms requiring only subject, message and user_id of user it is being sent to.
// I've made it an easy to use function so you can adapt it to use in many situations on your site
// an example is in the welcome message system which is included with this package. The function
// also sends emails (if $send_email set) and does all the inbox checking stuff that normal pms do.
//
function iai_send_pm($user_to_id, $iai_subject, $iai_message, $send_email)
{
global $board_config, $lang, $db, $phpbb_root_path, $phpEx;

$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_id = " . $user_to_id . "
AND user_id <> " . ANONYMOUS;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);
}
$usertodata = $db->sql_fetchrow($result);

// prepare IAI message (IAI may have used html, smilies etc...)
$bbcode_uid = make_bbcode_uid();
$iai_message = str_replace("'", "''", $iai_message);

// This is to fix up some of the bad formatting which comes out of the AI
if(empty($iai_message))
{
$iai_message = "Thank you.";
}
$iai_message = prepare_message(trim($iai_message), 0, 1, 1, $bbcode_uid);

$msg_time = time();

// Do inbox limit stuff
$sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time
FROM " . PRIVMSGS_TABLE . "
WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
OR privmsgs_type = " . PRIVMSGS_READ_MAIL . "
OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )
AND privmsgs_to_userid = " . $usertodata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, $lang['No_such_user']);
}

$sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : '';

if ( $inbox_info = $db->sql_fetchrow($result) )
{
if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] )
{
$sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . "
WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
OR privmsgs_type = " . PRIVMSGS_READ_MAIL . "
OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )
AND privmsgs_date = " . $inbox_info['oldest_post_time'] . "
AND privmsgs_to_userid = " . $usertodata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete your oldest privmsgs', '', __LINE__, __FILE__, $sql);
}
}
}

$sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)
VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $iai_subject) . "', " . $board_config['iai_userid'] . ", " . $usertodata['user_id'] . ", $msg_time, '$user_ip', 0, 1, 1, 1)";

if ( !($result = $db->sql_query($sql_info, BEGIN_TRANSACTION)) )
{
message_die(GENERAL_ERROR, "Could not insert private message sent info.", "", __LINE__, __FILE__, $sql_info);
}

$privmsg_sent_id = $db->sql_nextid();

$sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace("\'", "''", $iai_message) . "')";

if ( !$db->sql_query($sql, END_TRANSACTION) )
{
message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info);
}

// Add to the users new pm counter
$sql = "UPDATE " . USERS_TABLE . "
SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "
WHERE user_id = " . $usertodata['user_id'];
if ( !$status = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
}

// now send email if all the usual conditions & $send_email is set
if ( $send_email && $usertodata['user_notify_pm'] && !empty($usertodata['user_email']) && $usertodata['user_active'] )
{
$email_headers = 'From: ' . $board_config['board_email'] . "
Return-Path: " . $board_config['board_email'] . "\r
";

$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);

$emailer->use_template('privmsg_notify', $usertodata['user_lang']);
$emailer->extra_headers($email_headers);
$emailer->email_address($usertodata['user_email']);
$emailer->set_subject(); //$lang['Notification_subject']

$emailer->assign_vars(array(
'USERNAME' => $usertodata['username'],
'SITENAME' => $board_config['sitename'],
'EMAIL_SIG' => str_replace('<br />', "
", "--
" . $board_config['board_email_sig']),

'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')
);

$emailer->send();
$emailer->reset();
}

return;
}



ADD BEFORE line #444
//
// START PM SYSTEM FOR IAI
//

// Should IAI respond to this pm?
if (
(
$mode != "edit"
)
&&
(
$to_userdata['user_id'] == $board_config['iai_userid']
)
&&
(
$board_config['iai_active_pm']
)
)
{

$iai_root_path = $phpbb_root_path . "mods/iai/";
include($iai_root_path . 'includes/iai_functions.'.$phpEx);

// Init IAI specific vars
$iai_subject = ( ( !preg_match('/^Re:/', $privmsg_subject) ) ? 'Re: ' : '' ) . $privmsg_subject;

// Get IAI reply
$user_id = ($userdata['session_logged_in']) ? $userdata['user_id'] : 0;
$topic_id = 0; // the null topic
$sesh_id = $userdata['session_id']; // should NOT be null in any situation
$numselects = 0;
// set bot to reply to subject as well as message as long as subject is not a reply (i.e. has Re: out the front)
$iai_reply_to = ( ( !preg_match('/^Re:/', $privmsg_subject) ) ? $privmsg_subject . " " : "" ) . $privmsg_message;
$iai_reply_to = str_replace("is " . $board_config['iai_username'], "are you", $iai_reply_to);
$iai_reply_to = str_replace($board_config['iai_username'], "you", $iai_reply_to);
$iai_reply = reply($iai_reply_to,$user_id,$topic_id,$sesh_id);
$iai_message = $iai_reply->response;

//
// START Delete user's message from bot's inbox/user's outbox (it gets too full and wastes space otherwise).
// Note that this wipes ALL PAST pms in the bot's inbox from the user. This ensures that any backlog of pms
// sent while bot was inactive are also wiped.
//
$sql = "UPDATE " . USERS_TABLE . "
SET user_unread_privmsg = user_unread_privmsg - 1
WHERE user_id = " . $board_config['iai_userid'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update private message read status for user', '', __LINE__, __FILE__, $sql);
}
$sql = "SELECT privmsgs_id
FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_to_userid = " . $board_config['iai_userid'] . " AND (privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain id list to delete all messages', '', __LINE__, __FILE__, $sql);
}
$mark_list = array();
while ( $row = $db->sql_fetchrow($result) )
{
$mark_list[] = $row['privmsgs_id'];
}
unset($delete_type);

if ( count($mark_list) )
{
$delete_sql_id = implode(', ', $mark_list);
}

$delete_text_sql = "DELETE FROM " . PRIVMSGS_TEXT_TABLE . "
WHERE privmsgs_text_id IN ($delete_sql_id)";
$delete_sql = "DELETE FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_id IN ($delete_sql_id)
AND privmsgs_to_userid = " . $board_config['iai_userid'] . "
AND (privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )";

if ( !$db->sql_query($delete_sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not delete private message info', '', __LINE__, __FILE__, $delete_sql);
}

if ( !$db->sql_query($delete_text_sql, END_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not delete private message text', '', __LINE__, __FILE__, $delete_text_sql);
}
//
// END delete sent pms
//

// run iai pm send function
$iai_message = str_replace(".", ". ", $iai_message);
$iai_message = str_replace("!", "! ", $iai_message);
$iai_message = str_replace("?", "? ", $iai_message);
iai_send_pm($userdata['user_id'], $iai_subject, $iai_message, 0);
}
//
// END PM SYSTEM FOR IAI
//



ADD BEFORE line #559
//
// START IAI welcome pm message
//
$iai_root_path = $phpbb_root_path . "mods/iai/";
include($iai_root_path.'includes/constants.'.$phpEx);
if($board_config['iai_active_wpm'])
{
$sql = "SELECT *
FROM " . IAI_BOT_T;
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not query bot information", "", __LINE__, __FILE__, $sql);
}
else
{
while($row = $db->sql_fetchrow($result))
{
$bot_config[$row['name']] = $row['value'];
}
}

// Just a couple of replaces for better customisation on a per user basis
// no point making a special function since there are so few needed

$iai_wpm_subject = str_replace("[username]", $username, $bot_config['iai_wpm_subject']);
$iai_wpm_subject = str_replace("[user_id]", $user_id, $iai_wpm_subject);
$iai_wpm_subject = str_replace("[sitename]", $board_config['sitename'], $iai_wpm_subject);
$iai_wpm_subject = str_replace("[botname]", $bot_config['name'], $iai_wpm_subject);

$iai_wpm_message = str_replace("[username]", $username, $bot_config['iai_wpm_message']);
$iai_wpm_message = str_replace("[user_id]", $user_id, $iai_wpm_message);
$iai_wpm_message = str_replace("[sitename]", $board_config['sitename'], $iai_wpm_message);
$iai_wpm_message = str_replace("[botname]", $bot_config['name'], $iai_wpm_message);

// Will not send a pm notification via email (already sent the standard welcome email)
// Simply change the 0 to a 1 to turn it on
iai_send_pm($user_id, $iai_wpm_subject, $iai_wpm_message, 0);
}
//
// END IAI welcome pm message
//

EasyMOD successfully processed the following commands:
Commands Processed

OPEN line #77
posting.php



FIND line #82
update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);


OPEN line #225
includes/functions_post.php


FIND line #230
//
// This function will prepare a posted message for
// entry into the database.
//


OPEN line #432
privmsg.php


FIND line #437
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("privmsg.$phpEx?folder=inbox") . '">')
);


OPEN line #546
includes/usercp_register.php



FIND line #551
message_die(GENERAL_MESSAGE, $message);
} // if mode == register
}
} // End of submit


CLOSE line #604

User avatar
GPHemsley
Registered User
Posts: 1617
Joined: Fri Apr 18, 2003 4:01 am
Location: Long Beach, NY
Contact:

Re: Forum AI 0.2.0 mod help (unreconized commands)

Post by GPHemsley »

The commands are wrong, simple as that. The MOD author has not used the commands as listed in the MOD Template Tutorial. Contact the MOD Author.

Locked