Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] połaczenie kodu ze skryptem
Forum PHP.pl > Forum > PHP
kominek
Witam !

Mam taki skrypt który wyświetla mi na stronie czy użytkownik jest zalogowany, jeśli nie jest pokazuje link do logowania a jeśli jest zalogowany pokazuje skrócone menu , o to on

  1. <?php
  2. if(isset($PHORUM["user"])){
  3.  
  4. $GLOBALS["USER"] = $PHORUM["user"];
  5.  
  6. } else {
  7.  
  8. define("PHORUM", "quick_auth");
  9.  
  10. // wrap all this in a function to protect it and other code
  11. function check_session()
  12. {
  13. // one of these needs to be commented out.
  14. $require = "sessid_lt"; // long term cookie that will exist over time
  15. //$require = "sessid_st"; // short term cookie that may not be required at all, but is more secure
  16.  
  17. include_once($_SERVER["DOCUMENT_ROOT"]."/czarneplyty_strona/forum/include/db/config.php");
  18.  
  19. list( $user_id, $sess_id ) = explode( ":", $_COOKIE["phorum_session_v5"], 2 );
  20.  
  21. $conn=mysql_connect($PHORUM["DBCONFIG"]["server"], $PHORUM["DBCONFIG"]["user"], $PHORUM["DBCONFIG"]["password"], true);
  22. mysql_select_db($PHORUM["DBCONFIG"]["name"], $conn);
  23.  
  24. $sql="select * from ".$PHORUM["DBCONFIG"]["table_prefix"]."_users where user_id='".mysql_escape_string($user_id)."' and $require='".mysql_escape_string($sess_id)."'";
  25.  
  26. $res=mysql_query($sql, $conn);
  27.  
  28. if(mysql_num_rows($res)){
  29. $USER=mysql_fetch_assoc($res);
  30.  
  31. $sql="select data from ".$PHORUM["DBCONFIG"]["table_prefix"]."_settings where name='PROFILE_FIELDS'";
  32.  
  33. $res=mysql_query($sql, $conn);
  34. if(mysql_num_rows($res)){
  35. $fields=unserialize(mysql_result($res, 0, "data"));
  36.  
  37. $sql="select * from ".$PHORUM["DBCONFIG"]["table_prefix"]."_user_custom_fields where user_id='".mysql_escape_string($user_id)."'";
  38.  
  39. $res=mysql_query($sql, $conn);
  40. if(mysql_num_rows($res)){
  41. while($row=mysql_fetch_assoc($res)){
  42. $USER[$fields[$row["type"]]["name"]]=$row["data"];
  43. }
  44. }
  45. }
  46.  
  47. } else {
  48. $USER=array();
  49. }
  50.  
  51. $GLOBALS["USER"]=$USER;
  52.  
  53. }
  54.  
  55.  
  56. check_session();
  57. }
  58.  
  59.  
  60. }
  61.  
  62. if ( isset($GLOBALS['USER']) && !empty($GLOBALS['USER']['user_id']) ) {
  63. $display_name = htmlspecialchars($GLOBALS['USER']['display_name']);
  64. print "Witaj $display_name";
  65. } else {
  66. print "zaloguj się";
  67. }
  68. ?>


Chciałbym aby w tym skróconym menu pojawiała się ikona która inforumje użytkownika czy mamy nową wiadomość , problem polega na tym , że nie wiem jak pogodzić skrypt ( ten u góry ) z tym kodem :

  1. <?php
  2. if (!empty($PHORUM["enable_new_pm_count"]) &&
  3. !empty($PHORUM["enable_pm"])) {
  4. $PHORUM['user']['new_private_messages'] =
  5. phorum_db_pm_checknew($PHORUM['user']['user_id']);
  6. }
  7. }
  8. ?>



Jeśli ktoś by mógł mi pomóc byłbym bardzo wdzięczny.
nowotny
I myślisz że komuś będzie się chciało odcyfrowywać ten śmietnik...? Wstaw to porządnie, z wcięciami i w odpowiednim tagu... I popraw tytuł wątku bo cię zaraz administracja zjedzie...
kominek
no jakoś mi wyszło .... przepraszam
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.