Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Analiza skryptu
marconni
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 25.02.2008

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


Witam Wszystkich,
Ostatnio taki skrypt znalazłem w sieci, nie wiem o co w nim biega dokładnie, proszę o analizę
Kod
<?php

/*

CREATE TABLE `lyrics` (
  `id` int(11) NOT NULL auto_increment,
  `artist_name` varchar(100) collate latin1_general_ci NOT NULL,
  `song_name` varchar(100) collate latin1_general_ci NOT NULL,
  `lyrics` longtext collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1;

*/

function get_lyrics()
{
    $maindir = './'; // With slash at the end.
    
    $config['username'] = 'root';
    $config['password'] = '';
    $config['database'] = 'lyrics';
    $config['hostname'] = 'localhost';
    
    ####################### DO NOT EDIT BELOW #######################
    
    $con = mysql_connect
    (
        $config['hostname'],
        $config['username'],
        $config['password']
        
    ) OR die( mysql_error() );
    
    mysql_select_db($config['database'], $con) OR die( mysql_error() );
    
    @set_time_limit(300); // Just incase...
    
    for ($i = 65; $i <= 90; $i++)
    {
        if ($dir = @opendir($maindir . chr($i) ))
        {
            while (($artist = readdir($dir)) !== false)
            {
                if (!in_array($artist, array('.', '..')) AND !is_file($artist))
                {
                    $artistdir = @opendir($maindir . chr($i) .'/'. $artist);
                    
                    while (($song = readdir($artistdir)) !== false)
                    {
                        if (substr(strrchr($song, '.'), 1) == 'txt')
                        {
                            $lyrics = @file_get_contents($maindir . chr($i) .'/'. $artist .'/'. $song);
                            $db_lyrics = mysql_real_escape_string($lyrics);
                        
                            $db_artist = ucwords(str_replace('_', ' ', $artist));
                            $db_song   = ucfirst(str_replace(array('_', '-', '.txt'), array(' ', ' ', NULL), $song));
                            
                            $query = "INSERT INTO lyrics
                                      (artist_name, song_name, lyrics)
                                      VALUES
                                      ('". $db_artist ."', '". $db_song ."', '". $db_lyrics ."')";
                            
                            mysql_query($query) OR die( mysql_error() .'<br />'. $query);
                        }
                    }
                }
            }
        }
    }
}


get_lyrics();

?>


Ten post edytował marconni 1.03.2008, 22:24:03
Go to the top of the page
+Quote Post
Sabistik
post
Post #2


Administrator wortalu


Grupa: Przyjaciele php.pl
Postów: 960
Pomógł: 39
Dołączył: 21.10.2003
Skąd: Kraków

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


Proszę o poprawę tematu na zgodny z regulaminem działu przedszkole inaczej zostanie zamknięty.
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 Aktualny czas: 19.08.2025 - 19:21