Kirjautuminen

Haku

Tehtävät

Keskustelu: Nettisivujen teko: Muutama virhe jota en löydä/osaa korjata...

ZeBe [22.01.2004 20:34:04]

#

Tämä kaikki siin on dpBB:n foorumista.... jota en saa toimimaan kunnolla...

Tuota prefs.php:ssä tämä sanoo että:
Warning: Cannot modify header information - headers already sent by (output started at /home/ruokakom/public_html/yla.html:17) in /home/ruokakom/public_html/include/session.php on line 5

Eli missä vika kerronko session.php:n koodin vain tuon toisen?
session.php:n koodi on tälläinen

<?php
function authenticate($npage)
{
  global $board_url;
  header("Location: " . $board_url . "auth.php?next=$npage");
  exit;
}

function auth_admin_by_id($id)
{
  $result = db_query("SELECT id FROM superusers WHERE userid=$id AND mode=1");
  if(mysql_num_rows($result) != 1) return false;
  return db_fetch1($result);
}

function auth_moderator_by_id($id)
{
  $result = db_query("SELECT id FROM superusers WHERE userid=$id AND mode=2");
  if(mysql_num_rows($result) != 1) return false;
  return db_fetch1($result);
}

function auth_user($name, $password)
{
   $pass = md5($password);
  $result = db_query("SELECT id FROM users WHERE name='$name' AND password='$pass'");
  if(mysql_num_rows($result) == 1) return db_fetch1($result);
  else return false;
}

function auth_admin($name, $password)
{
   $pass = md5($pasword);

  $result = db_query("SELECT id FROM users WHERE name='$name' AND password='$pass'");
  if(mysql_num_rows($result) != 1) return false;

  $id = db_fetch1($result);
  return auth_admin_by_id($id);
}

function create_session($userid)
{
  global $expire_mins;

  db_query("DELETE FROM sessions WHERE expire < NOW()");
   db_query("DELETE FROM sessions WHERE userid=$userid");

  $sid = uniqid("");
  $result = db_query("SELECT id FROM sessions WHERE id=$sid");
  while($result && mysql_fetch_row($result))
  {
    $sid = uniqid("");
    $result = db_query("SELECT id FROM sessions WHERE id=$sid");
  }
  db_query("INSERT INTO sessions (id, userid, start, expire) VALUES('$sid', $userid, NOW(), NOW() + INTERVAL $expire_mins MINUTE)");
  return $sid;
}

function delete_session($sessionid)
{
  db_query("DELETE FROM sessions WHERE id='$sessionid'");
}

function auth_session($id)
{
   $result = db_query("SELECT userid, expire FROM sessions WHERE id='$id'");
  if($session = mysql_fetch_array($result))
  {
      $userid = $session["userid"];
    $expire = $session["expire"];

    $r = db_fetch1(db_query("SELECT NOW() < '$expire'"));
    if($r == '1')
    {
         db_query("UPDATE sessions SET expire=NOW() + INTERVAL 120 MINUTE WHERE id='$id'");
      return true;
    }
    else
    {
       db_query("DELETE FROM sessions WHERE id='$id'");
      return false;
    }
  }
  else return false;
}

function auth_moderator_session($id)
{
  if(!isset($id)) return false;
   $result = db_query("SELECT userid, expire FROM sessions WHERE id='$id'");
  if($session = mysql_fetch_array($result))
  {
      $userid = $session["userid"];
      if(auth_moderator_by_id($userid) == false) return false;
    $expire = $session["expire"];

    $r = db_fetch1(db_query("SELECT NOW() < '$expire'"));
    if($r == '1')
    {
         db_query("UPDATE sessions SET expire=NOW() + INTERVAL 120 MINUTE WHERE id='$id'");
      return true;
    }
    else
    {
       db_query("DELETE FROM sessions WHERE id='$id'");
      return false;
    }
  }
  else return false;
}

function auth_admin_session($id)
{
  if(!isset($id)) return false;
   $result = db_query("SELECT userid, expire FROM sessions WHERE id='$id'");
  if($session = mysql_fetch_array($result))
  {
      $userid = $session["userid"];
      if(auth_admin_by_id($userid) == false) return false;
    $expire = $session["expire"];

    $r = db_fetch1(db_query("SELECT NOW() < '$expire'"));
    if($r == '1')
    {
         db_query("UPDATE sessions SET expire=NOW() + INTERVAL 120 MINUTE WHERE id='$id'");
      return true;
    }
    else
    {
       db_query("DELETE FROM sessions WHERE id='$id'");
      return false;
    }
  }
  else return false;
}

?>

ja auth.php:ssä sanoo vian:

Warning: Cannot modify header information - headers already sent by (output started at /home/ruokakom/public_html/yla.html:17) in /home/ruokakom/public_html/auth.php on line 43

Warning: Cannot modify header information - headers already sent by (output started at /home/ruokakom/public_html/yla.html:17) in /home/ruokakom/public_html/auth.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /home/ruokakom/public_html/yla.html:17) in /home/ruokakom/public_html/auth.php on line 47

Warning: Cannot modify header information - headers already sent by (output started at /home/ruokakom/public_html/yla.html:17) in /home/ruokakom/public_html/auth.php on line 48

koodi on:

<?php include("yla.html"); ?>
<BR>
<?php // AUTH.PHP

$root_inc = "";
include($root_inc . "common.php");

if(!isset($submit))
{
  $title = $l_login;
  include($root_inc . "page_header.php");
 ?>
 <form method="post" action="<?php echo $PHP_SELF ?>">
 <input type="hidden" name="next" value="<?php echo $next ?>" />
 <?php start_table_w(50); ?>
  <tr><td class="header" colspan="2" width="100%"><?php echo $l_login;?></td></tr>
  <tr>
   <td class="light" width="50%"><b><?php echo $l_username;?></b></td>
   <td class="light" width="50%"><input type="text" name="name" size="25" maxlength="32" /></td>
  </tr>
  <tr>
   <td class="dark"><b><?php echo $l_password;?></b></td>
   <td class="dark"><input type="password" name="password" size="25" maxlength="16" /></td>
  </tr>
  <tr><td class="light" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $l_login;?>" /></td></tr>
 <?php
 end_table();
}
else
{
  if(!db_connect()) {
    include($root_inc . "page_header.php");
    dpbb_error_cdb();
  }
  $userid = auth_user($name, $password);
  if($userid == false) {
    include($root_inc . "page_header.php");
    dpbb_error($l_invalidlogin_text);
  }
  else
  {
    $user = db_fetch_user_by_id($userid, "language");
    if ($user["language"] == "default") setcookie("dpbblanguage");
    else setcookie("dpbblanguage", $user["language"], time()+31104000);
    $sid = create_session($userid);
    setcookie("sessionid", $sid, time() + ($expire_mins * 60));
    setcookie("userid", $userid, time() + ($expire_mins * 60));
    header("Location: $board_url" . (isset($next) ? $next : "index.php") . "?sessionid=$sid");
    exit;
  }
}

include($root_inc . "page_footer.php");
?>  <BR>
<?php include("ala.php"); ?>

Sen jälkeen kun yrittää kirjautua... :S


Sitten kun yrittää kirjautua niin se sanoo myös virheen... koodi on logout.php:ssä tälläinen

<?php // LOGOUT.PHP

$root_inc = "keskustelu.php";
include($root_inc . "common.php");

if(!db_connect())
{
  include($root_inc . "page_header.php");
  dpbb_error_cdb();
}
else
{
  if (isset($sessionid)) delete_session($sessionid);
  setcookie("sessionid");
  setcookie("userid");
  header("Location: $board_url" . "keskustelu.php");
}
echo "**$root_inc**";
?>

ZeBe [23.01.2004 08:11:07]

#

Tämä kaikki siin on dpBB:n foorumista.... jota en saa toimimaan kunnolla...

Edelliset virheet korjattu jo on...

Enää on virhe logout.php:ssä.
sanoo näin:
Warning: main(keskustelu.phpcommon.php): failed to open stream: No such file or directory in /home/ruokakom/public_html/logout.php on line 4

Warning: main(): Failed opening 'keskustelu.phpcommon.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php­') in /home/ruokakom/public_html/logout.php on line 4

Fatal error: Call to undefined function: db_connect() in /home/ruokakom/public_html/logout.php on line 6

ja koodi on tälläinen:

<?php // LOGOUT.PHP

$root_inc = "keskustelu.php";
include($root_inc . "common.php");

if(!db_connect())
{
  include($root_inc . "page_header.php");
  dpbb_error_cdb();
}
else
{
  if (isset($sessionid)) delete_session($sessionid);
  setcookie("sessionid");
  setcookie("userid");
  header("Location: $board_url" . "keskustelu.php");
}

?>

edit:

toinenkin kohta löyty:

Parse error: parse error in /home/ruokakom/public_html/reply.php on line 410

ja se koodi loppuu:

<?php
end_table();
?>
 </form>

riville 409 eli mitä rivillä 410 pitäis olla?

tsuriga [23.01.2004 10:02:06]

#

Tukeeko php noita iffejä ilman {} -merkkejä?
mietin vain, että tarvitseeko tämä: if (isset($sessionid)) delete_session($sessionid); {} -merkkejä.

Olga [23.01.2004 10:46:22]

#

Juu, kyllä tukee. Noi yksriviset menee ilman enkeleitä niin iffeissä ku foreissakin. Mut ZeBe, nyt on ainaki kymmenellä palstalla vastattu sun samaan ongelmaan... :)

ZeBe [23.01.2004 11:21:28]

#

jaah... no mutta nytten heitin hemmettiin sen foorumin ja väsään uuden taikka sitten hankin jostain taikka jotain...

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta