Visualizzazione dei risultati da 1 a 8 su 8

Discussione: script impazzito!!!

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    22

    script impazzito!!!

    questo script PHP mi ha letteralmente fatto impazzire! non riesco a trovare l'errore sintattico e quando provo a commentare la riga che mi da' errore, l'errore va' da altri parti e cosi via, nonostante mi pare sia tutto giusto, forse voi avete più occhio di me perchè io mi sono arreso :P se non lo trovate manco voi allora il parser PHP è buggato :\ perchè il bello che se commento la parte buggata (IN ARANCIONE!) da' comunque errore ma se la tolgo sparisce, per questo dico che sia un bug

    Codice PHP:
    <?

    function getHTML($url) {
      
    $ch curl_init();
      
    curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_HEADER,true);
      
    $urldata parse_url($url); 
      
    $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
      
    $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
      
    $header[] = "Cache-Control: max-age=0";
      
    $header[] = "Connection: keep-alive";
      
    $header[] = "Keep-Alive: 300";
      
    $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
      
    $header[] = "Accept-Language: en-us,en;q=0.5";
      
    $header[] = "Pragma: ";
      
    curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
      
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
      
    curl_setopt($ch,CURLOPT_RETURNTRANSFERtrue);
      
    $r curl_exec($ch); curl_close($ch); return ($r);
    }

    function 
    getLinks($html) {
      
    preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#'$html$match);
      foreach (
    $match as $i) {
        echo 
    $match[0] . "
    "
    ;
      }
      echo 
    "<hr>";
    }

    if (
    $_GET['p']=="chiavechenonvidiromaiXD") {
      include 
    "connect.php"$url htmlspecialchars($_POST['url']); $title htmlspecialchars($_POST['title']); $descr htmlspecialchars($_POST['descr']);
      
    $keywords htmlspecialchars($_POST['keywords']);
      
      echo 
    "<h3>CYNEK SEARCH ENGINE CRAWLER</h3><form method='POST' action='cynek_crawler.php?p=chiavechenonvidiromaiXD&a=update'>
        <input type='text' size=70' name='url' required autofocus placeholder='URL da analizzare' value='
    $url'>

        <input type='text' size=70' name='title' placeholder='Titolo' value='
    $title'>

        <input type='text' size=70' name='descr' placeholder='Descrizione' value='
    $descr'>

        <input type='text' size=70' name='keywords' placeholder='Keywords' value='
    $keywords'>

        <input type='submit' value='Analizza'>
      </form><hr>"
    ;

      if (
    $_GET['a']=='update') {
        if (
    $url!="") {
          
    $time microtime(true);
          
    $html getHTML($url);
          
    $timef microtime(true)-$time;
          
          if (
    substr($html,0,12)=="HTTP/1.1 200") {
            
    /*getLinks($html);
            $score = 0;
            if ($title!="") {$score += .1;}  if ($descr!="") {$score += .1;} if ($keywords!="") {$score += .1;}
    _      
            $visits = mysql_num_rows(mysql_query("SELECT ID FROM search_visits WHERE url='$url'"));
            $score += $visits * 0.000001; $score /= $timef;
           
            $time = intval(microtime(true));
            
            echo "Visite al sito: " . $visits . "
    Outbound links: N/A (FP: N/A)
    Incoming links: N/A (FP: N/A)
    Punteggio assegnato: $score";
            */
           
    } else {
            echo 
    substr($html,0,12);
          }
         } else {
         
    header("location:cynek_crawler.php?p=6ce64016b1270e8399bd59e1fe0da83c05916a3c");
        }    
      }
     } else {
      
    header("location:index.php");
    }

    ?>
    L'errore che esce: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\cynek_crawler.php on line 52

    P.S: la parte commentata è quella dove "presumibilmente" c'è l'errore!
    P.P.S: lo script si tratta di uno spider bot non ancora completato proprio per questo problema

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2012
    Messaggi
    1,453
    "_" Hai lasciato questo pezzettino di codice inutile ed errato

    Codice PHP:
     /* if ($title!="") {$score += .1;}  if ($descr!="") {$score += .1;} if ($keywords!="") {$score += .1;} 
    _      
            $visits = mysql_num_rows(mysql_query("SELECT ID FROM search_visits WHERE url='$url'")); */ 

  3. #3
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    22
    Originariamente inviato da RoTeam
    "_" Hai lasciato questo pezzettino di codice inutile ed errato

    Codice PHP:
     /* if ($title!="") {$score += .1;}  if ($descr!="") {$score += .1;} if ($keywords!="") {$score += .1;} 
    _      
            $visits = mysql_num_rows(mysql_query("SELECT ID FROM search_visits WHERE url='$url'")); */ 
    no, quello deve essere un errore di copia, non c'è nel file originale

  4. #4
    Prova cosi
    Codice PHP:
       $visits mysql_query("SELECT ID FROM search_visits WHERE url='$url' ");
            
    $count mysql_num_rows($visits); 

  5. #5
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    22
    Originariamente inviato da TecnoSystem
    Prova cosi
    Codice PHP:
       $visits mysql_query("SELECT ID FROM search_visits WHERE url='$url' ");
            
    $count mysql_num_rows($visits); 
    stesso errore e se provo a commentare da comunque errore, anche se alla riga 65, quella dove c'è } else { dopo l'echo

  6. #6
    Codice PHP:
    <? 

    function getHTML($url) { 
      
    $ch curl_init(); 
      
    curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_HEADER,true); 
      
    $urldata parse_url($url);  
      
    $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"
      
    $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
      
    $header[] = "Cache-Control: max-age=0"
      
    $header[] = "Connection: keep-alive"
      
    $header[] = "Keep-Alive: 300"
      
    $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"
      
    $header[] = "Accept-Language: en-us,en;q=0.5"
      
    $header[] = "Pragma: "
      
    curl_setopt($ch,CURLOPT_HTTPHEADER,$header); 
      
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10); 
      
    curl_setopt($ch,CURLOPT_RETURNTRANSFERtrue); 
      
    $r curl_exec($ch); curl_close($ch); return ($r); 


    function 
    getLinks($html) { 
      
    preg_match_all('#bhttps?://[^s()<>]+(?:([wd]+)|([^[:punct:]s]|/))#'$html$match); 
      foreach (
    $match as $i) { 
        echo 
    $match[0] . "
    "

      } 
      echo 
    "<hr>"


    if (
    $_GET['p']=="chiavechenonvidiromaiXD") { 
      include 
    "connect.php"$url htmlspecialchars($_POST['url']); $title htmlspecialchars($_POST['title']); $descr htmlspecialchars($_POST['descr']); 
      
    $keywords htmlspecialchars($_POST['keywords']); 
       
      echo 
    "<h3>CYNEK SEARCH ENGINE CRAWLER</h3><form method='POST' action='cynek_crawler.php?p=chiavechenonvidiromaiXD&a=update'> 
        <input type='text' size=70' name='url' required autofocus placeholder='URL da analizzare' value='
    $url'>
     
        <input type='text' size=70' name='title' placeholder='Titolo' value='
    $title'>
     
        <input type='text' size=70' name='descr' placeholder='Descrizione' value='
    $descr'>
     
        <input type='text' size=70' name='keywords' placeholder='Keywords' value='
    $keywords'>
     
        <input type='submit' value='Analizza'> 
      </form><hr>"


      if (
    $_GET['a']=='update') { 
        if (
    $url!="") { 
          
    $time microtime(true); 
          
    $html getHTML($url); 
          
    $timef microtime(true)-$time
           
          if (
    substr($html,0,12)=="HTTP/1.1 200") { 
            
    getLinks($html); 
            
    $score 0
            if (
    $title!="") {$score += .1;}  if ($descr!="") {$score += .1;} if ($keywords!="") {$score += .1;} 
    _       
            $visits 
    mysql_num_rows(mysql_query("SELECT ID FROM search_visits WHERE url='$url'")); 
            
    $score += $visits 0.000001$score /= $timef
            
            
    $time intval(microtime(true)); 
             
            echo 
    "Visite al sito: " $visits "
    Outbound links: N/A (FP: N/A)
    Incoming links: N/A (FP: N/A)
    Punteggio assegnato: 
    $score"
            } else { 
            echo 
    substr($html,0,12); 
        
         } else { 
         
    header("location:cynek_crawler.php?p=6ce64016b1270e8399bd59e1fe0da83c05916a3c"); 
        }     
      } 
     } else { 
      
    header("location:index.php"); 


    ?>

  7. #7
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    22
    complimenti per aver risolto tecnosystem!
    ma dove è che sbagliavo, non riesco proprio a capire

  8. #8
    Originariamente inviato da xeryan
    complimenti per aver risolto tecnosystem!
    ma dove è che sbagliavo, non riesco proprio a capire
    ci stava una parentesi in più

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.