TinyPortal

Development => Feedback => Bugs/Errors => Topic started by: Nokonium on January 20, 2007, 04:19:44 PM

Title: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 04:19:44 PM
I am trying to put a large php script into an article, 1080 rows. I have put it into a <div></div> to no avail. After I save it, this is what the Article editor looks like. The code has overflowed the text box into the editor.

Title: Re: Overlow problem with PHP article.
Post by: Lesmond on January 20, 2007, 04:40:25 PM
Would you like to give me the code and I will test it on my site for you :)
Title: Re: Overlow problem with PHP article.
Post by: jacortina on January 20, 2007, 04:43:11 PM
I bet that last $t_out = before it goes haywire is a closing textarea tag.

So, you're closing the editor textarea.

Do it this way:
$t_out .= '</text'.'area>'
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 04:53:33 PM
Thanks  :)

It works Fine as a stand alone (pair of) file and the contact form works, I was trying to put it into an article to see if I could get the form, with verification, to load in the centre space. The formmailer.php file is the one I was fiddling with and the syntax is all OK according to my checker.

I have put both files into a zip, and given it a txt extension, you'll need to rename it. Please only use the first recipient in the drop down as that will come to me.
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 04:54:01 PM
Quote from: J.A.Cortina on January 20, 2007, 04:43:11 PM
I bet that last $t_out = before it goes haywire is a closing textarea tag.

So, you're closing the editor textarea.

Do it this way:
$t_out .= '</text'.'area>'

I'll try that  :up:
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 05:03:03 PM
I got this to pass the syntax check

$t_out .= '</text'.'area><div>';

But I still got the overflow.
Title: Re: Overlow problem with PHP article.
Post by: jacortina on January 20, 2007, 05:07:03 PM
Well, I can't look at the attachment (it's not plain text to me). It's only 6k and you said this thing had over 1000 lines.

Are there any other closing textarea tags?
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 05:10:35 PM
The attachment is a rar file, not a zip, that I changed to txtÃ,  :uglystupid2:
Title: Re: Overlow problem with PHP article.
Post by: Lesmond on January 20, 2007, 05:15:20 PM
this is what I get when I open the att Rar! ÏÃ,s 
       Ã...“Ã,¬t Ã,? [  [  eÃ,®Ë†Vââ,¬Â¦463     formmailer-for-article.php Ã,°7XÍ Éââ,¬Å"Ã¥]ââ,¬ÂºÃƒÅ"Oââ,¬Â¦Pü3$â„¢ââ,¬Å¾ÃƒÂ¨ éÃÅ'Ã, ÂÂfíØæyÃ,¼Ã,»Ã,¿'ââ,¬ËœÃƒÅ½Ã¢â,¬Â¹$ncnYfà}ßyrÃ,Ã,´ââ,¬Â¢U>Ã,¸ôï3yåç2Õ*Ã,ªTÃ,ºÃ©*sâââ,¬Â¹ÃƒÂ¸N~üââ,¬Â¢$Ã...¡Ã,Â¥KÃ... JÃ...¾ââ,¬Â°ÃƒÂ¨zßÃ,¦Ã,¸f-fëfkZÃ,½Ã®Ã˜ââ,¬ÂºVcK4ÕæÃ,®Ã“jÃ,²ÃÅ"éùBe*FâÃÅ'<LÃ,¬n7Ã,·gÃ,½
ÞÃ,¾Ã,³9ZË7Ã,°Ã,¶owââ,¬Â Ã...½Ã,® Æ’mtââ,¬Â¦[ZÑÃ,¬sg/Þp.Ã,6Ãâ€"[o
NÃ,¿ââ,¬â€Ã,¨Ã,£i[Ã...½7iÈÃ,¯\^Ã,ââ,¬â€œ0R
õÃ...“Êjââ,¬Å"E Ð>ââ,¬Â¦Ã,¼ââ,¬Â Ã¢â,¬Â  kAÃ,¯ââ,¬Â¦!ÉwÃ,¼åaÿÃ,º8 Ã,¸Ã,¢Ãâ€"ðé™W 2ërÃ,ºeˆêöQÃ,¼Ã,ȉâ,¬Â¡ÃƒÂ¢xÃ,µÃ®eÃ,³Ã,k !Ã,´
ââ,¬Â¡)ÃÅ"ø$äËjÐî?Ã¥Ã,¾xöxxÍÃ,¿Ã,¹Ã•pqîïïqwÃ,¬9gÃ,¼5Ã,¶Ã,·x7koqÆÁÃ,Ã...½Ã»Ã,¹Ã”1ÿÊ:sÃ,ª=ãÒóÎXwÃ,¤ÃµÑÃ... Ã»yJøââ,¬Å¡Ã,©Æ’Ã,±üZÍââ,¬Å"ùÃ,±Ãâ€"O@aÃ,µúêÏÃÅ'Ã,¥ââ,¬ÂºÃ,³Fââ,¬Â°Ã¢â,¬Â¹
Title: Re: Overlow problem with PHP article.
Post by: jacortina on January 20, 2007, 05:16:38 PM
And I can't 'un-rar' it.
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 05:21:19 PM
I've remade it as a zip file
Title: Re: Overlow problem with PHP article.
Post by: jacortina on January 20, 2007, 05:29:41 PM
Line 863 of formmailer-for-article.php has the closing textarea tag.

If I split that up, that file acts fine in the editor for me:
$t_out .= '</text'.'area><br />';
Title: Re: Overlow problem with PHP article.
Post by: Lesmond on January 20, 2007, 05:39:51 PM
that looks better :) http://www.lesmonds.co.uk/smf/index.php?page=44
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 05:44:03 PM
How do you get it to appear in the centre space? All I get is a space.
Title: Re: Overlow problem with PHP article.
Post by: Lesmond on January 20, 2007, 05:50:18 PM
Thats how it came out, I just changed the bit that J.A shown us $t_out .= '</text'.'area><br />'; and pasted the code in, But I did notice that the editor has changed the code by putting extra \ everywhere   :o
Title: Re: Overlow problem with PHP article.
Post by: Lesmond on January 20, 2007, 05:51:58 PM
this is what the code looks like now and I didnt do it echo\'
<div>\';
session_start();

// Secure PHP Form Mailer Script v4.21
// Created by Aleister
// http://www.dagondesign.com/articles/secure-php-form-mailer-script/
// Visit site for help, and new versions, including a Wordpress plugin version



// --------------------------------
// START OF OPTIONS
// --------------------------------


// RECIPIENTS
// ----------
// One:       \"onerecip|(email)\"
// Multiple:  \"mulrecip|(cc or bcc)|(email 1)|(email 2)  etc.. \"
// Drop-down: \"selrecip\"
// (the drop-down data must be added to the form structure below)

$recipients = \"selrecip\";



// FORM STRUCTURE
// --------------
// Please see the website for a full explanation of the structure.
// It is easy to use, but a bit too long to explain here :)

$form_structure = array(
\"openfieldset|fmset\",
\"selrecip|fmselect|Send to|fm_sendto|Information|information@south-gwent-ramblers.co.uk|Rambles|rambles@south-gwent-ramblers.co.uk|Footpaths    |footpaths@south-gwent-ramblers.co.uk\",
\"info|fminfofull|Send me an email...\",
\"text|fmtext|Name|fm_name|32|100|true|none\",
\"text|fmtext|Email|fm_email|32|100|false|email\",
\"text|fmtext|Subject|fm_subject|32|100|false|none\",
\"text|fmtext|Verify|fm_verify|7|5|true|none\",
\"textarea|fmtextarea|Message|fm_message|6 |26 |true\",
\"closefieldset\"
);


// SPECIAL FIELDS
// ----------------
// This lets the script know the names of the \'special\' fields
//
// VERIFICATION FIELD
// To disable verification, set this to \"\", and
// remove the verification line from the form structure

$field_verification = \"fm_verify\";

// EMAIL HEADER FIELDS
// These are the fields that will be used to generate the header
// for the email(s). If these are set to \"\", the email will use
// the default values (and you will not see the user\'s info in
// the email header - only in the message)

$field_name = \"fm_name\";
$field_subject = \"fm_subject\";
$field_email = \"fm_email\";

// DROP DOWN RECIPIENT
// Only applies if you are using a drop down to select a recipient

$field_dropdownrecip = \"fm_sendto\";



// FORM OPTIONS
// ------------
// SHOW USER WHICH FIELDS ARE REQUIRED
//
// If enabled, this will put an asterisk next to required fields.
// (styled with .fmrequired)

$show_required = TRUE;



// MESSAGE GENERATION
// ------------------

// SUBJECT [PREFIX]
// If you ask for a subject, this will be its prefix.
// If not, this will be the complete subject line.

$subject = \'Website Contact: \';

// SHOW HEADER FIELDS IN MESSAGE
// If using name, email, and/or subject fields in the email header,
// disabling this option will keep those fields from being shown in the
// body of the message. (since the information will already be in the header)

$show_headers_in_message = TRUE;

// SHOW VERIFICATION CODE IN MESSAGE
// If enabled, this will show the entered code in the email.

$show_code_in_message = TRUE;

// WRAP MESSAGES
// Required to meet RFC specifications (70 characters per line).

$wrap_messages = TRUE;

// INCLUDE IP
// If enabled, adds the sender\'s IP and host info to the message

$include_ip = TRUE;



// LANGUAGE OPTIONS
// ----------------

// SERVER ERROR MESSAGE
// Shown when message cannot be sent (do not use html tags).

$msg_mailserver = \"No connection to the mailserver. Please try again later.\";

// SUCCESS MESSAGE
// Shown when message has been sent (you can use html tags).

$msg_sent = \"<h2>Thank you!</h2><p>Your message has been sent!</p>\";

// FORM ERROR MESSAGE
// Shown when there is a mistake on the form
// (do not use html tags - styled with .fmerrortitle).

$msg_error = \"Error!\";

// SUBMIT BUTTON
// The text for the send button (do not use html tags).

$msg_submit = \"Send Email\";






// --------------------------------
// END OF OPTIONS
// --------------------------------



// --------------------------------
// CSS DECLARATIONS
// --------------------------------

// It is best to put these declarations in your main style sheet
// Since it is not always proper to have CSS declarations in the middle
// of a file. :)

// In the form structure above, you can specify custom class names
// for each input field if you like.

?>


<style type=\"text/css\">
<!--


.mailwrapper {
text-align: center;
}


.maildiv {
margin: 0 auto 0 auto;
text-align: left;
color:#0B194F;
width: 365px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 90%;
background-color:#EDEDED;
border: #0B194F outset;
}
.maildiv form {
text-align: left;
}
.maildiv label {
/* used for right side captions */
vertical-align: top;
padding: 0 0 0 3px;
}

.maildiv .sidelbl {
/* used for left side labels */
width: 95px;
text-align: right;
padding: 0 10px 0 0;
vertical-align: top;
position: relative;
    display: block;
    float: left;
clear: left;
}
.maildiv a {
color: #005ABE;
}
.maildiv h2 {
color: #005ABE;
font-size: 120%;
}
.maildiv input {
margin-bottom: 10px;
background-color:#DFE8EE;

}
.maildiv select {
margin-bottom: 10px;

}
.maildiv textarea {
margin-bottom: 10px;
background-color:#DFE8EE;

}
.maildiv .ver_img {
padding: 0;
margin: 0 0 10px 10px;
vertical-align:bottom;
border: 1px solid #005ABE;
}
.maildiv fieldset {
padding: 5px 5px 5px 5px;
margin-bottom: 10px;
}
.maildiv .legendspacing {
height: 10px;
}
.maildiv .fmcredits {
float: left;
font-size: 90%;
}
.maildiv .fmsubmit {
float: right;
}
.maildiv .fmrequired {
color: #005ABE;
font-size: 90%;
float: left;
margin-top: 3px;
margin-left: 5px;
}
.maildiv .fmspacer {
height: 10px;
}

.maildiv .fminfofull {
padding: 0 10px 0 10px;
color: #005ABE;
margin-bottom: 15px;
}
.maildiv .fminfohalf {
padding: 0 10px 0 10px;
color: #005ABE;
margin-left: 110px;
margin-bottom: 15px;
}
.maildiv .fmerrorbox {
text-align: left;
}
.maildiv li {
margin: 0 0 4px 0;
}
.maildiv .fmerrortitle {
color: #FF0000;
font-size: 120%;
}

-->
</style>


<?php

// --------------------------------
// END OF CSS DECLARATIONS
// --------------------------------





// Do not edit anything below unless you know what you are doing :)


$email_sent FALSE;
$t_out = \"\";


// turn 
$recipients into a useable array
$recipients = explode(\"|\", $recipients);
for (
$i = 0; $i < count($recipients); $i++) {
$recipients[$i] = trim($recipients[$i]);
}

// turn form fields into a useable array
for (
$i = 0; $i < count($form_structure); $i++) {
$form_structure[$i] = explode(\"|\", $form_structure[$i]);
for (
$j = 0; $j < count($form_structure[$i]); $j++) {
$form_structure[$i][$j] = trim($form_structure[$i][$j]);
}
}


function is_valid_url(
$link) {
// returns TRUE if url actually exists

if (strpos(
$link, \"http://\") === FALSE) { $link = \"http://\" . $link; }
    
$url_parts = @parse_url($link);
if (empty(
$url_parts[\"host\"])) return( false );
if (!empty(
$url_parts[\"path\"])) { $documentpath = $url_parts[\"path\"]; }
    else { 
$documentpath = \"/\"; }
if (!empty(
$url_parts[\"query\"])) { $documentpath .= \"?\" . $url_parts[\"query\"]; }
$host = $url_parts[\"host\"]; $port = $url_parts[\"port\"];
if (empty(
$port)) $port = \"80\";
$socket = @fsockopen( $host$port$errno$errstr, 30 );
if (!
$socket) { return(false); }
    else {fwrite (
$socket, \"HEAD \".$documentpath.\" HTTP/1.0\\r\\nHost: $host\\r\\n\\r\\n\");
$http_response = fgets( $socket, 22 );
if (ereg(\"200 OK\", 
$http_response$regs)) { return(true); fclose($socket); }
else { return(false); } }
}


function is_valid_email(
$email) {
// returns TRUE if email address is valid

$qtext = \'[^\\\\x0d\\\\x22\\\\x5c\\\\x80-\\\\xff]\';
$dtext = \'[^\\\\x0d\\\\x5b-\\\\x5d\\\\x80-\\\\xff]\';
$atom = \'[^\\\\x00-\\\\x20\\\\x22\\\\x28\\\\x29\\\\x2c\\\\x2e\\\\x3a-\\\\x3c\'.
\'\\\\x3e\\\\x40\\\\x5b-\\\\x5d\\\\x7f-\\\\xff]+\';
$quoted_pair = \'\\\\x5c[\\\\x00-\\\\x7f]\';
$domain_literal = \"\\\\x5b($dtext|$quoted_pair)*\\\\x5d\";
$quoted_string = \"\\\\x22($qtext|$quoted_pair)*\\\\x22\";
$domain_ref = $atom;
$sub_domain = \"($domain_ref|$domain_literal)\";
$word = \"($atom|$quoted_string)\";
$domain = \"$sub_domain(\\\\x2e$sub_domain)*\";
$local_part = \"$word(\\\\x2e$word)*\";
$addr_spec = \"$local_part\\\\x40$domain\";
return preg_match(\"!^
$addr_spec$!\", $email) ? 1 : 0;
}


function injection_chars(
$s) {
// returns TRUE if \'bad\' characters are found
return (eregi(\"\\r\", 
$s) || eregi(\"\\n\", $s) || eregi(\"%0a\", $s) || eregi(\"%0d\", $s)) ? TRUE : FALSE;
}


function generate_verification() {
srand((double)microtime()*1000000);
$rand = rand(0,999999999);
$thecode = substr(strtoupper(md5($rand)), 2, 5);
$thecode = str_replace(\"O\", \"A\", $thecode);
$thecode = str_replace(\"0\", \"B\", $thecode);
$_SESSION[\"thecode\"] = $thecode;
}

function strip_colons(
$s) {
return str_replace(array(\':\', \'%3a\'), \" \", 
$s);
}


$first_load = TRUE;

if (isset(
$_POST[\"form_submitted\"])) {
// if the form has been submitted

$first_load = FALSE;

// prepare error list
unset(
$errors);


// prepare mail variables
$mail_message = \"\";
$mail_name = \"Anonymous\";
$mail_subject = $subject;
$mail_email = \'noone@nowhere.com\';


// process input
foreach (
$form_structure as $form_field) {


switch (
$form_field[0]) {

case \"text\":
case \"password\":

$f_type = $form_field[0];
$f_name = $form_field[2];
$f_fmname = $form_field[3];
$f_max = $form_field[5];
$f_req = $form_field[6];
$f_ver = $form_field[7];

// get data
$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : \"\";
if (get_magic_quotes_gpc()) {
$t = stripslashes($t);
}

// check for size limits
if (strlen(
$t) > $f_max) {
$errors[] = \"There is a $f_max character limit for \'$f_name\'.\";
}

// check for required fields
if ((
$f_req == \"true\") && ($t == \"\")) {
if (
$f_fmname != $field_verification) { // has it\'s own check
$errors[] = \"Missing required field: \'$f_name\'.\";
}
}

// check for injection characters
if ((
$f_type != \"textarea\") && (injection_chars($t))) {
$errors[] = \"Invalid input in \'$f_name\'!\";
}

// check for valid email (if present/required)
if ((
$f_ver == \'email\') && ($f_req == \"true\" || (trim($t) != \"\"))) {
if (!is_valid_email(
$t)) {
$errors[] = \"Invalid email address: \'$f_name\'\";
}
}
// check for valid url (if present/required)
if ((
$f_ver == \'url\') && ($f_req == \"true\" || (trim($t) != \"\"))) {
if (!is_valid_url(
$t)) {
$errors[] = \"Invalid link: \'$f_name\'\";
}
}


// check for headers/verification fields
if (
$f_fmname == $field_name) {

if (
$t != \"\") {
$mail_name = strip_colons($t);
if (
$show_headers_in_message)
$mail_message .= $f_name . \' = \' . $t . \"\\n\\n\";
}

} elseif (
$f_fmname == $field_subject) {

if (
$t != \"\") {
$mail_subject = $subject . strip_colons($t);
if (
$show_headers_in_message)
$mail_message .= $f_name . \' = \' . $t . \"\\n\\n\";
}

} elseif (
$f_fmname == $field_email) {

if (
$t != \"\") {
$mail_email = strip_colons($t);
if (
$show_headers_in_message)
$mail_message .= $f_name . \' = \' . $t . \"\\n\\n\";
}

} elseif (
$f_fmname == $field_verification) {

if (
$t == \"\") {
$errors[] = \"Enter the verification code!\";
} else if (trim(
$_SESSION[\"thecode\"]) == \"\") {
$errors[] = \"No verification code generated!\";
} else if (
$_SESSION[\"thecode\"] != strtoupper($t)) {
$errors[] = \"Invalid verification code!\";
} else {
if (
$show_code_in_message)
$mail_message .= $f_name . \' = \' . $t . \"\\n\\n\";
}

} else {

if (
$t != \"\") {
$mail_message .= $f_name . \' = \' . $t . \"\\n\\n\";
}

}


break;


case \"textarea\":

$f_name = $form_field[2];
$f_fmname = $form_field[3];
$f_req = $form_field[6];

// get data
$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : \"\";
if (get_magic_quotes_gpc()) {
$t = stripslashes($t);
}

// check for required fields
if ((
$f_req == \"true\") && ($t == \"\")) {
if (
$f_fmname != $field_verification) { // has it\'s own check
$errors[] = \"Missing required field: \'$f_name\'.\";
}
}

if (
$t != \"\") {
$mail_message .= $f_name . \" = \\n\" . $t . \"\\n\\n\";
}

break;


case \"checkbox\":

$f_name = $form_field[2];

$t_message = $f_name . \' =\';

$f = FALSE;
for (
$i = 3; $i < count($form_field); $i+=3) {
$f_fmname = $form_field[$i];
$f_caption = $form_field[$i+1];

$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : \"\";
if (
$t == \'on\') {
$t_message .= \" \" . $f_caption . \",\";
$f = TRUE;
}
}

$t_message = rtrim($t_message, \',\');

if (
$f) {
$mail_message .= $t_message . \"\\n\\n\";
}

break;


case \"radio\":

$f_name = $form_field[2];
$f_fmname = $form_field[3];

$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : \"\";

$f = FALSE;
for (
$i = 5; $i < count($form_field); $i+=2) {
if (
$t == $form_field[$i]) {
$f = TRUE;
}
}

if (
$f) {
$mail_message .= $f_name . \' = \' . $t . \"\\n\\n\";
}

break;


case \"select\":

$f_name = $form_field[2];
$f_fmname = $form_field[3];

$t_message = $f_name . \' =\';

$t = (isset($_POST[$f_fmname])) ? $_POST[$f_fmname] : \"\";

foreach ((array)
$t as $tt) {

$f = FALSE;
for (
$i = 6; $i < count($form_field); $i++) {
if ((
$form_field[$i] == $tt) && (trim($tt) != \"\")) {
$f = TRUE;
}
}
if (
$f) {
$t_message .= \' \' . $tt . \',\';
}

}


$t_message = rtrim($t_message, \',\');

if (
$f) {
$mail_message .= $t_message . \"\\n\\n\";
}

break;


}

}


// if no errors, process
if (empty(
$errors)) {

$mail_message = trim($mail_message);

// wrap messages if set
if (
$wrap_messages) {
$mail_message = wordwrap($mail_message, 70);
}


// prepare the headers
// \\r\\n seems to be the best method for most servers to handle
$ip = $_SERVER[\"REMOTE_ADDR\"];
$mail_header = \"\";
$mail_header .= \"MIME-Version: 1.0\\r\\n\";
$mail_header .= \"X-Sender-IP: $ip\\r\\n\";
$mail_header .= \"Content-Type: text/plain\\r\\n\";
$mail_header .= \"From: \" . $mail_name . \" <\" . $mail_email . \">\";


if (
$recipients[0] == \'onerecip\') {

$mail_to = $recipients[1];

} elseif (
$recipients[0] == \'mulrecip\') {

$mail_to = $recipients[2];
for (
$i = 3; $i < count($recipients); $i++) {

$mail_header .= \"\\r\\n\";
if (
$recipients[1] == \'cc\') {
$mail_header .= \"Cc: \";
} else {
$mail_header .= \"Bcc: \";
}
$mail_header .= $recipients[$i];
}

} elseif (
$recipients[0] == \'selrecip\') {

$recip_number = (int)$_POST[$field_dropdownrecip];
foreach (
$form_structure as $form_field) {
if (
$form_field[0] == \'selrecip\') {
$j = 1;
for (
$i = 4; $i < count($form_field); $i++) {
if (strpos(
$form_field[$i], \"#\") === 0) {
$i++;
}
$i++;
if (
$recip_number == $j) {
$mail_to = $form_field[$i];
}
$j++;
}
}
}
}


// send mail, setting 
$email_sent to true or false


if (
$include_ip) {
$mail_message .= \"\\n\";
$mail_message .= \"\\nHost: \" . $_SERVER[\"HTTP_HOST\"];
$mail_message .= \"\\nIP: \" . $_SERVER[\"REMOTE_ADDR\"];
$mail_message .= \"\\nBrowser: \" . $_SERVER[\"HTTP_USER_AGENT\"];
}


if (mail(
$mail_to$mail_subject$mail_message$mail_header, \"-f $mail_email\")) {
$email_sent = true;
} else {
$errors[] = $msg_mailserver;
$email_sent = false;
}

}


if (isset(
$errors)) {

// if there were errors, list them

$t_out .= \'<div class=\"mailwrapper\"><div class=\"maildiv\"><div class=\"fmerrorbox\">\';
$t_out .= \'<p class=\"fmerrortitle\">\' . $msg_error . \'</p><ul>\';

foreach (
$errors as $f)
$t_out .= \'<li>\' . $f . \'</li>\';

$t_out .= \'</ul></div></div></div>\';

} else {

// the message was sent, display message


$t_out .= \'<div class=\"mailwrapper\"><div class=\"maildiv\">\';

$t_out .= $msg_sent;

$t_out .= \'</div></div>\';

generate_verification();

}

}





if (!
$email_sent) {

// SHOW FORM

generate_verification();

if (!extension_loaded(\"gd\")) {
   
$t_out .= \"<p><b>GD Support not detected!</b> GD is required for this script.</p>\";
}

$t_out .= \'<div class=\"mailwrapper\"><div class=\"maildiv\">\';
$t_out .= \'<form method=\"post\" action=\"\' . basename($_SERVER[\"PHP_SELF\"]) . \'\" enctype=\"multipart/form-data\">\';


// go through fields
foreach (
$form_structure as $form_field) {


// process field types
switch (
$form_field[0]) {


case \"openfieldset\":

$f_class = $form_field[1];

$t_out .= \'<fieldset class=\"\' . $f_class . \'\">\';

if (count(
$form_field) > 2) {

$f_legend = $form_field[2];

$t_out .= \'<legend>\' . $f_legend . \'</legend><div class=\"legendspacing\"></div>\';
}

break;


case \"closefieldset\":

$t_out .= \'</fieldset>\';

break;


case \"info\":

$f_class = $form_field[1];
$f_text = $form_field[2];

$t_out .= \'<div class=\"\' . $f_class . \'\">\' . $f_text . \'</div>\';

break;


case \"text\":

$f_class = $form_field[1];
$f_name = $form_field[2];
$f_fmname = $form_field[3];
$f_size = $form_field[4];
$f_max = $form_field[5];
$f_req = $form_field[6];

$t_out .= \'<label class=\"sidelbl\" for=\"\' . $f_fmname . \'\">\';
if ((
$f_req == \"true\") && ($show_required))
$t_out .= \'<span class=\"fmrequired\">* </span>\';
$t_out .= $f_name . \'</label>\';

$t_out .= \'<input type=\"text\" class=\"\' . $f_class . \'\" name=\"\' . $f_fmname . \'\"
id=\"\' . 
$f_fmname . \'\" size=\"\' . $f_size . \'\" maxlength=\"\' . $f_max . \'\"\';

if (isset(
$_POST[$f_fmname])) {
if (
$f_fmname != $field_verification) {
$t_out .= \' value=\"\' . htmlspecialchars($_POST[$f_fmname]) . \'\"\';
}
}

$t_out .= \' />\';

if (
$f_fmname == $field_verification) {
$t_out .= \'<img class=\"ver_img\" src=\"formmailer_verify.php\" width=\"60\" height=\"20\" alt=\"Please enter the number from this image\" />\';
}

$t_out .= \'<br />\';

break;


  case \"password\":

$f_class = $form_field[1];
$f_name = $form_field[2];
$f_fmname = $form_field[3];
$f_size = $form_field[4];
$f_max = $form_field[5];
$f_req = $form_field[6];

$t_out .= \'<label class=\"sidelbl\" for=\"\' . $f_fmname . \'\">\';
if ((
$f_req == \"true\") && ($show_required))
$t_out .= \'<span class=\"fmrequired\">* </span>\';
$t_out .= $f_name . \'</label>\';

$t_out .= \'<input type=\"password\" class=\"\' . $f_class . \'\" name=\"\' . $f_fmname . \'\"
id=\"\' . 
$f_fmname . \'\" size=\"\' . $f_size . \'\" maxlength=\"\' . $f_max . \'\"\';

if (isset(
$_POST[$f_fmname])) {
if (
$f_fmname != $field_verification) {
$t_out .= \' value=\"\' . htmlspecialchars($_POST[$f_fmname]) . \'\"\';
}
}

$t_out .= \' /><br />\';

break;


case \"textarea\":

$f_class = $form_field[1];
$f_name = $form_field[2];
$f_fmname = $form_field[3];
$f_rows = $form_field[4];
$f_cols = $form_field[5];
$f_req = $form_field[6];

$t_out .= \'<label class=\"sidelbl\" for=\"\' . $f_fmname . \'\">\';
if ((
$f_req == \"true\") && ($show_required))
$t_out .= \'<span class=\"fmrequired\">* </span>\';
$t_out .= $f_name . \'</label>\';

$t_out .= \'<textarea class=\"\' . $f_class . \'\" name=\"\' . $f_fmname . \'\"
id=\"\' . 
$f_fmname . \'\" rows=\"\' . $f_rows . \'\" cols=\"\' . $f_cols . \'\" >\';

if (isset(
$_POST[$f_fmname])) {
if (
$f_fmname != $field_verification) {
$t_out .= htmlspecialchars($_POST[$f_fmname]);
}
}


$t_out .= \'</text\'.\'area><br />\';
break;


case \"checkbox\":

$f_class = $form_field[1];
$f_name = $form_field[2];

$t_out .= \'<label class=\"sidelbl\">\' . $f_name . \'</label>\';

for (
$i = 3; $i < count($form_field)-1; $i+=3) {
if (
$i > 3) {
$t_out .= \'<label class=\"sidelbl\"> </label>\';
}

$f_fmname = $form_field[$i];
$f_caption = $form_field[$i+1];
$f_checked = $form_field[$i+2];

$t_out .= \'<input class=\"\' . $f_class . \'\" type=\"checkbox\" name=\"\' . $f_fmname . \'\" id=\"\' . $f_fmname . \'\"\';

if (
$first_load) {
if (
$f_checked == \'true\') {
$t_out .= \' checked=\"checked\" \';
}
} else {
if (isset(
$_POST[$f_fmname])) {
if (
$_POST[$f_fmname] == \"on\") {
$t_out .= \' checked \';
}
}
}

$t_out .= \' />\';
$t_out .= \'<label for=\"\' . $f_fmname . \'\">\' . $f_caption . \'</label> <br />\';
}

break;


case \"radio\":

$f_class = $form_field[1];
$f_name = $form_field[2];
$f_fmname = $form_field[3];
$f_def = $form_field[4];

$t_out .= \'<label class=\"sidelbl\">\' . $f_name . \'</label>\';

$j = 1;
for (
$i = 5; $i < count($form_field); $i+=2) {

$f_value = $form_field[$i];
$f_caption = $form_field[$i+1];

if (
$i > 5) {
$t_out .= \'<label class=\"sidelbl\"> </label>\';
}
$t_out .= \'<input class=\"\' . $f_class . \'\" type=\"radio\" name=\"\' . $f_fmname . \'\" id=\"\' . $f_fmname . $j . \'\" value=\"\' . $f_value . \'\"\';


if (
$first_load) {
if ((int)
$f_def == $j) {
$t_out .= \' checked=\"checked\" \';
}
} else {

if (isset(
$_POST[$f_fmname])) {
if (
$_POST[$f_fmname] == $f_value) {
$t_out .= \' checked=\"checked\" \';
}
}
}

$t_out .= \' />\';
$t_out .= \'<label for=\"\' . $f_fmname . $j . \'\">\' . $f_caption . \'</label> <br />\';

$j++;
}

break;


case \"select\":

$f_class = $form_field[1];
$f_name = $form_field[2];
$f_fmname = $form_field[3];
$f_mul = $form_field[4];

$t_out .= \'<label class=\"sidelbl\" for=\"\' . $f_fmname . \'\">\' . $f_name . \'</label>\';
$t_out .= \'<select class=\"\' . $f_class . \'\" name=\"\' . $f_fmname;
if (
$f_mul === \"true\") {
$t_out .= \'[]\';
}
$t_out .= \'\" id=\"\' . $f_fmname . \'\"\';
if (
$f_mul === \"true\") {
$t_out .= \' multiple=\"multiple\" \';
}

$t_out .= \'>\';

$grp_count = 0;
for (
$i = 5; $i < count($form_field)-1; $i++) {

if (strpos(
$form_field[$i], \"#\") === 0) {

if (
$grp_count > 0) {
$t_out .= \"</optgroup>\";
}

$t_out .= \'<optgroup label=\"\' . ltrim($form_field[$i], \"#\") . \'\">\';

$grp_count++;
$i++;
}

$t_out .= \'<option value=\"\' . $form_field[$i] . \'\"\';

if (
$f_mul == \"true\") {
if (isset(
$_POST[$f_fmname])) {
foreach (
$_POST[$f_fmname] as $p) {
if (
$p == $form_field[$i]) {
$t_out .= \' selected\';
}
}
}
} else {
if (isset(
$_POST[$f_fmname])) {
if (
$_POST[$f_fmname] == $form_field[$i]) {
$t_out .= \' selected\';
}
}
}


$t_out .= \' > \' . $form_field[$i+1] . \'</option>\';

$i++;

}

if (
$grp_count > 0) {
$t_out .= \"</optgroup>\";
}
$t_out .= \'</select><br />\';

break;


case \"selrecip\":

$f_class = $form_field[1];
$f_name = $form_field[2];
$f_fmname = $form_field[3];

$t_out .= \'<label class=\"sidelbl\" for=\"\' . $f_fmname . \'\">\' . $f_name . \'</label>\';
$t_out .= \'<select class=\"\' . $f_class . \'\" name=\"\' . $f_fmname . \'\" id=\"\' . $f_fmname . \'\" >\';


$j = 1;
$grp_count = 0;
for (
$i = 4; $i < count($form_field)-1; $i++) {

if (strpos(
$form_field[$i], \"#\") === 0) {

if (
$grp_count > 0) {
$t_out .= \"</optgroup>\";
}

$t_out .= \'<optgroup label=\"\' . ltrim($form_field[$i], \"#\") . \'\">\';

$grp_count++;
$i++;
}

$t_out .= \'<option value=\"\' . $j . \'\"\';


if (isset(
$_POST[$f_fmname])) {
if (
$_POST[$f_fmname] == $j) {
$t_out .= \' selected\';
}
}

$t_out .= \' > \' . $form_field[$i] . \'</option>\';

$i++;
$j++;
}

if (
$grp_count > 0) {
$t_out .= \"</optgroup>\";
}
$t_out .= \'</select><br />\';

break;

}
}

$t_out .= \'<div class=\"fmspacer\"><!-- --></div>\';

$t_out .= \'<div class=\"fmcredits\">script by <a href=\"http://www.dagondesign.com\">dagondesign.com</a></div>\';

$t_out .= \'<div class=\"fmsubmit\"><input name=\"form_submitted\" type=\"submit\" id=\"Submit\" value=\"\' . $msg_submit . \'\" /></div>\';

$t_out .= \'</form></div></div>\';

}



echo 
$t_out;
echo\'
<div>\';
Title: Re: Overlow problem with PHP article.
Post by: jacortina on January 20, 2007, 05:57:12 PM
Quote from: Lesmond on January 20, 2007, 05:50:18 PM
But I did notice that the editor has changed the code by putting extra / everywhere   :o

Really? I don't see any when I test (aside from those which were there for comments to start with). Are you using the plain text editor?

And, yes, my preview comes out centered.
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 05:58:30 PM
QuoteWarning: Unexpected character in input: '\' (ASCII=92) state=1 in ......

I don't use the text editor.
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 06:03:49 PM
I have Just the title now, set to title only

http://nokonium.co.uk/Cat-and-Fiddler/index.php?page=14

I have it called as an article from the menu block
Title: Re: Overlow problem with PHP article.
Post by: Lesmond on January 20, 2007, 06:04:45 PM
Yeah I am using the plain text editor
Title: Re: Overlow problem with PHP article.
Post by: JPDeni on January 20, 2007, 06:26:36 PM
I'm not sure if this is a factor, but I thought I'd toss in my experience.

I found that if I create a php article and paste in text immediately before and save it -- create and save all in on one action -- I end up with all sorts of extraneous / characters. If, instead, I create the php article and don't put anything at all in it, then go back and put the code in, then the / characters aren't added and everything is fine.
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 06:44:01 PM
I have the text editor off and I do not get the extra escape slashes, either way of pasting in.
Title: Re: Overlow problem with PHP article.
Post by: Lesmond on January 20, 2007, 06:49:41 PM
Yes Thanks JP that works :)

How are you doing with your form nokonium? and can I ask what you want to do with it?
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 06:59:51 PM
I have a basic contact form working on one of my public sites, I would like to A) Add Visual Verification and B) Get it to load as an article in the centre space.

If I use the code in a seperate file and use a link from the menu it will load and will send e-mails. The problem came when I tried to put it into an article.

Thanks to you two I now have code that will work, only I cannot get it to show. I have the title and whatever else is selected to display with the article but no contact form.
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 20, 2007, 09:28:52 PM
I've done it  ;D

iframe

Thanks for your help, I thought the overflow was a TP problem.
Title: Re: Overlow problem with PHP article.
Post by: jacortina on January 20, 2007, 09:41:51 PM
No. The overflow part of things was just the nature (a limitation?) of textareas. They don't nest.

The edit box is iteslf a textarea, so when a browser parses code within it and finds a closing tag, it takes that as the close of the edit area (it doesn't track 'levels' of depth). So when coding for textareas, you have to be careful not to present the browser with a premature end.

Because the split/concatenated version doesn't present the actual end tag until the code runs, it works.

JPDeni posted a 'heads up' about this a while back:
http://www.tinyportal.net/index.php?topic=6384.0
Title: Re: Overlow problem with PHP article.
Post by: Nokonium on January 21, 2007, 04:05:10 PM
That was from Jul 10, 06  ::)  ;)


I'd made the assumption that because it worked in a file and it was OK for syntax that it was all OK.

I've just started on the road of learning PHP, I thought that it was about time I knew what I was doing.
Title: Re: Overlow problem with PHP article.
Post by: JPDeni on January 21, 2007, 05:19:24 PM
I forget about that issue all the time, even though I'm the one who brought it to the attention of the forum. I can't tell you how many times since then I've worked and worked trying to figure out why something wasn't working, only to finally remember that there was a textarea in there.