Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Klon YouTube i Class 'SFile'
K0walD3sign
post
Post #1





Grupa: Zarejestrowani
Postów: 25
Pomógł: 0
Dołączył: 22.03.2009

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


Witam was. Ostatnio wpadł mi w rękę skrypt klonu YouTube'a. Tak sobie myśle, że pobawie się tym. Mam na celu stworzenie hostingu filmów ze serwerow role play z pewnej gry. No i 7GB do dyspozycji.

Więc wszystko wgralem na FTP, było troche roboty z plikami konfiguracji ale conieco tam podołałem.

Teraz jest problem z bazą danych podczas instalacji. Sprawa wygląda tak:

Po wpisaniu danych bazy MySQL klikam dalej i wyskakuje takowy błąd.

Kod
Fatal error: Class 'SFile' not found in /home/marc3l/ftp/yt/install/run_sql.php on line 126


No dobra, wywnioskować można w prosty sposób, że SFile to coś dziwnego w 126 linii tego pliku. Więc pokaże wam ten plik.

Kod
<?php

ini_set('max_execution_time', '0');

function PMA_splitSqlFile(&$ret, $sql, $release)
{
    $sql          = trim($sql);
    $sql_len      = strlen($sql);
    $char         = '';
    $string_start = '';
    $in_string    = FALSE;
    $time0        = time();

    for ($i = 0; $i < $sql_len; ++$i) {
        $char = $sql[$i];

        // We are in a string, check for not escaped end of strings except for
        // backquotes that can't be escaped
        if ($in_string) {
            for (;;) {
                $i         = strpos($sql, $string_start, $i);
                // No end of string found -> add the current substring to the
                // returned array
                if (!$i) {
                    $ret[] = $sql;
                    return TRUE;
                }
                // Backquotes or no backslashes before quotes: it's indeed the
                // end of the string -> exit the loop
                else if ($string_start == '`' || $sql[$i-1] != '\\') {
                    $string_start      = '';
                    $in_string         = FALSE;
                    break;
                }
                // one or more Backslashes before the presumed end of string...
                else {
                    // ... first checks for escaped backslashes
                    $j                     = 2;
                    $escaped_backslash     = FALSE;
                    while ($i-$j > 0 && $sql[$i-$j] == '\\') {
                        $escaped_backslash = !$escaped_backslash;
                        $j++;
                    }
                    // ... if escaped backslashes: it's really the end of the
                    // string -> exit the loop
                    if ($escaped_backslash) {
                        $string_start  = '';
                        $in_string     = FALSE;
                        break;
                    }
                    // ... else loop
                    else {
                        $i++;
                    }
                } // end if...elseif...else
            } // end for
        } // end if (in string)

        // We are not in a string, first check for delimiter...
        else if ($char == ';') {
            // if delimiter found, add the parsed part to the returned array
            $ret[]      = substr($sql, 0, $i);
            $sql        = ltrim(substr($sql, min($i + 1, $sql_len)));
            $sql_len    = strlen($sql);
            if ($sql_len) {
                $i      = -1;
            } else {
                // The submited statement(s) end(s) here
                return TRUE;
            }
        } // end else if (is delimiter)

        // ... then check for start of a string,...
        else if (($char == '"') || ($char == '\'') || ($char == '`')) {
            $in_string    = TRUE;
            $string_start = $char;
        } // end else if (is start of string)

        // ... for start of a comment (and remove this comment if found)...
        else if ($char == '#'
                 || ($char == ' ' && $i > 1 && $sql[$i-2] . $sql[$i-1] == '--')) {
            // starting position of the comment depends on the comment type
            $start_of_comment = (($sql[$i] == '#') ? $i : $i-2);
            // if no "\n" exits in the remaining string, checks for "\r"
            // (Mac eol style)
            $end_of_comment   = (strpos(' ' . $sql, "12", $i+2))
                              ? strpos(' ' . $sql, "12", $i+2)
                              : strpos(' ' . $sql, "15", $i+2);
            if (!$end_of_comment) {
                // no eol found after '#', add the parsed part to the returned
                // array if required and exit
                if ($start_of_comment > 0) {
                    $ret[]    = trim(substr($sql, 0, $start_of_comment));
                }
                return TRUE;
            } else {
                $sql          = substr($sql, 0, $start_of_comment)
                              . ltrim(substr($sql, $end_of_comment));
                $sql_len      = strlen($sql);
                $i--;
            } // end if...else
        } // end else if (is comment)

        // ... and finally disactivate the "/*!...*/" syntax if MySQL < 3.22.07
        else if ($release < 32270
                 && ($char == '!' && $i > 1  && $sql[$i-2] . $sql[$i-1] == '/*')) {
            $sql[$i] = ' ';
        } // end else if

        // loic1: send a fake header each 30 sec. to bypass browser timeout
        $time1     = time();
        if ($time1 >= $time0 + 30) {
            $time0 = $time1;
            header('X-pmaPing: Pong');
        } // end if
    } // end for

    // add any rest to the returned array
    if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
        $ret[] = $sql;
    }

    return TRUE;
} // end of the 'PMA_splitSqlFile()' function

SFile::setRoot($config['basedir']."/install"); // TUTAJ
$queries = SFile::read("db.sql");

PMA_splitSqlFile($queries_ar, $queries, 0);

foreach ($queries_ar as $query) {
       
        mysql_query($query);
}

//SDatabase::getErrors(true);

?>




Jak mogę zapobiec temu błędowi? Wiem, ze te klony są dziwne, ale chciałem spróbować to zrobić, bo samemu od zera na pewno nie dał bym rady.



UWAGA!
Poradziłem sobie szybciej niż się dało. Skomentowałem niepotrzebny kawałek kodu.

Ale teraz mam kolejny problem...
Kod
Warning: Smarty error: unable to read resource: "siteadmin/login.tpl" in /home/marc3l/ftp/smarty/libs/Smarty.class.php on line 1088


Brakuje pliku, ale skąd go wezmę?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
fander
post
Post #2





Grupa: Zarejestrowani
Postów: 231
Pomógł: 22
Dołączył: 6.10.2008

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


PHP może zanleść klasy SFile, poszukaj pliku SFile lub definicji klasy SFile i zrób include_one("ścieżką do SFile/plik z definicja SFile");

Smarty to system szablonów. Musisz ustawić ścieżkę z plikami templeatu dla smarty, znajdź w kodzie coś w stylo $cos = new Smarty();

a następnie sprawdz czy jest ustawione coś takiego $cos->template_dir('sciezka') i zmień ścieżka na ścieżkę gdzie masz templeaty

odsyłam do manuala http://www.smarty.net/manual/en/installing.smarty.basic.php

Ten post edytował fander 17.07.2009, 14:45:17
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 - 20:35