private static function detectOS()
 {
     if (self::$OS == null) {
         if (stristr(PHP_OS, 'WIN')) {
             self::$OS = self::OS_WIN;
         } else {
             self::$OS = self::OS_UNIX;
         }
     }
     return self::$OS;
 }
Example #2
0
$sql = 'SELECT * FROM ' . TABLE_PREFIX . 'mod_foldergallery_files WHERE parent_id="' . $parent_id . '" ORDER BY position ASC;';
$query = $database->query($sql);
if ($query->numRows()) {
    while ($result = $query->fetchRow()) {
        // Falls es das Vorschaubild noch nicht gibt:
        //Chio Start
        $bildfilename = $result['file_name'];
        $file = $pathToFolder . $bildfilename;
        if (!is_file(DirectoryHandler::DecodePath($file))) {
            $deletesql = 'DELETE FROM ' . TABLE_PREFIX . 'mod_foldergallery_files WHERE id=' . $result['id'];
            $database->query($deletesql);
            continue;
        }
        $file = $pathToFolder . $bildfilename;
        $thumb = $pathToThumb . $bildfilename;
        if (!is_file(DirectoryHandler::DecodePath($thumb))) {
            FG_createThumb($file, $bildfilename, $pathToThumb, $settings['tbSettings']);
        }
        //Chio Ende
        $bilder[] = array('id' => $result['id'], 'file_name' => $bildfilename, 'caption' => $result['caption'], 'thumb_link' => $urlToThumb . $bildfilename);
    }
} else {
    // Diese Kategorie enthält noch keine Bilder
    $error['noimages'] = 1;
}
//Template
$t = new Template(dirname(__FILE__) . '/templates', 'remove');
$t->set_file('modify_cat', 'modify_cat.htt');
// clear the comment-block, if present
$t->set_block('modify_cat', 'CommentDoc');
$t->clear_var('CommentDoc');
Example #3
0
mysql_set_charset('utf8', $database->db_handle);
$settings = getSettings($section_id);
$flag = false;
/* syncDB($galerie) ist kompletter updatealgorithmus */
if (syncDB($settings)) {
    echo "<div class=\"info\">" . $MOD_FOLDERGALLERY['SYNC_DATABASE'] . "</div><br />";
    // Wieder alle Angaben aus der DB holen um Sortierung festzulegen
    $results = array();
    $sql = "SELECT * FROM " . TABLE_PREFIX . "mod_foldergallery_categories WHERE section_id =" . $section_id;
    $query = $database->query($sql);
    if ($query->numRows() > 0) {
        while ($result = $query->fetchRow()) {
            if ($result['parent'] != -1) {
                $folder = $settings['root_dir'] . '/' . $result['parent'] . '/' . $result['categorie'];
                $pathToFolder = $path . $folder;
                if (!is_dir(DirectoryHandler::DecodePath($pathToFolder))) {
                    $delete_sql = 'DELETE FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE id="' . $result['id'] . '";';
                    $database->query($delete_sql);
                    continue;
                }
            }
            $results[] = $result;
            //			$folder = $settings['root_dir'].'/'.$result['parent'].'/'.$result['categorie'];
            //			$pathToFolder = $path.$folder;
            //                        var_dump($pathToFolder);
            //			if ($result['parent'] != -1) {; //nicht die roots;
            //				//checken, ob es das Verzeichnis noch gibt:
            //				if(!is_dir(DirectoryHandler::DecodePath($pathToFolder))){
            //					$delete_sql = 'DELETE FROM '.TABLE_PREFIX.'mod_foldergallery_categories WHERE id="'.$result['id'].'";';
            //					$database->query($delete_sql);
            //					continue;
Example #4
0
$allowedFileTypes = explode(',', $settings['extensions']);
$fileParts = pathinfo($_FILES['Filedata']['name']);
$filename = $v->getSaveFilename($fileParts['filename']);
$extension = strtolower($fileParts['extension']);
if (!in_array($fileParts['extension'], $allowedFileTypes)) {
    exit;
}
// Move the image and create the thumb:
$handle = new upload($_FILES['Filedata']['tmp_name']);
if ($handle->uploaded) {
    // Save the image in the right categorie
    $handle->file_new_name_body = $filename;
    $handle->file_new_name_ext = $extension;
    $handle->process(DirectoryHandler::DecodePath($categoriePath));
    if (!$handle->processed) {
        echo DirectoryHandler::DecodePath($categoriePath);
        exit;
    }
    $handle->clean();
    // Create the thumb
    $success = FG_createThumb($categoriePath . $filename . '.' . $extension, $filename . '.' . $extension, $categoriePath . 'fg-thumbs/', $settings['tbSettings']);
    if (!$success) {
        exit;
    }
} else {
    exit;
}
// get DB infos
$sql = 'SELECT position FROM `' . TABLE_PREFIX . 'mod_foldergallery_files` WHERE `parent_id`= ' . $cat_id . ' ORDER BY `position` DESC LIMIT 1;';
$query = $database->query($sql);
$result = $query->fetchRow();
Example #5
0
/**
 * Creates a thumbnail out of the given File/Image
 *
 * This function creates a thumbimage out of the File/Image given in $imagePath
 * The settings which are given in $settings are applied during creation. Finaly
 * the new image is saved in the $thumbPath-Folder with the Name $imageName.
 * If it is not possible to create a thumbnail out of $imagePath, a Icon is used
 * and transformed according the $settings.
 *
 * @param string $imagePath Image/File
 * @param string $imageName Name of the Image/File which is created, inclusive extension
 * @param string $thumbPath Path to the folder in which the created file is saved
 * @param array $settings   Settings array with the configuration of the uploadclass
 * @return boolean
 */
function FG_createThumb($imagePath, $imageName, $thumbPath, $settings)
{
    $handle = new upload(DirectoryHandler::DecodePath($imagePath));
    if (!$handle->file_is_image) {
        switch ($handle->file_src_mime) {
            case 'application/x-shockwave-flash':
                $handle = new upload(WB_PATH . '/modules/foldergallery/images/swf_icon.png');
                break;
            case 'video/quicktime':
                $handle = new upload(WB_PATH . '/modules/foldergallery/images/quicktime_icon.png');
                break;
            default:
                $handle = new upload(WB_PATH . '/modules/foldergallery/images/unknown_icon.png');
        }
    }
    if ($handle->file_is_image) {
        FG_appendThumbSettings($handle, $settings, DirectoryHandler::DecodePath($imageName));
        $handle->process(DirectoryHandler::DecodePath($thumbPath));
        if ($handle->processed) {
            return true;
        }
    }
    return false;
}
Example #6
0
            //Create the new Thumb
            $handle = new upload(DirectoryHandler::DecodePath($full_file));
            FG_appendThumbSettings($handle, $settings['tbSettings'], DirectoryHandler::DecodePath($bildfilename));
            $topCrop = floor($_POST['y1']);
            $rightCrop = floor($handle->image_src_x - $_POST['x2']);
            $bottomCrop = floor($handle->image_src_y - $_POST['y2']);
            $leftCrop = floor($_POST['x1']);
            $handle->image_precrop = "{$topCrop} {$rightCrop} {$bottomCrop} {$leftCrop}";
            $handle->process(DirectoryHandler::DecodePath($thumbFolder));
            if ($handle->processed) {
                $admin->print_success($MOD_FOLDERGALLERY['UPDATED_THUMB'], WB_URL . '/modules/foldergallery/admin/modify_cat.php?page_id=' . $page_id . '&section_id=' . $section_id . '&cat_id=' . $cat_id);
            } else {
                $admin->print_error("Could not create a new thumbnail!", WB_URL . '/modules/foldergallery/admin/modify_cat.php?page_id=' . $page_id . '&section_id=' . $section_id . '&cat_id=' . $cat_id);
            }
        } else {
            list($width, $height, $type, $attr) = getimagesize(DirectoryHandler::DecodePath($full_file));
            $previewWidth = $settings['tbSettings']['image_x'];
            $previewHeight = $settings['tbSettings']['image_y'];
            $t = new Template(dirname(__FILE__) . '/templates', 'remove');
            $t->set_file('modify_thumb', 'modify_thumb.htt');
            // clear the comment-block, if present
            $t->set_block('modify_thumb', 'CommentDoc');
            $t->clear_var('CommentDoc');
            $t->set_var(array('REL_WIDTH' => $width, 'REL_HEIGHT' => $height, 'THUMB_SIZE' => $previewWidth, 'RATIO' => $previewWidth / $previewHeight, 'EDIT_THUMB' => $MOD_FOLDERGALLERY['EDIT_THUMB'], 'EDIT_THUMB_DESCR' => $MOD_FOLDERGALLERY['EDIT_THUMB_DESCRIPTION'], 'SAVE_NEW_THUMB' => $MOD_FOLDERGALLERY['EDIT_THUMB_BUTTON'], 'CANCEL' => $TEXT['CANCEL'], 'FULL_FILE_LINK' => $full_file_link, 'PREVIEW_HEIGHT' => $previewHeight, 'PREVIEW_WIDTH' => $previewWidth, 'WB_URL' => WB_URL, 'PAGE_ID' => $page_id, 'SECTION_ID' => $section_id, 'CAT_ID' => $cat_id, 'IMG_ID' => $_GET['id']));
            $t->pparse('output', 'modify_thumb');
        }
    }
} else {
    $admin->print_error($MOD_FOLDERGALLERY['ERROR_MESSAGE'], WB_URL . '/modules/foldergallery/admin/modify_cat.php?page_id=' . $page_id . '&section_id=' . $section_id . '&cat_id=' . $cat_id);
}
$admin->print_footer();
/**
 * Einfache Funktion zum ein File löschen
 * @return bool true wenn alles gut ging, sonst false
 * @param string $path pfad zum files
 */
function deleteFile($path)
{
    if (is_file(DirectoryHandler::DecodePath($path))) {
        unlink(DirectoryHandler::DecodePath($path));
        return true;
    } else {
        return false;
    }
}