Aktuelle Version 0.1.6 von emergence und Snoopy
will be continued......
Input
Code: Alles auswählen
/**
* Comments v0.1.6
*
* INPUT
*
* @autor Martin Horwath <horwath@dayside.net>, Peter Beauvain <pbeauvain@web.de>
* @copyright dayside.net,Sommer & Partner 2004
* @lastmodified 2004-07-06
*/
// configuration
$cfg["tab"]["comments"] = $cfg['sql']['sqlprefix']."_comments"; // for syntax reasons only
if($db->query("SELECT * FROM ".$cfg["tab"]["comments"]." WHERE idclient =".$client." AND idlang = ".$lang)) {
// do something table exists
echo "Works...";
} else {
echo "error-> table: ".$cfg["tab"]["comments"]." does not exist<br>";
// init table creation
$sql= "CREATE TABLE ".$cfg["tab"]["comments"]." (
idcomments INT(10) NOT NULL default '0',
idclient INT(10) NOT NULL default '0',
idlang INT(10) NOT NULL default '0',
idart INT(10) NOT NULL default '0',
text text NOT NULL default '',
name varchar(64) NOT NULL,
email varchar(64) NOT NULL default '',
parentid INT(10) NOT NULL default '0',
vote INT(10) NOT NULL default '0',
status INT(10) NOT NULL default '0',
created datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (idcomments) )";
if ($db->query($sql)) {
// table successfully created
echo "init-> created table: ".$cfg["tab"]["comments"]."<br>";
} else {
echo "error-> table: ".$cfg["tab"]["comments"]."<br>";
}
$sql= "INSERT INTO ".$cfg["tab"]["sequence"]." (seq_name,nextid) VALUES ('".$cfg["tab"]["comments"]."','0')";
if ($db->query($sql)) {
// value successfully insert
echo "init-> value insert into ".$cfg["tab"]["sequence"]." - ".$cfg["tab"]["comments"]."<br>";
} else {
echo "error-> value: ".$cfg["tab"]["sequence"]." - ".$cfg["tab"]["comments"]."<br>";
}
}
// begin option table
echo "<table align=\"left\" cellpadding=\"0\" cellspacing=\"0\">";
/**
* option email notification on/off --> set recipient
*
* @CMS_VAR[1] = notification on/off
* @CMS_VAR[2] = set recipient
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-07-06
*/
echo "<tr valign=\"top\"><td width=\"150\">Emailbenachrichtigung: ";
echo "</td><td>Ja <INPUT TYPE=\"checkbox\" NAME=\"CMS_VAR[1]\" VALUE=\"1\" ";
if("CMS_VALUE[1]" == 1){echo "checked=checked"; };
echo "> An:</td><td>";
echo "<INPUT TYPE=\"text\" NAME=\"CMS_VAR[2]\" VALUE=\"";
if(("CMS_VALUE[1]") && ("CMS_VALUE[2]")){ echo "CMS_VALUE[2]"; } else { echo "eMail angeben !!"; };
echo "\"></td></tr>";
/**
* option ubb-editor on/off
*
* @CMS_VAR[3] = ubb-editor on/off
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-07-06
*/
echo "<tr valign=\"top\"><td width=\"150\">UBB-Editor Aktiviert: ";
echo "</td><td>Ja <INPUT TYPE=\"checkbox\" NAME=\"CMS_VAR[3]\" VALUE=\"true\" ";
if("CMS_VALUE[3]" == true){echo "checked=checked"; };
echo "<td></td></tr>";
//end option table
echo "</table>";
Output:
Code: Alles auswählen
<?
/**
* Comments v0.1.6
*
* OUTPUT
*
* @autor Martin Horwath <horwath@dayside.net>, Peter Beauvain <pbeauvain@web.de>
* @copyright dayside.net,Sommer & Partner 2004
* @lastmodified 2004-06-30
*/
// options UBB
$useUBB = "CMS_VALUE[3]"; // use ubb extention style
$imageUBB['other'] = "./images/";
$imageUBB['buttons'] = "./images/buttons/";
$imageUBB['smileys'] = "./images/smileys/";
// options display
$flatTree = false; // disable nesting levels
// configuration
$cfg["tab"]["comments"] = $cfg['sql']['sqlprefix']."_comments"; // for syntax reasons only
$clink = "front_content.php?idcat=$idcat&idart=$idart&lang=$lang&client=$client";
if ($edit) {
$clink = $sess->url($clink);
}
$debug = false;
// functions
if (!isset($comments_functions)) {
// only init once
$comments_functions = true;
/**
* SPAM safe email
*
* @param string $email
*
* @return $value
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-05-31
*/
function safeEmail($email)
{
return str_replace(array('@', '.'), array(' at ', ' dot '), $email);
}
/**
* Prepare comment for email notification
*
* @param string $source
*
* @return $source
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-05-31
*/
function prepMail($source)
{
global $imageUBB;
$source = eregi_replace('<br>','\n',$source);
$source = eregi_replace('<img src="'.$imageUBB['smileys'].'wink.png" border="0">',' ;-) ',$source);
$source = eregi_replace('<img src="'.$imageUBB['smileys'].'smile.png" border="0">',' :-) ',$source);
$source = eregi_replace('<img src="'.$imageUBB['smileys'].'cool.png" border="0">',' 8-) ',$source);
$source = eregi_replace('<img src="'.$imageUBB['smileys'].'look.png" border="0">',' info: ',$source);
$source = eregi_replace('<img src="'.$imageUBB['smileys'].'attention.png" border="0">',' ! ',$source);
$source = strip_tags($source);
return preg_replace('/<(.*?)>/ie', "'<'.delAttr('\\1').'>'", $source);
}
/**
* Delete unallowed tags
*
* @param string $source
*
* @return $value
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-05-31
*/
function delTags($source)
{
$allowedTags='<a><br><b><i><img><li><ol><p><strong><table><tr><td><font><th><u><ul>';
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie', "'<'.delAttr('\\1').'>'", $source);
}
/**
* Delete class or style definitions
*
* @param string $tagSource
*
* @return $value
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-05-31
*/
function delAttr($tagSource)
{
$stripAttrib = "' (style|class)=\"(.*?)\"'i";
$tagSource = stripslashes($tagSource);
$tagSource = preg_replace($stripAttrib, '', $tagSource);
return $tagSource;
}
/**
* Prevent long strings
*
* @param string $string
* @param string $seperator = " "
* @param int $maxlenght = 50
*
* @return $value
*
* @autor Martin Horwath <horwath@dayside.net>
* @modified 2004-06-23
*/
function shortenWords ($string, $seperator = " ", $maxlenght = 50 ) {
$c = 0;
for ($i=0; $i < strlen($string); $i++) {
if (($string[$i] == " ") or ($string[$i] == "\n") or ($string[$i] == "\r")) {
$c = 0;
}
if ($c > $maxlenght) {
$string = substr_replace($string, $seperator, $i, 0);
$i = $i+strlen($seperator);
$c = 0;
}
$c++;
}
return $string;
}
/**
* Cut comment after 100 words | prevent novel writers
*
* @param string $str
* @param string $char
* @return $shortStr
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-06-30
*/
function makeShorterText($str, $char)
{
$str = ereg_replace("[[:space:]]+", " ", $str);
$arrStr = explode(" ", $str);
$shortStr = "";
if (count($arrStr) > $char) {
for ($j = 0; $j <= $char; $j++) {
$shortStr .= $arrStr[$j]." ";
}
$shortStr .= "...";
}
else {
$shortStr = $str;
}
return $shortStr;
}
/**
* Parse UBB code
*
* @param string $ret
*
* @return $value
*
* @autor Peter Beauvain <pbeauvain@web.de>
* @modified 2004-05-28
*/
function parseUBB($ret)
{
global $imageUBB;
$ret = stripslashes($ret);
$pattern = array( '{\[b\](.*)\[/b\]}smUi',
'{\[u\](.*)\[/u\]}smUi',
'{\[i\](.*)\[/i\]}smUi',
'{\[ul\](.*)\[/ul\]}smUi',
'{\[li\](.*)\[/li\]}smUi',
'{\[url=(.*)\](.*)\[/url\]}smUi',
'{\[url\](.*)\[/url\]}smUi',
'{\[img\](.*)\[/img\]}smUi',
'{\[size=(.*)\](.*)\[/size\]}smUi',
'{\[color=(.*)\](.*)\[/color\]}smUi',
'{\[align=(.*)\](.*)\[/align\]}smUi',
'{\[\\\\\]}smUi',
'{\[center\](.*)\[/center\]}smUi',
'{\[(h[1-6]+)\](.*)\[/\\1\]}smUi',
'{\[email\](.*)\[/email\]}smUi',
'{\[fimg\](.*)\[/fimg\]}smUi',
'{\[fimg desc=(.*)\](.*)\[/fimg\]}smUi',
'{\[quote\](.*)\[/quote\]}smUi',
'{\[email\](.*)\[/email\]}smUi'
);
$replace = array( '<b>\\1</b>',
'<u>\\1</u>',
'<i>\\1</i>',
'<ul type="square">\\1</ul>',
'<li>\\1</li>',
'<a href="http://\\1" target="_blank">\\2</a>',
'<a href="http://\\1" target="_blank">\\1</a>',
'<img src="\\1" border="0"><span>',
'<span style="font-size: \\1px;">\\2</span>',
'<font color="\\1">\\2</font>',
'<div align="\\1">\\2</div>',
'\\\\'.'\n',
'<div align="center">\\1</div>',
'<\\1>\\2</\\1>',
'<a href="mailto:\\1">\\1</a>',
'<img src="'.$imageUBB['other'].'\\1" border="0">',
'<img src="'.$imageUBB['other'].'\\2" border="0" alt="\\1" onMouseOver="'."self.status='\\1'; return(true);".'" onMouseOut="'."self.status=''; return(true);".'">',
'<table width="90%" border="0" cellspacing="2" cellpadding="2" align="center" style="border: 1px dashed black;"><tr><td>Zitat:<br />\\1</td></tr></table>',
'<a href="http://mailto:\\1">\\1</a>'
);
$ret = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $ret);//umwandeln von Tags ">" in > etc. | @@ Peter Beauvain, 2004-05-25
$ret = preg_replace($pattern,$replace,$ret);
$ret = str_replace('http://http://','http://',$ret);
$ret = eregi_replace(";-\)|:wink:",'<img src="'.$imageUBB['smileys'].'wink.png" border="0">',$ret);
$ret = eregi_replace(":-\)|:smile:",'<img src="'.$imageUBB['smileys'].'smile.png" border="0">',$ret);
$ret = eregi_replace("8-\)|:cool:",'<img src="'.$imageUBB['smileys'].'cool.png" border="0">',$ret);
$ret = eregi_replace(":info:",'<img src="'.$imageUBB['smileys'].'look.png" border="0">',$ret);
$ret = eregi_replace(":!:",'<img src="'.$imageUBB['smileys'].'attention.png" border="0">',$ret);
return nl2br($ret);
}
/**
* Build comments tree
*
* @param int $parentid
* @param int $level = 0
*
* @return array $tree
*
* @autor Martin Horwath <horwath@dayside.net>
* @modified 2004-06-29
*/
function getCommentsTreeElements ($parentid, $level = 0, $mode = false) {
global $cfg, $idart, $client, $lang, $errorComments;
$errorComments = false;
$db = new DB_Contenido; // do not set global !!
if (!$mode) { // nested
$sql = "SELECT idcomments, created, status FROM ".$cfg["tab"]["comments"]." WHERE idclient =".$client." AND idlang = ".$lang." AND idart = ".$idart." AND parentid = '".$parentid."' ORDER BY created DESC ";
if($db->query($sql)) {
while ($db->next_record()) {
if (!isset($TreeElements)) {
$TreeElements = Array();
}
if ($subTree = getCommentsTreeElements($db->f("idcomments"), ($level+1))) {
$TreeElements[] = Array ( 'level' => $level, 'idcomment' => $db->f("idcomments"), 'status' => $db->f("status"), 'created' => $db->f("created"), 'sub' => $subTree );
} else {
$TreeElements[] = Array ( 'level' => $level, 'idcomment' => $db->f("idcomments"), 'status' => $db->f("status"), 'created' => $db->f("created") );
}
}
if (isset($TreeElements)) {
return $TreeElements;
} else {
return false;
}
} else {
$errorComments = true;
}
} else { // flat mode
$sql = "SELECT idcomments, created, status FROM ".$cfg["tab"]["comments"]." WHERE idclient =".$client." AND idlang = ".$lang." AND idart = ".$idart." ORDER BY created DESC ";
if($db->query($sql)) {
while ($db->next_record()) {
if (!isset($TreeElements)) {
$TreeElements = Array();
}
$TreeElements[] = Array ( 'level' => $level, 'idcomment' => $db->f("idcomments"), 'status' => $db->f("status"), 'created' => $db->f("created") );
}
if (isset($TreeElements)) {
return $TreeElements;
} else {
return false;
}
} else {
$errorComments = true;
}
}
}
/**
* show comments
*
* @param array $tree
*
* @return
*
* @autor Martin Horwath <horwath@dayside.net>
* @modified 2004-06-29
*/
function showComments ($commentsTree, $level = 0) {
global $cfg, $edit, $clink, $flatTree, $useUBB;
$db = new DB_Contenido; // do not set global !!
foreach ($commentsTree as $commentsNode => $treeElement) {
$sql = "SELECT * FROM ".$cfg["tab"]["comments"]." WHERE idcomments =".$treeElement['idcomment']."";
$db->query($sql);
$db->next_record(); // there can be only one
// echo "level:".$treeElement['level']."->".$db->f("name")."|"; // debug info
if ($db->f("status") == '1' || $edit) { // only show online elements
// generate output variable
$comment['template'] = '<a name="comment'.$db->f("idcomments").'"></a><table width="410" style="font-family:verdana, arial, sans-serif; font-size:11px;"><tr valign="top"><td>%s</td><td>%s</td></table>';
if ($db->f("email") != "") {
$comment['header'] = '<a href="mailto:'.safeEmail($db->f("email")).'">%s</a>';
} else {
$comment['header'] = '%s';
}
$comment['header'] = sprintf($comment['header'],$db->f("name"));
$comment['header'].= " schrieb am ".date("d.m.Y \u\m G:i:s",strtotime($db->f("created"))); // reformat stored datestring
$comment['text'] = parseUBB($db->f("text"));
$comment['complete'] = "<p><b>".$comment['header']."</b><br>\n".$comment['text']."</p>\n";
if (!$flatTree) {
$clinkform = $clink."&cmode=form&creplyto=".$db->f("idcomments");
$comment['complete'].= '<p><a href="'.$clinkform.'" style="font-family:verdana, arial, sans-serif; font-size:11px;">Auf diesen Kommentar antworten</a></p>';
}
if ($edit) {
$clinkdelete = $clink."&cmode=delete&commentid=".$db->f("idcomments");
$comment['complete'].= '<a href="'.$clinkdelete.'" style="font-family:verdana, arial, sans-serif; font-size:11px;">Delete <img src="'.$cfg['path']['contenido_fullhtml'].'images/delete.gif" border="0"></a>';
if ($db->f("status") == '0') {
$clinkonline = $clink."&cmode=online&commentid=".$db->f("idcomments");
$comment['complete'].= ' | <a href="'.$clinkonline.'" style="font-family:verdana, arial, sans-serif; font-size:11px;">Set Online <img src="'.$cfg['path']['contenido_fullhtml'].'images/offline.gif" border="0"></a>';
} else {
$clinkoffline = $clink."&cmode=offline&commentid=".$db->f("idcomments");
$comment['complete'].= ' | <a href="'.$clinkoffline.'" style="font-family:verdana, arial, sans-serif; font-size:11px;">Set Offline <img src="'.$cfg['path']['contenido_fullhtml'].'images/online.gif" border="0"></a>';
}
}
$comment['complete'].= "<hr size=\"1\">\n";
$comment['seperator'] = "";
if ($level > 0) {
for ($counter = 0; $counter <= $level; $counter++) {
$comment['seperator'] .= " ";
}
}
// print output
echo sprintf($comment['template'],$comment['seperator'],$comment['complete']);
if (isset($treeElement['sub'])) {
showComments ($treeElement['sub'], ($level+1));
}
} else {
if (isset($treeElement['sub'])) {
showComments ($treeElement['sub'], $level);
}
}
}
}
}
if ($cmode == "delete" && $edit) {
// check for parentid entries and update them
$sql = "SELECT parentid FROM ".$cfg["tab"]["comments"]." WHERE idcomments = $commentid";
$db->query($sql);
$db->next_record();
$sql = "UPDATE ".$cfg["tab"]["comments"]." SET parentid=".$db->f("parentid")." WHERE parentid = $commentid";
$db->query($sql);
$sql = "DELETE FROM ".$cfg["tab"]["comments"]." WHERE idcomments = $commentid";
if ($db->query($sql)) {
echo "Deleted<br>";
} else {
echo "Delete failed<br>";
}
unset($cmode);
}
if (($cmode == "online" || $cmode == "offline") && $edit) {
($cmode == "online") ? $cmode = 1 : $cmode = 0;
$sql = "UPDATE ".$cfg["tab"]["comments"]." SET `status`=$cmode WHERE idcomments = $commentid";
if ($db->query($sql)) {
echo "Updated<br>";
} else {
echo "Update failed<br>";
}
unset($cmode);
}
if (trim($commentname) == "" && trim($commentemail) == "" && trim($commenttext) == "" && $cmode == "add" ) unset($cmode); // do nothing
if ($cmode == "add") {
// check if all entries are correct otherwise show form
if (trim($commentname) == "") {
echo "Bitte einen Namen eingeben.<br>";
$cmode = "form";
}
if (trim($commentemail) != "") {
if (!preg_match("/^[\w-]+((\.|\+)[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/i",$commentemail)) {
echo "Bitte geben Sie eine korrekte Email Adresse an.<br>";
$cmode = "form";
}
}
if (trim($commenttext) == "") {
echo "Sie haben kein Kommentar geschrieben.<br>";
$cmode = "form";
}
if ($cmode == "add") {
$commenttext = shortenWords(delTags($commenttext),"- \r\n",48); // take care of allowed tags, remove others
$commenttext = makeShorterText($commenttext, 100); // if someone trys to write a novel, cut after 100 words
$commentname = shortenWords(strip_tags($commentname)); // we dont need any tags in the name, shortenwords
$commentemail = strip_tags($commentemail); // strip tags in email => but should not be nessessary
$sql = "INSERT INTO ".$cfg["tab"]["comments"]." (idcomments,idclient,idlang,idart,text,name,email,status,parentid,created) VALUES ('".$db->nextid($cfg["tab"]["comments"])."','".$client."','".$lang."','".$idart."','".$commenttext."','".$commentname."','".$commentemail."','1','".$creplyto."','".date("Y-m-d H:i:s")."')";
if ($db->query($sql)) {
echo "Created<br>";
// Mailbenachrichtigung an den Admin | @@ Peter Beauvain, 2004-06-30
// Select Admin email adress
$admin_mail = "CMS_VALUE[2]";
// Select mandant name
$sql2 = "SELECT * FROM ".$cfg["tab"]["clients"]." WHERE idclient = '$client'";
$db->query($sql2);
$db->next_record();
$mandant_name = $db->f("name");
$client_url = $db->f("htmlpath");
if ($commentemail == ''){
$commentemail = "keine Angabe";
}
$url = $client_url."front_content.php?client=".$client."&lang=".$lang."&idcat=".$idcat."&idart=".$idart;
$mailbody = "Kommentar von: ".$commentname." | E-Mail: ".$commentemail." \n\nDer Kommentar wurde zu folgendem Artikel abgegeben :\n\n".$url."\n\nInhalt: ".prepMail(parseUBB($commenttext))."\n";
mail($admin_mail, "neuer Kommentar zu einem Artikel !", $mailbody, "From: $mandant_name\nX-Mailer: PHP/" . phpversion(). "\n");
// Mailbenachrichtigung Ende
} else {
echo "Creation failed<br>";
}
unset($cmode); // show all comments
}
}
if (!$cmode) { // show comments
$parentid = 0;
$commentsTree = getCommentsTreeElements ($parentid,0,$flatTree); // build my tree baby
if($errorComments) {
echo "<!-- comments init failed - table does not exist //-->";
} else {
if ($debug) {
echo "<pre>";
print_r ($commentsTree); // debug only
echo "</pre>";
}
$clinkform = $clink."&cmode=form&creplyto=0";
echo '<a href="'.$clinkform.'" style="font-family:verdana, arial, sans-serif; font-size:11px;">Neuen Kommentar hinzufügen</a><br>'; // creplyto is used for reply
if ($commentsTree) { // tree elements found
showComments($commentsTree);
}
}
} else { // show form
if ($cmode == "form") {
echo ("<form name=\"comments\" method=\"post\" action=\"$clink#comment$creplyto\">");
echo ("<table cellpadding=\"0\" cellspacing=\"0\" style=\"font-family:verdana, arial, sans-serif; font-size:11px;\">");
echo ("<tr>");
echo ("<td width=\"75\"><p>Name:</p></td>");
echo ("<td><input type=\"text\" name=\"commentname\" style=\"width: 335px;\" value=\"$commentname\"></td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td><p>Email:</p></td>");
echo ("<td><input type=\"text\" name=\"commentemail\" style=\"width: 335px;\" value=\"$commentemail\"></td>");
echo ("</tr>");
echo ("</table>");
if ($useUBB) {
?>
<script language="JavaScript" type="text/javascript">
// Define the bbCode tags
var imageTag = false;
var theSelection = false;
// Array für BB-Code Parser | @@ Peter Beauvain, 2004-05-27
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[align=left]','[/align]','[center]','[/center]','[align=right]','[/align]','[align=justify]','[/align]','[ul]','[/ul]','[li]','[/li]','[img]','[/img]','[url]','[/url]','[email]','[/email]','[lart= lang=]','','[code]','
','[php]','[/php]','[quote]','[/quote]');
imageTag = false;
//-----------------------------------------------
// Browser Variablen | @@ Peter Beauvain, 2004-05-27
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
&& (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
//------------------------------------------------
// Array der Texte für die Permanent Hilfe | @@ Peter Beauvain, 2004-05-27
a_help = "Alle noch offenen UBB-Tags schließen:[/..]";
b_help = "Text in fett:
Text";
i_help = "Text in kursiv:
Text";
u_help = "Unterstrichener Text:
Text";
l_help ="Linksbündiger Text: [align=left]Text[/align]";
c_help ="Zentrierter Text: [center]Text[/center]";
r_help ="Linksbündiger Text: [align=right]Text[/align]";
j_help ="Text im Blocksatz: [align=justify]Text[/align]";
ul_help ="Geordnete Liste: [ul]Text[/ul]";
li_help ="Listenelement: [li]Text[/li]";
url_help ="Link:
www.homepage.de oder
Text";
mail_help ="E-Mail Adresse:
John@Doe.com";
s_help ="Schriftfarbe:
Text";
t_help ="Schriftgröße:
kleiner Text bis
großer Text";
icon1_help ="Emoticon Augenzwinkern
";
icon2_help ="Emoticon Lachen
";
icon3_help ="Emoticon Information :info:";
icon4_help ="Emoticon Achtung!
";
icon5_help ="Emoticon Cool
";
//---------------------------------------------
// Funktion für die Permanent Hilfe | @@ Peter Beauvain, 2004-05-27
function helpline(help)
{
document.comments.helpbox.value = eval(help + "_help");
}
function getarraysize(thearray)
{
for (i = 0; i < thearray.length; i++) {
if ((thearray
== "undefined") || (thearray == "") || (thearray == null))
return i;
}
return thearray.length;
}
// Replacement for arrayname.push(value) not implemented in IE until version 5.5 | @@ Peter Beauvain, 2004-05-27
// Appends element to the array
function arraypush(thearray,value)
{
thearray[ getarraysize(thearray) ] = value;
}
// Replacement for arrayname.pop() not implemented in IE until version 5.5 | @@ Peter Beauvain, 2004-05-27
// Removes and returns the last element of an array
function arraypop(thearray)
{
thearraysize = getarraysize(thearray);
retval = thearray[thearraysize - 1];
delete thearray[thearraysize - 1];
return retval;
}
// Funktion für die Textgrössen | @@ Peter Beauvain, 2004-05-27
function bbfontstyle(bbopen, bbclose)
{
var txtarea = document.comments.commenttext;
if ((clientVer >= 4) && is_ie && is_win) {
theSelection = document.selection.createRange().text;
if (!theSelection) {
txtarea.value += bbopen + bbclose;
txtarea.focus();
return;
}
document.selection.createRange().text = bbopen + theSelection + bbclose;
txtarea.focus();
return;
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
mozWrap(txtarea, bbopen, bbclose);
return;
}
else
{
txtarea.value += bbopen + bbclose;
txtarea.focus();
}
storeCaret(txtarea);
}
//Funktion für die Abfrage der Buttons | @@ Peter Beauvain, 2004-05-27
function bbstyle(bbnumber)
{
var txtarea = document.comments.commenttext;
donotinsert = false;
theSelection = false;
bblast = 0;
if (bbnumber == -1) { // Close all open tags & default button names
while (bbcode[0]) {
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
}
imageTag = false; // All tags are closed including image tags
txtarea.focus();
return;
}
if ((clientVer >= 4) && is_ie && is_win)
{
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection) {
// Add tags around selection
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
txtarea.focus();
theSelection = '';
return;
}
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
return;
}
// Find last occurance of an open tag the same as the one just clicked
for (i = 0; i < bbcode.length; i++) {
if (bbcode == bbnumber+1) {
bblast = i;
donotinsert = true;
}
}
if (donotinsert) { // Close all open tags up to the one just clicked & default button names
while (bbcode[bblast]) {
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
imageTag = false;
}
txtarea.focus();
return;
} else { // Open tags
if (imageTag && (bbnumber != 18)) { // Close image tag before adding another
txtarea.value += bbtags[19];
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
imageTag = false;
}
// Open tag
txtarea.value += bbtags[bbnumber];
if ((bbnumber == 18) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
txtarea.focus();
return;
}
storeCaret(txtarea);
}
function Picture(pic,title,width,height)
{
popup=window.open(pic, title,'width='+width+',height='+height+',toolbar=no,directories=no,status=no,scrollbars=no,resizable=yes,menubar=no');
popup.focus();
}
// Taken from http://www.massless.org/mozedit/
var thisForm;
function mozWrap(txtarea, lft, rgt)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
if (selEnd==1 || selEnd==2) selEnd=selLength;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + lft + s2 + rgt + s3;
}
function emoticon(text)
{
var txtarea = document.comments.commenttext;
text = ' ' + text + ' ';
if (txtarea.createTextRange && txtarea.caretPos) {
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
txtarea.focus();
} else {
txtarea.value += text;
txtarea.focus();
}
}
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/vie ... 52/fid/130
function storeCaret(textEl)
{
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
</script>
<table cellpadding="0" cellspacing="0" style="font-family:verdana, arial, sans-serif; font-size:11px;"><tr>
<td width="75"><b> </b></td><td colspan="2">
<a href="JavaScript:bbstyle(0)" onMouseOver="helpline('b')"><img src="<?= $imageUBB['buttons']; ?>button_bold.gif" alt="Bold Style" border="0"></a>
<a href="JavaScript:bbstyle(2)" onMouseOver="helpline('i')"><img src="<?= $imageUBB['buttons']; ?>button_italic.gif" alt="Italic Style" border="0"></a>
<a href="JavaScript:bbstyle(4)" onMouseOver="helpline('u')"><img src="<?= $imageUBB['buttons']; ?>button_underlined.gif" alt="Underlined Style" border="0"></a>
<a href="JavaScript:bbstyle(6)" onMouseOver="helpline('l')"><img src="<?= $imageUBB['buttons']; ?>button_left.gif" alt="Left alignment" border="0"></a>
<a href="JavaScript:bbstyle(8)" onMouseOver="helpline('c')"><img src="<?= $imageUBB['buttons']; ?>button_center.gif" alt="Centered" border="0"></a>
<a href="JavaScript:bbstyle(10)" onMouseOver="helpline('r')"><img src="<?= $imageUBB['buttons']; ?>button_right.gif" alt="Right Alignment" border="0"></a>
<a href="JavaScript:bbstyle(12)" onMouseOver="helpline('j')"><img src="<?= $imageUBB['buttons']; ?>button_justify.gif" alt="Justified" border="0"></a>
<a href="JavaScript:bbstyle(14)" onMouseOver="helpline('ul')"><img src="<?= $imageUBB['buttons']; ?>button_list.gif" alt="List" border="0"></a>
<a href="JavaScript:bbstyle(16)" onMouseOver="helpline('li')"><img src="<?= $imageUBB['buttons']; ?>button_list_item.gif" alt="List Item" border="0"></a>
<a href="JavaScript:bbstyle(20)" onMouseOver="helpline('url')"><img src="<?= $imageUBB['buttons']; ?>button_url.gif" alt="Insert URL" border="0"></a>
<a href="JavaScript:bbstyle(22)" onMouseOver="helpline('mail')"><img src="<?= $imageUBB['buttons']; ?>button_email.gif" alt="Insert email adress" border="0"></a>
<a href="javascript:bbstyle(-1)" onMouseOver="helpline('a')"><img src="<?= $imageUBB['buttons']; ?>button_close.gif" alt="Close Tags" border="0"></a><br>
<a href="JavaScript:emoticon('')" onMouseOver="helpline('icon1')"><img src="<?= $imageUBB['buttons']; ?>button_wink.gif" alt="emoticon wink" border="0"></a>
<a href="JavaScript:emoticon('')" onMouseOver="helpline('icon2')"><img src="<?= $imageUBB['buttons']; ?>button_smile.gif" alt="emoticon smile" border="0"></a>
<a href="JavaScript:emoticon(':info:')" onMouseOver="helpline('icon3')"><img src="<?= $imageUBB['buttons']; ?>button_look.gif" alt="emoticon info" border="0"></a>
<a href="JavaScript:emoticon(':!:')" onMouseOver="helpline('icon4')"><img src="<?= $imageUBB['buttons']; ?>button_attention.gif" alt="emoticon attention" border="0"></a>
<a href="JavaScript:emoticon('')" onMouseOver="helpline('icon5')"><img src="<?= $imageUBB['buttons']; ?>button_cool.gif" alt="emoticon cool" border="0"></a>
<select name="addbbcode32" onChange="bbfontstyle('[color=' + this.form.addbbcode32.options[this.form.addbbcode32.selectedIndex].value + ']', '[/color]');this.selectedIndex=0;" onMouseOver="helpline('s')">
<option style="background-color:darkred;" value="darkred"> </option>
<option style="background-color:red;" value="red"> </option>
<option style="background-color:orange;" value="orange"> </option>
<option style="background-color:brown;" value="brown"> </option>
<option style="background-color:yellow;" value="yellow"> </option>
<option style="background-color:green;" value="green"> </option>
<option style="background-color:chartreuse;" value="chartreuse"> </option>
<option style="background-color:olive;" value="olive"> </option>
<option style="background-color:cyan;" value="cyan"> </option>
<option style="background-color:blue;" value="blue"> </option>
<option style="background-color:darkblue;" value="darkblue"> </option>
<option style="background-color:indigo;" value="indigo"> </option>
<option style="background-color:violet;" value="violet"> </option>
<option style="background-color:white;" value="white"> </option>
<option style="background-color:black;" value="black"> </option>
</select>
<select name="addbbcode34" onChange="bbfontstyle('[size=' + this.form.addbbcode34.options[this.form.addbbcode34.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('t')">
<option value="7">XS</option>
<option value="9">S</option>
<option value="12" selected>M</option>
<option value="18">L</option>
<option value="24">XL</option>
</select>
</td></tr>
<tr><td width="75"><b>Hilfe: </b></td>
<td>
<input type="text" name="helpbox" style="width: 335px; border: 0px; font-size:12px;" value="Tipp: hier können Sie die Funktion der Buttons sehen">
</td>
</tr>
</table>
<?
echo ("<table cellpadding=\"0\" cellspacing=\"0\" style=\"font-family:verdana, arial, sans-serif; font-size:11px;\">");
echo ("<tr>");
echo ("<td width=\"75\" valign=\"top\"><p>Kommentar:</p></td>");
echo ("<td><textarea style=\"width: 335px;\" rows=\"5\" name=\"commenttext\" onselect=\"storeCaret(this);\" onclick=\"storeCaret(this);\" onkeyup=\"storeCaret(this);\">$commenttext</textarea><br></td>");
} else {
echo ("<table cellpadding=\"0\" cellspacing=\"0\" style=\"font-family:verdana, arial, sans-serif; font-size:11px;\">");
echo ("<tr>");
echo ("<td width=\"75\" valign=\"top\"><p>Kommentar:</p></td>");
echo ("<td><textarea style=\"width: 335px;\" rows=\"5\" name=\"commenttext\">$commenttext</textarea><br></td>");
}
echo ("<input type=\"hidden\" name=\"creplyto\" value=\"$creplyto\">");
echo ("<input type=\"hidden\" name=\"cmode\" value=\"add\">");
echo ("<tr>");
echo ("<td width=\"75\"> </td>");
echo ("<td><input type=\"submit\" name=\"submit\" value=\"Absenden\"></td>");
echo ("</form></table>");
}
}
?>[/code]