Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    Script che non funziona in locale

    Ciao a tutti, ho scaricato questoquesto script per i sondaggi (che fra parentesi è l'unico valido xhtml che ho trovato).

    In locale lo script non funziona, mi dà questi errori:


    Warning: opendir(localhost\miosito\poll/data/) [function.opendir]: failed to open dir: Invalid argument in C:\www\miosito\poll\vote.php on line 14

    Warning: rsort() expects parameter 1 to be array, null given in C:\www\miosito\poll\vote.php on line 80

    Warning: Invalid argument supplied for foreach() in C:\www\miosito\poll\vote.php on line 93

    Warning: Invalid argument supplied for foreach() in C:\www\miosito\poll\vote.php on line 105

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in C:\www\miosito\poll\vote.php on line 132

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in C:\www\miosito\poll\vote.php on line 132

    Warning: array_sum() [function.array-sum]: The argument should be an array in C:\www\miosito\poll\vote.php on line 142

    Warning: Invalid argument supplied for foreach() in C:\www\miosito\poll\vote.php on line 153


    Il file vote.php è questo (ho indicato le linee dove dà errore):

    Codice PHP:
    <?PHP
    error_reporting
    (E_ALL E_NOTICE);    
    unset(
    $file_array);
    include(
    dirname(__FILE__).'/config.php');
    if(
    $cptemplate and in_array($cptemplate$config['templates'])) include('templates/'.$cptemplate.'.tpl');
    if(!
    $cptemplate){ @include(dirname(__FILE__).'/templates/default.tpl');
    if(!
    $votingheader) exit('Default template can\'t be found.
    '
    ); }
    if(
    $cptemplate and !in_array($cptemplate$config['templates']) and !in_array('default'$config['templates'])){
        echo 
    $cptemplate.' or default template can\'t be found.
    '
    ;
        exit;
    }
    @include(
    $config['path'].'/inc/users.db.php');
    $dir $config['path']."/data/";
    /*line 14*/  if ($dh opendir($dir)){
            while((
    $file readdir($dh)) !== false){
                if(
    $file != "." && $file != ".."$file_array[] = $file;
            }
        
    closedir($dh);
        }
    if(isset(
    $group)){
        foreach(
    $file_array as $key => $file){
            @include(
    $config['path'].'/data/'.$file);
            if(
    $polldata['group'] == $group)
            
    $group_array[] = $file;
        }
        
    $days = array(=> 'Mon''Tue''Wed''Thu''Fri''Sat''Sun');
        
    $date date('D.H.i');
        foreach(
    $days as $key => $day){
        
    $date str_replace($day$key$date);
        }
        if(
    $config['groupdata'][$group]['time'] <= date('H.i')     and $config['groupdata'][$group]['update'] < date('j.n') and $config['groupdata'][$group]['method'] == 'every day' 
        
    or $config['groupdata'][$group]['time'] <= $date          and $config['groupdata'][$group]['update'] < date('j.n') and $config['groupdata'][$group]['method'] == 'every week' 
        
    or $config['groupdata'][$group]['time'] <= date('t.H.i') and $config['groupdata'][$group]['update'] < date('j.n') and $config['groupdata'][$group]['method'] == 'every month'){
            
    $config['groupdata'][$group]['count']++;
            
    $config['groupdata'][$group]['update'] = date('j.n');
            
    $file fopen($config['path'].'/group.php''w+');
            
    fwrite ($file'<?PHP $config = '.var_export($configtrue).' ?>');
            
    fclose($file);
        }
        if(
    $config['groupdata'][$group]['end'] == 'normal' and count($group_array) == $config['groupdata'][$group]['count']) unset($group);
        if(
    $config['groupdata'][$group]['end'] == 'message' and count($group_array) == $config['groupdata'][$group]['count']) echo $groupmessage;
        if(
    $config['groupdata'][$group]['end'] == 'result' and count($group_array) == $config['groupdata'][$group]['count']) include('show_result.php');
        else @include(
    $config['path'].'/data/'.$group_array[$config['groupdata'][$group]['count']]);
    }
    if(!isset(
    $group)){
    if(
    $cpcategory and !$not_cpcategory$category_array explode(','$cpcategory);
    if(
    $not_cpcategory and !$cpcategory){
        
    $not_category_array explode(','$not_cpcategory);
        foreach(
    $file_array as $key => $file){
            @include(
    $config['path'].'/data/'.$file);
            if(
    $polldata['category'] and @!in_array($polldata['category'], $category_array)){ 
                
    $category_array[] = $polldata['category'];
            }
        }
        foreach(
    $not_category_array as $key => $cat){
            unset(
    $category_array[array_search($cat$category_array)]);        
        }
    }
    if(
    $cpcategory and $not_cpcategory or $cpcategory and $cpcategory_id or $not_cpcategory and $cpcategory_id){
    echo
    'You can only use either $cpcategory or $not_cpcategory or $cpcategory_id in one include. You can not mix them';
    exit;
    }
    if(
    $cpcategory_id){
        
    $cpcategory_id explode(','$cpcategory_id);
        foreach(
    $file_array as $key => $file){
            @include(
    $config['path'].'/data/'.$file);
            if(
    $polldata['category'] and @!in_array($polldata['category'], $category_id_array)){ 
                
    $category_id_array[] = $polldata['category'];
            }
        }
        
    sort($category_id_array);
        foreach(
    $cpcategory_id as $key => $id){
            
    $category_array[] = $category_id_array[$id];
        }
    }
    }
    if(!isset(
    $group)){
        
    $count count($file_array) + 1;
        if(!
    $cpcategory and !$not_cpcategory and !$cpcategory_id){
    /*line 80*/        rsort($file_array);
            @include(
    $config['path'].'/data/'.$file_array[0]);
            
    $filename $file_array[0];
        }
        if(
    $cpcategory or $not_cpcategory or $cpcategory_id){
            
    rsort($file_array);
            foreach(
    $file_array as $key => $file){
                @include(
    $config['path'].'/data/'.$file);
                if(
    in_array($polldata['category'], $category_array)){ $filename $file; break; }
            }
            
    $cpcategory $polldata['category'];
        }
    }
    /*line 93*/foreach($polldata['results'] as $key => $results){
        
    $pros[$key] = @round($results array_sum($polldata['results']) * 100);
    }
    if(
    $config['registered only vote'] == 'no' or $config['registered only vote'] == 'yes' and $memberdata[$_POST["cpusername"]]['password'] == md5($_POST["cppassword"]) or $_COOKIE["cppasswordp"] and $memberdata[$_COOKIE["cpusernamep"]]['password'] == $_COOKIE["cppasswordp"]){
    if(!
    $hidden or $hidden and $hidden == $memberdata[$_COOKIE["cpusernamep"]]['group'] or $hidden and $hidden == $memberdata[$_POST["cpusername"]]['group']){
        if(!
    $popup){
        if (
    $_GET["do"] == "showresults" and $cpcategory == $_GET["cpcat"]){
            
    $isback TRUE;
            @include(
    'show_result.php');
            unset(
    $isback);
        }    
    else{
    /*line 105*/    foreach($polldata['results'] as $key => $results){
            if(
    $_POST[$key]) break;
            
    $voted TRUE;
        }
        if(!
    $_POST['poll'] and $_POST['vote'] and $polldata['type'] == 'radio' and !$voted or !$voted and $_POST['vote'] and $polldata['type'] == 'check') echo $selectvote;
        else{
            if(
    $_POST['vote'] and $cpcategory == $_POST["cpcategory"]){
                if (
    in_array($_SERVER['REMOTE_ADDR'], $polldata['ip'])  and $config['ip check'] == 'yes' or in_array($_COOKIE["cpusernamep"], $polldata['registered vote']) and $config['registered only vote'] == 'yes' and $config['limited vote'] == 'yes') {
                    @include(
    'show_result.php');
                }
                    else{
                        if(!
    in_array($_SERVER['REMOTE_ADDR'], $polldata['ip'])) $polldata['ip'][] = $_SERVER['REMOTE_ADDR'];
                        if(
    $config['limited vote'] == 'yes'$polldata['registered vote'][] = $_COOKIE["cpusernamep"];
                        if(
    $polldata['type'] == 'radio'$polldata['results'][$_POST['poll']]++;
                        if(
    $polldata['type'] == 'check'){
                            foreach(
    $polldata['results'] as $key => $results){
                                if(!
    $_POST[$key] and $_POST[$key] != '0') continue;
                                
    $polldata['results'][$_POST[$key]]++; 
                            }
                        }
                        
    $filewrite fopen($config['path'].'/data/'.$filename'w+');
                        
    fwrite ($filewrite'<?PHP $polldata = '.var_export($polldatatrue).' ?>');
                        
    fclose($filewrite);
                        @include(
    'show_result.php');
                    }
                }    
                else{
    /*line 132*/                if (in_array($_SERVER['REMOTE_ADDR'], $polldata['ip']) and $config['ip check'] == 'yes' or in_array($_COOKIE["cpusernamep"], $polldata['registered vote']) and $config['registered only vote'] == 'yes' and $config['limited vote'] == 'yes') {
                        @include(
    'show_result.php');
                    }
                    else{
                        
    $votingheader str_replace("{title}"$polldata['title'], $votingheader);
                        if(
    $cpcategory$votingfooter str_replace("[show-results]""<a href=\"?do=showresults&amp;cpcat=".$cpcategory."\">"$votingfooter);
                        if(!
    $cpcategory$votingfooter str_replace("[show-results]""<a href=\"?do=showresults\">"$votingfooter);
                        
    $votingfooter str_replace("[/show-results]""</a>"$votingfooter);
                        
    $votingfooter str_replace("{submit}""<input type=\"submit\" value=\"".$votebutton."\" ".$votebuttonstyle."/>"$votingfooter);
                        
    $votingfooter str_replace("{submit}""<input type=\"submit\" value=\"".$votebutton."\" ".$votebuttonstyle."/>"$votingfooter);
    /*line 142*/                    $votingfooter str_replace("{total-votes}"array_sum($polldata['results']), $votingfooter);
                    if(
    $config['comment popup'] == 'yes'){
                        
    $votingfooterstr_replace("[comment-link]""<a href=\"#\" onclick=\"window.open('poll/comment.php?cpcat=".$cpcategory."', '_Comments', '".$config['popup']."');return false;\">"$votingfooter );
                    }
                    else{
                        if(
    $cpcategory$votingfooterstr_replace("[comment-link]""<a href=\"?do=poll_comment&amp;cpcat=".$cpcategory."\">"$votingfooter );
                        if(!
    $cpcategory$votingfooterstr_replace("[comment-link]""<a href=\"?do=poll_comment\">"$votingfooter );
                    }
                    
    $votingfooter str_replace("[/comment-link]""</a>"$votingfooter );
                    echo 
    '<form action="" method="post">'.stripslashes($votingheader);
                    if(!
    $a$a 'a';
    /*line 153*/                foreach($polldata['options'] as $key => $options){
                        
    $cpoutput $mainvotingarea;
                        
    $cpoutput str_replace("{options}"$options$cpoutput);
                        
    $cpoutput str_replace("{lable}""<label for=\"".$a."\"> ".$options."</label>"$cpoutput);
                        if(
    $polldata['type'] == 'radio'$cpoutput str_replace("{input}""<input type=\"radio\" name=\"poll\" value=\"".$key."\" id=\"".$a."\" />"$cpoutput);
                        if(
    $polldata['type'] == 'check'$cpoutput str_replace("{input}""<input type=\"checkbox\" name=\"".$key."\" value=\"".$key."\" id=\"".$a."\" />"$cpoutput);
                        echo 
    stripslashes($cpoutput);
                        
    $a++;
                    }
                    echo 
    '<input type="hidden" name="vote" value="TRUE" />
                    <input type="hidden" name="cpcategory" value="'
    .$cpcategory.'" />'.stripslashes($votingfooter).'</form>';
                    }
                    }
            }
        }
    }
    }
    }
    else{
    @include(
    'show_result.php');
    }
    unset(
    $group);
    unset(
    $hidden);
    unset(
    $cpcategory);
    unset(
    $not_cpcategory);
    unset(
    $cpcategory_id);
    unset(
    $cptemplate);
    ?>

    In remoto tutto ok il sondaggio funziona, ma siccome non posso usare sempre il server vorrei poter provare lo script in locale, potete aiutarmi per piacere?

    Può dipendere dal fatto che in locale ho installato Php 5.2.0 (con Apache 2.0.59), mentre in remoto la versione di php è la 4.4.4?

  2. #2
    piu' probabile che in remoto ci sia linux ed in locale windows.

    verifica cosa c'e' in $config['path'] ... stampa $dir

    occhio a come sono gli slash ed i backslash

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  3. #3
    Grazie per la risposta piero.mac!

    Originariamente inviato da piero.mac
    piu' probabile che in remoto ci sia linux ed in locale windows.
    Infatti mi sa che è proprio così...

    verifica cosa c'e' in $config['path'] ... stampa $dir
    Queste sono le prime righe del file config.php (sempre che c'entri qualcosa...) :master: :

    Codice PHP:
    <?php $config = array (
      
    'path' => 'localhost\\miosito\\poll',
    (In realtà c'è il \\ ma il forum l'ha cambiato in \)

    occhio a come sono gli slash ed i backslash
    Avevo provato con varie combinazioni di slash e backslash (arrivando a questa soluzione per intuito, visto che non conosco molto bene il php...) ma nulla cambiava...

  4. #4
    prova a mettere il path assoluto:

    Codice PHP:
    <?php $config = array (
      
    'path' => 'C:\\www\\miosito\\poll';
    e stampa la variabile $dir per vedere come risolve.

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  5. #5
    Grande!!

    Col percorso assoluto funziona!

    Sinceramente non saprei come stampare la variabile $dir ma a questo punto non credo sia necessario...

    Grazie mille!

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.