Pagina 1 di 2 12 UltimoUltimo
Visualizzazione risultati 1 fino 30 di 31

Discussione: Forum "Molto" rallentato...

  1. #1
    Guest

    Predefinito Forum "Molto" rallentato...

    Salve a tutti vorrei farvi una domanda.
    Sul mio sito il forum è in continuo e progressivo rallentamento, da cosa può essere dipeso? C'è un modo per renderlo più veloce e snello?
    Il problema maggiore sta nel fatto che una volta inviata una risposta ad un topic per ritornare alla schermata del topic ci vuole quasi un minuto!! (Con adsl!)
    pazzesco no? Da cosa può dipendere? Forse il server 7 di altervista è più lento di altri? O ho qualche problema con il mio db.

    Inoltre non riesco a correggere questo errore secondo voi da che può essere dato (nonostante venga segnalato questo errore il forum funziona perfettamente cmq). a fondo pagina lo trovate una volta entrati nel forum:

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /membri/zaxarius/includes/sql_layer.php on line 286


    grazie per l'aiuto!

  2. #2
    Guest

    Predefinito

    non ti è mai passato per la mente di controllare la linea 286?????

  3. #3
    Guest

    Predefinito

    Hai ragione ma diciamo che la mia conoscenza del php è molto, molto basilare:) Cmq ti posto qui la riga 286 magari riesci a darmi un mano.


    /*
    * sql_fetch_row(&$res,$row)
    * given a result identifier, returns an array with the resulting row
    * Needs also a row number for compatibility with postgres
    */

    function sql_fetch_row(&$res, $nr=0)
    {
    global $dbtype;
    switch ($dbtype) {

    case "MySQL":
    $row = mysql_fetch_row($res);
    return $row;
    break;;

    case "mSQL":
    $row = msql_fetch_row($res);
    return $row;
    break;;

    case "postgres":
    case "postgres_local":
    if ( $res->get_total_rows() > $res->get_fetched_rows() ) {
    $row = pg_fetch_row($res->get_result(), $res->get_fetched_rows() );
    $res->increment_fetched_rows();
    return $row;
    } else {
    return false;
    }
    break;;

    case "ODBC":
    case "ODBC_Adabas":
    $row = array();
    $cols = odbc_fetch_into($res, $nr, $row);
    return $row;
    break;;

    case "Interbase":
    $row = ibase_fetch_row($res);
    return $row;
    break;;

    case "Sybase":
    $row = sybase_fetch_row($res);
    return $row;
    break;;

    default:
    break;;
    }
    }

    /*
    * sql_fetch_array($res,$row)
    * given a result identifier, returns an associative array
    * with the resulting row using field names as keys.
    * Needs also a row number for compatibility with postgres.
    */

    function sql_fetch_array(&$res, $nr=0)
    {
    global $dbtype;
    switch ($dbtype)
    {
    case "MySQL":
    $row = array();
    $row = mysql_fetch_array($res);
    return $row;
    break;;

    case "mSQL":
    $row = array();
    $row = msql_fetch_array($res);
    return $row;
    break;;

    case "postgres":
    case "postgres_local":
    if( $res->get_total_rows() > $res->get_fetched_rows() ) {
    $row = array();
    $row = pg_fetch_array($res->get_result(), $res->get_fetched_rows() );
    $res->increment_fetched_rows();
    return $row;
    } else {
    return false;
    }
    break;;

    /*
    * ODBC doesn't have a native _fetch_array(), so we have to
    * use a trick. Beware: this might cause HUGE loads!
    */

    ecco qui dalla riga 274 alla riga 367 in rosso la 286
    grazie ancora

  4. #4
    Guest

    Predefinito

    @cornaro cerca di essere + comprensivo e usa toni + "dolci"...

    @zaxarius la discussione andava postata nel livello3,lì puoi ricevere + aiuto riguardo il php.
    Per la lentezza è probabile che il server sia in manutenzione o magari il forum è lenticello...
    ciao!

  5. #5
    Guest

    Predefinito

    la riga non ha errori...almeno imho

  6. #6
    Guest

    Predefinito

    E allora perchè mi da questo errore!! Mamma mia quanto vorrei capirci di php!

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /membri/zaxarius/includes/sql_layer.php on line 286

  7. #7
    Guest

    Predefinito

    per il motivo del rallentamento, prova ad andare nel my_admin e ottimizzare le tabelle, anche se credo che lo faccia in automatico il forum...

  8. #8
    Guest

    Predefinito

    Fatto ma non ho visto un aumento di velocità...sigh..
    Per quell'errore sapete darmi una mano?

  9. #9
    Guest

    Predefinito

    hai installato mod?

  10. #10
    Guest

    Predefinito

    Si in effetti si però dopo non funzionando non ci avevo più lavorato, provo a pulire dei file che avevo appunto toccato tempo fa poi ti dico!

  11. #11
    pokestudio non è connesso Altervistiano Junior
    Data registrazione
    16-01-2004
    Residenza
    127.0.0.1
    Messaggi
    547

    Predefinito

    Sembra che non ci sia una query "SELECT" nella variabile $res...
    Poi ripara le tabelle e vedi un po'
    Dal server 5 con amore

  12. #12
    Guest

    Predefinito

    Mi sai dire come fare per inserirla o mi puoi ripostare il codice con la variabile inserita?

  13. #13
    pokestudio non è connesso Altervistiano Junior
    Data registrazione
    16-01-2004
    Residenza
    127.0.0.1
    Messaggi
    547

    Predefinito

    Codice PHP:
    /*
    * sql_fetch_row(&$res,$row)
    * given a result identifier, returns an array with the resulting row
    * Needs also a row number for compatibility with postgres
    */

    function sql_fetch_row(&$res, $nr=0)
    {
    global
    $dbtype;
    switch (
    $dbtype) {

    case
    "MySQL":
    [
    COLOR=Red] $row = mysql_fetch_row([B]$res[/B]);[/COLOR]
    return
    $row;
    break;;

    case
    "mSQL":
    $row = msql_fetch_row($res);
    return
    $row;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    if (
    $res->get_total_rows() > $res->get_fetched_rows() ) {
    $row = pg_fetch_row($res->get_result(), $res->get_fetched_rows() );
    $res->increment_fetched_rows();
    return
    $row;
    } else {
    return
    false;
    }
    break;;

    case
    "ODBC":
    case
    "ODBC_Adabas":
    $row = array();
    $cols = odbc_fetch_into($res, $nr, $row);
    return
    $row;
    break;;

    case
    "Interbase":
    $row = ibase_fetch_row($res);
    return
    $row;
    break;;

    case
    "Sybase":
    $row = sybase_fetch_row($res);
    return
    $row;
    break;;

    default:
    break;;
    }
    }

    /*
    * sql_fetch_array($res,$row)
    * given a result identifier, returns an associative array
    * with the resulting row using field names as keys.
    * Needs also a row number for compatibility with postgres.
    */

    function sql_fetch_array(&$res, $nr=0)
    {
    global
    $dbtype;
    switch (
    $dbtype)
    {
    case
    "MySQL":
    $row = array();
    $row = mysql_fetch_array($res);
    return
    $row;
    break;;

    case
    "mSQL":
    $row = array();
    $row = msql_fetch_array($res);
    return
    $row;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    if(
    $res->get_total_rows() > $res->get_fetched_rows() ) {
    $row = array();
    $row = pg_fetch_array($res->get_result(), $res->get_fetched_rows() );
    $res->increment_fetched_rows();
    return
    $row;
    } else {
    return
    false;
    }
    break;;

    /*
    * ODBC doesn't have a native _fetch_array(), so we have to
    * use a trick. Beware: this might cause HUGE loads!
    */
    Prendi un po' tutta la pagina php perche nn vedo nessun include ne una query...
    Ultima modifica di pokestudio : 28-11-2004 alle ore 23.09.14
    Dal server 5 con amore

  14. #14
    Guest

    Predefinito

    Eccola qua

    Codice PHP:

    <?php


    if (eregi("sql_layer.php",$_SERVER['PHP_SELF'])) {
    Header("Location: ../index.php");
    die();
    }

    /* $dbtype = "MySQL"; */
    /* $dbtype = "mSQL"; */
    /* $dbtype = "postgres"; */
    /* $dbtype = "postgres_local";// When postmaster start without "-i" option. */
    /* $dbtype = "ODBC"; */
    /* $dbtype = "ODBC_Adabas"; */
    /* $dbtype = "Interbase"; */
    /* $dbtype = "Sybase"; */

    /*
    * sql_connect($host, $user, $password, $db)
    * returns the connection ID
    */


    class ResultSet {
    var
    $result;
    var
    $total_rows;
    var
    $fetched_rows;

    function
    set_result( $res ) {
    $this->result = $res;
    }

    function
    get_result() {
    return
    $this->result;
    }

    function
    set_total_rows( $rows ) {
    $this->total_rows = $rows;
    }

    function
    get_total_rows() {
    return
    $this->total_rows;
    }

    function
    set_fetched_rows( $rows ) {
    $this->fetched_rows = $rows;
    }

    function
    get_fetched_rows() {
    return
    $this->fetched_rows;
    }

    function
    increment_fetched_rows() {
    $this->fetched_rows = $this->fetched_rows + 1;
    }
    }



    function
    sql_connect($host, $user, $password, $db)
    {
    global
    $dbtype;
    switch (
    $dbtype) {

    case
    "MySQL":
    $dbi=@mysql_connect($host, $user, $password);
    mysql_select_db($db);
    return
    $dbi;
    break;;

    case
    "mSQL":
    $dbi=msql_connect($host);
    msql_select_db($db);
    return
    $dbi;
    break;;


    case
    "postgres":
    $dbi=@pg_connect("host=$host user=$user password=$password port=5432 dbname=$db");
    return
    $dbi;
    break;;

    case
    "postgres_local":
    $dbi=@pg_connect("user=$user password=$password dbname=$db");
    return
    $dbi;
    break;;

    case
    "ODBC":
    $dbi=@odbc_connect($db,$user,$password);
    return
    $dbi;
    break;;

    case
    "ODBC_Adabas":
    $dbi=@odbc_connect($host.":".$db,$user,$password);
    return
    $dbi;
    break;;

    case
    "Interbase":
    $dbi=@ibase_connect($host.":".$db,$user,$password);
    return
    $dbi;
    break;;

    case
    "Sybase":
    $dbi=@sybase_connect($host, $user, $password);
    sybase_select_db($db,$dbi);
    return
    $dbi;
    break;;

    default:
    break;;
    }

    }

    function
    sql_logout($id)
    {
    global
    $dbtype;
    switch (
    $dbtype) {

    case
    "MySQL":
    $dbi=@mysql_close($id);
    return
    $dbi;
    break;;

    case
    "mSQL":
    $dbi=@msql_close($id);
    return
    $dbi;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    $dbi=@pg_close($id);
    return
    $dbi;
    break;;

    case
    "ODBC":
    case
    "ODBC_Adabas":
    $dbi=@odbc_close($id);
    return
    $dbi;
    break;;

    case
    "Interbase":
    $dbi=@ibase_close($id);
    return
    $dbi;
    break;;

    case
    "Sybase":
    $dbi=@sybase_close($id);
    return
    $dbi;
    break;;

    default:
    break;;
    }
    }


    /*
    * sql_query($query, $id)
    * executes an SQL statement, returns a result identifier
    */

    function sql_query($query, $id)
    {

    global
    $dbtype;
    global
    $sql_debug;
    $sql_debug = 0;
    if(
    $sql_debug) echo "SQL query: ".str_replace(",",", ",$query)."<BR>";
    switch (
    $dbtype) {

    case
    "MySQL":
    $res=@mysql_query($query, $id);
    return
    $res;
    break;;

    case
    "mSQL":
    $res=@msql_query($query, $id);
    return
    $res;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    $res=pg_exec($id,$query);
    $result_set = new ResultSet;
    $result_set->set_result( $res );
    $result_set->set_total_rows( sql_num_rows( $result_set ) );
    $result_set->set_fetched_rows( 0 );
    return
    $result_set;
    break;;

    case
    "ODBC":
    case
    "ODBC_Adabas":
    $res=@odbc_exec($id,$query);
    return
    $res;
    break;;

    case
    "Interbase":
    $res=@ibase_query($id,$query);
    return
    $res;
    break;;

    case
    "Sybase":
    $res=@sybase_query($query, $id);
    return
    $res;
    break;;

    default:
    break;;

    }
    }

    /*
    * sql_num_rows($res)
    * given a result identifier, returns the number of affected rows
    */

    function sql_num_rows($res)
    {
    global
    $dbtype;
    switch (
    $dbtype) {

    case
    "MySQL":
    $rows=mysql_num_rows($res);
    return
    $rows;
    break;;

    case
    "mSQL":
    $rows=msql_num_rows($res);
    return
    $rows;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    $rows=pg_numrows( $res->get_result() );
    return
    $rows;
    break;;

    case
    "ODBC":
    case
    "ODBC_Adabas":
    $rows=odbc_num_rows($res);
    return
    $rows;
    break;;

    case
    "Interbase":
    echo
    "<BR>Error! PHP dosen't support ibase_numrows!<BR>";
    return
    $rows;
    break;;

    case
    "Sybase":
    $rows=sybase_num_rows($res);
    return
    $rows;
    break;;

    default:
    break;;
    }
    }

    /*
    * sql_fetch_row(&$res,$row)
    * given a result identifier, returns an array with the resulting row
    * Needs also a row number for compatibility with postgres
    */

    function sql_fetch_row(&$res, $nr=0)
    {
    global
    $dbtype;
    switch (
    $dbtype) {

    case
    "MySQL":
    $row = mysql_fetch_row($res);
    return
    $row;
    break;;

    case
    "mSQL":
    $row = msql_fetch_row($res);
    return
    $row;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    if (
    $res->get_total_rows() > $res->get_fetched_rows() ) {
    $row = pg_fetch_row($res->get_result(), $res->get_fetched_rows() );
    $res->increment_fetched_rows();
    return
    $row;
    } else {
    return
    false;
    }
    break;;

    case
    "ODBC":
    case
    "ODBC_Adabas":
    $row = array();
    $cols = odbc_fetch_into($res, $nr, $row);
    return
    $row;
    break;;

    case
    "Interbase":
    $row = ibase_fetch_row($res);
    return
    $row;
    break;;

    case
    "Sybase":
    $row = sybase_fetch_row($res);
    return
    $row;
    break;;

    default:
    break;;
    }
    }

    /*
    * sql_fetch_array($res,$row)
    * given a result identifier, returns an associative array
    * with the resulting row using field names as keys.
    * Needs also a row number for compatibility with postgres.
    */

    function sql_fetch_array(&$res, $nr=0)
    {
    global
    $dbtype;
    switch (
    $dbtype)
    {
    case
    "MySQL":
    $row = array();
    $row = mysql_fetch_array($res);
    return
    $row;
    break;;

    case
    "mSQL":
    $row = array();
    $row = msql_fetch_array($res);
    return
    $row;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    if(
    $res->get_total_rows() > $res->get_fetched_rows() ) {
    $row = array();
    $row = pg_fetch_array($res->get_result(), $res->get_fetched_rows() );
    $res->increment_fetched_rows();
    return
    $row;
    } else {
    return
    false;
    }
    break;;

    /*
    * ODBC doesn't have a native _fetch_array(), so we have to
    * use a trick. Beware: this might cause HUGE loads!
    */

    case "ODBC":
    $row = array();
    $result = array();
    $result = odbc_fetch_row($res, $nr);
    $nf = odbc_num_fields($res); /* Field numbering starts at 1 */
    for($count=1; $count < $nf+1; $count++)
    {
    $field_name = odbc_field_name($res, $count);
    $field_value = odbc_result($res, $field_name);
    $row[$field_name] = $field_value;
    }
    return
    $row;
    break;;

    case
    "ODBC_Adabas":
    $row = array();
    $result = array();
    $result = odbc_fetch_row($res, $nr);

    $nf = count($result)+2; /* Field numbering starts at 1 */
    for($count=1; $count < $nf; $count++) {
    $field_name = odbc_field_name($res, $count);
    $field_value = odbc_result($res, $field_name);
    $row[$field_name] = $field_value;
    }
    return
    $row;
    break;;

    case
    "Interbase":
    $orow=ibase_fetch_object($res);
    $row=get_object_vars($orow);
    return
    $row;
    break;;

    case
    "Sybase":
    $row = sybase_fetch_array($res);
    return
    $row;
    break;;

    }
    }

  15. #15
    Guest

    Predefinito

    e questa è il secondo e ultimo pezzo

    Codice PHP:

    function sql_fetch_object(&$res, $nr=0)
    {
    global
    $dbtype;
    switch (
    $dbtype)
    {
    case
    "MySQL":
    $row = mysql_fetch_object($res);
    if(
    $row) return $row;
    else return
    false;
    break;;

    case
    "mSQL":
    $row = msql_fetch_object($res);
    if(
    $row) return $row;
    else return
    false;
    break;;

    case
    "postgres":
    case
    "postgres_local":
    if(
    $res->get_total_rows() > $res->get_fetched_rows() ) {
    $row = pg_fetch_object( $res->get_result(), $res->get_fetched_rows() );
    $res->increment_fetched_rows();
    if(
    $row) return $row;
    else return
    false;
    } else {
    return
    false;
    }
    break;;

    case
    "ODBC":
    $result = odbc_fetch_row($res, $nr);
    if(!
    $result) return false;
    $nf = odbc_num_fields($res); /* Field numbering starts at 1 */
    for($count=1; $count < $nf+1; $count++)
    {
    $field_name = odbc_field_name($res, $count);
    $field_value = odbc_result($res, $field_name);
    $row->$field_name = $field_value;
    }
    return
    $row;
    break;;

    case
    "ODBC_Adabas":
    $result = odbc_fetch_row($res, $nr);
    if(!
    $result) return false;

    $nf = count($result)+2; /* Field numbering starts at 1 */
    for($count=1; $count < $nf; $count++) {
    $field_name = odbc_field_name($res, $count);
    $field_value = odbc_result($res, $field_name);
    $row->$field_name = $field_value;
    }
    return
    $row;
    break;;

    case
    "Interbase":
    $orow = ibase_fetch_object($res);
    if(
    $orow)
    {
    $arow=get_object_vars($orow);
    while(list(
    $name,$key)=each($arow))
    {
    $name=strtolower($name);
    $row->$name=$key;
    }
    return
    $row;
    }else return
    false;
    break;;

    case
    "Sybase":
    $row = sybase_fetch_object($res);
    return
    $row;
    break;;

    }
    }

    /*** Function Free Result for function free the memory ***/
    function sql_free_result($res) {
    global
    $dbtype;
    switch (
    $dbtype) {

    case
    "MySQL":
    $row = mysql_free_result($res);
    return
    $row;
    break;;

    case
    "mSQL":
    $row = msql_free_result($res);
    return
    $row;
    break;;


    case
    "postgres":
    case
    "postgres_local":
    $rows=pg_FreeResult( $res->get_result() );
    return
    $rows;
    break;;

    case
    "ODBC":
    case
    "ODBC_Adabas":
    $rows=odbc_free_result($res);
    return
    $rows;
    break;;

    case
    "Interbase":
    echo
    "<BR>Error! PHP dosen't support ibase_numrows!<BR>";
    return
    $rows;
    break;;

    case
    "Sybase":
    $rows=sybase_free_result($res);
    return
    $rows;
    break;;
    }
    }

    ?>

  16. #16
    Guest

    Predefinito

    ti ho inserito tutta la pagina pokestudio, aspetto una tua venuta! :)

  17. #17
    Guest

    Predefinito

    Nessuno sa dirmi cosa posso rimuover o se c'è qualche errore in questa pagina? scusate l'insistenza

  18. #18
    pokestudio non è connesso Altervistiano Junior
    Data registrazione
    16-01-2004
    Residenza
    127.0.0.1
    Messaggi
    547

    Predefinito

    E' tutta la pagina? (Dico dalla linea 1 alla fine)
    Dal server 5 con amore

  19. #19
    Guest

    Predefinito

    si ho tolto le righe di descrizione iniziali per non occupare troppo spazio.

  20. #20
    pokestudio non è connesso Altervistiano Junior
    Data registrazione
    16-01-2004
    Residenza
    127.0.0.1
    Messaggi
    547

    Predefinito

    Prova a mettere anche la pagina in cui ti viene l'errore...
    Dal server 5 con amore

  21. #21
    Guest

    Predefinito

    Allore l'errore me lo da una volta che entri nel forum e durante tutta la navigazione dentro al forum. Se si esce dal forum e si naviga nel resto del sito non appare più questo errore. Che file ti dovrei mandare quindi?

  22. #22
    Guest

    Predefinito

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /membri/zaxarius/includes/sql_layer.php on line 286
    questo è l'errore che mi da.

  23. #23
    pokestudio non è connesso Altervistiano Junior
    Data registrazione
    16-01-2004
    Residenza
    127.0.0.1
    Messaggi
    547

    Predefinito

    Prova a mettere qui il codice di index.php del forum...
    Dal server 5 con amore

  24. #24
    Guest

    Predefinito part1

    eccolo qui
    Codice PHP:
    <?php

    if (!eregi("modules.php", $_SERVER['PHP_SELF']))
    {
    die (
    "You can't access this file directly...");
    }
    if (
    $popup != "1")
    {
    $module_name = basename(dirname(__FILE__));
    require(
    "modules/".$module_name."/nukebb.php");
    }
    else
    {
    $phpbb_root_path = 'modules/Forums/';
    }
    define('IN_PHPBB', true);
    include(
    $phpbb_root_path . 'extension.inc');
    include(
    $phpbb_root_path . 'common.'.$phpEx);

    //
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_INDEX, $nukeuser);
    init_userprefs($userdata);
    //
    // End session management
    //

    $viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;

    if( isset(
    $HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
    {
    $mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] :

    $HTTP_GET_VARS['mark'];
    }
    else
    {
    $mark_read = '';
    }

    //
    // Handle marking posts
    //
    if( $mark_read == 'forums' )
    {
    if(
    $userdata['session_logged_in'] )
    {
    setcookie($board_config['cookie_name'] . '_f_all', time(), 0,

    $board_config['cookie_path'], $board_config['cookie_domain'],

    $board_config['cookie_secure']);
    }

    $template->assign_vars(array(
    "META" => '<meta http-equiv="refresh" content="3;url='

    .append_sid("index.$phpEx") . '">')
    );

    $message = $lang['Forums_marked_read'] . '<br /><br />' .

    sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">',

    '</a> ');

    message_die(GENERAL_MESSAGE, $message);
    }
    //
    // End handle marking posts
    //

    $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ?

    unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
    $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ?

    unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();

    //
    // If you don't use these stats on your index you may want to consider
    // removing them
    //
    $total_posts = get_db_stat('postcount');
    $total_users = get_db_stat('usercount');
    $newest_userdata = get_db_stat('newestuser');
    $newest_user = $newest_userdata['username'];
    $newest_uid = $newest_userdata['user_id'];

    if(
    $total_posts == 0 )
    {
    $l_total_post_s = $lang['Posted_articles_zero_total'];
    }
    else if(
    $total_posts == 1 )
    {
    $l_total_post_s = $lang['Posted_article_total'];
    }
    else
    {
    $l_total_post_s = $lang['Posted_articles_total'];
    }

    if(
    $total_users == 0 )
    {
    $l_total_user_s = $lang['Registered_users_zero_total'];
    }
    else if(
    $total_users == 1 )
    {
    $l_total_user_s = $lang['Registered_user_total'];
    }
    else
    {
    $l_total_user_s = $lang['Registered_users_total'];
    }


    //
    // Start page proper
    //
    $sql = "SELECT c.cat_id, c.cat_title, c.cat_order
    FROM "
    . CATEGORIES_TABLE . " c
    "
    .(($userdata['user_level']!=ADMIN)? "WHERE

    c.cat_title<>\"global_announcement\""
    :"" )."
    ORDER BY c.cat_order"
    ;
    if( !(
    $result = $db->sql_query($sql)) )
    {
    message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__,

    __FILE__, $sql);
    }

    while(
    $category_rows[] = $db->sql_fetchrow($result) );

    if( (
    $total_categories = count($category_rows) ) )
    {
    //
    // Define appropriate SQL
    //
    switch(SQL_LAYER)
    {
    case
    'postgresql':
    $sql = "SELECT f.*, p.post_time, p.post_username, u.username,

    u.user_id
    FROM "
    . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " .

    USERS_TABLE . " u
    WHERE p.post_id = f.forum_last_post_id
    AND u.user_id = p.poster_id
    UNION (
    SELECT f.*, NULL, NULL, NULL, NULL
    FROM "
    . FORUMS_TABLE . " f
    WHERE NOT EXISTS (
    SELECT p.post_time
    FROM "
    . POSTS_TABLE . " p
    WHERE p.post_id =

    f.forum_last_post_id
    )
    )
    ORDER BY cat_id, forum_order"
    ;
    break;

    case
    'oracle':
    $sql = "SELECT f.*, p.post_time, p.post_username, u.username,

    u.user_id
    FROM "
    . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " .

    USERS_TABLE . " u
    WHERE p.post_id = f.forum_last_post_id(+)
    AND u.user_id = p.poster_id(+)
    ORDER BY f.cat_id, f.forum_order"
    ;
    break;

    default:
    $sql = "SELECT f.*, p.post_time, p.post_username, u.username,

    u.user_id
    FROM (( "
    . FORUMS_TABLE . " f
    LEFT JOIN "
    . POSTS_TABLE . " p ON p.post_id =

    f.forum_last_post_id )
    LEFT JOIN "
    . USERS_TABLE . " u ON u.user_id = p.poster_id

    )
    ORDER BY f.cat_id, f.forum_order"
    ;
    break;
    }
    if ( !(
    $result = $db->sql_query($sql)) )
    {
    message_die(GENERAL_ERROR, 'Could not query forums information', '',

    __LINE__, __FILE__, $sql);
    }

    $forum_data = array();
    while(
    $row = $db->sql_fetchrow($result) )
    {
    $forum_data[] = $row;
    }

    if ( !(
    $total_forums = count($forum_data)) )
    {
    message_die(GENERAL_MESSAGE, $lang['No_forums']);
    }

    //
    // Obtain a list of topic ids which contain
    // posts made since user last visited
    //
    if ( $userdata['session_logged_in'] )
    {
    $sql = "SELECT t.forum_id, t.topic_id, p.post_time
    FROM "
    . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
    WHERE p.post_id = t.topic_last_post_id
    AND p.post_time > "
    . $userdata['user_lastvisit'] . "
    AND t.topic_moved_id = '0'"
    ;
    if ( !(
    $result = $db->sql_query($sql)) )
    {
    message_die(GENERAL_ERROR, 'Could not query new topic

    information'
    , '', __LINE__, __FILE__, $sql);
    }

    $new_topic_data = array();
    while(
    $topic_data = $db->sql_fetchrow($result) )
    {
    $new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']]

    =
    $topic_data['post_time'];
    }
    }

    //
    // Obtain list of moderators of each forum
    // First users, then groups ... broken into two queries
    //
    $sql = "SELECT aa.forum_id, u.user_id, u.username
    FROM "
    . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " .

    GROUPS_TABLE . " g, " . USERS_TABLE . " u
    WHERE aa.auth_mod = "
    . TRUE . "
    AND g.group_single_user = '1'
    AND ug.group_id = aa.group_id
    AND g.group_id = aa.group_id
    AND u.user_id = ug.user_id
    GROUP BY u.user_id, u.username, aa.forum_id
    ORDER BY aa.forum_id, u.user_id"
    ;
    if ( !(
    $result = $db->sql_query($sql)) )
    {
    message_die(GENERAL_ERROR, 'Could not query forum moderator information',

    '', __LINE__, __FILE__, $sql);
    }

    $forum_moderators = array();
    while(
    $row = $db->sql_fetchrow($result) )
    {
    $forum_moderators[$row['forum_id']][] = '<a href="' .

    append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" .

    $row['user_id']) . '">' . $row['username'] . '</a>';
    }

    $sql = "SELECT aa.forum_id, g.group_id, g.group_name
    FROM "
    . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " .

  25. #25
    Guest

    Predefinito

    part2
    Codice PHP:

    GROUPS_TABLE
    . " g
    WHERE aa.auth_mod = "
    . TRUE . "
    AND g.group_single_user = '0'
    AND g.group_type <> "
    . GROUP_HIDDEN . "
    AND ug.group_id = aa.group_id
    AND g.group_id = aa.group_id
    GROUP BY g.group_id, g.group_name, aa.forum_id
    ORDER BY aa.forum_id, g.group_id"
    ;
    if ( !(
    $result = $db->sql_query($sql)) )
    {
    message_die(GENERAL_ERROR, 'Could not query forum moderator information',

    '', __LINE__, __FILE__, $sql);
    }

    while(
    $row = $db->sql_fetchrow($result) )
    {
    $forum_moderators[$row['forum_id']][] = '<a href="' .

    append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' .

    $row['group_name'] . '</a>';
    }

    //
    // Find which forums are visible for this user
    //
    $is_auth_ary = array();
    $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);

    //
    // Start output of page
    //
    define('SHOW_ONLINE', true);
    $page_title = $lang['Index'];
    include(
    "includes/page_header.php");

    $template->set_filenames(array(
    'body' => 'index_body.tpl')
    );

    $template->assign_vars(array(
    'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
    'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
    'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' .

    append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$newest_uid") .

    '">', $newest_user, '</a>'),

    'FORUM_IMG' => $images['forum'],
    'FORUM_NEW_IMG' => $images['forum_new'],
    'FORUM_LOCKED_IMG' => $images['forum_locked'],

    'L_FORUM' => $lang['Forum'],
    'L_TOPICS' => $lang['Topics'],
    'L_REPLIES' => $lang['Replies'],
    'L_VIEWS' => $lang['Views'],
    'L_POSTS' => $lang['Posts'],
    'L_LASTPOST' => $lang['Last_Post'],
    'L_NO_NEW_POSTS' => $lang['No_new_posts'],
    'L_NEW_POSTS' => $lang['New_posts'],
    'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
    'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
    'L_ONLINE_EXPLAIN' => $lang['Online_explain'],

    'L_MODERATOR' => $lang['Moderators'],
    'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
    'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],

    'U_MARK_READ' => append_sid("index.$phpEx?mark=forums"))
    );

    //
    // Okay, let's build the index
    //
    for($i = 0; $i < $total_categories; $i++)
    {
    $cat_id = $category_rows[$i]['cat_id'];

    //
    // Should we display this category/forum set?
    //
    $display_forums = false;
    for(
    $j = 0; $j < $total_forums; $j++)
    {
    if (
    $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view'] &&

    $forum_data[$j]['cat_id'] == $cat_id )
    {
    $display_forums = true;
    }
    }

    //
    // Yes, we should, so first dump out the category
    // title, then, if appropriate the forum list
    //
    if ( $display_forums )
    {
    $template->assign_block_vars('catrow', array(
    'CAT_ID' => $cat_id,
    'CAT_DESC' => $category_rows[$i]['cat_title'],
    'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL .

    "=$cat_id"))
    );

    if (
    $viewcat == $cat_id || $viewcat == -1 )
    {
    for(
    $j = 0; $j < $total_forums; $j++)
    {
    if (
    $forum_data[$j]['cat_id'] == $cat_id )
    {
    $forum_id = $forum_data[$j]['forum_id'];

    if (
    $is_auth_ary[$forum_id]['auth_view']

    )
    {
    if (

    $forum_data[$j]['forum_status'] == FORUM_LOCKED )
    {
    $folder_image =

    $images['forum_locked'];
    $folder_alt =

    $lang['Forum_locked'];
    }
    else
    {
    $unread_topics = false;
    if (

    $userdata['session_logged_in'] )
    {
    if (

    !empty(
    $new_topic_data[$forum_id]) )
    {


    $forum_last_post_time = 0;

    while(

    list(
    $check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
    {
    if

  26. #26
    Guest

    Predefinito

    part3
    Codice PHP:
    ( empty($tracking_topics[$check_topic_id]) )
    {


    $unread_topics = true;


    $forum_last_post_time = max($check_post_time, $forum_last_post_time);

    }


    else
    {


    if (
    $tracking_topics[$check_topic_id] < $check_post_time )


    {


    $unread_topics = true;


    $forum_last_post_time = max($check_post_time, $forum_last_post_time);


    }
    }
    }

    if (

    !empty(
    $tracking_forums[$forum_id]) )
    {
    if

    (
    $tracking_forums[$forum_id] > $forum_last_post_time )
    {


    $unread_topics = false;
    }
    }

    if (

    isset(
    $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
    {
    if

    (
    $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
    {


    $unread_topics = false;
    }
    }

    }
    }

    $folder_image = (

    $unread_topics ) ? $images['forum_new'] : $images['forum'];
    $folder_alt = (

    $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts'];
    }

    $posts =

    $forum_data[$j]['forum_posts'];
    $topics =

    $forum_data[$j]['forum_topics'];

    if (

    $forum_data[$j]['forum_last_post_id'] )
    {
    $last_post_time =

    create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'],

    $board_config['board_timezone']);

    $last_post =

    $last_post_time . '<br />';

    $last_post .= (

    $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ?

    $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' .

    append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' .

    $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';

    $last_post .= '<a href="'

    . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' .

    $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] .

    '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' .

    $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
    }
    else
    {
    $last_post =

    $lang['No_Posts'];
    }

    if (

    count($forum_moderators[$forum_id]) > 0 )
    {
    $l_moderators = (

    count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
    $moderator_list =

    implode(', ', $forum_moderators[$forum_id]);
    }
    else
    {
    $l_moderators = '&nbsp;';
    $moderator_list =

    '&nbsp;';
    }

    $row_color = ( !($i % 2) ) ?

    $theme['td_color1'] : $theme['td_color2'];
    $row_class = ( !($i % 2) ) ?

    $theme['td_class1'] : $theme['td_class2'];



    $template->assign_block_vars('catrow.forumrow', array(
    'ROW_COLOR' => '#' .

    $row_color,
    'ROW_CLASS' => $row_class,
    'FORUM_FOLDER_IMG' =>

    $folder_image,
    'FORUM_NAME' =>

    $forum_data[$j]['forum_name'],
    'FORUM_DESC' =>

    $forum_data[$j]['forum_desc'],
    'POSTS' =>

    $forum_data[$j]['forum_posts'],
    'TOPICS' =>

    $forum_data[$j]['forum_topics'],
    'LAST_POST' => $last_post,
    'MODERATORS' =>

    $moderator_list,

    'L_MODERATOR' =>

    $l_moderators,
    'L_FORUM_FOLDER_ALT' =>

    $folder_alt,

    'U_VIEWFORUM' =>

    append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
    );
    }
    }
    }
    }
    }
    }
    // for ... categories

    }// if ... total_categories
    else
    {
    message_die(GENERAL_MESSAGE, $lang['No_forums']);
    }

    //
    // Generate the page
    //
    $template->pparse('body');

    include(
    "includes/page_tail.php");

    ?>

  27. #27
    Guest

    Predefinito

    Eccoti tutte e tre le parti. Nella prima ti ho tolto il copyright per risparmiare caratteri.
    Peccato che non si possano inserire più caratteri e tocca sempre fare sta manovra!
    O c'è un altro modo e io non lo conosco? 0.o
    Ultima modifica di zaxarius : 30-11-2004 alle ore 21.49.02

  28. #28
    pokestudio non è connesso Altervistiano Junior
    Data registrazione
    16-01-2004
    Residenza
    127.0.0.1
    Messaggi
    547

    Predefinito

    Evidenzia la parte in cui include il file errorifico...
    Dal server 5 con amore

  29. #29
    Guest

    Predefinito

    cioè cosa devo trovare scritto include sql_layer.php?

  30. #30
    pokestudio non è connesso Altervistiano Junior
    Data registrazione
    16-01-2004
    Residenza
    127.0.0.1
    Messaggi
    547

    Predefinito

    Si + o -
    Dal server 5 con amore

Pagina 1 di 2 12 UltimoUltimo

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •