| Zobrazit předchozí téma :: Zobrazit následující téma |
| Autor |
Zpráva |
Rohlik
Založen: 2.8.2008 Příspěvky: 2
|
Zaslal: 02 srpen 2008 21:24 Předmět: PHP - Cannot modify header information |
|
|
Zdar, mam problem....
Mám chat (ne muj) v PHP, ktery nevyzaduje databazi mysql.
Nejede v nem jedna vec. Lze si tam vybrat z nabidky zvuk, ktery se ma prehrat, kdyz dojde prispevek. Ale kdyz si nejaky zvolim, tak se napise toto:
| kód: | | Warning: Cannot modify header information - headers already sent by (output started at /storage/www2/2/site39002/wwwroot/echat/output.php:14) in /storage/www2/2/site39002/wwwroot/echat/output.php on line 25 |
Ta hlavicka je na zacatku a zadna UTF-8 BOM tam neni....
Zde je ten script:
| kód: | <?php
session_name('AshChat');session_set_cookie_params(0,'/','',false);
session_start();header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<meta http-equiv="Cache-Control" content="no-store,max-age=-1">
<meta name="Author" content="Ashus, ashus.ashus.net">
<META NAME="eastside" CONTENT="NONE">
<META NAME="cod2 klan" CONTENT="NOARCHIVE">
<title>Eastside chat</title>
<link rel="stylesheet" type="text/css" href="css.css">
<style type="text/css">
span { font-weight: bold; }
</style>
</head>
</html>
<?php
$sound = TryToGetCookie($sound, 'chat-sound', '-');
if ($_POST['setcookie'] == '1')
{
$maxtime = time() + 31536000;
setcookie('chat-sound', $sound, $maxtime,'/');
};
function getcookie($name)
{
global $_COOKIE;
if(!isset($_COOKIE[$name])) return false;
return $_COOKIE[$name];
}
function TryToGetCookie($x, $y, $z)
{
if ($x == '')
{$x = getcookie($y);
if ($x == '')
{$x = $z;}};
return $x;
}
$name = $_SESSION['chat-name'];
if ($name == '')
{
$name = $_COOKIE['chat-name'];
}
$table_color_1 = '444444';
$table_color_2 = '333333';
$chatfile = 'data/chat';
$sound = $_POST['sound'];
$highlight = $_GET['highlight'];
if ($highlight == '')
{
$highlight = $name;
$i = strpos($highlight,':'); // odstrihnuti friendly jmena z original-name
if ($i !== false)
{$highlight=substr($highlight,0,$i);}
}
if ($highlight != '')
{
$highlight = trim($highlight);
}
function str_highlight($text, $needle, $options = null, $highlight = null)
{
// Default highlighting
if ($highlight === null) {
$highlight = '<font color="yellow">\1</font>';
}
// Select pattern to use
if ($options & STR_HIGHLIGHT_SIMPLE) {
$pattern = '#(%s)#';
$sl_pattern = '#(%s)#';
} else {
$pattern = '#(?!<.*?)(%s)(?![^<>]*?'.'>)#';
$sl_pattern = '#<a\s(?:.*?)>(%s)</a>#';
}
// Case sensitivity
if (!($options & STR_HIGHLIGHT_CASESENS)) {
$pattern .= 'i';
$sl_pattern .= 'i';
}
$needle = (array) $needle;
foreach ($needle as $needle_s) {
$needle_s = preg_quote($needle_s);
// Escape needle with optional whole word check
if ($options & STR_HIGHLIGHT_WHOLEWD) {
$needle_s = '\b' . $needle_s . '\b';
}
// Strip links
if ($options & STR_HIGHLIGHT_STRIPLINKS) {
$sl_regex = sprintf($sl_pattern, $needle_s);
$text = preg_replace($sl_regex, '\1', $text);
}
$regex = sprintf($pattern, $needle_s);
$text = preg_replace($regex, $highlight, $text);
}
return $text;
}
$default_last = '30'; // default hodnota poctu radku
$default_big = '150'; // default hodnota poctu radku (big)
$show_header = true;
$last = $_GET['last'];
if ($last == '')
$last = $default_last;
if ($last != $default_last) $show_header = false;
if ($show_header)
echo '<script type="text/javascript">
<!--
function AddReply(x,y)
{
var evtobj = window.event ? event : e
if (evtobj.shiftKey)
{parent.FrameChatB.document.form_input.msg.value=parent.FrameChatB.document.form_input.msg.value+y+\'|\'+x;} else
{parent.FrameChatB.document.form_input.msg.value=parent.FrameChatB.document.form_input.msg.value+x;}
}
-->
</script>';
echo '</head><body'
.' style="margin-left: 8pt; margin-right: 8pt; margin-top: 7pt; margin-bottom: 2pt;">';
if ($show_header === true)
{
$lines = file('data/topic');
echo '<center><table border="0" cellpadding="0" cellspacing="0" width="97%">
<tr><td width="*"><h1 style="margin-bottom:0">Ash Chat'
.(($lines[0]!='') ? ' - '.$lines[0] : '') // topic
.(($sound!='-') ? '<embed src="mediaplayer.swf" width="0" height="0" bgcolor="#FFFFFF"
type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
flashvars="file=sounds/'.$sound.'.mp3&autostart=true&shownavigation=false"/>' : '')
.'</h1></td><td width="8%" align="right"><font size="1">Zvuk </font></td>
<td width="10%" align="left">
<form method="post" action="'.$_SERVER['PHP_SELF'].'" style="margin-bottom:0">
<span title="Zvuk se přehraje při vstupu na chat a při každé nové zprávě. Pro přístě se zapamatuje jako cookie.">
<select name="sound" class="dropdown" onchange="this.form.submit();" style="font-size: 7pt">';
include('sounds.php');
foreach ($Sounds as $snd)
{if ($sound==$snd[0]) {$tmp=' selected';} else {$tmp='';};
echo '<option value="'.$snd[0].'"'.$tmp.'>'.$snd[1].'</option>';
};
echo '</select><input type="hidden" name="setcookie" value="1"><input type="hidden" name="last" value="'.$last.'">
<input type="hidden" name="name" value="'.$name.'"></span></form></td>
<td width="150" align="right"><iframe name="FrameChatI" src="refresh.php?timestamp='. filemtime($chatfile) .'" FRAMEBORDER="0" MARGINWIDTH="0"
MARGINHEIGHT="0" WIDTH="100%" HEIGHT="16" SCROLLING="no">Browser nepodporuje iframes.</iframe></td>
</tr></table></center><br><img src="separator.gif" alt="-" height="2" width="100%"><br><br>';
}
function IncludeLast($file, $lines)
{
global $highlight, $default_last, $chatfile;
$handle = fopen($file, "r");
$linecounter = $lines;
$pos = -2;
$beginning = false;
$text = array();
while ($linecounter > 0) {
$t = " ";
while ($t != "\n") {
if(fseek($handle, $pos, SEEK_END) == -1) {
$beginning = true; break; }
$t = fgetc($handle);
$pos --;
}
$linecounter --;
if($beginning) rewind($handle);
$text[$lines-$linecounter-1] = fgets($handle);
if($beginning) break;
}
fclose ($handle);
$text = array_reverse($text);
for ($i = 0; $i < $lines; $i++)
{
if ($lines == $default_last)
{ // pridani clickable jmena - se shiftem admin uprava
$o = strpos($text[$i], '</span>');
$s2 = substr($text[$i],0,$o);
$s1 = substr($s2,strpos($s2,' title="')+8,19); //date-time
$s2 = substr($s2,strpos($s2,'">')+2, strlen($s2)); //nick
$text[$i]='<span title="'.$s1.'" onClick="AddReply(\''.$s2.'\',\''.$s1.'\')">'.$s2.'</span>' . substr($text[$i], $o+7, strlen($text[$i]));
}
if ($highlight != '')
{ // zvyraznovani vseho co neni v html tagach
$text[$i] = str_highlight($text[$i],$highlight);
$text[$i] = eregi_replace('><font color="yellow">([A-Za-z0-9. ]+)</font>: </span>',' style="color: yellow;">\\1: </span>', $text[$i]);
}
echo $text[$i];
}
}
if (($last != $default_last) && ($last != $default_big) && ($last != 'present'))
{
include('passwords.php');
if ($hasadminrights == 1)
{
if ($last == 'all')
include($chatfile);
elseif ($last == 'iplog')
{
/////////////////// list of IPs begin
echo '<h1>IP log</h1><h2>Seznam přezdívek a posledních IP adres, ze kterých sem něco napsali</h2>';
$file = file('data/iplog');
$cnt = count($file);
echo '<table><tr style="font-weight: bold;"><td>Nick</td><td>IP</td><td>Proxy</td>'."\n";
if ($cnt>0)
{
usort($file, create_function('$a,$b','return strcasecmp($a,$b);'));
for ($i=0; $i<$cnt; $i++)
{
unset($t);
$t = explode('~~',$file[$i]);
echo '<tr><td>'.$t[0].'</td><td>'.$t[1].'</td><td>'.$t[2].'</td></tr>'."\n";
}
}
echo '</table>';
/////////////////// list of IPs end
}
else IncludeLast($chatfile, $last);
} else {
IncludeLast($chatfile, $default_last);
}
} else
{
if ($last == 'present')
{
/////////////////// present users begin
echo '<h1>Kdo tu je?</h1>';
$listdir = 'data/present';
$pth = opendir($listdir);
$color2 = true;
echo '<table width="99%"><tr style="font-weight: bold;"><td>IP</td><td>Proxy</td><td>Browser</td><td>TempNick</td><td>PermNick</td></tr>'."\n";
while (false !== ($file = readdir($pth)))
{
if ( ($file != ".") && ($file != "..") )
{
unset($t);
$t = explode('~~',$file);
$color2 = ! $color2;
echo '<tr bgcolor="#'.(($color2) ? $table_color_1 : $table_color_2).'"><td>'.$t[0].'</td><td>'.$t[1].'</td><td>'.$t[2].'</td><td>'.$t[3].'</td><td>'.$t[4].'</td></tr>'."\n";
}
}
closedir($pth);
echo '</table>';
/////////////////// present users end
}
else
IncludeLast($chatfile, $last);
}
?>
<a name="down"></a>
</body>
</html> |
Zkousel jsem to u dvou hostingu (php5.cz a fakaheda.eu), ale porad to samy...
Kdyby nekdo chtel cely ten script, tak ho poslu.....
Predem diky moc za rady! _________________ -No cement- |
|
| Návrat nahoru |
|
 |
Webhosting C4 - 2 GB, PHP, MySQL, administrační systém, 1.200 Kč na rok s doménou v ceně. Srubové domy, dřevostavby a víkendové sruby.
Bezproblémová instalace phpBB, Joomla, Drupal. Návody pro C4 - užitečné rady pro zákazníky. Nafukovací balonky s potiskem.
Výhodné sázkové kanceláře. značkové oblečení z USA, luxusní kabelky a také peněženky nabízí eshop usaboutique.cz.
Apartment in Prague - accommodation in Prag, prague apartments, luxusní anglické dýmky a kvalitní doutníky, značkové spodní prádlo a podprsenky
|  |
|
|
|
|
Nemůžete odesílat nové téma do tohoto fóra. Nemůžete odpovídat na témata v tomto fóru. Nemůžete upravovat své příspěvky v tomto fóru. Nemůžete mazat své příspěvky v tomto fóru. Nemůžete hlasovat v tomto fóru. Nemůžete připojovat soubory k příspěvkům Nemůžete stahovat ani prohlížet přiložené soubory
|
Powered by phpBB & phpBB SEO © 2001, 2005 phpBB Group Český překlad phpBB Czech - www.phpbbcz.com Optimalizoval JanoF - PCforum.sk
|