Przedszkolak
Postów: 81 Ostrzeżeń: 4
Data rejestracji: 20.10.2007 13:25
|
Witam, ostatnio przeszukiwałem różne supporty PHP Fusion w poszukiwaniu skryptu do aplikacji.
W końcu na http://www.phpfus... znalazłem skrypt kolegi Starefossen i po lekkim przerobieniu wygląda on tak:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: application.php
| Author: Starefossen
+--------------------------------------------------------+
| Form is made on request by Starefossen.
| No warranty is given, please visit the PHP-Fusion
| MODs & Infusions site for help :)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
if (!iMEMBER) { redirect(BASEDIR."index.php"); }
/*-------------------------------------------------------+
| APPLICATION SETTINGS |
+--------------------------------------------------------*/
$form_settings['name'] = "Application Form"; // This will be the name of the Application Form
$form_settings['desc'] = "Welcome to this Application Form. Please fill out the form and it will be posted automatically in the forum";
[b]$form_settings['subject_key'] = "form_name";[/b] // This will be the form input which is used as subject.
$form_settings['subject_prefix'] = "Application: "; // This will come right before the subject. Set this to blank if not needed.
$form_settings['forum_id'] = "7"; // This will be the forum the thread is posted in.
/*-------------------------------------------------------+
| APPLICATION FORM |
+--------------------------------------------------------*/
/*
IMPORTANT
ALL FORM INPUTS MUST START WITH form_ OR ELSE THEY WILL NOT BE SUBMITTED
EG: <input type='text' class='textbox' name='form_name' style='width:250px;' />
*/
function application_form($country_opts) {
global $form_settings;
// Start Form
echo "<form action='".FUSION_SELF."' method='post'>";
echo "<table class='tbl-border' width='100%'>\n<tr>\n";
echo "<td class='tbl1' colspan='2'>".$form_settings['desc']."</td>\n";
// Character Name And Current Spec Input
echo "</tr>\n<tr>\n";
echo "<td class='tbl2'><strong>Name - spec class:</strong></td>\n";
echo "<td class='tbl2'><input type='text' class='textbox' name='form_name' style='width:250px;' /></td>\n";
// Character Class Input
echo "</tr>\n<tr>\n";
echo "<td class='tbl2'><strong>Class:</strong></td>\n";
echo "<td class='tbl2'><input type='text' class='textbox' name='form_class' style='width:250px;' /></td>\n";
// First Profession Input
echo "</tr>\n<tr>\n";
echo "<td class='tbl1'><strong>First Profession:</strong></td>\n";
echo "<td class='tbl1'><input type='text' class='textbox' name='form_first_profession' style='width:250px;' /></td>\n";
// Second Profession
echo "</tr>\n<tr>\n";
echo "<td class='tbl1'><strong>Second profession:</strong></td>\n";
echo "<td class='tbl1'><input type='text' class='textbox' name='form_second_profession' style='width:250px;' /></td>\n";
// Country Input
echo "</tr>\n<tr>\n";
echo "<td class='tbl2'><strong>Country:</strong></td>\n";
echo "<td class='tbl2'><select class='textbox' name='form_country' style='width:250px;'>$country_opts</select></td>\n";
// Submit Form
echo "</tr>\n<tr>\n";
echo "<td class='tbl1'></td>\n";
echo "<td class='tbl1'>";
echo "<input type='submit' class='button' name='submit_form' value='Submit' />\n";
echo "<input type='reset' class='button' name='reset_form' value='Reset' /></td>\n";
echo "</tr>\n</table>\n</form>\n";
}
/*-------------------------------------------------------+
| NO EDIT BELLOW THIS NEEEDED |
+--------------------------------------------------------*/
if (!function_exists("stripos")) {
function stripos($haystack, $needle){
return strpos($haystack, stristr( $haystack, $needle ));
}
}
if (isset($_POST['submit_form'])) {
$message = "";
$subject = "Unknown Name";
while (list($key, $value) = each($_POST)) {
if (stripos($key, "form_") === 0) {
if ($key == $form_settings['subject_key']) {
$subject = $form_settings['subject_prefix'].stripinput($value);
}
$new_key = str_replace("form_", "", $key);
$new_key = str_replace("_", " ", $new_key);
$new_key = ucwords(stripinput($new_key));
$message .= "[b]$new_key:[/b]\n".stripinput($value)."\n\n";
}
}
$result = dbquery("INSERT INTO ".DB_THREADS." (
forum_id,
thread_subject,
thread_author,
thread_views,
thread_lastpost,
thread_lastpostid,
thread_lastuser,
thread_postcount,
thread_poll,
thread_sticky,
thread_locked
) VALUES (
'".$form_settings['forum_id']."',
'".$subject."',
'".$userdata['user_id']."',
'0',
'".time()."',
'0',
'".$userdata['user_id']."',
'1',
'0',
'0',
'0'
)");
$thread_id = mysql_insert_id();
$result = dbquery("INSERT INTO ".DB_POSTS." (
forum_id,
thread_id,
post_message,
post_showsig,
post_smileys,
post_author,
post_datestamp,
post_ip,
post_edituser,
post_edittime
) VALUES (
'".$form_settings['forum_id']."',
'".$thread_id."',
'".$message."',
'1',
'1',
'".$userdata['user_id']."',
'".time()."',
'".USER_IP."',
'0',
'0'
)");
$post_id = mysql_insert_id();
$result = dbquery("UPDATE ".DB_FORUMS." SET forum_lastpost='".time()."', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastuser='".$userdata['user_id']."' WHERE forum_id='".$form_settings['forum_id']."' LIMIT 1");
$result = dbquery("UPDATE ".DB_THREADS." SET thread_lastpostid='".$post_id."' WHERE thread_id='".$thread_id."' LIMIT 1");
$result = dbquery("UPDATE ".DB_USERS." SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."' LIMIT 1");
redirect(BASEDIR."forum/viewthread.php?thread_id=".$thread_id."&pid=".$post_id."#post_".$post_id);
}
$country_list = array(
"Afghanistan",
"Albania",
"Algeria",
"Andorra",
"Angola",
"Antigua and Barbuda",
"Argentina",
"Armenia",
"Australia",
"Austria",
"Azerbaijan",
"Bahamas",
"Bahrain",
"Bangladesh",
"Barbados",
"Belarus",
"Belgium",
"Belize",
"Benin",
"Bhutan",
"Bolivia",
"Bosnia and Herzegovina",
"Botswana",
"Brazil",
"Brunei",
"Bulgaria",
"Burkina Faso",
"Burundi",
"Cambodia",
"Cameroon",
"Canada",
"Cape Verde",
"Central African Republic",
"Chad",
"Chile",
"China",
"Colombi",
"Comoros",
"Congo (Brazzaville)",
"Congo",
"Costa Rica",
"Cote d'Ivoire",
"Croatia",
"Cuba",
"Cyprus",
"Czech Republic",
"Denmark",
"Djibouti",
"Dominica",
"Dominican Republic",
"East Timor (Timor Timur)",
"Ecuador",
"Egypt",
"El Salvador",
"Equatorial Guinea",
"Eritrea",
"Estonia",
"Ethiopia",
"Fiji",
"Finland",
"France",
"Gabon",
"Gambia, The",
"Georgia",
"Germany",
"Ghana",
"Greece",
"Grenada",
"Guatemala",
"Guinea",
"Guinea-Bissau",
"Guyana",
"Haiti",
"Honduras",
"Hungary",
"Iceland",
"India",
"Indonesia",
"Iran",
"Iraq",
"Ireland",
"Israel",
"Italy",
"Jamaica",
"Japan",
"Jordan",
"Kazakhstan",
"Kenya",
"Kiribati",
"Korea, North",
"Korea, South",
"Kuwait",
"Kyrgyzstan",
"Laos",
"Latvia",
"Lebanon",
"Lesotho",
"Liberia",
"Libya",
"Liechtenstein",
"Lithuania",
"Luxembourg",
"Macedonia",
"Madagascar",
"Malawi",
"Malaysia",
"Maldives",
"Mali",
"Malta",
"Marshall Islands",
"Mauritania",
"Mauritius",
"Mexico",
"Micronesia",
"Moldova",
"Monaco",
"Mongolia",
"Morocco",
"Mozambique",
"Myanmar",
"Namibia",
"Nauru",
"Nepa",
"Netherlands",
"New Zealand",
"Nicaragua",
"Niger",
"Nigeria",
"Norway",
"Oman",
"Pakistan",
"Palau",
"Panama",
"Papua New Guinea",
"Paraguay",
"Peru",
"Philippines",
"Poland",
"Portugal",
"Qatar",
"Romania",
"Russia",
"Rwanda",
"Saint Kitts and Nevis",
"Saint Lucia",
"Saint Vincent",
"Samoa",
"San Marino",
"Sao Tome and Principe",
"Saudi Arabia",
"Senegal",
"Serbia and Montenegro",
"Seychelles",
"Sierra Leone",
"Singapore",
"Slovakia",
"Slovenia",
"Solomon Islands",
"Somalia",
"South Africa",
"Spain",
"Sri Lanka",
"Sudan",
"Suriname",
"Swaziland",
"Sweden",
"Switzerland",
"Syria",
"Taiwan",
"Tajikistan",
"Tanzania",
"Thailand",
"Togo",
"Tonga",
"Trinidad and Tobago",
"Tunisia",
"Turkey",
"Turkmenistan",
"Tuvalu",
"Uganda",
"Ukraine",
"United Arab Emirates",
"United Kingdom",
"United States",
"Uruguay",
"Uzbekistan",
"Vanuatu",
"Vatican City",
"Venezuela",
"Vietnam",
"Yemen",
"Zambia",
"Zimbabwe"
);
$country_opts = ""; $sel = ""; $selected = "";
while(list($key, $country) = each($country_list)){
$sel = ($country == $selected ? " selected='selected'" : "");
$country_opts .= "<option".$sel.">".$country."</option>\n";
}
opentable("Application Form");
application_form($country_opts);
closetable();
echo "<!-- Application From Made by Starefossen @ <a href='http://dev.starefossen.com'>http://www.starefossen.com</a> -->";
require_once THEMES."templates/footer.php";
?>
Scrypt posiada okienka do wpisywania tekstu, po czym robi nowy temat na danym podforum ze danymi które zostały wypełnione.
Problem w tym, że chciałbym żeby nazwa wątku, wynik:
$form_settings['subject_key']
składała się z:
form_name
i
form_class
Czyli w jednym okienku wpisuję nazwę postaci a w drugim klasę, po czym nazwa wątku jest:
Application: form_name form_class
Niestety nie udaje mi się ich połączyć. Próbowałem przecinkiem, cudzysłowami...
Proszę o pomoc :)
Edytowane przez Pieka dnia 30.06.2009 11:09:29
|