check(5); include dirname(__FILE__).'/inc/connexion.php'; $page_title = __('Manage images'); $img_p = dc_img_root; $img_p = path::real($img_p); $p = !empty($_REQUEST['p']) ? $_REQUEST['p'] : ''; $mode = !isset($mode) ? '' : $mode; $pscript = ($mode == 'popup') ? 'images-popup.php' : 'images.php'; $imgM = new imgmanager($img_p,$p,dc_img_url,$pscript); $err = ''; # Upload d'image if (!$imgM->isExclude() && $imgM->isWritable() && !empty($_FILES['up_img'])) { $tmp_file = $_FILES['up_img']['tmp_name']; $img_name = $_FILES['up_img']['name']; $up_dir = $imgM->root.'/'.$imgM->base_path; if (version_compare(phpversion(),'4.2.0','>=')) { $upd_error = $_FILES['up_img']['error']; } else { $upd_error = 0; } if($upd_error != 0) { switch ($upd_error) { case 1: case 2: $err .= '
  • '.__('File size exceeds the authorized limit').'
  • '; break; case 3: $err .= '
  • '.__('File was only partially uploaded').'
  • '; break; case 4: $err .= '
  • '.__('No file').'
  • '; break; } } elseif(@move_uploaded_file($tmp_file,$up_dir.'/'.$img_name)) { $dest_img = $up_dir.'/'.$img_name; if(filesize($dest_img) > dc_upload_size) { $err .= '
  • '.__('File size exceeds the authorized limit').'
  • '; } else { if(($img_size = @getimagesize($dest_img)) === false) { $err .= '
  • '.sprintf(__('The file %s is not an image'), ''.$img_name.'').'
  • '; } else { $max_s = explode('x',dc_max_img_size); $max_w = (int) $max_s[0]; $max_h = isset($max_s[1]) ? (int) $max_s[1] : 0; if ($max_w > 0 && $img_size[0] > $max_w) { $err .= '
  • '.__('Image is too large').'
  • '; } elseif ($max_h > 0 && $img_size[1] > $max_h) { $err .= '
  • '.__('Image is too large').'
  • '; } } } if ($err != '') { unlink($dest_img); } else { chmod($up_dir.'/'.$img_name,fileperms($up_dir) & ~0111); # On fait le thumbnail if (($img_type = images::type($dest_img)) !== false) { $tn_file = preg_replace('/^(.*)([.]\\w+)$/','$1.TN__$2',$up_dir.'/'.$img_name); images::cropImg($dest_img,$tn_file,$img_type,140,140); } $msg = __('Image uploaded'); header('Location: '.$pscript.'?p='.$p.'&msg='.rawurlencode($msg)); exit(); } } else { $err .= '
  • '.__('An error occured while uploading the image').'
  • '; } } # Création d'une miniature if (!$imgM->isExclude() && $imgM->isImg() && isset($_GET['tn'])) { $type = $imgM->getImgType(); if ($type != 'png' && $type != 'jpeg') { $err .= '
  • '.__('Wrong image type').'
  • '; } elseif (!$imgM->isParentWritable()) { $err .= '
  • '.__('This folder is not writable.').'
  • '; } else { $img_file = $imgM->root.'/'.$imgM->base_path; $tn_file = preg_replace('/^(.*)([.]\\w+)$/','$1.TN__$2',$img_file); if (images::cropImg($img_file,$tn_file,$type,140,140) !== false) { header('Location: '.$pscript.'?p='.dirname($p)); exit; } } } # Suppression if (!$imgM->isExclude() && $imgM->isDeletable() && isset($_GET['del'])) { if ($imgM->isImg()) { $img_tn = $imgM->getThumb(NULL,true); } if ($imgM->delete() === false) { $err .= '
  • '.__('Cannot delete.').'
  • '; } else { if (!empty($img_tn)) { @unlink($img_tn); } header('Location: '.$pscript.'?p='.dirname($p)); exit; } } # Création d'un répertoire if (!$imgM->isExclude() && $imgM->isWritable() && !empty($_POST['new_dir'])) { if ($imgM->newDir($_POST['new_dir']) !== false) { header('Location: '.$pscript.'?p='.$p); exit; } else { $err = '
  • '.__('Cannot create this directory.').'
  • '; } } # Affichage if ($mode == 'popup') { openPopup($page_title); echo ''; echo '"; } else { # Sous menu $mySubMenu->addItem( __('Back to list of entries'),'index.php','images/ico_retour.png',false); openPage($page_title); } echo '

    '.$page_title.'

    '; if ($err != '') { echo '

    '.__('Error(s)').' :

    '. '
    '; } echo '

    '.__('Your images').'

    '; echo '

    '.$imgM->getNavBar().'

    '; # Affichage des image if (!$imgM->isExclude() && $imgM->isDir() && ($f_list = $imgM->getDir()) !== false) { $redir_link = ''.$pscript.'?p='.$imgM->base_path; foreach ($f_list['dirs'] as $k => $v) { $action = ''; if ($v['del']) { $action .= ''. ''.__('delete').''; } $action = '

    '.$action.'

    '; $dir_link = '
    '. '

    '. ''. ''. '%2$s

    '. $action. '
    '; echo $imgM->listDir($k,$v,$dir_link); } foreach ($f_list['files'] as $k => $v) { $action = ''; if ($v['del']) { $action .= ''. ''.__('delete').''; } $action = '

    '.$action.'

    '; if ($mode != 'popup') { $img_href = '%1$s'; } else { $img_href = '%1$s" '. 'onclick="tbImg.insImg(\'%4$s\'); '. 'window.close(); return false;'; } $img_link = '
    '. '

    '. '
    %2$s'. '

    '. __('Try to create thumbnail').'

    '. $action. '
    '; $img_link_tn = '
    '. '

    '. '%2$s'. '%2$s

    '. $action. '
    '; if (!preg_match('/TN__[.]\w+$/',$k)) { # Thumbnail ? if (($tn_url = $imgM->getThumb($k)) !== false) { echo $imgM->listImg($k,$v,$img_link_tn); } else { echo $imgM->listImg($k,$v,$img_link); } } } } # Formulaire if ($imgM->isWritable()) { echo '
    '. '
    '.__('Upload an image').''. '

    '. ''. ''. ''. ''. ' 

    '. '
    '. '
    '; echo '
    '. '
    '.__('New directory').''. '

    '. form::field('new_dir',20,255,''). ''. ''. ' 

    '. '
    '. '
    '; } if ($mode == 'popup') { closePopup(); } else { closePage(); } ?>