Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    52

    Problema "Maximum execution time"

    Quando apro la pagina web in cui è contenuto lo script php mi da questo errore:
    codice:
    Fatal error: Maximum execution time of 10 seconds exceeded in xxx/index.php on line 44
    il codice php è questo:
    codice:
    <?
    /***************************************************************************
     *
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms available from CloudMods.
     *   Written by Olympus_Hermes and FOPT_Cloudberry
     *
     ***************************************************************************/
    // ~~ Array Initializations ~~
    $sockets = Array();
    $ret_done = Array();
    $ret_data = Array();
    $parsed_data = Array();
    
    // ~~ Include necessary files ~~
    include('functions.php');
    include('template_engine.php');
    $template = new Template;
    
    // ~~ Obtain the list of players which have to be on the ratings list ~~
    $player_file = 'players.txt';
    $fp = fopen($player_file, 'r');
    $player_list = fread($fp, filesize($player_file));
    $players = explode("\n", $player_list);
    $num_players = count($players);
    
    // ~~ Open the sockets and prepare them for non-blocking! ~~
    $host = 'classic.zone.msn.com';
    for( $i = 0; $i < $num_players; $i++ )
    {
    	$sockets[$i] = fsockopen($host, 80, $errno, $errstr, 30);
    	stream_set_blocking($sockets[$i], FALSE);
    	$path = '/Profile/RatingsPlayer.asp?Players=2&Teams=&PlayerID=' . trim($players[$i]) . '&TeamID=&pguest=1';
    	fputs($sockets[$i],"GET $path HTTP/1.0\r\nHost: $host\r\n\r\n");
    }
    
    // ~~ Grab the data from each profile simeltaneous, using the prepared sockets! ~~
    $done = false;
    while( !$done )
    {
    	for( $i = 0; $i < $num_players; $i++ ) 
    	{
       		if( !feof($sockets[$i]) ) 
    		{
        		if( $ret_data[$i] )
    			{
         			$ret_data[$i] .= fgets($sockets[$i], 8192);
        		}
    			else
    			{
         			$ret_data[$i] = fgets($sockets[$i], 8192);
    			}
       		}
    		else
    		{
    			$ret_done[$i] = 1;
    		}
      	}
     	$done = (array_sum($ret_done) == $num_players);
    }
    
    // ~~ Parse the obtained data ~~
    $total_rat=0; 
    $unrated=0; 
    for( $i = 0; $i < count($ret_data); $i++ ) 
    { 
       $ret_data[$i]= substr($ret_data[$i], 8000); 
       $parsed_data[$i] = parse_profile(&$ret_data[$i]); 
       $total_rat+=$parsed_data[$i]['rating']; 
       if ($parsed_data[$i]['rating']=='-') $unrated+=1; 
    }
    
    // ~~ Sort the player attributes on rating ~~
    usort( $parsed_data, "sorter" ); 
    
    // ~~ Assign the template file ~~
    $template->set_filenames(array(
    	'template' => 'template.htm' )
    );
    
    // ~~ Put the data in the template blocks ~~
    for( $i = 0; $i < count($parsed_data); $i++ )
    {
    	if( !empty($parsed_data[$i]['nick']) )
    	{
    		$template->assign_block_vars('row', array(
    			'NICK' => '' . $parsed_data[$i]['nick'] . '',
    			'RATING' => $parsed_data[$i]['rating'],
    			'GAMES' => $parsed_data[$i]['games'],
    			'WINS' => $parsed_data[$i]['wins'],
    			'LOSSES' => $parsed_data[$i]['losses'],
    			'TIES' => $parsed_data[$i]['ties'],
    			'INCOMP' => $parsed_data[$i]['incomp'],
    			'STREAK' => $parsed_data[$i]['streak'],
    			'CLASS' => give_class(),
    			'WINPERCENT' => $parsed_data[$i]['winpercent'] )
    		);
    	}
    }
    $template->assign_vars(array( 
       'AVERAGE' => round($total_rat/($num_players-$unrated))) 
    );
    // ~~ Output the data to the template ~~
    $template->pparse('template');
    ?>
    e la linea 44 è questa:
    codice:
    41 	for( $i = 0; $i < $num_players; $i++ ) 
    42	{
    43   		if( !feof($sockets[$i]) ) 
    44		{
    45    		if( $ret_data[$i] )
    46			{
    47     			$ret_data[$i] .= fgets($sockets[$i], 8192);

  2. #2
    Il 90% dei problemi di un pc si trova
    tra la tastiera e la sedia.

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    52
    ho guardato, ma non riesco a capire, ho provato a mettere
    codice:
    set_time_limit(900);
    a inizio pagina ma non funzia (non so quasi niente di php)

  4. #4
    probabilmente hai safe mode attivo e quindi non ti considera set_time_limit

    10 secondi cmq è un tempo veramente basso.

    se hai molti echo potresti provare a mettere ob_start a inizio pagina e vedere se la situazione migliora

    Ciao

  5. #5
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    52
    ho provato a mettere
    codice:
    ob_start();
    all'inizio, ma non cambia niente

  6. #6
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    52
    please...

  7. #7
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    52
    non è il safe_mode xkè ho provato a mettere all'inizio dell script anke
    Codice PHP:
    $safe_mode Off 
    ma il problema è sempre lo stesso

  8. #8
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    52
    a quanto pare il broblema è
    Codice PHP:
            if( !feof($sockets[$i]) ) 
    ho potovato a sostituirlo con
    Codice PHP:
            if( feof($sockets[$i]) ) 
    e con
    Codice PHP:
            if( stream_get_meta_data($sockets[$i]) ) 
    solo ke in entrambi i casi mi si visualizza la pagina con un errore legato ad un altra pagina, e mi dice ke non può caricare "sorter" in questo punto
    Codice PHP:
    function sorter$arrayA$arrayB ){ 
        if( 
    $arrayA['rating'] == $arrayB['rating'] ) 
            return 
    0
        return( 
    $arrayA['rating'] > $arrayB['rating'] ? -); 

    please...

  9. #9
    Il time out in questione mi sembra essere quello del server, che è impostato in php.ini. Se è così e non hai diritti di amministrazione non puoi modificarlo. In genere viene inserito quando si gestiscono siti in hosting per evitare il congestionamento del server.

    Con 10 secondi di timeout a disposizione è quasi impossibile usare funzioni come socket per collegarsi all'esterno, che a causa delle latenze della rete richiedono spessissimo tempi più lunghi.

    Ho avuto problemi simili per un cliente e per risolvere ho dovuto sostituire quegli script con dei CGI scritti in Perl, che non sono soggetti a questi limiti.
    Marco Allegretti
    shishii@tiscalinet.it
    Lang: PERL, PHP, SQL.
    Linux user n° 268623 Fedora Core 10, Fedora Core 6, Debian Sarge on mips

  10. #10
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    52
    azz ke casino hehe, grazie cmq

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.