Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL][PHP]Ilość niewykonanych zdarzeń na ikonie
Forum PHP.pl > Forum > Przedszkole
kubax33
Chciałbym np. co 2 min odczytywać dane z bazy i sprawdzać ile określonych zdarzeń jest niewykonanych. Coś na wzór gmaila, który pokazuje w ikonie ilość nieprzeczytanych wiadomości.
Widzicie jakieś dobre rozwiązanie? Zdaje mi się, że to działa na zasadzie ikon z określonymi liczbami czyli ogólnie zwykły favicon.

Coś takiego:
trueblue
http://www.p01.org/defender_of_the_favicon/
Niree
CRON.
nospor
@Niree i jak ma sie ta genialna odpowiedz CRON do wyswietlania danych w tytule zakladki przegladarki?
kubax33
Znalazłem coś takiego:

http://viralpatel.net/blogs/dynamic-unread...favicon-in-php/

Niestety generuje tylko do 9 czy ktoś widzi rozwiązanie, aby generował dwucyfrowe liczy?

POBIERZ: http://viralpatel.net/blogs/demo/php/dynam...dynafavicon.zip

Zapisuję poniżej bo być może komuś się przyda.

favico.php
  1. <?php
  2.  
  3. //Read the favicon template from favicon.png
  4. //file from current directory
  5. $im = imagecreatefrompng("favicon.png");
  6.  
  7.  
  8. /* Read the character which needs to be added in favicon from
  9.  * get request
  10.  */
  11. if(isset($_GET['char']) && !empty($_GET['char'])) {
  12. $string = $_GET['char'];
  13. } else {
  14. /* If no character is specified; add some default value */
  15. $string = 'V';
  16. }
  17.  
  18. /* background color for the favicon */
  19. $bg = imagecolorallocate($im, 255, 255, 255);
  20.  
  21. /* foreground (font) color for the favicon */
  22. $black = imagecolorallocate($im, 0, 0, 0);
  23.  
  24. /* Write the character in favicon
  25.  * arguements: image, fontsize, x-coordinate,
  26.  * y-coordinate, characterstring, color
  27.  */
  28. imagechar($im, 2, 5, 1, $string, $black);
  29.  
  30. header('Content-type: image/png');
  31.  
  32. imagepng($im);
  33.  
  34. ?>


index.php

  1. <html>
  2. <head>
  3. <title>Dynamic unread count favicon in PHP!</title>
  4. <link rel="shortcut icon" href="favicon.php?char=<?php if(isset($_POST['char'])) { echo $_POST['char']; } ?>" />
  5. <STYLE>
  6. body, input{
  7. font-family: Calibri, Arial;
  8. margin:0px;
  9. font-size: 19px;
  10. }
  11. h1 {
  12. margin: 0 0 0 20px;
  13. }
  14. html, body, #container { height: 100%; }
  15. body > #container { height: auto; min-height: 100%; }
  16.  
  17. #header {
  18. height:50px;
  19. background-color:#ddd;
  20. border-bottom:1px solid #aaa;
  21. width:100%;
  22. font-size: 15px;
  23. }
  24. #footer {
  25. font-size: 12px;
  26. clear: both;
  27. position: relative;
  28. z-index: 10;
  29. height: 3em;
  30. margin-top: -3em;
  31. text-align:center;
  32. }
  33. .demo {
  34. width:150px;
  35. height:150px;
  36. padding:5px;
  37. background-color:#ff8811;
  38. position:absolute;
  39. top:150px;
  40. left:300px;
  41. }
  42. #content { padding-bottom: 3em; margin: 20px;}
  43. </STYLE>
  44. </head>
  45. <body>
  46.  
  47.  
  48. <div id="container">
  49. <div id="header">
  50. <h1>Dynamic unread count favicon in PHP</h1>
  51. </div>
  52. <div id="content">
  53.  
  54.  
  55. <p><a href="http://viralpatel.net/blogs/2011/01/dynamic-unread-count-favicon-in-php.html">Click here to view Tutorial</a></p>
  56.  
  57. <p>Enter any character in the following textbox and hit Generate button. The dynamic favicon will be
  58. generated and the character will be added into it. Also check the favicon in browser tab.
  59. Also check the favicon in the browser tab.</p>
  60.  
  61. <form method="post">
  62. <label>Enter a Character to add in favicon</label>
  63. <input type="text" name="char" style="width:40px" maxlength="1"/>
  64. <br/>
  65. <input type="submit" value="Generate favicon" />
  66. </form>
  67.  
  68. Dynamic Favicon
  69. <img src="favicon.php?char=<?php if(isset($_POST['char'])) { echo $_POST['char']; } ?>" border="0"/>
  70. <br/>
  71. </div>
  72. </div>
  73.  
  74. <div id="footer">
  75. Copyright &copy; <a href="http://viralpatel.net">ViralPatel.net</a>
  76. | <a href="http://viralpatel.net/blogs/about">About</a>
  77. </div>
  78.  
  79. </body>
  80. </html>


oraz ikona favico.png o wymiarach 16x16px

fajne rozwiązanie na pewno przyda się do niektórych projektów.
nospor
imagechar()
jak sama nazwa wskazuje rysuje tylko jeden znak. To samo masz napisane zreszta w manualu przy tej funkcji.
W tymze samym manualu w komentarzach masz podany kod ktory rysuje dluzsze teksty

http://php.net/manual/en/function.imagechar.php
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.