Ejemplo n.º 1
0
function gallery_list($selected = 0)
{
    echo '<select name="galid">' . get_gallery_list($selected) . '</select>';
}
Ejemplo n.º 2
0
 function padd()
 {
     global $set, $db, $apx, $html;
     $_REQUEST['id'] = (int) $_REQUEST['id'];
     if (!$_REQUEST['id']) {
         die('missing ID!');
     }
     @set_time_limit(600);
     if ($_POST['send'] == 1) {
         if (!checkToken()) {
             infoInvalidToken();
         } else {
             $files = array();
             require_once BASEDIR . 'lib/class.mediamanager.php';
             $mm = new mediamanager();
             //ZIP
             if ($_REQUEST['what'] == 'zip' && $_FILES['zip']['tmp_name']) {
                 $mm->uploadfile($_FILES['zip'], 'gallery/uploads', $mm->getfile($_FILES['zip']['tmp_name']));
                 $zipfile = zip_open(BASEDIR . getpath('uploads') . 'gallery/uploads/' . $mm->getfile($_FILES['zip']['tmp_name']));
                 while ($zipentry = zip_read($zipfile)) {
                     if (zip_entry_open($zipfile, $zipentry, 'r')) {
                         if (substr(zip_entry_name($zipentry), -1) == '/') {
                             continue;
                         }
                         $content = zip_entry_read($zipentry, zip_entry_filesize($zipentry));
                         $zipname = str_replace('/', '%1%', zip_entry_name($zipentry));
                         $outfilepath = 'gallery/uploads/' . $zipname;
                         zip_entry_close($zipentry);
                         //Datei schreiben
                         $outfile = fopen(BASEDIR . getpath('uploads') . $outfilepath, 'w');
                         fwrite($outfile, $content);
                         fclose($outfile);
                         $ext = strtolower($mm->getext($outfilepath));
                         if ($ext == 'gif') {
                             $ext = 'jpg';
                         }
                         $files[] = array('ext' => $ext, 'source' => $outfilepath, 'watermark' => $_POST['watermark'], 'noresize' => $_POST['noresize'], 'allowcoms' => $_POST['allowcoms'], 'allowrating' => $_POST['allowrating'], 'caption' => $_POST['caption']);
                     }
                 }
                 zip_close($zipfile);
                 $mm->deletefile('gallery/uploads/' . $mm->getfile($_FILES['zip']['tmp_name']));
             } elseif ($_REQUEST['what'] == 'ftp') {
                 if (!is_array($_POST['ftp'])) {
                     $_POST['ftp'] = array();
                 }
                 require_once BASEDIR . 'lib/class.mediamanager.php';
                 $mm = new mediamanager();
                 foreach ($_POST['ftp'] as $key => $file) {
                     $file = $mm->securefile($file);
                     $ext = strtolower($mm->getext($file));
                     if ($ext == 'gif') {
                         $ext = 'jpg';
                     }
                     $files[] = array('ext' => $ext, 'source' => 'gallery/uploads/' . $file, 'watermark' => $_POST['watermark' . $key], 'noresize' => $_POST['noresize' . $key], 'allowcoms' => $_POST['allowcoms' . $key], 'allowrating' => $_POST['allowrating' . $key], 'caption' => $_POST['caption' . $key]);
                 }
             } else {
                 for ($i = 1; $i <= $set['gallery']['addpics']; $i++) {
                     if (!$_FILES['upload' . $i]['tmp_name']) {
                         continue;
                     }
                     //Erfolgreichen Upload prüfen
                     if (!$mm->uploadfile($_FILES['upload' . $i], 'gallery/uploads', $mm->getfile($_FILES['upload' . $i]['tmp_name']))) {
                         continue;
                     }
                     $ext = strtolower($mm->getext($_FILES['upload' . $i]['name']));
                     if ($ext == 'gif') {
                         $ext = 'jpg';
                     }
                     $files[] = array('ext' => $ext, 'source' => 'gallery/uploads/' . $mm->getfile($_FILES['upload' . $i]['tmp_name']), 'watermark' => $_POST['watermark' . $i], 'noresize' => $_POST['noresize' . $i], 'allowcoms' => $_POST['allowcoms' . $i], 'allowrating' => $_POST['allowrating' . $i], 'caption' => $_POST['caption' . $i]);
                 }
             }
             $this->process_files($files);
             //Gallery Updatetime
             $this->setGalleryUpdatetime($_REQUEST['id']);
             //Weitere Bilder anfügen
             if ($_POST['addnext']) {
                 printJSRedirect('action.php?action=gallery.padd&id=' . $_REQUEST['id'] . '&updateparent=' . $_REQUEST['updateparent']);
             } else {
                 if ($_REQUEST['updateparent']) {
                     printJSUpdateObject($_REQUEST['updateparent'], get_gallery_list($_REQUEST['id']));
                 } else {
                     printJSRedirect('action.php?action=gallery.pshow&id=' . $_REQUEST['id']);
                 }
             }
         }
     } else {
         //Layer
         $layerdef[] = array('LAYER_UPLOAD', 'action.php?action=gallery.padd&amp;id=' . $_REQUEST['id'] . '&amp;updateparent=' . $_REQUEST['updateparent'], !$_REQUEST['what']);
         $layerdef[] = array('LAYER_ZIP', 'action.php?action=gallery.padd&amp;id=' . $_REQUEST['id'] . '&amp;what=zip&amp;updateparent=' . $_REQUEST['updateparent'], $_REQUEST['what'] == 'zip');
         $layerdef[] = array('LAYER_FTP', 'action.php?action=gallery.padd&amp;id=' . $_REQUEST['id'] . '&amp;what=ftp&amp;updateparent=' . $_REQUEST['updateparent'], $_REQUEST['what'] == 'ftp');
         if (!function_exists('zip_open')) {
             unset($layerdef[1]);
         }
         $html->layer_header($layerdef);
         //ZIP
         if ($_REQUEST['what'] == 'zip') {
             $apx->tmpl->assign('ID', $_REQUEST['id']);
             $apx->tmpl->assign('SET_OPTIONS', $apx->is_module('comments') && $set['gallery']['coms'] || $apx->is_module('ratings') && $set['gallery']['ratings'] || $set['gallery']['watermark'] || $set['gallery']['picwidth'] && $set['gallery']['picheight']);
             $apx->tmpl->assign('SET_COMS', $apx->is_module('comments') && $set['gallery']['coms']);
             $apx->tmpl->assign('SET_RATING', $apx->is_module('ratings') && $set['gallery']['ratings']);
             $apx->tmpl->assign('SET_WATERMARK', iif($set['gallery']['watermark'], 1, 0));
             $apx->tmpl->assign('SET_NORESIZE', iif($set['gallery']['picwidth'] && $set['gallery']['picheight'], 1, 0));
             $apx->tmpl->assign('UPDATEPARENT', (int) $_REQUEST['updateparent']);
             $apx->tmpl->parse('padd_zip');
         } elseif ($_REQUEST['what'] == 'ftp') {
             require_once BASEDIR . 'lib/class.mediamanager.php';
             $mm = new mediamanager();
             $extensions = array('jpg', 'jpeg', 'jpe', 'png', 'gif');
             $files = array();
             $dirs = array();
             if (is_dir(BASEDIR . getpath('uploads') . 'gallery/uploads/' . iif($_REQUEST['dir'], $_REQUEST['dir'] . '/'))) {
                 $dir = opendir(BASEDIR . getpath('uploads') . 'gallery/uploads/' . iif($_REQUEST['dir'], $_REQUEST['dir'] . '/'));
                 while ($file = readdir($dir)) {
                     if ($file == '.' || $file == '..') {
                         continue;
                     }
                     //Ordner
                     if (is_dir(BASEDIR . getpath('uploads') . 'gallery/uploads/' . iif($_REQUEST['dir'], $_REQUEST['dir'] . '/') . $file)) {
                         $dirs[] = $file;
                         continue;
                     }
                     //Datei
                     if (!in_array(strtolower($mm->getext($file)), $extensions)) {
                         continue;
                     }
                     $files[] = $file;
                 }
                 closedir($dir);
             }
             sort($files);
             sort($dirs);
             //Ordner auflisten
             foreach ($dirs as $dir) {
                 ++$i;
                 $subdir[$i]['NAME'] = $dir;
                 $subdir[$i]['LINK'] = 'action.php?action=gallery.padd&amp;id=' . $_REQUEST['id'] . '&amp;what=ftp&amp;dir=' . iif($_REQUEST['dir'], $_REQUEST['dir'] . '/') . $dir;
             }
             //Dateien auflisten
             foreach ($files as $file) {
                 ++$i;
                 $upload[$i]['FILE'] = $file;
                 $upload[$i]['FILEID'] = iif($_REQUEST['dir'], $_REQUEST['dir'] . '/') . $file;
                 $upload[$i]['LINK'] = HTTPDIR . getpath('uploads') . 'gallery/uploads/' . iif($_REQUEST['dir'], $_REQUEST['dir'] . '/') . $file;
             }
             //Pfad erstellen
             $pp = explode('/', $_REQUEST['dir']);
             if ($_REQUEST['dir'] && count($pp)) {
                 foreach ($pp as $dirname) {
                     ++$i;
                     $path .= iif($path, '/') . $dirname;
                     $pathdata[$i]['NAME'] = $dirname;
                     $pathdata[$i]['LINK'] = 'action.php?action=gallery.padd&amp;id=' . $_REQUEST['id'] . '&amp;what=ftp&amp;dir=' . $path;
                 }
             }
             $apx->tmpl->assign('ID', $_REQUEST['id']);
             $apx->tmpl->assign('FTP', $upload);
             $apx->tmpl->assign('DIR', $subdir);
             $apx->tmpl->assign('PATH', $pathdata);
             $apx->tmpl->assign('SET_OPTIONS', $apx->is_module('comments') && $set['gallery']['coms'] || $apx->is_module('ratings') && $set['gallery']['ratings'] || $set['gallery']['watermark'] || $set['gallery']['picwidth'] && $set['gallery']['picheight']);
             $apx->tmpl->assign('SET_COMS', $apx->is_module('comments') && $set['gallery']['coms']);
             $apx->tmpl->assign('SET_RATING', $apx->is_module('ratings') && $set['gallery']['ratings']);
             $apx->tmpl->assign('SET_WATERMARK', iif($set['gallery']['watermark'], 1, 0));
             $apx->tmpl->assign('SET_NORESIZE', iif($set['gallery']['picwidth'] && $set['gallery']['picheight'], 1, 0));
             $apx->tmpl->assign('UPDATEPARENT', (int) $_REQUEST['updateparent']);
             $apx->tmpl->parse('padd_ftp');
         } else {
             for ($i = 1; $i <= $set['gallery']['addpics']; $i++) {
                 $upload[$i]['ASD'] = 1;
             }
             $apx->tmpl->assign('ID', $_REQUEST['id']);
             $apx->tmpl->assign('UPLOAD', $upload);
             $apx->tmpl->assign('SET_COMS', $apx->is_module('comments') && $set['gallery']['coms']);
             $apx->tmpl->assign('SET_RATING', $apx->is_module('ratings') && $set['gallery']['ratings']);
             $apx->tmpl->assign('SET_WATERMARK', iif($set['gallery']['watermark'], 1, 0));
             $apx->tmpl->assign('SET_NORESIZE', iif($set['gallery']['picwidth'] && $set['gallery']['picheight'], 1, 0));
             $apx->tmpl->assign('UPDATEPARENT', (int) $_REQUEST['updateparent']);
             $apx->tmpl->parse('padd_upload');
         }
         //Layer Ende
         $html->layer_footer();
     }
 }