[GELÖST] [Tell-a-friend Tag] URL ändern

Hilfe zu Modulen und Tags
Post Reply
Pulli
Forum Members
Forum Members
Posts: 183
Joined: Fri Sep 12, 2008 9:16 am

[GELÖST] [Tell-a-friend Tag] URL ändern

Post by Pulli »

Hallo,

habe auf einer Seite den Tell a friend Tag eingesetzt. Soweit so gut. Nun wird jedoch im Textfeld (also da wo man auch noch eine Nachricht schreiben kann) ein Link zu der Seite bereits eingebettet. Ist ja auch super. Jedoch verweist dieser Link nur auf die spezielle Unterseite wo der Tag eingesetzt wurde.

Wie und wo kann ich die übernommene Adresse auf die Startseite ändern ?

Wäre super, wenn mir jemand eine kleine Hilfestellung geben könnte.

Danke und schöne Grüße
Marco
Last edited by Pulli on Fri Oct 31, 2008 7:38 am, edited 1 time in total.
NaN

Re: [Tell-a-friend Tag] URL ändern

Post by NaN »

Das wollte ich Dir letztens schon sagen, dass da die falsche Adresse drin steht.
Ich dachte, die hättest Du selber eingefügt.
Ich schätze da muss ich mal in den Quellcode schauen...
Pulli
Forum Members
Forum Members
Posts: 183
Joined: Fri Sep 12, 2008 9:16 am

Re: [Tell-a-friend Tag] URL ändern

Post by Pulli »

NaN wrote:
Das wollte ich Dir letztens schon sagen, dass da die falsche Adresse drin steht.
Ich dachte, die hättest Du selber eingefügt.
Ich schätze da muss ich mal in den Quellcode schauen...
nein von mir kommt das nicht. ich mein an sich ist das ja ne super sache, aber so natürlich weniger.

hatte auch schon mal in den genauen code geschaut und nichts gefunden, außer etlichen codes, mit denen ich nichts anfangen kann.

aber poste nachher mal was vom code...
Pulli
Forum Members
Forum Members
Posts: 183
Joined: Fri Sep 12, 2008 9:16 am

Re: [Tell-a-friend Tag] URL ändern

Post by Pulli »

ne also ich blick da nicht so richtig durch, wo ich die korrekte adresse eingeben muss.

anbei der komplette code des tell-a-friend tags:

Code: Select all

<?php

# CMSMS - CMS Made Simple
#
# (c)2004 by Ted Kulp (wishy@users.sf.net)
#
# This project's homepage is: http://cmsmadesimple.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function smarty_cms_function_tellafriend_form($params, &$smarty) {

    global $gCms;

    if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) 
    {
        $captcha =& $gCms->modules['Captcha']['object'];
    }


	if (empty($params['emailsubject'])){
		echo '<div class="formError">An email subject must be specified in order to use this plugin, using the format emailsubject="Your subject here"</div>';
		return;
	}else{
		$subject = $params['emailsubject'];
          $canned = $params['cannedtext'];
	}





	$style = true; // Use default styles
	if (FALSE == empty($params['style']) && $params['style'] === "false" ) $style = false; // Except if "false" given in params
	
	// Default styles
	$inputStyle = 'style="width:330px;border: 1px solid #999999; margin:0 0 5px 0;"'; // input boxes
	$taStyle = 'style="word-wrap:break-word; overflow-x:hidden; overflow-y:auto; width:330px; border: 1px solid black; margin:0 0 5px 0; font-size:1.2em; font-family:arial,helvetica,sans-serif;"'; // TextArea boxes
	$formStyle = 'style="line-height:90%;"'; // form
	$errorsStyle = 'style="color: #666666; background-color: #F6F8FB; font-weight: normal; margin: 5px;"'; // Errors box (div)
        $labelStyle = 'style="display:block; font-size:.1.2em; font-family:arial,helvetica,sans-serif;"';
        $buttonStyle = 'style="float:left; width:50%;"';
        $fieldsetStyle = 'style="padding:12px; border:1px solid #999999; text-align:left;"';
        $captchaStyle = 'style="margin-bottom:5px; text-align: center;"';

	$errors=$to=$name=$email=$message = '';


 $pageURL = "\r\n\r\nhttp";
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }

$message = $canned . $pageURL ;


	if($_SERVER['REQUEST_METHOD']=='POST'){
		if (!empty($_POST['subject'])) $subject = tafsanitize($_POST['subject']);
		if (!empty($_POST['to'])) $to = tafsanitize($_POST['to']);
		if (!empty($_POST['name'])) $name = tafsanitize($_POST['name']);
		if (!empty($_POST['email'])) $email = tafsanitize($_POST['email']);
		if (!empty($_POST['canned'])) $canned = $_POST['canned'];
		if (!empty($_POST['message'])) $message = $_POST['message'];
		
		if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) 
		{
		    if (!empty($_POST['captcha_resp'])) { $captcha_resp = $_POST['captcha_resp']; }
		}






		//Mail headers
		$extra = "From: $name <$email>\r\n";
		$charset = isset($gCms->config['default_encoding']) && $gCms->config['default_encoding'] != '' ? $gCms->config['default_encoding'] : 'utf-8';
		$extra .= "Content-Type: text/plain; charset=" . $charset . "\r\n";
		
		if (empty($name)) $errors .= "\t\t<li>" . 'Bitte geben Sie Ihren Namen ein' . "</li>\n";
		if (empty($email)) $errors .= "\t\t<li>" . 'Bitte geben Sie Ihre E-Mail-Adresse ein' . "</li>\n";
		elseif (!tafvalidEmail($email)) $errors .= "\t\t<li>" . 'Ihre E-Mail-Adresse ist nicht korrekt' . "</li>\n";
		if (empty($to)) $errors .= "\t\t<li>" . 'Bitte geben Sie die Empfänger Adresse ein' . "</li>\n";
		elseif (!tafvalidtoEmail($to)) $errors .= "\t\t<li>" . 'Empfänger Adresse ist nicht korrekt' . "</li>\n";
		if (empty($message)) $errors .= "\t\t<li>" . 'Bitte geben Sie eine Nachricht ein' . "</li>\n";
		if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha']))
		{
		    if (empty($captcha_resp)) $errors .= "\t\t<li>" . 'Please enter the text in the image' . "</li>\n";
		    elseif (! ($captcha->checkCaptcha($captcha_resp))) $errors .= "\t\t<li>" . 'The text from the image was not entered correctly' . "</li>\n";
		}
		
		if (!empty($errors)) {
			echo '<div class="formError" ' . (($style) ? $errorsStyle:'') . '>' . "\n";
						echo "\t<ul>\n";
			echo $errors;
			echo "\t</ul>\n";
			echo "</div>";
		}
		elseif (@mail($to, $subject, $message, $extra)) {
			echo '<div class="formMessage">Vielen Dank. Ihre Empfehlung wurde erfolgreich versendet.</div>' . "\n";
			return;
		}
		else {
			echo '<div class="formError" ' . (($style) ? $errorsStyle:'') . '>Leider konnte Ihre Empfehlung nicht versendet werden. Versuchen Sie es später noch einmal.</div>' . "\n";
			return;
		}
	}

    if (isset($_SERVER['REQUEST_URI'])) 
    {
	$action = $_SERVER['REQUEST_URI'];
    }
    else
    {
	$action = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '';
	if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') 
	{
	    $action .= '?'.$_SERVER['QUERY_STRING'];
	}
    }
?>

	<!-- TELLAFRIEND_FORM -->
	<form action="<?php echo $action ?>" class="tellafriendform" method="post" <?php echo ($style) ? $formStyle:''; ?>>
                 <fieldset <?php echo ($style) ? $fieldsetStyle:''; ?>>
                        
			<label for="name" <?php echo ($style) ? $labelStyle:''; ?> >Ihr Name :</label>
			<input type="text" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" <?php echo ($style) ? $inputStyle:''; ?>/>

			<label for="email" <?php echo ($style) ? $labelStyle:''; ?> >Ihre E-Mail-Adresse : </label>
			<input type="text" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" <?php echo ($style) ? $inputStyle:''; ?>/>

			<label for="to" <?php echo ($style) ? $labelStyle:''; ?> >Empfänger E-Mail-Adresse : </label>
			<input type="text" id="to" name="to" value="<?php echo htmlspecialchars($to); ?>" <?php echo ($style) ? $inputStyle:''; ?>/>

			<label for="message" <?php echo ($style) ? $labelStyle:''; ?> >Nachricht : </label>
			<textarea id="message" name="message" rows="5" cols="48" <?php echo ($style) ? $taStyle:''; ?>><?php echo $message; ?></textarea>

<?php
if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) 
{
?>
			<label for="captcha_resp" <?php echo ($style) ? $labelStyle:''; ?> >Enter the text from the image below : </label>
			<input type="text" id="captcha_resp" name="captcha_resp" value="" <?php echo ($style) ? $inputStyle:''; ?>/>

<?php
    echo "<div $captchaStyle>" . $captcha->getCaptcha() . '</div>';
}
?>

		        <input type="submit" class="button" value="senden" <?php echo ($style) ? $buttonStyle: ''; ?> /> 
                        <input type="reset"  class="button" value="zurücksetzen" <?php echo ($style) ? $buttonStyle: ''; ?> />
                 </fieldset>
	</form>
	<!-- END of TELLAFRIEND_FORM -->

<?php
}

function smarty_cms_help_function_tellafriend_form() {
	?>
	<h3>What does this do?</h3>
	<p>This tag renders a small "Tell a Friend" form, which automatically includes the URL of the page the form is on. The user fills in their name and email address, the recipients email address, and optionally a message. Pressing submit sends an email to the recipient.</p>
	<p>This tag is a mashup of the contact_form tag and some code <a href="http://forum.cmsmadesimple.org/index.php/topic,8827.0.html" target="_blank">posted in the forums</a> by <b>samalah</b>. This tag was created to offer something more formal than a mailto link, and something more spam-resistant than a plain form (through Captcha support).</p>
	<h3>How do I use it?</h3>
	<p>Just insert the tag into your template/page like: <code>{tellafriend_form emailsubject="Check out this page at foo.com!"}</code><br>
	<br>
</p>
	<h3>What parameters does it take?</h3>
	<ul>
		<li>emailsubject - The subject of the email that will be sent.</li>
		<li><em>(optional)</em>style - true/false, use the predefined styles. Default is true.</li>
		<li><em>(optional)</em>cannedtext - Used to include some default text in the message field. If you omit this, the message field will just contain the page URL.</li>
		<li><em>(optional)</em>captcha - true/false, use Captcha response test (Captcha module must be installed). Default is false.</li>
	</ul>
	</p>
	<?php
}

function smarty_cms_about_function_tellafriend_form() {
	?>
	<p>Author: Vaughn Teegarden <vaughn@vaughnsphotoart.com>, with heavy credit to Brett Batie <brett-cms@classicwebdevelopment.com> & Simon van der Linden <ifmy@geekbox.be> for their work on the contact_form tag, and to forum member "samalah" for the URL code.</p>
	<p>Version: 1.0 (20070308)</p>
	<p>
	Change History:<br/>
        <ul>
        <li>Initial publication of 1.0</li>
        </ul>
	</p>
	<?php
}

function tafsanitize($content){
	return str_replace(array("\r", "\n"), "", trim($content));
}

function tafvalidEmail($email) {
	if (!preg_match("/^([\w|\.|\-|_]+)@([\w||\-|_]+)\.([\w|\.|\-|_]+)$/i", $email)) {
		return false;
		exit;
	}
	return true;
}

function tafvalidtoEmail($to) {
	if (!preg_match("/^([\w|\.|\-|_]+)@([\w||\-|_]+)\.([\w|\.|\-|_]+)$/i", $to)) {
		return false;
		exit;
	}
	return true;
}

?>
NaN

Re: [Tell-a-friend Tag] URL ändern

Post by NaN »

Der Fehler liegt an dieser Stelle:

Code: Select all

 

$message = $canned . $pageURL;


Ändere das mal in folgendes (habs noch nicht getestet):

Code: Select all


$message = $canned . $gCms->config['root_url'];

Somit wird generell auf die Root-URL verwiesen (dürfte in der Regel die Startseite sein).
Pulli
Forum Members
Forum Members
Posts: 183
Joined: Fri Sep 12, 2008 9:16 am

Re: [Tell-a-friend Tag] URL ändern

Post by Pulli »

ja super...scheint zu funktionieren...danke
Post Reply

Return to “Module und Tags”