[Script] Mentiuni ca pe Facebook

Locked
User avatar
! Manticore ♛
Membru
Membru
Posts: 1542
Joined: 8 years ago
Location: New York , SUA
Has thanked: 0
Been thanked: 0
Zodiac:
Age: 27
Status: Offline

7 years ago

Mentiuni ca pe Facebook

Code: Select all

function mentiune($string)
        {
          // Modificati cu variabila voastra MySQLi.
          global$sqli;
          
          $regex_mentiune = "/@+([a-zA-Z0-9_-]+)/i";
          preg_match_all($regex_mentiune, $string, $match);
    
             foreach($match[1] as $mentiune)
                {
                    $fetch_user = $sqli->query("SELECT COUNT(id) FROM tabela_utilizatori WHERE nume='$mentiune'");
                    $count = $fetch_user->fetch_array();
                         
                        if($count[0] == "0")
                             {
                                  $string = preg_replace($regex_mentiune, '$0', $string);

                                     return($string);

                              } else {

                                 $fetch_id = $sqli->query("SELECT id FROM tabela_utilizatori WHERE nume='$mentiune'");
                                 $id = $fetch_id->fetch_array();
                                 $user_id = $id[0];
                
                                    preg_match_all($regex_mentiune, $string, $match);
                                    
                                       foreach($match[1] as $mentiune)
                                          {
                                             $replace = "<a href=\"profil.php?id=$user_id\">$mentiune</a>";
                                             $string = str_replace($mentiune, $replace, $string);
                                             $string = str_replace('@', '', $string);

                                                      return($string);
                                 }
                
                        }
        
                }
        
             return($string);
         
       } 
Daca utilizatorul este gasit in baza de date, se va sterge @ si va ramane numele sau sub forma de link spre profilul lui. Daca nu este gasit, va ramane @numeutilizator fara sa se transforme in link... Este case sensitive, puteti mentiona @NuMeUsEr chiar daca el are numele scris cu majuscule, etc.
Image Image

Image

© ! Manticore ♛

"Many things that seems threatening in the dark,become more welcoming when we shine a light on them."
"Maybe for the world you are just a person,but for a person you are the entire world."
"Nothing is impossible,the word itself says <<I'm Possible>>."
"If the pain will ever speak,then my pain will scream."
''The fastest way to happiness is to avoid the reality."

Image
Locked

Return to “Script-uri”