PHP Code:
// #######################################################################
// ############################# MAIN SCRIPT #############################
// #######################################################################
if ($imp_vars['do'] == 'main')
{
$vbgpc = array(
'username' => '',
'firstname' => '',
'yourage' => '',
'location' => '',
'sn' => '',
'contactemail' => '',
'aboutyou' => '',
'storyapplying' => '',
'chartype' => '',
'tfwdesiredrole' => '',
'auditionscene' => '',
'charmedexperience' => '',
'jointhestory' => '',
'commentsquestions' => '',
'humanverify' => ''
);
$forumids = rpg_auditionapp_construct_forum_options(rpg_auditionapp_construct_forum_chooser());
if ($vbulletin->userinfo['permissions']['rpgaaperms'] & $vbulletin->bf_ugp_rpgaaperms['auditionappreqhv'])
{
require_once(DIR . '/includes/class_humanverify.php');
$verify =& vB_HumanVerify::fetch_library($vbulletin);
$human_verify = $verify->output_token();
}
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('rpg_auditionapp') . '");');
}
if ($imp_vars['do'] == 'send')
{
$vbulletin->input->clean_array_gpc('p', array(
'username' => TYPE_NOHTML,
'firstname' => TYPE_NOHTML,
'yourage' => TYPE_NOHTML,
'location' => TYPE_NOHTML,
'sn' => TYPE_NOHTML,
'contactemail' => TYPE_NOHTML,
'aboutyou' => TYPE_NOHTML,
'storyapplying' => TYPE_NOHTML,
'chartype' => TYPE_NOHTML,
'tfwdesiredrole' => TYPE_NOHTML,
'auditionscene' => TYPE_NOHTML,
'charmedexperience' => TYPE_NOHTML,
'jointhestory' => TYPE_NOHTML,
'commentsquestions' => TYPE_NOHTML,
'humanverify' => TYPE_ARRAY
));
$forumids = rpg_construct_forum_options(usml_construct_forum_chooser());
if ($vbulletin->userinfo['permissions']['rpgaaperms'] & $vbulletin->bf_ugp_rpgaaperms['auditionappreqhv'])
{
require_once(DIR . '/includes/class_humanverify.php');
$verify =& vB_HumanVerify::fetch_library($vbulletin);
$human_verify = $verify->output_token();
}
if (empty($vbulletin->GPC['firstname'])) { $errors[] = fetch_error('rpg_auditionapp_firstname'); }
if (empty($vbulletin->GPC['yourage'])) { $errors[] = fetch_error('rpg_auditionapp_yourage'); }
if (empty($vbulletin->GPC['location'])) { $errors[] = fetch_error('rpg_auditionapp_location'); }
if (empty($vbulletin->GPC['screenname'])) { $errors[] = fetch_error('rpg_auditionapp_screenname'); }
if (empty($vbulletin->GPC['contactemail'])) { $errors[] = fetch_error('rpg_auditionapp_contactemail'); }
if (empty($vbulletin->GPC['aboutyou'])) { $errors[] = fetch_error('rpg_auditionapp_aboutyou'); }
if (empty($vbulletin->GPC['storyapplying'])) { $errors[] = fetch_error('rpg_auditionapp_storyapplying'); }
if (empty($vbulletin->GPC['chartype'])) { $errors[] = fetch_error('rpg_auditionapp_chartype'); }
if (empty($vbulletin->GPC['tfwdesiredrole'])) { $errors[] = fetch_error('rpg_auditionapp_tfwdesiredrole'); }
if (empty($vbulletin->GPC['auditionscene'])) { $errors[] = fetch_error('rpg_auditionapp_auditionscene', $vbulletin->options['bbtitle']);
if (empty($vbulletin->GPC['charmedexperience'])) { $errors[] = fetch_error('rpg_auditionapp_charmedexperience', $vbulletin->options['bbtitle']); }
if (empty($vbulletin->GPC['jointhestory'])) { $errors[] = fetch_error('rpg_auditionapp_jointhestory'); }
if (empty($vbulletin->GPC['commentsquestions'])) { $errors[] = fetch_error('rpg_auditionapp_commentsquestions'); }
if (empty($vbulletin->GPC['humanverify'])) { $errors[] = fetch_error('rpg_auditionapp_auditionscene'); }
if ($vbulletin->userinfo['permissions']['rpgaaperms'] & $vbulletin->bf_ugp_rpgaaperms['auditionappreqhv']) { if (!$verify->verify_token($vbulletin->GPC['humanverify'])) { $errors[] = fetch_error('humanverify_image_wronganswer'); } }
if ($vbulletin->userinfo['permissions']['rpgaaperms'] & $vbulletin->bf_ugp_rpgaaperms['auditionappviewip']) { $ipaddress = IPADDRESS; } else { $ipaddress = $vbphrase['rpg_auditionapp_restricted']; }
if ($vbulletin->userinfo['permissions']['rpgaaperms'] & $vbulletin->bf_ugp_rpgaaperms['auditionappviewhost']) { $hostname = gethostbyaddr(IPADDRESS); } else { $hostname = $vbphrase['rpg_auditionapp_restricted']; }
if (!empty($vbulletin->GPC['forumids']))
{
foreach ($vbulletin->GPC['forumids'] AS $forumid)
{
$applyingto[] = $vbulletin->forumcache["$forumid"]['title_clean'];
}
$applyingto = implode(', ', $applyingto);
}
if (count($errors) > 0)
{
foreach ($errors AS $error)
{
$new_errors .= $error . ".<br />\n";
}
$errors = $vbphrase['rpg_auditionapp_errorsfound'];
$errors .= $new_errors;
$submit = false;
} else {
$submit = true;
}
if ($submit)
{
// ####################### START BUILDING MESSAGES #######################
$subject = construct_phrase($vbphrase['rpg_auditionapp_subject'], $vbulletin->GPC['storyapplying'], $vbulletin->GPC['username']);
$posttitle = construct_phrase($vbphrase['rpg_auditionapp_vote'], $vbulletin->GPC['username'], $vbulletin->GPC['storyapplying']);
$emailappmsg = "$vbphrase[rpg_auditionapp_firstname]: {$vbulletin->GPC['firstname']}
$vbphrase[rpg_auditionapp_username]: {$vbulletin->GPC['username']}
$vbphrase[rpg_auditionapp_fname]: {$vbulletin->GPC['firstname']}
$vbphrase[rpg_auditionapp_age]: {$vbulletin->GPC['yourage']}
$vbphrase[rpg_auditionapp_loc]: {$vbulletin->GPC['location']}
$vbphrase[rpg_auditionapp_sn]: {$vbulletin->GPC['screenname']}
$vbphrase[rpg_auditionapp_email]: {$vbulletin->GPC['contactemail']}
$vbphrase[rpg_auditionapp_aboutyou] {$vbulletin->options['bbtitle']}?::{$vbulletin->GPC['aboutyou']}
$vbphrase[rpg_auditionapp_applyingto]:
$applyingto
$vbphrase[rpg_auditionapp_storyapply]: {$vbulletin->GPC['storyapplying']}
$vbphrase[rpg_auditionapp_chararchtype]: {$vbulletin->GPC['chartype']}
$vbphrase[rpg_auditionapp_tfwrole]: {$vbulletin->GPC['tfwdesiredrole']}
$vbphrase[rpg_auditionapp_youraudscene]: {$vbulletin->GPC['auditionscene']}
$vbphrase[rpg_auditionapp_charmedxp]: {$vbulletin->GPC['charmedexperience']}
$vbphrase[rpg_auditionapp_joinstory]: {$vbulletin->GPC['jointhestory']}
$vbphrase[rpg_auditionapp_commentandquest]: {$vbulletin->GPC['commentsquestions']}
$vbphrase[ip_address]: $ipaddress
$vbphrase[rpg_auditionapp_hostname]: $hostname
$vbphrase[rpg_auditionapp_greeting]
$vbphrase[rpg_auditionapp_staff]
";
$postappmsg = "[b]$vbphrase[rpg_auditionapp_username][/b]: {$vbulletin->GPC['username']}
[b]$vbphrase[rpg_auditionapp_fname][/b]: {$vbulletin->GPC['firstname']}
[b]$vbphrase[rpg_auditionapp_age][/b]: {$vbulletin->GPC['yourage']}
[b]$vbphrase[rpg_auditionapp_loc][/b]: {$vbulletin->GPC['location']}
[b]$vbphrase[rpg_auditionapp_sn][/b]: {$vbulletin->GPC['screenname']}
[b]$vbphrase[rpg_auditionapp_email][/b]: {$vbulletin->GPC['contactemail']}
[b]$vbphrase[rpg_auditionapp_aboutyou][/b]: {$vbulletin->options['bbtitle']}?::{$vbulletin->GPC['aboutyou']}
[b]$vbphrase[rpg_auditionapp_storyapply][/b]: {$vbulletin->GPC['storyapplying']}
[b]$vbphrase[rpg_auditionapp_chararchtype][/b]: {$vbulletin->GPC['chartype']}
[b]$vbphrase[rpg_auditionapp_tfwrole][/b]: {$vbulletin->GPC['tfwdesiredrole']}
[b]$vbphrase[rpg_auditionapp_youraudscene][/b]: {$vbulletin->GPC['auditionscene']}
[b]$vbphrase[rpg_auditionapp_charmedxp][/b]: {$vbulletin->GPC['charmedexperience']}
[b]$vbphrase[rpg_auditionapp_joinstory][/b]: {$vbulletin->GPC['jointhestory']}
[b]$vbphrase[rpg_auditionapp_commentandquest][/b]: {$vbulletin->GPC['commentsquestions']}
[b]$vbphrase[ip_address]:[/b] $ipaddress
[b]$vbphrase[rpg_auditionapp_hostname]:[/b] $hostname
$vbphrase[rpg_auditionapp_greeting]
$vbphrase[rpg_auditionapp_staff]
";
// ############################# SEND E-MAIL #############################
if (!empty($addresses))
{
foreach ($addresses AS $address)
{
vbmail($address, $subject, $emailappmsg, true, $vbulletin->GPC['webmasteremail']);
}
}
// ###################### CREATE THREAD IF ENABLED #######################
switch($vbulletin->options['rpg_auditionapp_createthread'])
{
case 1;
require_once(DIR . '/includes/functions_newpost.php');
$forumid = $vbulletin->options['rpg_auditionapp_forumid'];
$user_id = $vbulletin->userinfo['userid'];
$username = $vbulletin->userinfo['username'];
$target_foruminfo = fetch_foruminfo($forumid);
$newpost = array(
'userid' => $user_id,
'username' => $username,
'message' => $postappmsg,
'title' => $subject,
'poststarttime' => TIMENOW,
'emailupdate' => 0
);
build_new_post('thread', $target_foruminfo, array(), array(), $newpost, $errors);
if (sizeof($errors) > 0) { $error_info = construct_errors($errors); }
require_once(DIR . '/includes/functions_databuild.php');
build_forum_counters($forumid);
break;
case 2;
require_once(DIR . '/includes/functions_newpost.php');
$forumid = $vbulletin->options['rpg_auditionapp_forumid'];
$user_id = $vbulletin->userinfo['userid'];
$username = $vbulletin->userinfo['username'];
$target_foruminfo = fetch_foruminfo($forumid);
$newpost = array(
'userid' => $user_id,
'username' => $username,
'message' => $postappmsg,
'title' => $subject,
'poststarttime' => TIMENOW,
'emailupdate' => 0
);
build_new_post('thread', $target_foruminfo, array(), array(), $newpost, $errors);
$pollpublic = ($vbulletin->options['rpg_auditionapp_pollpublic']);
$polloption[1] = ($vbulletin->options['rpg_auditionapp_polloption1']);
$polloption[2] = ($vbulletin->options['rpg_auditionapp_polloption2']);
if (!empty($vbulletin->options['rpg_auditionapp_polloption3'])) { $polloption[3] = ($vbulletin->options['rpg_auditionapp_polloption3']); }
if (!empty($vbulletin->options['rpg_auditionapp_polloption4'])) { $polloption[4] = ($vbulletin->options['rpg_auditionapp_polloption4']); }
if (!empty($vbulletin->options['rpg_auditionapp_polloption5'])) { $polloption[5] = ($vbulletin->options['rpg_auditionapp_polloption5']); }
$threadinfo = verify_id('thread', $newpost[threadid], 0, 1);
$polloptions = count($polloption);
$question = $posttitle;
$vbulletin->GPC['options'] = $polloption;
$counter = 0;
$optioncount = 0;
$badoption = '';
while ($counter++ < $polloptions)
{
if ($vbulletin->options['maxpolllength'] AND vbstrlen($vbulletin->GPC['options']["$counter"]) > $vbulletin->options['maxpolllength'])
{
$badoption .= iif($badoption, ', ') . $counter;
}
if (!empty($vbulletin->GPC['options']["$counter"]))
{
$optioncount++;
}
}
$poll =& datamanager_init('Poll', $vbulletin, ERRTYPE_STANDARD);
$counter = 0;
while ($counter++ < $polloptions)
{
if ($vbulletin->GPC['options']["$counter"] != '')
{
$poll->set_option($vbulletin->GPC['options']["$counter"]);
}
}
$poll->set('question', $question);
$poll->set('dateline', TIMENOW);
$poll->set('active', '1');
$poll->set('public', '1');
$pollid = $poll->save();
$threadman = datamanager_init('Thread', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
$threadman->set_existing($threadinfo);
$threadman->set('pollid', $pollid);
$threadman->save();
if (sizeof($errors) > 0) { $error_info = construct_errors($errors); }
require_once(DIR . '/includes/functions_databuild.php');
build_forum_counters($forumid);
break;
case 3;
require_once(DIR . '/includes/functions_newpost.php');
$forumid = $vbulletin->options['rpg_auditionapp_forumid'];
$user_id = $vbulletin->userinfo['userid'];
$username = $vbulletin->userinfo['username'];
$target_foruminfo = fetch_foruminfo($forumid);
$newpost = array(
'userid' => $user_id,
'username' => $username,
'message' => $postappmsg,
'title' => $subject,
'poststarttime' => TIMENOW,
'emailupdate' => 0
);
build_new_post('thread', $target_foruminfo, array(), array(), $newpost, $errors);
$pollpublic = ($vbulletin->options['rpg_auditionapp_pollpublic']);
$polloption[1] = ($vbulletin->options['rpg_auditionapp_polloption1']);
$polloption[2] = ($vbulletin->options['rpg_auditionapp_polloption2']);
if (!empty($vbulletin->options['rpg_auditionapp_polloption3'])) { $polloption[3] = ($vbulletin->options['rpg_auditionapp_polloption3']); }
if (!empty($vbulletin->options['rpg_auditionapp_polloption4'])) { $polloption[4] = ($vbulletin->options['rpg_auditionapp_polloption4']); }
if (!empty($vbulletin->options['rpg_auditionapp_polloption5'])) { $polloption[5] = ($vbulletin->options['rpg_auditionapp_polloption5']); }
$threadinfo = verify_id('thread', $newpost[threadid], 0, 1);
$polloptions = count($polloption);
$question = $posttitle;
$vbulletin->GPC['options'] = $polloption;
$counter = 0;
$optioncount = 0;
$badoption = '';
while ($counter++ < $polloptions)
{
if ($vbulletin->options['maxpolllength'] AND vbstrlen($vbulletin->GPC['options']["$counter"]) > $vbulletin->options['maxpolllength'])
{
$badoption .= iif($badoption, ', ') . $counter;
}
if (!empty($vbulletin->GPC['options']["$counter"]))
{
$optioncount++;
}
}
$poll =& datamanager_init('Poll', $vbulletin, ERRTYPE_STANDARD);
$counter = 0;
while ($counter++ < $polloptions)
{
if ($vbulletin->GPC['options']["$counter"] != '')
{
$poll->set_option($vbulletin->GPC['options']["$counter"]);
}
}
$poll->set('question', $question);
$poll->set('dateline', TIMENOW);
$poll->set('active', '1');
$poll->set('public', '0');
$pollid = $poll->save();
$threadman = datamanager_init('Thread', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
$threadman->set_existing($threadinfo);
$threadman->set('pollid', $pollid);
$threadman->save();
if (sizeof($errors) > 0) { $error_info = construct_errors($errors); }
require_once(DIR . '/includes/functions_databuild.php');
build_forum_counters($forumid);
break;
}
// ######################### CREATE PM IF ENABLED ########################
switch($vbulletin->options['rpg_auditionapp_notifypm'])
{
case 1;
require_once(DIR . '/includes/functions_auditionapp.php');
$sendfrom = $vbulletin->db->fetch_array(get_name($vbulletin->userinfo['userid']));
$blank = array();
$pmdata =& datamanager_init('PM', $vbulletin, ERRTYPE_SILENT);
$pmdata->set('fromuserid', $vbulletin->userinfo['userid']);
$pmdata->set('fromusername', $sendfrom['username']);
$pmdata->set_recipients($vbulletin->options['rpg_auditionapp_pmreceive'], $blank);
$pmdata->set_info('reciept', false);
$pmdata->set_info('savecopy', false);
$pmdata->set('title', $subject);
$pmdata->set('message', $postappmsg);
$pmdata->set('dateline', TIMENOW);
$pmdata->set_info('is_automated', true);
$pmdata->save();
unset($pmdata);
break;
case 2;
require_once(DIR . '/includes/functions_auditionapp.php');
$sendfrom = $vbulletin->db->fetch_array(get_name($vbulletin->options['rpg_auditionapp_pmsender']));
$blank = array();
$pmdata =& datamanager_init('PM', $vbulletin, ERRTYPE_SILENT);
$pmdata->set('fromuserid', $vbulletin->options['rpg_auditionapp_pmsender']);
$pmdata->set('fromusername', $sendfrom['username']);
$pmdata->set_recipients($vbulletin->options['rpg_auditionapp_pmreceive'], $blank);
$pmdata->set_info('reciept', false);
$pmdata->set_info('savecopy', false);
$pmdata->set('title', $subject);
$pmdata->set('message', $postappmsg);
$pmdata->set('dateline', TIMENOW);
$pmdata->set_info('is_automated', true);
$pmdata->save();
unset($pmdata);
break;
}
$vbulletin->url = $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'];
eval(print_standard_redirect('rpg_auditionapp_thanks', true, true));
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('rpg_auditionapp_application') . '");');
} else {
$imp_vars['do'] = 'errors';
$vbgpc =& $vbulletin->GPC;
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('rpg_auditionapp_application') . '");');
}
}
?>