Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Emotikony
Louner
post 26.07.2005, 20:29:30
Post #1





Grupa: Zarejestrowani
Postów: 99
Pomógł: 5
Dołączył: 20.06.2005
Skąd: Bielsk Podlaski

Ostrzeżenie: (0%)
-----


Witam
Chciałbtm się zapytać, czy istnieje jakiś gotowy skrypt który konwertuje odpowiednie znaki na emotikony? Nie mam jeszcze tyle doświadczenia w programowaniu, żeby napisać własny. Szukałem takowego na stronach:

http://php.skryptoteka.pl/
na hasła: emoty, emotikony, konwerter znaków

http://www.webinside.pl/skrypty
na hasła: emoty, emotikony, emotki

http://www.wirtuals.net/

http://www.megaskrypty.com/index.php?cat=3

http://www.hotscripts.pl/index.php

http://php.resourceindex.com/search/index.cgi


Wszystko okazało się płonne. Czy ktoś mógłby mi pomóc ? sad.gif

Ten post edytował Louner 26.07.2005, 20:33:41
Go to the top of the page
+Quote Post
crash
post 26.07.2005, 20:33:08
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $tekst = str_replace( ':-)', '<img src=\"./usmiech.gif\"/>', $tekst );
  3. ?>

Kombinuj smile.gif


--------------------
Go to the top of the page
+Quote Post
Louner
post 26.07.2005, 20:40:53
Post #3





Grupa: Zarejestrowani
Postów: 99
Pomógł: 5
Dołączył: 20.06.2005
Skąd: Bielsk Podlaski

Ostrzeżenie: (0%)
-----


Hmm. Sprawa jest wg mnie torchę bardziej złożona. Z pomocą bardziej doświadczonych osób jakoś złożyłem (złożyli? winksmiley.jpg) takowy skrypt do newsów:

  1. <?php
  2. $dzial = '8';
  3.  
  4. $sql=&#092;"SELECT p.post_id, pt.post_id, pt.post_text, pt.bbcode_uid, t.topic_id, t.to
    p
  5. c_title, t.topic_first_post_id, t.forum_id, t.topic_replies, u.user_id, 
  6.  
  7. u.username, u.user_posts, u.user_rank
  8.  FROM &#092;".TOPICS_TABLE.\" t, \".USERS_TABLE.\" u, \".POSTS_TABLE.\" p, \".POSTS_TEXT_TABLE.\" pt
  9.  WHERE t.forum_id = $dzial
  10.  AND t.topic_poster = u.user_id
  11.  AND t.topic_first_post_id = pt.post_id
  12.  AND t.topic_first_post_id = p.post_id
  13.  ORDER BY pt.post_id DESC&#092;";
  14.  $query=mysql_query($sql);
  15.  while(
  16.  $result=mysql_fetch_assoc($query))
  17.  {
  18.  $text = $result['post_text'];
  19.  $text = bbcode_strip($text, $result['bbcode_uid']);
  20.  $link = append_sid('viewtopic.' . $phpEx . '?t=' . $result['topic_id']);
  21.  if (strlen($text) > 1000){
  22.  $text = substr($text, 0, 1000).'...[space][space] <a href=\"forum/'.$link.'\" class=\"wiecej\">Wiecej</a>';}
  23.  $text = str_replace('
  24.  ', '<br>', $text);
  25.  $author = ' ';
  26.  echo '<div style=\"text-align:justify; background:#FCFCFC; border: solid #CACACA 1px; padding:5px; margi
    n:5px; font-size:10pt\"><b><a 
  27.  
  28. href=\"forum/'.$link.'\" class=\"tytul_newsa\">'.$result['topic_title'].'</a></b><hr width=\"90%\" align\"center\"><span 
  29.  
  30. class=\"news\">'.$text.'</span><div align=\"right\"><br /><span class=\"autor\">'.$author.' :: </span><a href=\"forum/'.$link.'\" 
  31.  
  32. class=\"autor\">Komentarzy: <span class=\"autor_red\">'.$result['topic_replies'].'</span></a></div></div>';
  33.  }
  34.  ?>


Chodzi mi o to, by w zmiennej $text podmieniało emoty.

  1. <?php
  2. $tekst = str_relpace( ':-)', '<img src=\"./usmiech.gif\"/>', $tekst );
  3. ?>


Mam pytania:
1) nie umiem posługiwać się tą funkcją. Gdzie mam umieścić tekst wiadomości?
2) kiedy używam jej w takiej formie wyświetla mi błąd o odwołaniu do nieistniejącej funkcji. Jak mogę temu zaradzić? smile.gif Domyślam się, że po przecinkach deklaruję jej parametry.

Ten post edytował Louner 26.07.2005, 20:46:23
Go to the top of the page
+Quote Post
crash
post 26.07.2005, 21:06:39
Post #4





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

Ostrzeżenie: (0%)
-----


Sorki, zrobiłem literówke tongue.gif Ma być: str_replace" title="Zobacz w manualu PHP" target="_manual. Przy okazji pod tym linkiem znajdziesz informacje jak jej używać...


--------------------
Go to the top of the page
+Quote Post
Louner
post 27.07.2005, 11:39:50
Post #5





Grupa: Zarejestrowani
Postów: 99
Pomógł: 5
Dołączył: 20.06.2005
Skąd: Bielsk Podlaski

Ostrzeżenie: (0%)
-----


Ok, dziękuję. winksmiley.jpg Już wątpiłem, że ktoś mi pomoże biggrin.gif Udało się, zrozumiałem i jest świetnie biggrin.gif Dziękuję winksmiley.jpg

edit:
Niestety nie działa tam gdzie powinno tongue.gif Używam takiego skryptu:

  1. <?php
  2. $text = str_replace(&#092;":)\", \"<img src=\"forum/images/smiles/icon_smile.gif\">\", $text);
  3. $text = str_replace(&#092;";)\", \"<img src=\"forum/images/smiles/icon_wink.gif\">\", $text); 
  4. $text = str_replace(&#092;":P\", \"<img src=\"forum/images/smiles/icon_razz.gif\">\", $text); 
  5. $text = str_replace(&#092;"X)\", \"<img src=\"forum/images/smiles/icon_twisted.gif\">\", $text); 
  6. $text = str_replace(&#092;":D\", \"<img src=\"forum/images/smiles/icon_biggrin.gif\">\", $text); 
  7. $text = str_replace(&#092;":(\", \"<img src=\"forum/images/smiles/icon_sad.gif\">\", $text);
  8. $text = str_replace(&#092;"->\", \"<img src=\"forum/images/smiles/icon_arrow.gif\">\", $text);
  9. $text = str_replace(&#092;";(\", \"<img src=\"forum/images/smiles/icon_cry.gif\">\", $text); 
  10.  
  11. $dzial = '8';
  12.  
  13. $sql=&#092;"SELECT p.post_id, pt.post_id, pt.post_text, pt.bbcode_uid, t.topic_id, t.to
    p
  14. c_title, t.topic_first_post_id, t.forum_id, t.topic_replies, u.user_id, 
  15.  
  16. u.username, u.user_posts, u.user_rank
  17.  FROM &#092;".TOPICS_TABLE.\" t, \".USERS_TABLE.\" u, \".POSTS_TABLE.\" p, \".POSTS_TEXT_TABLE.\" pt
  18.  WHERE t.forum_id = $dzial
  19.  AND t.topic_poster = u.user_id
  20.  AND t.topic_first_post_id = pt.post_id
  21.  AND t.topic_first_post_id = p.post_id
  22.  ORDER BY pt.post_id DESC&#092;";
  23.  $query=mysql_query($sql);
  24.  while(
  25.  $result=mysql_fetch_assoc($query))
  26.  {
  27.  $text = $result['post_text'];
  28.  $text = bbcode_strip($text, $result['bbcode_uid']);
  29.  $link = append_sid('viewtopic.' . $phpEx . '?t=' . $result['topic_id']);
  30.  if (strlen($text) > 1000){
  31.  $text = substr($text, 0, 1000).'...[space][space] <a href=\"forum/'.$link.'\" class=\"wiecej\">Wiecej</a>';}
  32.  $text = str_replace('
  33.  ', '<br>', $text);
  34.  $author = ' ';
  35.  echo '<div style=\"text-align:justify; background:#FCFCFC; border: solid #CACACA 1px; padding:5px; margi
    n:5px; font-size:10pt\"><b><a 
  36.  
  37. href=\"forum/'.$link.'\" class=\"tytul_newsa\">'.$result['topic_title'].'</a></b><hr width=\"90%\" align\"center\"><span 
  38.  
  39. class=\"news\">'.$text.'</span><div align=\"right\"><br /><span class=\"autor\">'.$author.' :: </span><a href=\"forum/'.$link.'\" 
  40.  
  41. class=\"autor\">Komentarzy: <span class=\"autor_red\">'.$result['topic_replies'].'</span></a></div></div>';
  42.  }
  43.  ?>


Może gdzieś popełniłem błąd?

Ten post edytował Louner 27.07.2005, 12:07:52
Go to the top of the page
+Quote Post
4d3x
post 27.07.2005, 13:41:15
Post #6





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 18.06.2005
Skąd: Rybnik

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $dzial = '8';
  3.  
  4. $sql=&#092;"SELECT p.post_id, pt.post_id, pt.post_text, pt.bbcode_uid, t.topic_id, t.to
    p
  5. c_title, t.topic_first_post_id, t.forum_id, t.topic_replies, u.user_id,
  6.  
  7. u.username, u.user_posts, u.user_rank
  8.  FROM &#092;".TOPICS_TABLE.\" t, \".USERS_TABLE.\" u, \".POSTS_TABLE.\" p, \".POSTS_TEXT_TABLE.\" pt
  9.  WHERE t.forum_id = $dzial
  10.  AND t.topic_poster = u.user_id
  11.  AND t.topic_first_post_id = pt.post_id
  12.  AND t.topic_first_post_id = p.post_id
  13.  ORDER BY pt.post_id DESC&#092;";
  14.  $query=mysql_query($sql);
  15.  while(
  16. $result=mysql_fetch_assoc($query))
  17.  {
  18. $text = $result['post_text'];
  19. $text = bbcode_strip($text, $result['bbcode_uid']);
  20.  
  21. $text = str_replace(&#092;":)\", \"<img src=\"forum/images/smiles/icon_smile.gif\">\", $text);
  22. $text = str_replace(&#092;";)\", \"<img src=\"forum/images/smiles/icon_wink.gif\">\", $text);
  23. $text = str_replace(&#092;":P\", \"<img src=\"forum/images/smiles/icon_razz.gif\">\", $text);
  24. $text = str_replace(&#092;"X)\", \"<img src=\"forum/images/smiles/icon_twisted.gif\">\", $text);
  25. $text = str_replace(&#092;":D\", \"<img src=\"forum/images/smiles/icon_biggrin.gif\">\", $text);
  26. $text = str_replace(&#092;":(\", \"<img src=\"forum/images/smiles/icon_sad.gif\">\", $text);
  27. $text = str_replace(&#092;"->\", \"<img src=\"forum/images/smiles/icon_arrow.gif\">\", $text);
  28. $text = str_replace(&#092;";(\", \"<img src=\"forum/images/smiles/icon_cry.gif\">\", $text);
  29.  
  30. $link = append_sid('viewtopic.' . $phpEx . '?t=' . $result['topic_id']);
  31. if (strlen($text) > 1000){
  32. $text = substr($text, 0, 1000).'...[space][space] <a href=\"forum/'.$link.'\" class=\"wiecej\">Wiecej</a>';}
  33. $text = str_replace('
  34. ', '<br>', $text);
  35. $author = ' ';
  36. echo '<div style=\"text-align:justify; background:#FCFCFC; border: solid #CACACA 1px; padding:5px; margi
    n:5px; font-size:10pt\"><b><a
  37.  
  38. href=\"forum/'.$link.'\" class=\"tytul_newsa\">'.$result['topic_title'].'</a></b><hr width=\"90%\" align\"center\"><span
  39.  
  40. class=\"news\">'.$text.'</span><div align=\"right\"><br /><span class=\"autor\">'.$author.' :: </span><a href=\"forum/'.$link.'\"
  41.  
  42. class=\"autor\">Komentarzy: <span class=\"autor_red\">'.$result['topic_replies'].'</span></a></div></div>';
  43. }
  44. ?>


Powinno być dobrze
Go to the top of the page
+Quote Post
Louner
post 27.07.2005, 18:31:44
Post #7





Grupa: Zarejestrowani
Postów: 99
Pomógł: 5
Dołączył: 20.06.2005
Skąd: Bielsk Podlaski

Ostrzeżenie: (0%)
-----


A tak biggrin.gif Działa świetnie, dziękuję smile.gif
Go to the top of the page
+Quote Post
aleksander
post 27.07.2005, 20:30:16
Post #8





Grupa: Przyjaciele php.pl
Postów: 742
Pomógł: 0
Dołączył: 14.12.2003
Skąd: Gdańsk, Trójmiasto

Ostrzeżenie: (0%)
-----


nie trzeba tyle razy wywoływac funkcję str_replac. Wystarczy jedno wywołaie z podaniem tablicy z tymi elementami.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.06.2025 - 23:34