Bonjour,

J'ai un code qui fonctionnait dans le temps et ne semble plus pouvoir passer sur php5, je n'en trouve pas la cause,
Auriez vous une idée de ce qui cloche ?
Cette fonction ajoute une image sur une fiche produit.
Il n'y a pas d'erreur visible mais tout reste décoché ...

Avec tout mes remerciements par avance !

Voici les bouts de code concernés :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php 
 
 
$dir = DIR_FS_CATALOG."/images/persoimg/1";
 
// Ouvre un dossier bien connu, et liste tous les fichiers
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        $elements = explode(":", $pInfo->perso);
        $nb=0;
        while (($file = readdir($dh)) !== false) {
        $file1 = strtolower($file);
        $dchecked="";
        $file2 = str_replace('\'','%1%',$file);
        $file2 = str_replace(' ','%2%',$file2);
        $file2 = str_replace('"','%3%',$file2);
        $file2 = str_replace('.','%4%',$file2);
 
                if (substr($file1, -4) == '.gif' || substr($file1, -4) == '.jpg') {
 
                for ($i = 0; $i < count($elements); $i++) {
                  if ($elements[$i]==$file2)
                    $dchecked=" CHECKED ";
                }
                if (($nb) == 5){
                  echo "</td></tr><tr><td width='20%' height='45px'>";
                  $nb=0;
                }
                ?>
                 <table border="0"  height='20px' width="100%" cellspacing="0" cellpadding="0" align="center">
        <tr bgcolor="#ebebff">
          <td class="main"><?echo tep_draw_checkbox_field('/images/persoimg_'.$file2,'',$dchecked);?></td>
          <td  height='45px' class="main"><img src="<?=HTTP_CATALOG_SERVER.DIR_WS_HTTP_CATALOG."/images/persoimg/1/".$file?>"></td>
        </tr>
        </table></td><td width='20%'  height="45px">
        <?php 
        $nb=$nb+1;
            }
        }
        closedir($dh);
        if ($nb>1)
        echo "</td></tr>";
    }
}





Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 $perso_str="";
            foreach($_POST as $index => $valeur)
            {
              if (substr($index,0,9)=="/images/persoimg_"){
              $perso_str .= substr($index,9).":";
              }
            }
            $perso_str=substr($perso_str,0,-1);


les fonctions :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()
  function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
 
    $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
 
    if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';
 
    if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
      $selection .= ' CHECKED';
    }
 
    if (tep_not_null($parameters)) $selection .= ' ' . $parameters;
 
    $selection .= '>';
 
    return $selection;
  }

et pour finir :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
// Output a form checkbox field
  function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
    return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
  }