Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Analiza skryptu
Forum PHP.pl > Forum > Przedszkole
marconni
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();

?>
Sabistik
Proszę o poprawę tematu na zgodny z regulaminem działu przedszkole inaczej zostanie zamknięty.
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.