December 1, 201213 yr Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /www/99k.org/a/l/t/alt-chan/htdocs/admin.php:1) in /www/99k.org/a/l/t/alt-chan/htdocs/config.php on line 50 I get this error on the admin panel of my site, does anyone have any idea how to remedy this please?
December 1, 201213 yr var http = require('http'); var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.end("http://stackoverflow.com/questions/8028957/warning-headers-already-sent-in-php\n"); }); server.listen(8000);
December 1, 201213 yr Author var http = require('http'); var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.end("http://stackoverflow.com/questions/8028957/warning-headers-already-sent-in-php\n"); }); server.listen(8000); ?
December 1, 201213 yr Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /www/99k.org/a/l/t/alt-chan/htdocs/admin.php:1) in /www/99k.org/a/l/t/alt-chan/htdocs/config.php on line 50 I get this error on the admin panel of my site, does anyone have any idea how to remedy this please? Your session start needs to be at the top of your page before any html or php code
December 1, 201213 yr ? hes just another idiot spammer ignore him not you but the guy you replied to with a question mark Edited December 1, 201213 yr by webdesigner93
December 1, 201213 yr Author Your session start needs to be at the top of your page before any html or php code Now it displays "session_start();" on my admin page where it previously displayed the error message.
December 2, 201213 yr Now it displays "session_start();" on my admin page where it previously displayed the error message. yea u gotta put it inside php tags
December 2, 201213 yr Author yea u gotta put it inside php tags Now I get the error message again but stating line 1 rather than line 50 if I do it like this; <?php session_start(); or line 2 if I do it like this; <?php session_start(); Edited December 2, 201213 yr by openwide
December 2, 201213 yr I'd imagine something is being output before config.php is loaded. Check any files included before config.php for errors.
December 2, 201213 yr Author Heres my config.php code, don't ask what the penis vagina thing is about I don't have a clue it was in the original script I've used. Line 50 is the sessionstart. <?php /* * HaChan configuration * Remember to change the password! */ class config { public static $name = 'alt-chan.99k.org'; // Your site name public static $user = '******'; // Your username to acess the admin panel public static $pass = '********'; // Your password to access the admin panel public static $banner_rotate = true; // Allow banner rotation? public static $url = 'http://alt-chan.99k.org'; // Your site url, without the final backslash '/' public static $copyright = 'All trademarks on this page are owned by their respective parties - Images uploaded are the responsibility of the poster - Comments are owned by the poster'; // Here are all your forums, for more info on this check the README public static $boards = array( '/art/'=>'Artwork', '/b/'=>'Random', '/bod/'=>'Body Art & Modification', '/c/'=>'Cute', '/com/'=>'Comics & Memes', '/g/'=>'Gadgets & Technology', '/gif/'=>'Animated GIFs', '/mus/'=>'Music', '/pol/'=>'News & Politics', '/q/'=>'Site Discussion', '/r/'=>'Requests', '/soc/'=>'Social', '/soft/'=>'Software', '/tv/'=>'Television & Film', '/vg/'=>'Video Games', '/wtf/'=>'WTF!?', ); // Add all the styles that you want... If you want to define a style as default, just name it default.css public static $styles = array( 'Default'=>'/styles/default.css', ); // All possible banners. If rotation is allowed, it will display a random one public static $banners = array( 'rotate/1.jpg', ); } /* * Do not edit this if you dont know what you are doing! */ session_start(); function clean() { foreach($_POST as $key => $val) { $_POST[$key] = stripslashes(strip_tags(htmlspecialchars($val, ENT_QUOTES))); $$key = stripslashes(strip_tags(htmlspecialchars($val, ENT_QUOTES))); } foreach($_GET as $key => $val) { $_GET[$key] = stripslashes(strip_tags(htmlspecialchars($val, ENT_QUOTES))); $$key = stripslashes(strip_tags(htmlspecialchars($val, ENT_QUOTES))); } } clean(); function error($str) { echo '<div class="forumListContainer"> <h1>Error!</h1> <div style="padding-left:5px;">'.$str.'<br />Click <a href="javascript:history.back();">here</a> to go back.</div><div style="clear:both "> </div> </div>'; } function crop($filename, $destination, $th_width, $th_height, $forcefill, $quality) { list($width, $height) = getimagesize($filename); $file_class = substr($filename, -3, 3); if($file_class == 'jpg' || substr($filename, -4, 4) == 'jpeg') $source = imagecreatefromjpeg($filename); elseif($file_class == 'gif') $source = imagecreatefromgif($filename); elseif($file_class == 'png') $source = imagecreatefrompng($filename); else die('No valid file type. ('.$file_class.')'); if($width > $th_width || $height > $th_height) { $a = $th_width/$th_height; $b = $width/$height; if(($a > $^$forcefill) { $src_rect_width = $a * $height; $src_rect_height = $height; if(!$forcefill) { $src_rect_width = $width; $th_width = $th_height/$height*$width; } } else { $src_rect_height = $width/$a; $src_rect_width = $width; if(!$forcefill) { $src_rect_height = $height; $th_height = $th_width/$width*$height; } } $src_rect_xoffset = ($width - $src_rect_width)/2*intval($forcefill); $src_rect_yoffset = ($height - $src_rect_height)/2*intval($forcefill); $thumb = imagecreatetruecolor($th_width, $th_height); imagecopyresized($thumb, $source, 0, 0, $src_rect_xoffset, $src_rect_yoffset, $th_width, $th_height, $src_rect_width, $src_rect_height); imagejpeg($thumb,$destination, $quality); imagedestroy($thumb); } } function isAdmin() { if($_SESSION['user'] == config::$user && $_SESSION['pass'] == config::$pass) return true; else return false; } function getFolderSize($d=".") { // © kasskooye and patricia benedetto $h = @opendir($d); if($h==0) return 0; while ($f=readdir($h)) { if ($f!= "..") { $sf+=filesize($nd=$d."/".$f); if($f!="."&&is_dir($nd)) $sf+=GetFolderSize($nd); } } closedir($h); return $sf; } function hacode($content) { if(isset($_GET['reply'])) $content = preg_replace("#>>(\d+)#i","<span class='quoteLink'><a href='#\\1'>>>\\1</a></span>",$content); $content = preg_replace("#>>>/(.+?)/(\d+)#i","<span class='quote'><a href='".config::$url."/\\1/?reply=\\2'>>>>/\\1/\\2</a></span> ",$content); $content = preg_replace("#>(.+?)<#i","<span class='quote'>> \\1 <</span> ",$content); $content = nl2br($content); // "Custom" $content = str_replace('7', 'over 9000', $content); $content = str_replace('penis', '<span style="background-color: #'.randomColor().';"><b> <span style="color:#'.randomColor().';">P</span> <span style="color:#'.randomColor().';">E</span> <span style="color:#'.randomColor().';">N</span> <span style="color:#'.randomColor().';">I</span> <span style="color:#'.randomColor().';">S</span> </b></span>', $content); $content = str_replace('vagina', '<span style="background-color: #'.randomColor().';"><b> <span style="color:#'.randomColor().';">V</span> <span style="color:#'.randomColor().';">A</span> <span style="color:#'.randomColor().';">G</span> <span style="color:#'.randomColor().';">I</span> <span style="color:#'.randomColor().';">N</span> <span style="color:#'.randomColor().';">A</span> </b></span>', $content); return $content; } function randomColor() { $c = null; while(strlen($c)<6) $c .= sprintf("%02X", rand(0, 255)); return $c; } function tripcode($nick) { $code = explode('#', $nick); if(empty($code[1])) return $nick; else return $code[0].'#'.substr(sha1(md5($code[1])),0,6); } ?> Edited December 2, 201213 yr by openwide
December 2, 201213 yr Author Heres my admin.php code, notice the url=?main that url doesn't exist anymore any ideas how I should remove this without causing more problems? <script type="text/javascript" language="Javascript"> $(document).ready(function(){ $('.delLink').click(function(e){ e.preventDefault(); $('#' + $(this).attr('name')).css({ backgroundColor:'red', color:'white' }); $('#' + $(this).attr("name")).fadeOut('slow'); $.get("admin.php", {'delete':'' , 'id':$(this).attr('name')}); }); }); </script> <div id="forumListContainer"> <h1>Admin Panel </h1> <?php include_once('lib/phlat.class.php'); include_once('config.php'); if(isAdmin()) { $reported = new phlat('reported', array('post_id', 'reply_id', 'reason', 'board')); echo '<div style="padding: 5px;" />'; if(isset($_GET['logout'])) { $_SESSION['user'] = ''; $_SESSION['pass'] = ''; echo 'You are now logged out.'; header('refresh:2;[b][color=#ff0000]url=?main[/color][/b]'); } else if(isset($_GET['delete'])) { $reported->deleteAt('id', $_GET['id']); } elseif(isset($_GET['reported'])) { $rep = $reported->get(); echo '<ul>'; if(empty($rep[0]['id'])) echo '<li>No reports</li>'; else { foreach($rep as $entry) { $type = empty($entry['reply_id']) ? 'post' : 'reply'; $id = empty($entry['reply_id']) ? $entry['post_id'] : $entry['reply_id']; echo '<li id="'.$entry['id'].'"><a href="#" name="'.$entry['id'].'" class="delLink">Delete</a> - '.$type.' nº <a href="'.config::$url.$entry['board'].'index.php?reply='.$entry['post_id'].'#'.$id.'">'.$id.'</a>: '.$entry['reason'].'</li>'; } } echo '</ul><br /><div align="right">[<a href="?admin&readall">Mark all as read</a>] [<a href="?admin">Admin menu</a>] </div>'; } elseif(isset($_GET['readall'])) { $reported->clear(); echo 'All reports marked as readed. [<a href="?admin&reported">Go back</a>]<div align="right"> [<a href="?admin">Admin menu</a>] </div>'; } else echo 'Welcome '.$_SESSION['user'].'!<br />You are now logged in.<br />You will be able to delete all posts and replies and view users IP.<br />HaChan is using <strong>'.round((getFolderSize()/1024)/1024).'</strong> Megabytes of disk space.<br /><div align="right">[<a href="?admin&reported">View Reported Posts</a>] [<a href="?admin&logout">Logout</a>] </div>'; echo '</div>'; } else { if($_POST['Submit']) { $_SESSION['user'] = $_POST['user']; $_SESSION['pass'] = $_POST['pass']; echo 'Verifying data...'; header('refresh:1;url=?admin'); } else { echo '<form action="" method="post"> <table border="0"> <tr> <td>Username</td> <td><input name="user" type="text" id="user" /></td> </tr> <tr> <td>Password</td> <td><input name="pass" type="password" id="pass" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Log in" /></td> </tr> </table></form>'; } } ?> </div>
December 2, 201213 yr <?php include_once('config.php'); include_once('lib/phlat.class.php'); ?> <script type="text/javascript" language="Javascript"> $(document).ready(function(){ $('.delLink').click(function(e){ e.preventDefault(); $('#' + $(this).attr('name')).css({ backgroundColor:'red', color:'white' }); $('#' + $(this).attr("name")).fadeOut('slow'); $.get("admin.php", {'delete':'' , 'id':$(this).attr('name')}); }); }); </script> <div id="forumListContainer"> <h1>Admin Panel </h1> <?php if(isAdmin()) { $reported = new phlat('reported', array('post_id', 'reply_id', 'reason', 'board')); echo '<div style="padding: 5px;" />'; if(isset($_GET['logout'])) { $_SESSION['user'] = ''; $_SESSION['pass'] = ''; echo 'You are now logged out.'; header('refresh:2;[b][color=#ff0000]url=?main[/color][/b]'); } else if(isset($_GET['delete'])) { $reported->deleteAt('id', $_GET['id']); } elseif(isset($_GET['reported'])) { $rep = $reported->get(); echo '<ul>'; if(empty($rep[0]['id'])) echo '<li>No reports</li>'; else { foreach($rep as $entry) { $type = empty($entry['reply_id']) ? 'post' : 'reply'; $id = empty($entry['reply_id']) ? $entry['post_id'] : $entry['reply_id']; echo '<li id="'.$entry['id'].'"><a href="#" name="'.$entry['id'].'" class="delLink">Delete</a> - '.$type.' nº <a href="'.config::$url.$entry['board'].'index.php?reply='.$entry['post_id'].'#'.$id.'">'.$id.'</a>: '.$entry['reason'].'</li>'; } } echo '</ul><br /><div align="right">[<a href="?admin&readall">Mark all as read</a>] [<a href="?admin">Admin menu</a>] </div>'; } elseif(isset($_GET['readall'])) { $reported->clear(); echo 'All reports marked as readed. [<a href="?admin&reported">Go back</a>]<div align="right"> [<a href="?admin">Admin menu</a>] </div>'; } else echo 'Welcome '.$_SESSION['user'].'!<br />You are now logged in.<br />You will be able to delete all posts and replies and view users IP.<br />HaChan is using <strong>'.round((getFolderSize()/1024)/1024).'</strong> Megabytes of disk space.<br /><div align="right">[<a href="?admin&reported">View Reported Posts</a>] [<a href="?admin&logout">Logout</a>] </div>'; echo '</div>'; } else { if($_POST['Submit']) { $_SESSION['user'] = $_POST['user']; $_SESSION['pass'] = $_POST['pass']; echo 'Verifying data...'; header('refresh:1;url=?admin'); } else { echo '<form action="" method="post"> <table border="0"> <tr> <td>Username</td> <td><input name="user" type="text" id="user" /></td> </tr> <tr> <td>Password</td> <td><input name="pass" type="password" id="pass" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Log in" /></td> </tr> </table></form>'; } } ?> </div>
December 2, 201213 yr Author Now I don't get the original error once I reach the admin page but when I submit my username and password I get this error Verifying data... Warning: Cannot modify header information - headers already sent by (output started at /www/99k.org/a/l/t/alt-chan/htdocs/admin.php:5) in /www/99k.org/a/l/t/alt-chan/htdocs/admin.php on line 70 Line 70 is header('refresh:1;url=?admin');
December 2, 201213 yr Now I don't get the original error once I reach the admin page but when I submit my username and password I get this error Verifying data... Warning: Cannot modify header information - headers already sent by (output started at /www/99k.org/a/l/t/alt-chan/htdocs/admin.php:5) in /www/99k.org/a/l/t/alt-chan/htdocs/admin.php on line 70 Line 70 is header('refresh:1;url=?admin'); <?php include_once('config.php'); include_once('lib/phlat.class.php'); ?> <script type="text/javascript" language="Javascript"> $(document).ready(function(){ $('.delLink').click(function(e){ e.preventDefault(); $('#' + $(this).attr('name')).css({ backgroundColor:'red', color:'white' }); $('#' + $(this).attr("name")).fadeOut('slow'); $.get("admin.php", {'delete':'' , 'id':$(this).attr('name')}); }); }); </script> <div id="forumListContainer"> <h1>Admin Panel </h1> <?php if(isAdmin()) { $reported = new phlat('reported', array('post_id', 'reply_id', 'reason', 'board')); echo '<div style="padding: 5px;" />'; if(isset($_GET['logout'])) { $_SESSION['user'] = ''; $_SESSION['pass'] = ''; echo 'You are now logged out.'; header('refresh:2;[b][color=#ff0000]url=?main[/color][/b]'); } else if(isset($_GET['delete'])) { $reported->deleteAt('id', $_GET['id']); } elseif(isset($_GET['reported'])) { $rep = $reported->get(); echo '<ul>'; if(empty($rep[0]['id'])) echo '<li>No reports</li>'; else { foreach($rep as $entry) { $type = empty($entry['reply_id']) ? 'post' : 'reply'; $id = empty($entry['reply_id']) ? $entry['post_id'] : $entry['reply_id']; echo '<li id="'.$entry['id'].'"><a href="#" name="'.$entry['id'].'" class="delLink">Delete</a> - '.$type.' nº <a href="'.config::$url.$entry['board'].'index.php?reply='.$entry['post_id'].'#'.$id.'">'.$id.'</a>: '.$entry['reason'].'</li>'; } } echo '</ul><br /><div align="right">[<a href="?admin&readall">Mark all as read</a>] [<a href="?admin">Admin menu</a>] </div>'; } elseif(isset($_GET['readall'])) { $reported->clear(); echo 'All reports marked as readed. [<a href="?admin&reported">Go back</a>]<div align="right"> [<a href="?admin">Admin menu</a>] </div>'; } else echo 'Welcome '.$_SESSION['user'].'!<br />You are now logged in.<br />You will be able to delete all posts and replies and view users IP.<br />HaChan is using <strong>'.round((getFolderSize()/1024)/1024).'</strong> Megabytes of disk space.<br /><div align="right">[<a href="?admin&reported">View Reported Posts</a>] [<a href="?admin&logout">Logout</a>] </div>'; echo '</div>'; } else { if($_POST['Submit']) { $_SESSION['user'] = $_POST['user']; $_SESSION['pass'] = $_POST['pass']; //echo 'Verifying data...'; header('refresh:1;url=?admin'); } else { echo '<form action="" method="post"> <table border="0"> <tr> <td>Username</td> <td><input name="user" type="text" id="user" /></td> </tr> <tr> <td>Password</td> <td><input name="pass" type="password" id="pass" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Log in" /></td> </tr> </table></form>'; } } ?> </div>
December 2, 201213 yr Author Now I get the error at line 30 when I log out and 69 when I log in. I really appreciate your help by the way, you can quit if its a waste of your time.
December 2, 201213 yr Now I get the error at line 30 when I log out and 69 when I log in. I really appreciate your help by the way, you can quit if its a waste of your time. <?php include_once('config.php'); include_once('lib/phlat.class.php'); ?> <?php if(isAdmin()) { $reported = new phlat('reported', array('post_id', 'reply_id', 'reason', 'board')); //echo '<div style="padding: 5px;" />'; if(isset($_GET['logout'])) { $_SESSION['user'] = ''; $_SESSION['pass'] = ''; header('refresh:2;[b][color=#ff0000]url=?main[/color][/b]'); echo 'You are now logged out.'; } else if(isset($_GET['delete'])) { $reported->deleteAt('id', $_GET['id']); } elseif(isset($_GET['reported'])) { $rep = $reported->get(); echo '<ul>'; if(empty($rep[0]['id'])) echo '<li>No reports</li>'; else { foreach($rep as $entry) { $type = empty($entry['reply_id']) ? 'post' : 'reply'; $id = empty($entry['reply_id']) ? $entry['post_id'] : $entry['reply_id']; echo '<li id="'.$entry['id'].'"><a href="#" name="'.$entry['id'].'" class="delLink">Delete</a> - '.$type.' nº <a href="'.config::$url.$entry['board'].'index.php?reply='.$entry['post_id'].'#'.$id.'">'.$id.'</a>: '.$entry['reason'].'</li>'; } } echo '</ul><br /><div align="right">[<a href="?admin&readall">Mark all as read</a>] [<a href="?admin">Admin menu</a>] </div>'; } elseif(isset($_GET['readall'])) { $reported->clear(); echo 'All reports marked as readed. [<a href="?admin&reported">Go back</a>]<div align="right"> [<a href="?admin">Admin menu</a>] </div>'; } else echo 'Welcome '.$_SESSION['user'].'!<br />You are now logged in.<br />You will be able to delete all posts and replies and view users IP.<br />HaChan is using <strong>'.round((getFolderSize()/1024)/1024).'</strong> Megabytes of disk space.<br /><div align="right">[<a href="?admin&reported">View Reported Posts</a>] [<a href="?admin&logout">Logout</a>] </div>'; echo '</div>'; } else { if($_POST['Submit']) { $_SESSION['user'] = $_POST['user']; $_SESSION['pass'] = $_POST['pass']; header('refresh:1;url=?admin'); echo 'Verifying data...'; } else { echo '<form action="" method="post"> <table border="0"> <tr> <td>Username</td> <td><input name="user" type="text" id="user" /></td> </tr> <tr> <td>Password</td> <td><input name="pass" type="password" id="pass" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Log in" /></td> </tr> </table></form>'; } } ?> <script type="text/javascript" language="Javascript"> $(document).ready(function(){ $('.delLink').click(function(e){ e.preventDefault(); $('#' + $(this).attr('name')).css({ backgroundColor:'red', color:'white' }); $('#' + $(this).attr("name")).fadeOut('slow'); $.get("admin.php", {'delete':'' , 'id':$(this).attr('name')}); }); }); </script> <div id="forumListContainer"> <h1>Admin Panel </h1> </div>
Create an account or sign in to comment