In a very short summary explaining my program.. It works like.. you visit the page, if not logged in, you get sent to login page, login and get sent back to the form. You fill out form, press submit, values are captured by request_vars and set to where they should be (you'll see by looking at the program), and basically a new topic is made, they get a confirmation, and are redirected to the new topic. At least that's what I'm aiming for lol. It's obviously not working at all.
First 2 issues I've noticed are when you view the page and are not logged in, you don't get sent to the login page, and when you enter the data into the form and press submit, no new topic is made. This could be my failure to correctly capture the $_POST data through request_var().
Recruit.php - Location: /forum/recruit.php
Code: Select all
<?php
/**
*
* This program will create topics from forms filled
* out by a user.
* User: Recruit Robot
* Forum: Recruit forum
*
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
// Lang...
$user->setup('mods/info_recruit');
// If user is not logged in, send them to login page
if ($user->data['user_type'] == ANONYMOUS)
{
login_box('', $user->lang['LOGIN']);
}
/*
Submit_post is tricky, as it uses current
auth and user data. This is a workaround so
we can have our bot submit data instead.
*/
// Backup $auth and $user data
$backup = array(
'user' => $user,
'auth' => $auth,
);
$my_subject = $user->data['username'] . "'s Application [NEW]";
// Restore original user auth data
// extract($backup);
// UserID = UserID of Recruit Bot
$user_id = '135';
// Overwrite with new data
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user->data = array_merge($user->data, $row);
$auth->acl($user->data);
//Overwrite users IP
$user->ip = '0.0.0.0';
$submit = (isset($_POST['submit'])) ? true : false;
if ($submit)
{
// subject and message
$my_message = "[b]Your soldier name:[/b] " . request_var('s_name', '', true);
$my_message .= "[b]Your age. (Lying will exclude you from membership):[/b] " . request_var('age', '', true);
$my_message .= "[b]Have you have been in a clan before? If so, what clans, and why did you leave?[/b] " . request_var('clans', '', true);
$my_message .= "[b]How did you find us?[/b] " . request_var('how_find', '', true);
$my_message .= "[b]Why do you want to join us?[/b] " . request_var('join_us', '', true);
$my_message .= "[b]Were you invited to join us? If so, by whom?[/b] " . request_var('invite', 'No I was not invited.', true);
$my_subject = utf8_normalize_nfc($my_subject);
$my_message = utf8_normalize_nfc($my_message);
// variables to hold the parameters for submit_post
$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);
// Data array
$data = array(
'forum_id' => 6,
'icon_id' => false,
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
'enable_sig' => true,
'message' => $my_message,
'message_md5' => md5($my_message),
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
'post_edit_locked' => 0,
'topic_title' => $my_subject,
'notify_set' => false,
'notify' => false,
'post_time' => 0,
'forum_name' => 'Recruiting',
'enable_indexing' => true,
'topic_time_limit' => 0,
'topic_approved' => true,
'post_time' => 0,
);
// Mode - Subject - username (only if guest poster) - topic type - poll - post data - update message
// We are creating a new topic
submit_post('post', $my_subject, '', POST_NORMAL, $poll, $data);
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx?t=" . $data['post_id']);
$message = $user->lang['FORM_SENT'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>');
meta_refresh(3, $meta_info);
trigger_error($message);
}
// Output the page
page_header($page_title);
$template->assign_vars(array(
'R_APP' => $user->lang['R_APP'],
'S_NAME' => $user->lang['S_NAME'],
'AGE' => $user->lang['AGE'],
'AGREE_TERMS' => $user->lang['AGREE_TERMS'],
'CLANS' => $user->lang['CLANS'],
'HOW_FIND' => $user->lang['HOW_FIND'],
'JOIN_US' => $user->lang['JOIN_US'],
'INVITE' => $user->lang['INVITE'],
'END_DESC' => $user->lang['END_DESC'],
'DESC' => $user->lang['DESC'],
'S_SEND_ACTION' => build_url('confirm_key'),
)
);
$template->set_filenames(array(
'body' => 'recruit.html')
);
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
Code: Select all
<?php
/**
*
* example [English]
*
* @package language
* @version $Id: v3_api.xml 52 2007-12-09 19:45:45Z jelly_doughnut $
* @copyright (c) 2007 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* DO NOT CHANGE
*/
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'PAGE_TITLE' => 'Recruit Form • Ultimate Military Alliance',
'FORM_SENT' => 'Your recruit application has been entered into the system. Thank you for applying!',
'RETURN_TOPIC' => '%sGo to your topic%s',
'DESC' => 'We currently are open recruiting (recruiting anyone).<br> If you would like to join us please read the following conditions, and the clan rules.<br><a href="http://www.umaclan.com/rules/bf2142-rules.html">BF2142 Rules</a><br><br><ul><li>We prefer a guidline age of 18+. (Be honest about your age)<br><li>Play online when available.<br><li>Mature personality (I.e. We do not want people who openly abuse people on public servers or chats)<br><li>Always Squad up and work as a Squad.<br><li>Willingness to always wear the Clan Tag.<br><li>We have a 0 tolerance policy against cheats, hacks, or stat padding! You do it, you are out!<br><li>Always play respectfully on whatever server you are on, so as not to bring shame on the clan tags.<br><li>You must have a mic. This is essential to be able to evaluate you and for in game communication and coordination of both squad and team strategies. (Mics are available from many stores for as little as $20-25)<br><li>There are no dues for regular members, but we appreciate donations. Dues for admins are $10 per month and dues for a reserved slot on a server is $5 per month.</ul><br>If you agree to these rules, including our clan rules, please fill out the form below:',
'END_DESC' => 'Wait for an admin or the Recruit Team to answer your post. Once the admin or Recruit Team gives you the go, add our clan recruit/pre-recruit tags to your name: =UMA(pr)=, or =UMA(r)=. After you have done this, we need to see you play regularly on our servers. Squad up with our full members, talk to them, and have a good game. You need a minimum of 3 recommendations by our members to be accepted as a full member; this can take on average a few weeks, or may be over very quickly. When you are a recruit, you are being evaluated by all our full members, Recruit Team, and the admins to make sure you follow the rules, and are a good player. If you break our rules, we will quickly revoke your recruit tags!',
'R_APP' => 'Recruit Application',
'S_NAME' => 'Your soldier name:',
'AGE' => 'Your age. (Lying will exclude you from membership):',
'AGREE_TERMS' => 'I agree to follow the Clan Rules.',
'CLANS' => 'Have you have been in a clan before? If so, what clans, and why did you leave?',
'HOW_FIND' => 'How did you find us?',
'JOIN_US' => 'Why do you want to join us?',
'INVITE' => 'Were you invited to join us? If so, by whom?',
));
?>
(P.S. DVGFX is my forum style)
Code: Select all
<!-- INCLUDE overall_header.html -->
<form name="send" action="{S_SEND_ACTION}" method="post">
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<h3>{R_APP}</h3>
<fieldset class="fields2">
<p>{DESC}</p><br>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>{S_NAME}</td>
<td><input name="s_name" type="text"></td>
</tr>
<tr>
<td>{AGE}</td>
<td><input type="text" maxlength="2" name="age"></td>
</tr>
<tr>
<td>{CLANS}</td>
<td><textarea name="clans"></textarea></td>
</tr>
<tr>
<td>{HOW_FIND}</td>
<td><textarea name="how_find"></textarea></td>
</tr>
<tr>
<td>{JOIN_US}</td>
<td><textarea name="join_us"></textarea></td>
</tr>
<tr>
<td>{INVITE}</td>
<td><input type="text" name="invite"></td>
</tr>
<tr>
<td><input type="checkbox">{AGREE_TERMS}</td>
</tr>
</table>
</fieldset>
<span class="corners-bottom"><span></span></span></div>
</div>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<fieldset class="submit-buttons">
<input type="reset" value="{L_RESET}" />
<input type="submit" name="submit" value="{L_SUBMIT}" />
</fieldset>
<span class="corners-bottom"><span></span></span></div>
</div>
<br clear="all" />
<!-- INCLUDE breadcrumbs.html -->
<br clear="all" />
<div align="{S_CONTENT_FLOW_END}"><!-- INCLUDE jumpbox.html --></div>
<!-- INCLUDE overall_footer.html -->
</form>
<!-- INCLUDE overall_footer.html -->