Javascript formulario web

Le comento mi problema esperando que me pueda ayudar.
He realizado la ss Web con un programa bastante sencillo que
facilita no emplear código: http://centroeducacion.es
El problema lo tengo a la hora de
Los formularios
pej. La página de contacto http://centroeducacion.es/contacto.html
Al pinchar sobre el botón enviar el navegador me indica que : “Debes
activar Javascript! Se vuelve atrás en 5 segundos”
Evidentemente de cara a los navegantes esto es un incordio y
no se como solucionarlo.
¿Me puede

6 Respuestas

Respuesta
1

Agradezco que me hayas tenido en cuenta para despejar tus dudas.

Hice el ejercicio de ingresar a tu enlace y fijate que no me sale el mensaje

"debes activar Javascript!Se vuelve atrás en 5 segundos"

el botón enviar me lleva a este enlace http://centroeducacion.es/imemail/imEmailForm_mq3519wp.php

Y me dice que "El sitio web no puede mostrar la página"

Hice la prueba con 2 navegadores y es igual,

Otra cosa pude evidenciar que no estas validando campos vacíos al momento de dar clic en el botón enviar . . .

Yo te recomiendo con manejo de formularios utilizar la librería phpmailer, es muy fácil de usar.

Cualquier inquietud con gusto la atenderé.

Respuesta
1

Dirigite al archivo http://centroeducacion.es/imemail/imEmailForm_mq3519wp.php y elimina la siguiente linea

<meta http-equiv="Refresh" content="5;URL=http://centroeducacion.es/contacto.html">

Como no se que código php contiene ese archivo no te puedo dar mayores antecedentes de como mejorar ese problema. Si quieres envía el código para verificarlo

Gracias por su rápida respuesta, pero en el código del archivo no aparece la linea que me indica: <meta http-equiv="Refresh" content="5;URL=http://centroeducacion.es/contacto.html">

El código del archivo imEmailForm_mq3519wp.php es:

<?php
if(substr(basename($_SERVER['PHP_SELF']), 0, 11) == "imEmailForm") {
include "../res/x5engine.php";
$form = new ImForm();
$form->setField('Nombre completo', $_POST['imObjectForm_2_1'], '', false);
$form->setField('Teléfono', $_POST['imObjectForm_2_2'], '', false);
$form->setField('Localidad', $_POST['imObjectForm_2_3'], '', false);
$form->setField('Provincia', $_POST['imObjectForm_2_4'], '', false);
$form->setField('E-mail', $_POST['imObjectForm_2_5'], '', false);
$form->setField('Comentarios', $_POST['imObjectForm_2_6'], '', false);
if(@$_POST['action'] != "check_answer") {
if(!isset($_POST['imJsCheck']) || $_POST['imJsCheck'] != "jsactive" || (isset($_POST['imSpProt']) && $_POST['imSpProt'] != ""))
die(imPrintJsError());
$form->mailToOwner($_POST['imObjectForm_2_5'] != "" ? $_POST['imObjectForm_2_5'] : '[email protected]', '[email protected]', 'CONSULTA WEB', '', true);
$form->mailToCustomer('[email protected]', $_POST['imObjectForm_2_5'], 'EDUCA-Apoyo Integral a la educación, formación y aprendizaje', 'Gracias por contactar con nosotros. En breve atenderemos su solicitud.
Si desea mayor agilidad puede contactar con nosotros telefónicamente en el 945 22 53 95 en horario de 15.30 a 20.00 horas.
EDUCA
Apoyo Integral a la educación, formación y aprendizaje', false);
@header('Location: ../index.html');
exit();
} else {
echo $form->checkAnswer(@$_POST['id'], @$_POST['answer']) ? 1 : 0;
}
}
// End of file

Tendrás que validar en el header de la aplicación porque tiene que existir un include que haga que la cabecera redireccione (puede ser esta llamada include "../res/x5engine.php"; )

Como no conozco la plataforma solo puedo ir guiándote de esta forma paso a paso.

Muchas gracias. No entiendo bien su respuesta. He abierto el archivo x5engine.php y en este si que no entiendo casi nada. Le adjunto su código y muchas muchas gracias.

<?php
/**
* This file contains all the classes used by the PHP code created by WebSite X5
*
* @category X5engine
* @package X5engine
* @copyright 2013 - Incomedia Srl
* @license Copyright by Incomedia Srl http://incomedia.eu
* @version WebSite X5 Evolution 10.0.0
* @link http://websitex5.com
*/
@session_start();
$imSettings = Array();
$l10n = Array();
$phpError = false;
$ImMailer = new ImSendEmail();
@include_once "imemail.inc.php";// Email class - Static
@include_once "x5settings.php";// Basic settings - Dynamically created by WebSite X5
@include_once "blog.inc.php";// Blog data - Dynamically created by WebSite X5
@include_once "access.inc.php";// Private area data - Dynamically created by WebSite X5
@include_once "l10n.php";// Localizations - Dynamically created by WebSite X5
@include_once "search.inc.php" ;// Search engine data - Dynamically created by WebSite X5
/**
* Blog class
* @access public
*/
class imBlog
{
var $comments;
/**
* Format a timestamp
*
* @param string $ts The timestamp
*
* @return string
*/
function formatTimestamp($ts)
{
return date("d/m/Y H:i:s", strtotime($ts));
}
/**
* Show the pagination links
*
* @param string $baseurl The base url of the pagination
* @param integer $start Start from this page
* @param integer $length For this length
* @param integer $count Count of the current objects to show
*
* @return void
*/
function paginate($baseurl = "", $start, $length, $count)
{
echo "<div style=\"text-align: center;\">";
if ($start > 0)
echo "<a href=\"" . $baseurl . "start=" . ($start - $length) . "&length=" . $length . "\">" . l10n("blog_pagination_prev", "<< Newer posts") . "</a>";
if ($start > 0 && $count > $start + $length)
echo " | ";
if ($count > $start + $length)
echo "<a href=\"" . $baseurl . "start=" . ($start + $length) . "&length=" . $length . "\">" . l10n("blog_pagination_next", "Older posts >>") . "</a>";
echo "</div>";
}
/**
* Provide the page title tag to be shown in the header
* Keep track of the page using the $_GET vars provided:
* - id
* - category
* - tag
* - month
* - search
*
* @param string $basetitle The base title of the blog, to be appended after the specific page title
* @param string $separator The separator char, default "-"
*
* @return string The page title
*/
function pageTitle($basetitle, $separator = "-") {
global $imSettings;
if (isset($_GET['id']) && isset($imSettings['blog']['posts'][$_GET['id']])) {
// Post
return htmlspecialchars($imSettings['blog']['posts'][$_GET['id']]['title'] . $separator . $basetitle);
} else if (isset($_GET['category']) && isset($imSettings['blog']['posts_cat'][$_GET['category']])) {
// Category
return htmlspecialchars(str_replace("_", " ", $_GET['category']) . $separator . $basetitle);
} else if (isset($_GET['tag'])) {
// Tag
return htmlspecialchars($_GET['tag'] . $separator . $basetitle);
} else if (isset($_GET['month']) && is_numeric($_GET['month']) && strlen($_GET['month']) == 6) {
// Month
return htmlspecialchars(substr($_GET['month'], 4, 2) . "/" . substr($_GET['month'], 0, 4) . $separator . $basetitle);
} else if (isset($_GET['search'])) {
// Search
return htmlspecialchars(urldecode($_GET['search']) . $separator . $basetitle);
}
// Default (Home page): Show the blog description
return htmlspecialchars($basetitle);
}
/**
* Show the page description to be echoed in the metatag description tag.
* Keep track of the page using the $_GET vars provided:
* - id
* - category
* - tag
* - month
* - search
*
* @return string The required description
*/
function pageDescription()
{
global $imSettings;
if (isset($_GET['id']) && isset($imSettings['blog']['posts'][$_GET['id']])) {
// Post
return htmlspecialchars(str_replace("\n", " ", $imSettings['blog']['posts'][$_GET['id']]['summary']));
} else if (isset($_GET['category'])) {
// Category
return htmlspecialchars(str_replace("_", " ", $_GET['category']));
} else if (isset($_GET['tag'])) {
// Tag
return htmlspecialchars($_GET['tag']);
} else if (isset($_GET['month'])) {
// Month
return htmlspecialchars(substr($_GET['month'], 4, 2) . "/" . substr($_GET['month'], 0, 4));
} else if (isset($_GET['search'])) {
// Search
return htmlspecialchars(urldecode($_GET['search']));
}
// Default (Home page): Show the blog description
return htmlspecialchars(str_replace("\n", " ", $imSettings['blog']['description']));
}
/**
* Get the last update date
*
* @return string
*/
function getLastModified()
{
global $imSettings;
$c = $this->comments->getComments($_GET['id']);
if ($_GET['id'] != "" && $c != -1) {
return $this->formatTimestamp($c[count($c)-1]['timestamp']);
} else {
$last_post = $imSettings['blog']['posts'];
$last_post = array_shift($last_post);
return $last_post['timestamp'];
}
}
/**
* Show a post
*
* @param string $id the post id
* @param intger $ext Set 1 to show as extended
* @param integer $first Set 1 if this is the first post in the list
*
* @return void
*/
function showPost($id, $ext=0, $first=0)
{
global $imSettings;
$bs = $imSettings['blog'];
$bp = $bs['posts'][$id];
$title = !$ext ? "<a href=\"?id=" . $id . "\">" . $bp['title'] . "</a>" : $bp['title'];
echo "<h2 id=\"imPgTitle\" style=\"display: block;\">" . $title . "</h2>\n";
echo "<div class=\"imBreadcrumb\" style=\"display: block;\">" . l10n('blog_published_by') . "<strong> " . $bp['author'] . " </strong>";
echo l10n('blog_in') . " <a href=\"?category=" . urlencode($bp['category']) . "\" target=\"_blank\" rel=\"nofollow\">" . $bp['category'] . "</a> &middot; " . $bp['timestamp'];
// Media audio/video
if (isset($bp['media'])) {
echo " &middot; <a href=\"" . $bp['media'] . "\">Download " . basename($bp['media']) . "</a>";
}
if (count($bp['tag']) > 0) {
echo "<br />Tags: ";
for ($i = 0; $i < count($bp['tag']); $i++) {
echo "<a href=\"?tag=" . $bp['tag'][$i] . "\">" . $bp['tag'][$i] . "</a>";
if ($i < count($bp['tag']) - 1)
echo ",&nbsp;";
}
}
echo "</div>\n";
if ($ext || $first && $imSettings['blog']['post_type'] == 'firstshown' || $imSettings['blog']['post_type'] == 'allshown') {
echo "<div class=\"imBlogPostBody\">\n";
if (isset($bp['mediahtml'])) {
echo $bp['mediahtml'] . "\n";
}
echo $bp['body'];
if (count($bp['sources']) > 0) {
echo "\t<div class=\"imBlogSources\">\n";
echo "\t\t<b>" . l10n('blog_sources') . "</b>:<br />\n";
echo "\t\t<ul>\n";
foreach ($bp['sources'] as $source) {
echo "\t\t\t<li>" . $source . "</li>\n";
}
echo "\t\t</ul>\n\t</div>\n";
}
echo (isset($imSettings['blog']['addThis']) ? "<br />" . $imSettings['blog']['addThis'] : "") . "<br /><br /></div>\n";
} else {
echo "<div class=\"imBlogPostSummary\">" . $bp['summary'] . "</div>\n";
}
if ($ext == 0) {
echo "<div class=\"imBlogPostRead\"><a class=\"imCssLink\" href=\"?id=" . $id . "\">" . l10n('blog_read_all') ." &raquo;</a></div>\n";
} else if (isset($bp['foo_html'])) {
echo "<div class=\"imBlogPostFooHTML\">" . $bp['foo_html'] . "</div>\n";
}
if ($ext != 0 && $bp['comments']) {
echo "<div id=\"blog-topic\">\n";
$this->comments = new ImTopic($imSettings['blog']['file_prefix'] . 'pc' . $id, "../", "index.php?id=" . $id);
// Show the comments
if ($bs['sendmode'] == "db")
$this->comments->loadDb($bs['dbhost'], $bs['dbuser'], $bs['dbpassword'], $bs['dbname'], $bs['dbtable']);
else
$this->comments->loadXML($bs['folder']);
$this->comments->setPostUrl("index.php?id=" . $id);
if ($imSettings['blog']['comment_type'] != "stars") {
$this->comments->showSummary();
$this->comments->showComments();
$this->comments->showForm($bs['comment_type'] != "comment", $bs['captcha'], $bs['moderate'], $bs['email'], "blog", $imSettings['general']['url'] . "/admin/blog.php?category=" . str_replace(" ", "_", $imSettings['blog']['posts'][$id]['category']) . "&id=" . $id);
} else {
$this->comments->showRating();
}
echo "</div>";
echo "<script type=\"text/javascript\">x5engine.boot.push('x5engine.topic({ target: \\'#blog-topic\\', scrollbar: false})', false, 6);</script>\n";
}
}
/**
* Find the posts tagged with tag
*
* @param string $tag The searched tag
*
* @return void
*/
function showTag($tag)
{
global $imSettings;
$start = isset($_GET['start']) ? max(0, (int)$_GET['start']) : 0;
$length = isset($_GET['length']) ? (int)$_GET['length'] : 5;
if (count($imSettings['blog']['posts']) > 0) {
$bps = array();
foreach ($imSettings['blog']['posts'] as $id => $post) {
if (in_array($tag, $post['tag'])) {
$bps[] = $post;
}
}
$bpsc = count($bps);
for($i = $start; $i < ($bpsc < $start + $length ? $bpsc : $start + $length); $i++) {
if ($i > $start)
echo "<div class=\"imBlogSeparator\"></div>";
$this->showPost($bps[$i]['id'], 0, ($i == $start ? 1 : 0));
}
$this->paginate("?tag=" . $tag . "&", $start, $length, $bpsc);
} else {
echo "<div class=\"imBlogEmpty\">Empty tag</div>";
}
}
/**
* Find the post in a category
*
* @param strmg $category the category ID
*
* @return void
*/
function showCategory($category)
{
global $imSettings;
$start = isset($_GET['start']) ? max(0, (int)$_GET['start']) : 0;
$length = isset($_GET['length']) ? (int)$_GET['length'] : 5;
$bps = $imSettings['blog']['posts_cat'][$category];
if (is_array($bps)) {
$bpsc = count($bps);
for($i = $start; $i < ($bpsc < $start + $length ? $bpsc : $start + $length); $i++) {
if ($i > $start)
echo "<div class=\"imBlogSeparator\"></div>";
$this->showPost($bps[$i], 0, ($i == 0 ? 1 : 0));
}
$this->paginate("?category=" . $category . "&", $start, $length, $bpsc);
} else {
echo "<div class=\"imBlogEmpty\">Empty category</div>";
}
}
/**
* Find the posts of the month
*
* @param string $month The mont
*
* @return void
*/
function showMonth($month)
{
global $imSettings;
$start = isset($_GET['start']) ? max(0, (int)$_GET['start']) : 0;
$length = isset($_GET['length']) ? (int)$_GET['length'] : 5;
$bps = $imSettings['blog']['posts_month'][$month];
if (is_array($bps)) {
$bpsc = count($bps);
for($i = $start; $i < ($bpsc < $start + $length ? $bpsc : $start + $length); $i++) {
if ($i > $start)
echo "<div class=\"imBlogSeparator\"></div>";
$this->showPost($bps[$i], 0, ($i == $start ? 1 : 0));
}
$this->paginate("?month=" . $month . "&", $start, $length, $bpsc);
} else {
echo "<div class=\"imBlogEmpty\">Empty month</div>";
}
}
/**
* Show the last n posts
*
* @param integer $count the number of posts to show
*
* @return void
*/
function showLast($count)
{
global $imSettings;
$start = isset($_GET['start']) ? max(0, (int)$_GET['start']) : 0;
$length = isset($_GET['length']) ? (int)$_GET['length'] : 5;
$bps = array_keys($imSettings['blog']['posts']);
if (is_array($bps)) {
$bpsc = count($bps);
for($i = $start; $i < ($bpsc < $start + $length ? $bpsc : $start + $length); $i++) {
if ($i > $start)
echo "<div class=\"imBlogSeparator\"></div>";
$this->showPost($bps[$i], 0, ($i == $start ? 1 : 0));
}
$this->paginate("?", $start, $length, $bpsc);
} else {
echo "<div class=\"imBlogEmpty\">Empty blog</div>";
}
}
/**
* Show the search results
*
* @param string $search the search query
*
* @return void
*/
function showSearch($search)
{
global $imSettings;
$start = isset($_GET['start']) ? max(0, (int)$_GET['start']) : 0;
$length = isset($_GET['length']) ? (int)$_GET['length'] : 5;
$bps = array_keys($imSettings['blog']['posts']);
$j = 0;
if (is_array($bps)) {
$bpsc = count($bps);
$results = array();
for ($i = $start; $i < $bpsc; $i++) {
if (stristr($imSettings['blog']['posts'][$bps[$i]]['title'], $search) || stristr($imSettings['blog']['posts'][$bps[$i]]['summary'], $search) || stristr($imSettings['blog']['posts'][$bps[$i]]['body'], $search)) {
$results[] = $bps[$i];
$j++;
}
}
for ($i = $start; $i < ($j < $start + $length ? $j : $start + $length); $i++) {
if ($i > $start)
echo "<div class=\"imBlogSeparator\"></div>";
$this->showPost($bps[$i], 0, ($i == $start ? 1 : 0));
}
$this->paginate("?search=" . $search . "&", $start, $length, $j);
if ($j == 0) {
echo "<div class=\"imBlogEmpty\">Empty search</div>";
}
} else {
echo "<div class=\"imBlogEmpty\">Empty blog</div>";
}
}
/**
* Show the categories sideblock
*
* @param integer $n The number of categories to show
*
* @return void
*/
function showBlockCategories($n)
{
global $imSettings;
if (is_array($imSettings['blog']['posts_cat'])) {
$categories = array_keys($imSettings['blog']['posts_cat']);
array_multisort($categories);
echo "<ul>";
for ($i = 0; $i < count($categories) && $i < $n; $i++) {
$post = $imSettings['blog']['posts'][$imSettings['blog']['posts_cat'][$categories[$i]][0]];
echo "<li><a href=\"?category=" . $categories[$i] . "\">" . $post['category'] . "</a></li>";
}
echo "</ul>";
}
}
/**
* Show the cloud sideblock
*
* @param string $type TAGS or CATEGORY
*
* @return void;
*/
function showBlockCloud($type)
{
global $imSettings;
$max = 0;
$min_em = 0.95;
$max_em = 1.25;
if ($type == "tags") {
$tags = array();
foreach ($imSettings['blog']['posts'] as $id => $post) {
foreach ($post['tag'] as $tag) {
if (!isset($tags[$tag]))
$tags[$tag] = 1;
else
$tags[$tag] = $tags[$tag] + 1;
if ($tags[$tag] > $max)
$max = $tags[$tag];
}
}
if (count($tags) == 0)
return;
$tags = shuffleAssoc($tags);
foreach ($tags as $name => $number) {
$size = number_format(($number/$max * ($max_em - $min_em)) + $min_em, 2, '.', '');
echo "\t\t\t<span class=\"imBlogCloudItem\" style=\"font-size: " . $size . "em;\">\n";
echo "\t\t\t\t<a href=\"?tag=" . $name . "\" style=\"font-size: " . $size . "em;\">" . $name . "</a>\n";
echo "\t\t\t</span>\n";
}
} else if ($type == "categories") {
$categories = array();
foreach ($imSettings['blog']['posts'] as $id => $post) {
if (!isset($categories[$post['category']]))
$categories[$post['category']] = 1;
else
$categories[$post['category']] = $categories[$post['category']] + 1;
if ($categories[$post['category']] > $max)
$max = $categories[$post['category']];
}
if (count($categories) == 0)
return;
$categories = shuffleAssoc($categories);
foreach ($categories as $name => $number) {
$size = number_format(($number/$max * ($max_em - $min_em)) + $min_em, 2, '.', '');
echo "\t\t\t<span class=\"imBlogCloudItem\" style=\"font-size: " . $size . "em;\">\n";
echo "\t\t\t\t<a href=\"?category=" . $name . "\" style=\"font-size: " . $size . "em;\">" . $name . "</a>\n";
echo "\t\t\t</span>\n";
}
}
}
/**
* Show the month sideblock
*
* @param integer $n Number of entries
*
* @return void
*/
function showBlockMonths($n)
{
global $imSettings;
if (is_array($imSettings['blog']['posts_month'])) {
$months = array_keys($imSettings['blog']['posts_month']);
array_multisort($months, SORT_DESC);
echo "<ul>";
for ($i = 0; $i < count($months) && $i < $n; $i++) {
echo "<li><a href=\"?month=" . $months[$i] . "\">" . substr($months[$i], 4) . "/" . substr($months[$i], 0, 4) . "</a></li>";
}
echo "</ul>";
}
}
/**
* Show the last posts block
*
* @param integer $n The number of post to show
*
* @return void
*/
function showBlockLast($n)
{
global $imSettings;
if (is_array($imSettings['blog']['posts'])) {
echo "<ul>";
for ($i = 0; $i < count($imSettings['blog']['posts']) && $i < $n; $i++) {
$post = array_keys($imSettings['blog']['posts']);
$post = $imSettings['blog']['posts'][$post[$i]];
echo "<li><a href=\"?id=" . $post['id'] . "\">" . $post['title'] . "</a></li>";
}
echo "</ul>";
}
}
}
/**
* Captcha handling class
* @access public
*/
class imCaptcha {
/**
* Show the captcha chars
*/
function show($sCode)
{
global $oNameList;
global $oCharList;
$text = "<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<meta http-equiv=\"pragma\" content=\"no-cache\">
<meta http-equiv=\"cache-control\" content=\"no-cache, must-revalidate\">
<meta http-equiv=\"expires\" content=\"0\">
<meta http-equiv=\"last-modified\" content=\"\">
</head>
<body style=\"margin: 0; padding: 0; border-collapse: collapse;\">";
for ($i=0; $i<strlen($sCode); $i++)
$text .= "<img style=\"margin:0; padding:0; border: 0; border-collapse: collapse; width: 24px; height: 24px; position: absolute; top: 0; left: " . (24 * $i) . "px;\" src=\"imcpa_".$oNameList[substr($sCode, $i, 1)].".gif\" width=\"24\" height=\"24\">";
$text .= "</body></html>";
return $text;
}
/**
* Check the sent data
* @param sCode The correct code (string)
* @param dans The user's answer (string)
*/
function check($sCode, $ans)
{
global $oCharList;
if ($ans == "")
return '-1';
for ($i=0; $i<strlen($sCode); $i++)
if ($oCharList[substr(strtoupper($sCode), $i, 1)] != substr(strtoupper($ans), $i, 1))
return '-1';
return '0';
}
}
/**
* Provide support for sending and saving a cart order as well as checking the coupon codes
*/
class ImCart {
/**
* Save the order data with the following structure:
* "orderNo": "",
* "userInvoiceData": {},
* "userShippingData": {},
* "shipping": {
* "name": "",
* "description": "",
* "email_text": "",
* "price": "",
* "rawPrice":
* "vat":""
* "rawVat":
* },
* "payment": {
* "name": "",
* "description":"",
* "price": "",
* "rawPrice":""
* "email_text": "",
* "vat": "",
* "rawVat":""
* "html": ""
* },
* "products": [{
* "name": "",
* "description": "",
* "option": "",
* "suboption": "",
* "rawSinglePrice": "",
* "rawPrice": "",
* "rawFullPrice": "",
* "singlePrice": "",
* "singleFullPrice": "",
* "price": "",
* "fullPrice": "",
* "quantity": "",
* "vat": ""
* }],
* "rawTotalPrice": "",
* "rawTalVat": "",
* "totalPrice": "",
* "totalVat": "",
* "currency": ""
* @var array
*/
var $orderData;
/**
* Contains the cart settings
* @var array
*/
var $settings = array(
'force_sender' => false,
'email_opening' => '',
'email_closing' => '',
'useCSV' => false,
'header_bg_color' => '#FFD34F',
'header_text_color' => '#404040',
'cell_bg_color' => '#FFFFFF',
'cell_text_color' => '#000000',
'border_color' => '#D3D3D3',
'owner_email' => '',
'vat_type' => 'none'
);
function setSettings($data)
{
$this->settings = $data;
}
function setOrderData($data)
{
// Sanitize the form data
if (isset($data['userInvoiceData'])) {
foreach ($data['userInvoiceData'] as $key => $value) {
if (isset($value['value']) && isset($value['label'])) {
$data['userInvoiceData'][$key] = array(
"label" => strip_tags($value['label']),
"value" => strip_tags($value['value'])
);
}
}
}
if (isset($data['userShippingData'])) {
foreach ($data['userShippingData'] as $key => $value) {
if (isset($value['value']) && isset($value['label'])) {
$data['userShippingData'][$key] = array(
"label" => strip_tags($value['label']),
"value" => strip_tags($value['value'])
);
}
}
}
$this->orderData = $data;
}
/**
* Send the order email
*
* @param boolean $isOwner true to send the owner's email
* @param string $from from address
* @param string $to to address
*
* @return boolean
*/
function sendEmail($isOwner, $from, $to)
{
global $ImMailer;
$separationLine = "<tr><td colspan=\"2\" style=\"margin: 10px 0; height: 10px; font-size: 0.1px; border-bottom: 1px solid [email:emailBackground];\">&nbsp;</td></tr>\n";
$opt = 0;
$vat = 0;
$userDataTxt = "";
$userDataHtml = "";
$userDataCSVH = Array();
$userDataCSV = Array();
$shippingDataTxt = "";
$shippingDataHtml = "";
$shippingDataCSVH = Array();
$shippingDataCSV = Array();
$orderDataTxt = "";
$orderDataHTML = "";
$orderDataCSV = "";
//
// Set the invoice data
//
if (isset($this->orderData['userInvoiceData']) && is_array($this->orderData['userInvoiceData'])) {
$i = 0;
foreach ($this->orderData['userInvoiceData'] as $key => $value) {
if (trim($value['value']) != "") {
// Is it an email?
if (preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])' . '(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', $value['value'])) {
$f = "\n\t\t\t\t<td><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['label']) . ":</b></td>\n\t\t\t\t<td><a href=\"mailto:" . $value['value'] . "\">". $value['value'] . "</a></td>";
} else if (preg_match('/^http[s]?:\/\/[a-zA-Z0-9\.\-]{2,}\.[a-zA-Z]{2,}/', $value['value'])) {
// Is it an URL?
$f = "\n\t\t\t\t<td><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['label']) . ":</b></td>\n\t\t\t\t<td><a href=\"" . $value['value'] . "\">". $value['value'] . "</a></td>";
} else {
$f = "\n\t\t\t\t<td><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['label']) . ":</b></td>\n\t\t\t\t<td>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['value']) . "</td>";
}
$userDataTxt .= $value['label'] . ": " . $value['value'] . "\n";
$userDataHtml .= "\n\t\t\t<tr" . ($i%2 ? " bgcolor=\"[email:bodyBackgroundOdd]\"" : "") . ">" . $f . "\n\t\t\t</tr>";
$userDataCSVH[] = $value['label'];
$userDataCSV[] = $value['value'];
$i++;
}
}
if ($userDataHtml != "")
$userDataHtml = "\n\t\t<table width=\"100%\" style=\"font: inherit;\">" . $userDataHtml . "\n\t\t</table>";
}
//
// Set the shipping data
//
if (isset($this->orderData['userShippingData']) && is_array($this->orderData['userShippingData'])) {
$i = 0;
foreach ($this->orderData['userShippingData'] as $key => $value) {
if (trim($value['value']) != "") {
// Is it an email?
if (preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])' . '(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', $value['value'])) {
$f = "\n\t\t\t\t<td><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['label']) . ":</b></td>\n\t\t\t\t<td><a href=\"mailto:" . $value['value'] . "\">". $value['value'] . "</a></td>";
} else if (preg_match('/^http[s]?:\/\/[a-zA-Z0-9\.\-]{2,}\.[a-zA-Z]{2,}/', $value['value'])) {
// Is it an URL?
$f = "\n\t\t\t\t<td><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['label']) . ":</b></td>\n\t\t\t\t<td><a href=\"" . $value['value'] . "\">". $value['value'] . "</a></td>";
} else {
$f = "\n\t\t\t\t<td><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['label']) . ":</b></td>\n\t\t\t\t<td>" . str_replace(array("\\'", '\\"'), array("'", '"'), $value['value']) . "</td>";
}
$shippingDataTxt .= $value['label'] . ": " . $value['value'] . "\n";
$shippingDataHtml .= "\n\t\t\t<tr" . ($i%2 ? " bgcolor=\"[email:bodyBackgroundOdd]\"" : "") . ">" . $f . "\n\t\t\t</tr>";
$shippingDataCSVH[] = $value['label'];
$shippingDataCSV[] = $value['value'];
$i++;
}
}
if ($shippingDataHtml != "")
$shippingDataHtml = "\n\t\t<table width=\"100%\" style=\"font: inherit;\">" . $shippingDataHtml . "\n\t\t</table>";
}
$userDataCSV = @implode(";", $userDataCSVH) . "\n" . @implode(";", $userDataCSV);
$shippingDataCSV = @implode(";", $shippingDataCSVH) . "\n" . @implode(";", $shippingDataCSV);
//
// Set the products data
//
if (isset($this->orderData['products']) && is_array($this->orderData['products'])) {
$i = 0;
foreach ($this->orderData['products'] as $key => $value)
$opt = (isset($value["option"]) && $value["option"] != "null");
$vat = ($this->settings['vat_type'] != "none");
$colspan = 3 + ($opt ? 1 : 0) + ($vat ? 1 : 0);
$orderDataHTML = "<table cellpadding=\"5\" width=\"100%\" style=\"font: inherit; border-collapse: collapse;\">
<tr bgcolor=\"[email:bodyBackgroundOdd]\">
<td style=\"border: 1px solid [email:bodyBackgroundBorder];\">
<b>" . l10n("cart_name") . "</b>
</td>" .
($opt ?
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; min-width: 80px;\">
<b>" . l10n("product_option") . "</b>
</td>" : "") .
"<td style=\"border: 1px solid [email:bodyBackgroundBorder];\">
<b>" . l10n("cart_qty") . "</b>
</td>
<td style=\"border: 1px solid [email:bodyBackgroundBorder]; min-width: 70px;\">
<b>" . l10n("cart_price") . "</b>
</td>" .
($vat ?
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; min-width: 70px;\">
<b>" . ($this->settings['vat_type'] == "included" ? l10n("cart_vat_included") : l10n("cart_vat")) ."</b>
</td>" : "") .
"<td style=\"border: 1px solid [email:bodyBackgroundBorder];\">
<b>" . l10n("cart_subtot") . "</b>
</td>
</tr>\n";
$orderDataCSV = l10n("cart_name") . ";" . l10n("cart_descr") . ";" . ($opt ? l10n("product_option") . ";" : "") . l10n("cart_qty") . ";" . l10n("cart_price") . ";" . ($vat ? l10n("cart_vat") .";" : "") . l10n("cart_subtot");
foreach ($this->orderData['products'] as $key => $value) {
// CSV
$orderDataCSV .= "\n"
. strip_tags(str_replace(array("\n", "\r"), "", $value["name"])) . ";"
. strip_tags(str_replace(array("\n", "\r"), "", $value["description"])) . ";"
. (($opt && $value["option"] != "null") ? $value["option"] . ( $value["suboption"] != "null" ? $value["suboption"] . ";" : "") : "")
. $value["quantity"] . ";"
. ($this->settings['vat_type'] == "excluded" ? $value["singlePrice"] : $value['singlePricePlusVat']) . ";"
. ($vat ? $value["vat"] .";" : "")
. ($this->settings['vat_type'] == "excluded" ? $value["price"] : $value['pricePlusVat']);
// Txt
$orderDataTxt .=
strip_tags(str_replace(array("\n", "\r"), "", $value["name"]))
. (($opt && $value["option"] != "null") ? " " . $value["option"] . ( $value["suboption"] != "null" ? " " . $value["suboption"] : "") : "")
. "- " . strip_tags(str_replace(array("\n", "\r"), "", $value["description"])) . "\n "
. $value["quantity"] . " x "
. ( $this->settings['vat_type'] == "excluded" ?
"(" . $value["singlePrice"] . " + " . l10n("cart_vat") . " " . $value["vat"] . ")"
:
$value["singlePricePlusVat"]
)
. " = " . ($this->settings['vat_type'] == "excluded" ? $value["price"] : $value['pricePlusVat']) . "\n\n";
// HTML
$orderDataHTML .= "\n\t\t\t\t<tr valign=\"top\" style=\"vertical-align: top\"" . ($i%2 ? " bgcolor=\"#EEEEEE\"" : "") . ">
<td style=\"border: 1px solid [email:bodyBackgroundBorder];\">" . $value["name"] . "<br />" . $value["description"] . "</td>" .
($opt ? "<td style=\"border: 1px solid [email:bodyBackgroundBorder];\">" . (($value["option"] != "null") ? $value["option"] . (($value["suboption"] != "null") ? $value["suboption"] : "") : "") . "</td>" : "") .
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $value["quantity"] . "</td>" .
($this->settings['vat_type'] == "excluded" ?
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . ($value["singlePrice"] == $value['singleFullPrice'] ? $value['singlePrice'] : $value['singlePrice'] . ' <span style="text-decoration: line-through;">' . $value['singleFullPrice'] . "</span>") . "</td>"
:
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . ($value["singlePricePlusVat"] == $value['singleFullPricePlusVat'] ? $value['singlePricePlusVat'] : $value['singlePricePlusVat'] . ' <span style="text-decoration: line-through;">' . $value['singleFullPrice'] . "</span>") . "</td>"
)
.
($vat ? "<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $value["vat"] ."</td>" : "") .
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . ($this->settings['vat_type'] == "excluded" ? $value["price"] : $value['pricePlusVat']) . "</td>
</tr>\n";
$i++;
}
}
//
// Shipping
//
if (isset($this->orderData['shipping']) && is_array($this->orderData['shipping'])) {
$orderDataHTML .= "\n\t\t\t<tr>" .
($this->settings['vat_type'] != "none" ?
"<td colspan=\"" . ($colspan - 1) . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . l10n('cart_shipping') . ": " . $this->orderData['shipping']['name'] . "</td>" .
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $this->orderData['shipping']['vat'] . "</td>"
:
"<td colspan=\"" . $colspan . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . l10n('cart_shipping') . ": " . $this->orderData['shipping']['name'] . "</td>"
)
. "<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . ($this->settings['vat_type'] == "excluded" ? $this->orderData['shipping']['price'] : $this->orderData['shipping']['pricePlusVat']) . "</td>
</tr>";
$orderDataTxt .= "\n" . l10n('cart_shipping') . " - " . $this->orderData['shipping']['name'] . ": " . ($this->settings['vat_type'] == "excluded" ? $this->orderData['shipping']['price'] : $this->orderData['shipping']['pricePlusVat']);
}
//
// Payment
//
if (isset($this->orderData['payment']) && is_array($this->orderData['payment'])) {
$orderDataHTML .= "\n\t\t\t<tr>" .
($this->settings['vat_type'] != "none" ?
"<td colspan=\"" . ($colspan - 1) . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . l10n('cart_payment') . ": " . $this->orderData['payment']['name'] . "</td>" .
"<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $this->orderData['payment']['vat'] . "</td>"
:
"<td colspan=\"" . $colspan . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . l10n('cart_payment') . ": " . $this->orderData['payment']['name'] . "</td>"
)
. "<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . ($this->settings['vat_type'] == "excluded" ? $this->orderData['payment']['price'] : $this->orderData['payment']['pricePlusVat']) . "</td>
</tr>";
$orderDataTxt .= "\n" . l10n('cart_payment') . " - " . $this->orderData['payment']['name'] . ": " . ($this->settings['vat_type'] == "excluded" ? $this->orderData['payment']['price'] : $this->orderData['payment']['pricePlusVat']);
}
//
// Total amounts
//
switch ($this->settings['vat_type']) {
case "excluded":
$orderDataHTML .= "\n\t\t\t<tr>
<td colspan=\"" . $colspan . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right; font-weight: bold;\">" . l10n('cart_vat') . "</td>
<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $this->orderData['totalVat'] . "</td>
</tr>";
$orderDataHTML .= "\n\t\t\t<tr>
<td colspan=\"" . $colspan . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right; font-weight: bold;\">" . l10n('cart_total_vat') . "</td>
<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $this->orderData['totalPricePlusVat'] . "</td>
</tr>";
$orderDataTxt .= "\n" . l10n('cart_vat') . ": " . $this->orderData['totalVat'];
$orderDataTxt .= "\n" . l10n('cart_total_vat') . ": " . $this->orderData['totalPricePlusVat'];
break;
case "included":
$orderDataHTML .= "\n\t\t\t<tr>
<td colspan=\"" . $colspan . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right; font-weight: bold;\">" . l10n('cart_total_vat') . "</td>
<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $this->orderData['totalPricePlusVat'] . "</td>
</tr>";
$orderDataHTML .= "\n\t\t\t<tr>
<td colspan=\"" . $colspan . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right; font-weight: bold;\">" . l10n('cart_vat_included') . "</td>
<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $this->orderData['totalVat'] . "</td>
</tr>";
$orderDataTxt .= "\n" . l10n('cart_total_vat') . ": " . $this->orderData['totalPricePlusVat'];
$orderDataTxt .= "\n" . l10n('cart_vat_included') . ": " . $this->orderData['totalVat'];
break;
case "none":
$orderDataHTML .= "\n\t\t\t<tr>
<td colspan=\"" . $colspan . "\" style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right; font-weight: bold;\">" . l10n('cart_total_price') . "</td>
<td style=\"border: 1px solid [email:bodyBackgroundBorder]; text-align: right;\">" . $this->orderData['totalPricePlusVat'] . "</td>
</tr>";
$orderDataTxt .= "\n" . l10n('cart_total_price') . ": " . $this->orderData['totalPricePlusVat'];
break;
}
$orderDataHTML .= "</table>";
$txtMsg = "";
$htmlMsg = "<table border=0 width=\"100%\" style=\"font: inherit;\">\n";
//
// Order number
//
$htmlMsg .= "<tr><td colspan=\"2\" style=\"text-align: center; font-weight: bold;font-size: 1.11em\">" . l10n('cart_order_no') . ": " . $this->orderData['orderNo'] . "</td></tr>";
$txtMsg .= str_replace("<br>", "\n", l10n('cart_order_no') . ": " . $this->orderData['orderNo']);
//
// Opening message
//
if (!$isOwner) {
$htmlMsg .= "\n<tr><td colspan=\"2\">" . $this->settings['email_opening'] . "</td></tr>";
$txtMsg .= "\n\n" . strip_tags(str_replace("<br />", "\n", $this->settings['email_opening']));
}
// Customer's data
if ($shippingDataHtml != "") {
$htmlMsg .= "\n<tr style=\"vertical-align: top\" valign=\"top\">\n\t<td style=\"width: 50%; padding: 20px 0;\">\n\t\t<h3 style=\"font-size: 1.11em\">" . l10n('cart_vat_address') . "</h3>\n\t\t" . $userDataHtml . "\n\t</td>";
$htmlMsg .= "\n\t<td style=\"width: 50%; padding: 20px 0;\">\n\t\t<h3 style=\"font-size: 1.11em\">" . l10n('cart_shipping_address') . "</h3>\n\t\t" . $shippingDataHtml . "</td>\n\t</tr>";
$txtMsg .= "\n" . str_replace("<br />", "\n", l10n('cart_vat_address') . "\n" . $userDataTxt);
$txtMsg .= "\n" . str_replace("<br />", "\n", l10n('cart_shipping_address') . "\n" . $shippingDataTxt);
} else {
$htmlMsg .= "\n<tr>\n\t<td colspan=\"2\" style=\"padding: 20px 0 0 0;\">\n\t\t<h3 style=\"font-size: 1.11em\">" . l10n('cart_vat_address') . "/" . l10n('cart_shipping_address') . "</h3>\n\t\t" . $userDataHtml . "</td>\n</tr>";
$txtMsg .= "\n" . str_replace("<br />", "\n", l10n('cart_vat_address') . "/" . l10n('cart_shipping_address') . "\n" . $userDataTxt);
}
$htmlMsg .= $separationLine;
// Products
$htmlMsg .= "<tr><td colspan=\"2\" style=\"padding: 5px 0 0 0;\"><h3 style=\"font-size: 1.11em\">" . l10n('cart_product_list') . "</h3>" . $orderDataHTML . "</td></tr>";
$txtMsg .= "\n\n" . str_replace("<br />", "\n", l10n('cart_product_list') . "\n" . $orderDataTxt);
$htmlMsg .= $separationLine;
// Payment
if (isset($this->orderData['payment']) && is_array($this->orderData['payment'])) {
$htmlMsg .= "<tr>
<td colspan=\"2\" style=\"padding: 5px 0 0 0;\">
<h3 style=\"font-size: 1.11em\">" . l10n('cart_payment') . "</h3>" .
nl2br($this->orderData['payment']['name']) .( !$isOwner ? '<br />' . nl2br($this->orderData['payment']['email_text']) . ($this->orderData['payment']['html'] != "" ? '<div style="text-align: center; margin-top: 20px;">' . $this->orderData['payment']['html'] . '</div>' : "") : "" ) .
"</td>
</tr>";
$txtMsg .= "\n\n" . str_replace("<br />", "\n", l10n('cart_payment') . "\n" . $this->orderData['payment']['name'] . ( !$isOwner ? "\n" . $this->orderData['payment']['email_text'] : "" ));
$htmlMsg .= $separationLine;
}
// Shipping
if (isset($this->orderData['shipping']) && is_array($this->orderData['shipping'])) {
$htmlMsg .= "<tr>
<td colspan=\"2\" style=\"padding: 5px 0 0 0;\">
<h3 style=\"font-size: 1.11em\">" . l10n('cart_shipping') . "</h3>" .
nl2br($this->orderData['shipping']['name']) . ( !$isOwner ? '<br />' . nl2br($this->orderData['shipping']['email_text']) : "" ) .
"</td>
</tr>";
$txtMsg .= "\n\n" . str_replace("<br />", "\n", l10n('cart_shipping') . "\n" . $this->orderData['shipping']['name'] . ( !$isOwner ? "\n" . $this->orderData['shipping']['email_text'] : "" ));
}
//
// Closing message
//
if (!$isOwner) {
$htmlMsg .= $separationLine;
$htmlMsg .= "\n<tr><td colspan=\"2\" style=\"padding: 5px 0 0 0;\">" . $this->settings['email_closing'] . "</td></tr>";
$txtMsg .= "\n\n" . strip_tags(str_replace("<br />", "\n", $this->settings['email_closing']));
}
// Close the html table
$htmlMsg .= "</table>\n";
$attachments = array();
if ($this->settings['useCSV'] && $isOwner) {
$txtMsg .= $userDataCSV . "\n" . $orderDataCSV;
$attachments[] = array("name" => "user_data.csv", "content" => $userDataCSV, "mime" => "text/csv");
$attachments[] = array("name" => "order_data.csv", "content" => $orderDataCSV, "mime" => "text/csv");
}
return $ImMailer->send($from, $to, l10n('cart_order_no') . " " . $this->orderData['orderNo'], $txtMsg, $htmlMsg, $attachments);
}
/**
* Send the order email to the owner
* @return boolean
*/
function sendOwnerEmail()
{
return $this->sendEmail(true, $this->settings['owner_email'], $this->settings['owner_email']);
}
/**
* Send the order email to the customer
* @return boolean
*/
function sendCustomerEmail()
{
return $this->sendEmail(false, $this->settings['owner_email'], $this->orderData['userInvoiceData']['Email']['value']);
}
}
/**
* This file stores the class used to add/remove/edit comments
*
* @category X5engine
* @package X5engine
* @license Copyright by Incomedia http://incomedia.eu
* @link http://websitex5.com
*/
/**
* Use this class to store comments
*
* @category X5engine
* @package X5engine
* @license Copyright by Incomedia http://incomedia.eu
* @link http://websitex5.com
*/
class ImComment
{
var $comments = array();
var $error = 0;
/**
* Get the comments from a file
*
* @param string $file The source file path
*
* @return void
*/
function loadFromXML($file)
{
if (!file_exists($file)) {
$this->comments = array();
return;
}
$xmlstring = @file_get_contents($file);
if (strpos($xmlstring, "<?xml") !== false) {
$xml = new imXML();
// Remove the garbage (needed to avoid loosing comments when the xml string is malformed)
$xmlstring = preg_replace('/<([0-9]+)>.*<\/\1>/i', '', $xmlstring);
$xmlstring = preg_replace('/<comment>\s*<\/comment>/i', '', $xmlstring);
$comments = $xml->parse_string($xmlstring);
if ($comments !== false && is_array($comments)) {
$tc = array();
if (!isset($comments['comment'][0]) || !is_array($comments['comment'][0]))
$comments['comment'] = array($comments['comment']);
for ($i = 0; $i < count($comments['comment']); $i++) {
foreach ($comments['comment'][$i] as $key => $value) {
$tc[$i][$key] = str_replace(array("\\'", '\\"'), array("'", '"'), htmlspecialchars_decode($value));
}
}
$this->comments = $tc;
} else {
// The comments cannot be retrieved. The XML is jammed.
// Do a backup copy of the file and then reset the xml.
// Hashed names ensure that a file is not copied more than once
$n = $file . "_version_" . md5($xmlstring);
if (!@file_exists($n))
@copy($file, $n);
$this->comments = array();
}
} else {
$this->loadFromOldFile($file);
}
}
/**
* Get the comments from a v8 comments file
*
* @param string $file The source file path
*
* @return void
*/
function loadFromOldFile($file)
{
if (@file_exists($file)) {
$f = @file_get_contents($file);
$f = explode("\n", $f);
for ($i = 0;$i < count($f)-1; $i += 6) {
$c[$i/6]['name'] = stripslashes($f[$i]);
$c[$i/6]['email'] = $f[$i+1];
$c[$i/6]['url'] = $f[$i+2];
$c[$i/6]['body'] = stripslashes($f[$i+3]);
$c[$i/6]['timestamp'] = $f[$i+4];
$c[$i/6]['approved'] = $f[$i+5];
$c[$i/6]['rating'] = 0;
}
return $this->comments = $c;
} else {
return $this->comments = array();
}
}
/**
* Save the comments in a xml file
*
* @param string $file The destination file path
*
* @return boolean
*/
function saveToXML($file)
{
// If the count is 0, delete the file and exit
if (count($this->comments) === 0) {
if (@file_exists($file))
@unlink($file);
return true;
}
// If the folder doesn't exists, try to create it
$dir = @dirname($file);
if ($dir != "" && $dir != "/" && $dir != "." && $dir != "./" && !file_exists($dir)) {
@mkdir($dir, 777, true);
}
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$xml .= "<comments>\n";
$i = 0;
foreach ($this->comments as $comment) {
$txml = "";
foreach ($comment as $key => $value) {
// Well formed content only
if (!preg_match('/[0-9]+/', $key) && in_array(gettype($value), array('string', 'integer', 'double'))) {
$code = str_replace(array("\\'", '\\"', "\\\""), array("'", '"', "\""), preg_replace('/[\n\r\t]*/', '', nl2br($value)));
$txml .= "\t\t<" . $key . "><![CDATA[" . htmlspecialchars($code) . "]]></" . $key . ">\n";
}
}
if ($txml != "")
$xml .= "\t<comment>\n" . $txml . "\t</comment>\n";
}
$xml .= "</comments>";
if ((is_writable($file) || !file_exists($file))) {
if (!$f = @fopen($file, 'w+')) {
$this->error = -3;
return false;
} else {
if (flock($f, LOCK_EX)) {
$locked = 1;
}
if (fwrite($f, $xml) === false) {
$this->error = -4;
return false;
} else {
if($locked)
flock($f, LOCK_UN);
fclose($f);
$this->error = 0;
return true;
}
}
} else {
$this->error = -2;
return false;
}
}
/**
* Add a comment to a file
*
* @param array $comment the array of data to store
*
* @return void
*/
function add($comment)
{
foreach ($comment as $key => $value) {
$comment[$key] = $this->filterCode($value, true);
}
$this->comments[] = $comment;
}
/**
* Sort the array
*
* @param string $orderby Field to compare when ordering the array
* @param string $sort Sort by ascending (asc) or descending (desc) order
*
* @return void
*/
function sort($orderby = "", $sort = "desc")
{
if (count($this->comments) === 0)
return;
// Find where the comments has this field
// This is useful to order using a field which is not present in every comment (like the ts field, which is missing in the stars-only vote type)
$comment = null;
for ($i=0; $i < count($this->comments) && $comment == null; $i++) {
if (isset($this->comments[$i][$orderby]))
$comment = $this->comments[$i];
}
if ($comment === null)
return;
// Order the array
$symbol = (strtolower($sort) == "desc" ? '<' : '>');
$compare = 'if (!isset($a["' . $orderby . '"]) || !isset($b["' . $orderby . '"])) return 0;';
$compare .= 'if($a["' . $orderby . '"] == $b["' . $orderby . '"]) return 0; ';
// The orderable field is a timestamp
if (preg_match("/[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}/", $comment[$orderby]))
$compare .= 'if (strtotime($a["' . $orderby . '"]) ' . $symbol . ' strtotime($b["' . $orderby . '"])) return -1; return 1;';
// The orderable field is a number
else if (is_numeric($comment[$orderby]))
$compare .= 'if ($a["' . $orderby . '"] ' . $symbol . ' $b["' . $orderby . '"]) return -1; return 1;';
// The orderable field is a string
else if (is_string($comment[$orderby]))
$compare .= 'return strcmp($a["' . $orderby . '"], $b["' . $orderby . '"]);';
// Sort and return
usort($this->comments, create_function('$a, $b', $compare));
}
/**
* Get all the comments
*
* @param string $orderby Field to compare when ordering the array
* @param string $sort Sort by ascending (asc) or descending (desc) order
*
* @return array
*/
function getAll($orderby = "", $sort = "desc")
{
if ($orderby == "" || count($this->comments) === 0)
return $this->comments;
$this->sort($orderby, $sort);
return $this->comments;
}
/**
* Get the comment n
*
* @param integer $n The index of comment
*
* @return array
*/
function get($n)
{
if (isset($this->comments[$n]))
return $this->comments[$n];
return array();
}
/**
*...

Uf!

Es un archivo bastante extenso. Es una librería y tiene todos los formularios de la aplicación.

Tendrías que estudiarlo para poder manipular toda la aplicación pero para poder solucionar este problema tienes que analizar esta sentencia

if(!isset($_POST['imJsCheck']) || $_POST['imJsCheck'] != "jsactive" || 
(isset($_POST['imSpProt']) && $_POST['imSpProt'] != ""))
die(imPrintJsError());

Ya que el

die(imPrintJsError())

Genera el error que indicas

Esta es la función

unction imPrintJsError($docType = true)
{
if ($docType) {
$html
 = "<DOCTYPE><html><head><meta 
http-equiv=\"Refresh\" content=\"5;URL=" . $_SERVER['HTTP_REFERER'] . 
"\"></head><body>";
$html .= l10n('form_js_error');
$html .= "</body></html>";
} else {
$html = "<meta http-equiv=\"Refresh\" content=\"5;URL=" . $_SERVER['HTTP_REFERER'] . "\">";
$html .= l10n('form_js_error');
}
return $html;
}

Gracias ya lo pensé que si que es muy extenso y le estoy pidiendo un esfuerzo.

No entiendo lo que me quieres decir con esta ultima respuesta.

Si la solución es tan complicada, quizás lo mejor seria hacer los formularios de nuevo con dreamweaver?

Fijate en el ultimo código que te envíe, ese código es el que genera el meta tag que hace la alerta de javascript. Tu tienes que ver que sucede en tu código para que se genere esta alerta y según tu criterio verificar si es necesario eliminar esta alerta o solucionar el problema. Eso depende de ti.

Gracias otra vez. Ya puedes perdonar mi desconocimiento en este área pero me resulta imposible entender lo que intentas decirme.

He revisado por encima parte del código del archivo x5engine.php y localizo esto que no sé si tendrá que ver.

|-------------------------------------------
|
Check for new messages
|-------------------------------------------
*/
if
(isset($_POST['x5topicid']) && $_POST['x5topicid'] == $this->id) {
// Spam!
if ($_POST['prt'] !=
"")
return false;
// Javascript disabled
if
(!isset($_POST['imJsCheck']) || $_POST['imJsCheck'] != 'jsactive') {
echo
imPrintJsError(false);
return false;

En el archivo imEmailForm_mq3519wp.php

Elimina toda esta linea y prueba la aplicación

if(@$_POST['action'] != "check_answer") {
if(!isset($_POST['imJsCheck'])
 || $_POST['imJsCheck'] != "jsactive" || (isset($_POST['imSpProt']) 
&& $_POST['imSpProt'] != ""))
die(imPrintJsError());

He quitado la linea que me indicas y ahora no da el error pero se queda en blanco la pagina. Lo puedes ver accediendo http://centroeducacion.es/contacto.html

Quita todos los Símbolos @ de tu script ya que estos ocultan los errores que se generan e intenta generar de nuevo tu formulario y me cuentas si cambia en algo la situación.

Si genera un error envíame el texto completo.

Gracias he quitado todos los símbolos @ del archivo x5engine.php y lo he vuelto a subir.

He localizado un archivo de errores que indica (fijate en la ultima linea que es el error de hoy)

[19-Feb-2014 16:54:49 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 22

Si voy a dicha linea del código que si lo hago bien es la que cuenta dreamweaver solo hay un símbolo }.

Te paso en otra aclaración el código de imEmailForm_mq3519wp.php

ARCHIVO ERROR:

[18-Feb-2014 19:14:28 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 24
[18-Feb-2014 19:14:46 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 24
[18-Feb-2014 22:05:34 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 24
[18-Feb-2014 22:06:42 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 24
[18-Feb-2014 22:07:01 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 24
[18-Feb-2014 22:07:22 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 24
[18-Feb-2014 22:14:17 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 24
[18-Feb-2014 22:27:41 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 22
[19-Feb-2014 16:54:49 Europe/Madrid] PHP Parse error: syntax error, unexpected '}' in /home/gesnor2/public_html/centroeducacion.es/imemail/imEmailForm_mq3519wp.php on line 22

Reemplaza el archivo por este código

¿
<?php
if(substr(basename($_SERVER['PHP_SELF']), 0, 11) == "imEmailForm") {
include "../res/x5engine.php";
$form = new ImForm();
$form->setField('Nombre completo', $_POST['imObjectForm_2_1'], '', false);
$form->setField('Teléfono', $_POST['imObjectForm_2_2'], '', false);
$form->setField('Localidad', $_POST['imObjectForm_2_3'], '', false);
$form->setField('Provincia', $_POST['imObjectForm_2_4'], '', false);
$form->setField('E-mail', $_POST['imObjectForm_2_5'], '', false);
$form->setField('Comentarios', $_POST['imObjectForm_2_6'], '', false);
if(@$_POST['action'] != "check_answer") {
$form->mailToOwner($_POST['imObjectForm_2_5'] != "" ? $_POST['imObjectForm_2_5'] : '[email protected]', '[email protected]', 'CONSULTA WEB', '', true);
$form->mailToCustomer('[email protected]', $_POST['imObjectForm_2_5'], 'EDUCA-Apoyo Integral a la educación, formación y aprendizaje', 'Gracias por contactar con nosotros. En breve atenderemos su solicitud.
Si desea mayor agilidad puede contactar con nosotros telefónicamente en el 945 22 53 95 en horario de 15.30 a 20.00 horas.
EDUCA
Apoyo Integral a la educación, formación y aprendizaje', false);
@header('Location: ../index.html');
exit();
} else {
echo $form->checkAnswer(@$_POST['id'], @$_POST['answer']) ? 1 : 0;
}
}
// End of file

Tendía que funcionar al no perder la llave

Respuesta
1

¿Puedes poner un pantallazo de lo que te ocurre? ¿Qué version de Navegador estas usando? ¿Qué navegador estas usando?

A mi directamente no me ejecuta la pagina, parece que el formulaio no esta bien echo en PHP

Gracias experto.

Es cierto lo que comentas que no ejecuta en estos momentos, porque he hecho una prueba quitando una linea de código y sigue sin funcionar (lista de mi que he hecho la prueba en el archivo que te he comentado, ya lo siento y por favor disculpa).

Es problema que intento solucionar lo puedes ver ahora en otro formulario p.ej. en http://www.centroeducacion.es/boletin-educativo.html

No es problema del navegador, porque los tengo actualizados. Utilizo chrome e IE8

¿Tienes el código de esa pagina en PHP? Porque realmente no parece un error de javascript, ya que comprobando no existe ningún fallo por esa vía.

Lo único que hace es mandarme a esa web que tiene una redirección a la ultima web visitada (como si le dieras al botón "atrás" del navegador) y nada mas.

Respuesta
1

Consulta con ellos cual es el problema, y comprueba sobre todo que tienes javascript activado, si no no vasa poder ver prácticamente nada en la Web.

Saludos

Jorge Vila.

http://www.dreamweaver-tutoriales.com

http://www.facebook.com/ayzweb

Respuesta
1

No me da ningún problema, creo que no tienes activado javascript, ¿quizás usas internet explorer?

El formulario funciona correctamente, y en caso de no poder funcionar, sale el aviso.

Respuesta

Me gusta lo que compartió en este artículo, continúe compartiendo con nosotros información útil.

minecraft 2

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas