• Since 1.7.1. it is not possible to add an new Gallery in Safe Mode.

    If in Safe mode you check for Safe Mode ON (admin/functions.php)and if so, you ask for manually creation of the image- and thumbs folder. But if these folders are created manually, on the next try you find these folders already existing and add a “1” as suffix to the folder name and again ask for manually creation of theses folder.

    So you can never add a galery if safe mode is on.

    I′ve already found some postings describing exact this issue. It would be nice to correct this problem, as it is not possible to use it if safe mode is on (which I am forced to use by my ISP) .

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter MuggelKid

    (@muggelkid)

    I’ve implemented a solution for the Safe-Mode problem, as I think it could be solved:

    In /admin/functions.php replace this code:

    // 1. Check for existing folder
    	                if ( is_dir(WINABSPATH . $defaultpath . $name ) ) {
    	                        $suffix = 1;
    	                        do {
    	                                $alt_name = substr ($name, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "_$suffix";
    	                                $dir_check = is_dir(WINABSPATH . $defaultpath . $alt_name );
    	                                $suffix++;
    	                        } while ( $dir_check );
    	                        $name = $alt_name;
    	                } 
    
                        // define relative path to gallery inside wp root folder
                        $nggpath = $defaultpath . $name;
    
    	                // 2. Create new gallery folder
    	                if ( !wp_mkdir_p (WINABSPATH . $nggpath) )
    	                  $txt  = __('Unable to create directory ', 'nggallery').$nggpath.'!<br />';
    
    	                // 3. Check folder permission
    	                if ( !is_writeable(WINABSPATH . $nggpath ) )
    	                        $txt .= __('Directory', 'nggallery').' <strong>'.$nggpath.'</strong> '.__('is not writeable !', 'nggallery').'<br />';
    
    	                // 4. Now create thumbnail folder inside
    	                if ( !is_dir(WINABSPATH . $nggpath . '/thumbs') ) {
    	                        if ( !wp_mkdir_p ( WINABSPATH . $nggpath . '/thumbs') )
    	                                $txt .= __('Unable to create directory ', 'nggallery').' <strong>' . $nggpath . '/thumbs !</strong>';
    	                }
    
    	                if (SAFE_MODE) {
    	                        $help  = __('The server setting Safe-Mode is on !', 'nggallery');
    	                        $help .= '<br />'.__('If you have problems, please create directory', 'nggallery').' <strong>' . $nggpath . '</strong> ';
    	                        $help .= __('and the thumbnails directory', 'nggallery').' <strong>' . $nggpath . '/thumbs</strong> '.__('with permission 777 manually !', 'nggallery');
    	                        if ($output) nggGallery::show_message($help);
    	                }
    
    	                // show a error message
    	                if ( !empty($txt) ) {
    	                        if (SAFE_MODE) {
    	                        // for safe_mode , better delete folder, both folder must be created manually
    	                                @rmdir(WINABSPATH . $nggpath . '/thumbs');
    	                                @rmdir(WINABSPATH . $nggpath);
    	                        }
    	                        if ($output) nggGallery::show_error($txt);
    	                        return false;
    	                }

    with

    if (SAFE_MODE) {
                // define relative path to gallery inside wp root folder
                $nggpath = $defaultpath . $name;
    
                // Only check for existing gallery an thumbs folders
                if ( (!is_dir(WINABSPATH . $nggpath) ) || (!is_dir(WINABSPATH . $nggpath . '/thumbs') ) ){
                    $help  = __('The server setting Safe-Mode is on !', 'nggallery');
                    $help .= '<br />'.__('If you have problems, please create directory', 'nggallery').' <strong>' . $nggpath . '</strong> ';
                    $help .= __('and the thumbnails directory', 'nggallery').' <strong>' . $nggpath . '/thumbs</strong> '.__('with permission 777 manually !', 'nggallery');
                    if ($output) nggGallery::show_message($help);            
    
                    if ( !is_dir(WINABSPATH . $nggpath))             $txt .= __('Directory must exist: ', 'nggallery').$nggpath.'!<br />';
                    if ( !is_dir(WINABSPATH . $nggpath . '/thumbs')) $txt .= __('Directory must exist: ', 'nggallery').$nggpath . '/thumbs! <br />';
    
                    if ($output) nggGallery::show_error($txt);
                    return false;
                }
            }
            else {
                // 1. Check for existing folder
                if ( is_dir(WINABSPATH . $defaultpath . $name ) ) {
                    $suffix = 1;
                    do {
                        $alt_name = substr ($name, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "_$suffix";
                        $dir_check = is_dir(WINABSPATH . $defaultpath . $alt_name );
                        $suffix++;
                    } while ( $dir_check );
                    $name = $alt_name;
                }
                // define relative path to gallery inside wp root folder
                $nggpath = $defaultpath . $name;
    
                // 2. Create new gallery folder
                if ( !wp_mkdir_p (WINABSPATH . $nggpath) )
                  $txt  = __('Unable to create directory ', 'nggallery').$nggpath.'!<br />';
    
                // 3. Check folder permission
                if ( !is_writeable(WINABSPATH . $nggpath ) )
                    $txt .= __('Directory', 'nggallery').' <strong>'.$nggpath.'</strong> '.__('is not writeable !', 'nggallery').'<br />';
                // 4. Now create thumbnail folder inside
                if ( !is_dir(WINABSPATH . $nggpath . '/thumbs') ) {
                    if ( !wp_mkdir_p ( WINABSPATH . $nggpath . '/thumbs') )
                        $txt .= __('Unable to create directory ', 'nggallery').' <strong>' . $nggpath . '/thumbs !</strong>';
                }
    
                // show a error message
                if ( !empty($txt) ) {
                    if ($output) nggGallery::show_error($txt);
                    return false;
                }
            }

    But of course hacking the plugin-files is not the best idea, as after an update these changes are gone.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: NextGEN Gallery] Add Galery in Safe-Mode does not work’ is closed to new replies.