Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Using SSI?
- if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
- require_once(dirname(__FILE__) . '/SSI.php');
- elseif (!defined('SMF'))
- die('<strong>Error:</strong> Cannot install - please make sure that this file in the same directory as SMF\'s SSI.php file.');
- // Call our template
- templateFunc();
- function templateFunc()
- {
- // Globalize everything we'll need...
- global $sourcedir, $scripturl, $fileName, $possibleBoards, $errors, $smcFunc;
- // Our Logic
- loadLogic();
- // Now the HTML
- echo '<form action="', $fileName, '" method="post">
- <!-- NAME -->
- <br /><br />
- <label for="name">
- <span style="font-weight: bold;', isset($errors['name']) ? ' color: #ff0000;' : '', '">*Name:</span>
- </label>
- <input type="text" maxlength="255" id="name" name="name" size="40"', isset($_POST['name']) && !empty($_POST['name']) ? ' value="' . $_POST['name'] . '"' : '', ' />
- <!-- EMAIL -->
- <br /><br />
- <label for="email">
- <strong>Email:</strong>
- </label>
- <input type="text" maxlength="255" id="email" name="email" size="40"', isset($_POST['email']) && !empty($_POST['email']) ? ' value="' . $_POST['email'] . '"' : '', ' />
- <!-- SUBJECT -->
- <br /><br />
- <label for="subject">
- <span style="font-weight: bold;', isset($errors['subject']) ? ' color: #ff0000;' : '', '">*Subject:</span>
- </label>
- <input type="text" maxlength="255" id="subject" name="subject" size="40"', isset($_POST['subject']) && !empty($_POST['subject']) ? ' value="' . $_POST['subject'] . '"' : '', ' />
- <!-- BOARD ID -->
- <br /><br />
- <label for="id_board">
- <strong>Board to Post in:</strong>
- </label>
- <select id="id_board" name="id_board" style="padding: 4px;">';
- if (!empty($possibleBoards))
- {
- foreach ($possibleBoards as $key => $value)
- {
- echo '<option value="' . $key . '"', isset($_POST['id_board']) && $_POST['id_board'] == $key ? ' selected="selected"' : '', '>' . $value . ' </option>';
- }
- }
- else
- {
- echo '<option value="">No Boards Available</option>';
- }
- echo '
- </select>
- <!-- BODY -->
- <br /><br />
- <label for="body">
- <span style="font-weight: bold;', isset($errors['body']) ? ' color: #ff0000;' : '', '">*Body:</span>
- </label>
- <textarea id="body" name="body" cols="50" rows="5">', isset($_POST['body']) && !empty($_POST['body']) ? $_POST['body'] : '', '</textarea>
- <span class="smalltext" style="margin-left: 70px; display: block;">BBC is Enabled</span>
- <br />
- <!-- SUBMIT -->
- <input type="submit" value="Submit" />
- </form>
- <span class="smalltext">* = Required Fields</span>';
- }
- function loadLogic()
- {
- // Globalize everything we'll need...
- global $sourcedir, $scripturl, $fileName, $smcFunc, $possibleBoards, $errors;
- // Subs-Post for createPost();
- require_once($sourcedir . '/Subs-Post.php');
- // File Name with ".php"
- $fileName = '.php';
- // Allow smileys? true : false;
- $smileysEnabled = true;
- // Default Board
- $defaultBoard = 1;
- // Possible boards?
- $possibleBoards = array();
- $query = $smcFunc['db_query']('', '
- SELECT id_board, name
- FROM {db_prefix}boards'
- );
- while ($row = $smcFunc['db_fetch_assoc']($query))
- {
- $possibleBoards[$row['id_board']] = $row['name'];
- }
- $smcFunc['db_free_result']($query);
- // Submitting...
- if (isset($_POST['name']))
- {
- // Validation
- $errors = array();
- if (isset($_POST['name']) && empty($_POST['name']))
- $errors['name'] = 1;
- if (isset($_POST['subject']) && empty($_POST['subject']))
- $errors['subject'] = 1;
- if (isset($_POST['body']) && empty($_POST['body']))
- $errors['body'] = 1;
- if (!in_array(1, $errors))
- {
- // Message Options
- $msgOptions = array(
- 'body' => !empty($_POST['body']) ? $smcFunc['htmlspecialchars']($_POST['body']) : '',
- 'subject' => !empty($_POST['subject']) ? $smcFunc['htmlspecialchars']($_POST['subject']) : '',
- 'attachments' => array(),
- 'icon' => 'xx',
- 'smileys_enabled' => isset($smileysEnabled) ? $smileysEnabled : true,
- );
- // Topic Options
- $topicOptions = array(
- 'board' => !empty($_POST['id_board']) ? (int) $_POST['id_board'] : $defaultBoard,
- 'mark_as_read' => false,
- 'lock_mode' => 0,
- 'poll' => 0,
- 'sticky_mode' => 0,
- );
- // Poster Options
- $posterOptions = array(
- 'email' => !empty($_POST['email']) ? $_POST['email'] : '',
- 'ip' => $_SERVER['remote_addr'],
- 'name' => $_POST['name'],
- 'update_post_count' => true,
- 'id' => 1,
- );
- // Create...
- createPost($msgOptions, $topicOptions, $posterOptions);
- // Then redirect
- redirectexit($scripturl);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement