<?php
/**************************************************************************
* PHP Üzenőfal v2.5 - output.php                                          *
* ======================================================================= *
* Görgetősáv                                                              *
* ----------------------------------------------------------------------- *
* Marqueeing                                                              *
* ======================================================================= *
* Ezt a programot a PHP Studio fejlesztette, a szerzők: / This program    *
* was developed by the PHP Studio, the authors:                           *
* Warner                                                                  *
* ----------------------------------------------------------------------- *
* Weboldalunk / Our webpage: http://www.phpstudio.hu                      *
* Segítségnyújtás / HelpDesk: http://forum.phpstudio.hu                   *
* Kapcsolat / Contact: warner@phpstudio.hu                                *
* ======================================================================= *
* Ez a program license alatt áll, amit itt tekinthetsz meg: / This        *
* program is under a license, which you can see here:                     *
* http://license.phpstudio.hu                                             *
* ----------------------------------------------------------------------- *
* A license-szel kapcsolatos észrevételeid, megjegyzéseid, kérdéseid  a   *
* license@phpstudio.hu e-mail címen várjuk.                               *
* ----------------------------------------------------------------------- *
* You can send your remarks, opinions, questions to the following e-mail  *
* address: license@phpstudio.hu                                           *
* ======================================================================= *
* Dátum / Date: 2006. 08. 03.                                             *
**************************************************************************/

// SQL adatok
if(!@require("sql.php"))
	{
	die("sql.php nem található itt: " . basename($_SERVER["PHP_SELF"]) . " !");
	}
// Beállítások
$settings_require = array("outputShow", "outputSeparator", "outputLink", "outputShowLinkColor", "outputLinkTarget", "outputSeeded", "outputSeededMessage", "outputCensor");
while(list($key, $setting) = each($settings_require))
	{
	$setting_get = mysql_query("SELECT value FROM {$dbprefix}settings WHERE variable = '$setting'");
	$setting_all = mysql_fetch_row($setting_get);
	$current[$setting] = $setting_all[0];
	}
// Üzenetek
$mysql_get = $current["outputShow"];
$messages_get = mysql_query("SELECT message FROM {$dbprefix}messages ORDER BY ID DESC LIMIT 0, $mysql_get");
while($message = mysql_fetch_row($messages_get))
	{
	$message[0] = str_replace('\"', '"', $message[0]);
	$message[0] = str_replace("\'", "'", $message[0]);
	$message[0] = str_replace("\\\\", "\\", $message[0]);
	$messages[] = $message[0];
	}
if(is_array($messages))
	{
	$message_final = implode(" " . $current["outputSeparator"] . " ", $messages);
	$message_final = " " . $message_final . " ";
	}
else
	{
	$message_final = "";	
	}

// Cenzúra
if($current["outputCensor"] == 1)
	{
	$cenzur_get = mysql_query("SELECT input, output FROM {$dbprefix}censor ORDER BY ID");
	while($cenzur_all = mysql_fetch_row($cenzur_get))
		{
		$cenzur_input = $cenzur_all[0];
		$cenzur_output = $cenzur_all[1];
		$message_final = str_replace($cenzur_input, $cenzur_output, $message_final);
		}
	}
	
// Kiemelt üzenet	
if($current["outputSeeded"] == 1)
	{
	$current["outputSeeded"] = str_replace('\"', '"', $current["outputSeeded"]);
	$current["outputSeeded"] = str_replace("\'", "'", $current["outputSeeded"]);
	$current["outputSeeded"] = str_replace("\\\\", "\\", $current["outputSeeded"]);	
	$message_final = " " . $current["outputSeededMessage"] . " " . $current["outputSeparator"] . $message_final;
	}

// Linkké konvertálás	
if($current["outputLink"] == 1)
	{
	// A http://-vel kezdődő linkeket linké teszi.
	function ConvertLinksHTTP($text, $color, $target = "_blank")
	{
	if(strpos($text, " http://") !== false)
		{
		$fragments = explode(" http://", $text);
		$number = count($fragments);
		for($n=1; $n<$number; $n++)
			{
			$frag_reverse = strrev($fragments[$n]);
			if(strpos($frag_reverse, " ") !== false)
				$link_reverse = strrchr($frag_reverse, " ");
			else
				$link_reverse = " " . $frag_reverse;
			$link_reverse = substr($link_reverse, 1);
			$link = strrev($link_reverse);
			$link_work = "http://" . $link;
			$link_ready = '<a href="' . $link_work . '" target="' . $target . '"><font face="Verdana" style="font-size: 8pt" color="' . $color . '"><span style="text-decoration: none">' . $link_work . '</span></font></a>';
			$fragments[$n] = str_replace($link_work, $link_ready, "http://" . $fragments[$n]);
			}
		$text_ready = implode(" ", $fragments);
		}
	else
		{
		$text_ready = $text;
		}
	return($text_ready);
	}	
	
	// A www.-tal kezdődő linkeket linké teszi.
	function ConvertLinksWWW($text, $color, $target = "_blank")
	{
	if(strpos($text, " www.") !== false)
		{
		$fragments = explode(" www.", $text);
		$number = count($fragments);
		for($n=1; $n<$number; $n++)
			{
			$frag_reverse = strrev($fragments[$n]);
			if(strpos($frag_reverse, " ") !== false)
				$link_reverse = strrchr($frag_reverse, " ");
			else
				$link_reverse = " " . $frag_reverse;
			$link_reverse = substr($link_reverse, 1);
			$link = strrev($link_reverse);
			$link_work = "www." . $link;
			$link_ready = '<a href="http://' . $link_work . '" target="' . $target . '"><font face="Verdana" style="font-size: 8pt" color="' . $color . '"><span style="text-decoration: none"> ' . $link_work . '</span></font></a>';
			$fragments[$n] = str_replace($link_work, $link_ready, "www." . $fragments[$n]);
			}
		$text_ready = implode(" ", $fragments);
		}
	else
		{
		$text_ready = $text;
		}
	return($text_ready);
	}
	if(!strlen($current["outputShowLinkColor"]))
		{
		$current["outputShowLinkColor"] = "#FF0000";
		}
	$message_final = ConvertLinksHTTP($message_final, $current["outputShowLinkColor"], $current["outputLinkTarget"]);
	$message_final = ConvertLinksWWW($message_final, $current["outputShowLinkColor"], $current["outputLinkTarget"]);
	}
	
// CSS
echo '<style type="text/css">
<!--
marquee {
    font-family: Verdana;
    font-size: 11px;
    background-color: transparent;
    width:662px;
    height:17px;
    color: #ffffff;
    font-weight: bold;
}

marquee_a {
    font-family: Verdana;
    font-size: 11px;
    font-weight: bold;
    color: #ffffff;
    text-decoration: none;
}
-->
</style>';


// JS
echo '<script language="JavaScript" type="text/JavaScript">
<!--
var ppState = \'pause\';
var mqWay = \'left\';

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reswapImage() { //v3.0
  var i,j=0,x,a=MM_reswapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; x.oSrc=x.src; x.src=a[i+2];}
}

MM_preloadImages(\'images/marquee_left_hover.png\', \'images/marquee_right_hover.png\', \'images/marquee_play_hover.png\', \'images/marquee_pause_hover.png\', \'images/marquee_new_hover.png\', \'images/marquee_list_hover.png\');
//-->
</script>';

// Görgető
echo '<table width="780" height="21" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td width="10" height="21" background="images/left.png"></td>
		<td width="13" height="21"><a href="#" onclick="mqWay=\'left\'; msgscroll.direction=mqWay; msgscroll.start(); return false;" title="Balra" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Left\',\'\',\'images/marquee_left_hover.png\',1)"><img src="images/marquee_left.png" name="Left" width="13" height="21" border="0"></a></td>
		<td width="14" height="21"><a href="#" onclick="mqWay=\'right\'; msgscroll.direction=mqWay; msgscroll.start(); return false;" title="Jobbra" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Right\',\'\',\'images/marquee_right_hover.png\',1)"><img src="images/marquee_right.png" name="Right" width="14" height="21" border="0"></a></td>
		<td width="16" height="21"><a href="#" onclick="if(ppState==\'pause\'){ppState=\'play\'; msgscroll.stop();} else{ppState=\'pause\'; msgscroll.direction=mqWay; msgscroll.start();} document.Pause.src=\'images/marquee_\' + ppState + \'.png\'; MM_reswapImage(\'Pause\',\'\',\'images/marquee_\' + ppState + \'_hover.png\',1); return false;" onMouseOut="MM_swapImgRestore()" title="Szünet" onMouseOver="MM_swapImage(\'Pause\',\'\',\'images/marquee_\' + ppState + \'_hover.png\',1)"><img src="images/marquee_pause.png" name="Pause" width="16" height="21" border="0"></a></td>
		<td width="12" height="21" background="images/left2.png"></td>
		<td width="662" height="21" background="images/middle.png" align="center" valign="bottom"><marquee align="bottom" scrollamount="3" scrolldelay="10" id="msgscroll" title="Üzenőfal" onmouseover="stop();" onmouseout="start();">' . $message_final . '</marquee></td>
		<td width="10" height="21" background="images/right2.png"></td>
		<td width="22" height="21"><a href="input.php" title="Új üzenet" target="_top" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'New\',\'\',\'images/message_new_hover.png\',1)"><img src="images/message_new.png" name="New" width="22" height="21" border="0"></a></td>
		<td width="16" height="21"><a href="lister.php" title="Összes üzenet" target="_top" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'List\',\'\',\'images/message_list_hover.png\',1)"><img src="images/message_list.png" name="List" width="16" height="21" border="0"></a></td>
		<td width="5" height="21" background="images/right.png"></td>
	</tr>
</table>';
?>