Witam

Mam taki maly problem:

Mam taki kod:

  1. <?php
  2.  
  3. //----------------------------------
  4. // Check if the name is protected
  5. //----------------------------------
  6. $is_member = FALSE;
  7. foreach($all_users as $member_db_line)
  8. {
  9. if(!eregi(&#092;"<?\",$member_db_line) and $member_db_line != \"\"){
  10. $user_arr = explode(&#092;"|\",$member_db_line);
  11.  
  12. //if the name is protected
  13. if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and ($user_arr[3] != $CNpass and $user_arr[3] != md5($password)) and $name != &#092;"\")
  14. if ($user_arr[1] == &#092;"5\") {
  15. echo&#092;"<div style=\"text-align: center;\">This name is banned from commenting.</div>\";
  16. $CN_HALT = TRUE;
  17. break 2;
  18.  
  19. } else {
  20.  
  21. {
  22.  
  23. //$comments = replace_comment(\"add\", $comments); //commented because will mess up the <br />
  24. $comments = preg_replace(array(&#092;"'\"'\", \"'''\", \"''\"), array(\"&quot;\", \"'\", \"\"), $comments);
  25. $name = replace_comment(&#092;"add\", preg_replace(\"/n/\", \"\",$name));
  26. $mail = replace_comment(&#092;"add\", preg_replace(\"/n/\", \"\",$mail));
  27.  
  28.  
  29. echo&#092;"
  30. <h2>Logowanie</h2>
  31. <div class=&#092;"lewo\">
  32. </div>
  33. wprowad¼ has³o otrzymane podczas rejestracji<br />
  34. <form name=&#092;"passwordForm\" id=\"passwordForm\" method=\"post\" action=\"\">
  35. <p><label for=&#092;"login\">login:</label></p>
  36. <p><input tabindex=&#092;"1\" type=\"text\" name=\"username\" value=\"\" style=\"width:134\"></p>
  37. <p><label for=&#092;"haslo\">has³o:</label></p>
  38. <p><input tabindex=&#092;"2\" type=\"password\" name=\"password\" size=\"35\" value=\"\" /></p>
  39. <input type=&#092;"hidden\" name=\"name\" value=\"$name\" />
  40. <input type=&#092;"hidden\" name=\"comments\" value=\"$comments\" />
  41. <input type=&#092;"hidden\" name=\"mail\" value=\"$mail\" />
  42. <input type=&#092;"hidden\" name=\"ip\" value=\"$ip\" />
  43. <input type=&#092;"hidden\" name=\"subaction\" value=\"addcomment\" />
  44. <input type=&#092;"hidden\" name=\"show\" value=\"$show\" />
  45. <input type=&#092;"hidden\" name=\"ucat\" value=\"$ucat\" />
  46. $user_post_query
  47. <input class=&#092;"bezramki\" type=\"checkbox\" name=\"CNrememberPass\" value=\"1\" />
  48. <div class=&#092;"prawo\">
  49. <p>&nbsp;</p>
  50. <p><input type=&#092;"submit\" value=\"wchodzê\"tabindex=\"3\" /></p>
  51. </div>
  52. </form>
  53. &#092;";
  54.  
  55.  
  56. $CN_HALT = TRUE;
  57.  break 2;
  58.  
  59. }
  60. }
  61. ?>


gdzie tutaj wstawic instrukcje ktora bedzie mi sprawdzala czy user jest zalogowany - sprawdzala czy jest ciasteczko.

Bo jestem zalogowany tylko ze w tym kodzie nic tego nie sprawdza i jest ponowne pytanie o haslo.

Poniezej daje fragment skryptu admin.php gdzie to jest rozwiazane ale ja nie wiem jak to umiescic w tym kodzie powyzej sad.gif

  1. <?php
  2.  
  3. error_reporting (E_ALL ^ E_NOTICE);
  4.  
  5. require_once(&#092;"./inc/functions.inc.php\");
  6. //#################
  7.  
  8. $PHP_SELF = &#092;"admin.php\";
  9. $cutepath = &#092;".\";
  10. $config_path_image_upload = &#092;"./data/upimages\";
  11.  
  12. $config_use_cookies = TRUE; // Use Cookies When Checking Authorization
  13. $config_use_sessions = FALSE; // Use Sessions When Checking Authorization
  14. $config_check_referer = FALSE; // Set to TRUE for more seciruty
  15. //#################
  16.  
  17. $Timer = new microTimer;
  18. $Timer->start();
  19.  
  20. // Check if CuteNews is not installed
  21. $all_users_db = file(&#092;"./data/users.db.php\");
  22. $check_users = $all_users_db;
  23. $check_users[1] = trim($check_users[1]);
  24. $check_users[2] = trim($check_users[2]);
  25. if((!$check_users[2] or $check_users[2] == &#092;"\") and (!$check_users[1] or $check_users[1] == \"\")){
  26. if(!file_exists(&#092;"./inc/install.mdu\")){ die('<h2>Error!</h2>CuteNews detected that you do not have users in your users.db.php file and w
  27. nts to run the install module.<br>
  28. However, the install module (<b>./inc/install.mdu</b>) can not be located, please reupload this file and make sure you set the proper permissions so the i
  29. stallation can continue.'); }
  30. require(\"./inc/install.mdu\");
  31. die();
  32. }
  33.  
  34. require_once(\"./data/config.php\");
  35. if(isset($config_skin) and $config_skin != \"\" and file_exists(\"./skins/${config_skin}.skin.php\")){
  36. require_once(\"./skins/${config_skin}.skin.php\");
  37. }else{
  38. $using_safe_skin = true;
  39. require_once(\"./skins/default.skin.php\");
  40. }
  41.  
  42. b64dck();
  43. if($config_use_sessions){
  44. @session_start();
  45. @header(\"Cache-control: private\");
  46. }
  47.  
  48. if($action == \"logout\")
  49. {
  50. setcookie(\"md5_password\",\"\");
  51. setcookie(\"username\",\"\");
  52. setcookie(\"login_referer\",\"\");
  53. // ------------------------------------------------
  54. // Set the file to 0
  55. // ------------------------------------------------
  56. $check_file = fopen(\"./_check.php\"\"wr\");
  57. fwrite($check_file, \"\" );
  58. fclose($check_file);
  59. // ------------------------------------------------
  60. if($config_use_sessions){
  61. @session_destroy();
  62. @session_unset();
  63. setcookie(session_name(),\"\");
  64. }
  65. msg(\"info\"\"Logout\"\"You are now logged out, <a href=\"$PHP_SELF\">login</a><br /><br>\");
  66. }
  67.  
  68.  
  69. $is_loged_in = FALSE;
  70. $cookie_logged = FALSE;
  71. $session_logged = FALSE;
  72. $temp_arr = explode(\"?\", $HTTP_REFERER);
  73. $HTTP_REFERER = $temp_arr[0];
  74. if(substr($HTTP_REFERER, -1) == \"/\"){ $HTTP_REFERER.= \"admin.php\"; }
  75.  
  76. // Check if The User is Identified
  77.  
  78. if($config_use_cookies == TRUE){
  79. /* Login Authorization using COOKIES */
  80.  
  81. if(isset($username))
  82. {
  83. if(isset($HTTP_COOKIE_VARS[\"md5_password\"])){ $cmd5_password = $HTTP_COOKIE_VARS[\"md5_password\"]; }
  84. elseif(isset($_COOKIE[\"md5_password\"])){ $cmd5_password = $_COOKIE[\"md5_password\"]; }
  85. else{ $cmd5_password = md5($password); }
  86.  
  87. if(check_login($username, $cmd5_password))
  88. {
  89. $cookie_logged = TRUE;
  90. setcookie(\"lastusername\", $username, time()+1012324305);
  91. setcookie(\"username\", $username);
  92. setcookie(\"md5_password\", $cmd5_password);
  93. // ------------------------------------------------
  94. // Write username to a file when logged in
  95. // ------------------------------------------------
  96. $check_file = fopen(\"./_check.php\"\"w\");
  97. fwrite($check_file, $username);
  98. fclose($check_file);
  99. // ------------------------------------------------
  100. }else{
  101. $result = \"<font color=red>Wrong username or password</font>\";
  102. $cookie_logged = FALSE;
  103.  }
  104. }
  105. /* END Login Authorization using COOKIES */
  106. }
  107.  
  108. if($config_use_sessions == TRUE){
  109. /* Login Authorization using SESSIONS */
  110. if(isset($HTTP_X_FORWARDED_FOR)){ $ip = $HTTP_X_FORWARDED_FOR; }
  111. elseif(isset($HTTP_CLIENT_IP)) { $ip = $HTTP_CLIENT_IP; }
  112. if($ip == \"\") { $ip = $REMOTE_ADDR; }
  113. if($ip == \"\") { $ip = \"not detected\";}
  114.  
  115. if($action == \"dologin\")
  116. {
  117. $md5_password = md5($password);
  118. if(check_login($username, $md5_password)){
  119. $session_logged = TRUE;
  120.  
  121. @session_register('username');
  122. @session_register('md5_password');
  123. @session_register('ip');
  124. @session_register('login_referer');
  125.  
  126. $_SESSION['username'] = \"$username\";
  127. $_SESSION['md5_password'] = \"$md5_password\";
  128. $_SESSION['ip'] = \"$ip\";
  129. $_SESSION['login_referer'] = \"$HTTP_REFERER\";
  130.  
  131. }else{
  132. $result = \"<font color=red>Wrong username and/or password</font>\";
  133. $session_logged = FALSE;
  134. }
  135. }elseif(isset($_SESSION['username'])){ // Check the if member is using valid username/password
  136. if(check_login($_SESSION['username'], $_SESSION['md5_password'])){
  137. if($_SESSION['ip'] != $ip){ $session_logged = FALSE; $result = \"The IP in the session doesn not match with your IP\"; }
  138. else{ $session_logged = TRUE; }
  139. }else{
  140. $result = \"<font color=red>Wrong username and/or password !!!</font>\";
  141. $session_logged = FALSE;
  142. }
  143. }
  144.  
  145. if(!$username){ $username = $_SESSION['username]; }
  146. /* END Login Authorization using SESSIONS */
  147. }
  148. ?>