Exemple #1
0
function flag_tune($show_error = true, $skins_reset = false)
{
    /* Move skins outside the plugin folder */
    $flag_options = get_option('flag_options');
    $skins_dir = str_replace("\\", "/", WP_PLUGIN_DIR . '/flagallery-skins/');
    $old_skins_dir = FLAG_ABSPATH . 'skins/';
    $flag_options['skinsDirABS'] = $skins_dir;
    $flag_options['skinsDirURL'] = WP_PLUGIN_URL . '/flagallery-skins/';
    update_option('flag_options', $flag_options);
    if (version_compare(get_option('flagVersion'), '4.25', '<')) {
        $skins_reset = true;
        @unlink($skins_dir . 'banner_default');
        @unlink($skins_dir . 'banner_widget_default');
    }
    $errors = '';
    // check for main folder
    if (!wp_mkdir_p($skins_dir)) {
        $errors .= __('Directory <strong>"', 'flash-album-gallery') . $skins_dir . __('"</strong> doesn\'t exist. Please create first the <strong>"flagallery-skins"</strong> folder!', 'flash-album-gallery') . '<br />';
    } else {
        // check for permission settings, Safe mode limitations are not taken into account.
        if (!is_writeable($skins_dir)) {
            $errors .= __('Directory <strong>"', 'flash-album-gallery') . $skins_dir . __('"</strong> is not writeable!', 'flash-album-gallery') . '<br />';
        } else {
            // Files in flash-album-gallery/skins directory
            $open_old_skins_dir = @opendir($old_skins_dir);
            if ($open_old_skins_dir) {
                while (($file = readdir($open_old_skins_dir)) !== false) {
                    if (substr($file, 0, 1) == '.') {
                        continue;
                    }
                    if (is_dir($old_skins_dir . $file)) {
                        if (is_dir($skins_dir . $file)) {
                            if ($skins_reset) {
                                flagGallery::flagFolderDelete($skins_dir . $file);
                            } else {
                                continue;
                            }
                        }
                        if (!@rename($old_skins_dir . $file, $skins_dir . $file)) {
                            $errors .= sprintf(__('Failed to move files from %1$s to %2$s', 'flash-album-gallery'), '<strong>' . $old_skins_dir . $file . '</strong>', $skins_dir . $file) . '<br />';
                        }
                    }
                }
            }
            @closedir($open_old_skins_dir);
        }
    }
    if ($errors != '') {
        if ($show_error) {
            flagGallery::show_error($errors);
        }
        return false;
    }
    return true;
}
Exemple #2
0
        $flag->options['galleryPath'] = trailingslashit($flag->options['galleryPath']);
    }
    // Save options
    update_option('flag_options', $flag->options);
    flagGallery::show_message(__('Update Successfully', 'flash-album-gallery'));
}
if (isset($_GET['delete'])) {
    check_admin_referer('delete_skin');
    $delskin = sanitize_flagname($_GET['delete']);
    if (current_user_can('FlAG Delete skins') && false === strpos($delskin, '..')) {
        if ($flag_options['flashSkin'] != $delskin) {
            $skins_dir = trailingslashit($flag_options['skinsDirABS']);
            $skin = $skins_dir . $delskin . '/';
            if (basename($skin) != 'flagallery-skins') {
                if (is_dir($skin)) {
                    if (flagGallery::flagFolderDelete($skin)) {
                        flagGallery::show_message(__('Skin', 'flash-album-gallery') . ' \'' . $delskin . '\' ' . __('deleted successfully', 'flash-album-gallery'));
                    } else {
                        flagGallery::show_message(__('Can\'t find skin directory ', 'flash-album-gallery') . ' \'' . $delskin . '\' ' . __('. Try delete it manualy via ftp', 'flash-album-gallery'));
                    }
                }
            } else {
                flagGallery::show_message(__('Can\'t find skin directory ', 'flash-album-gallery') . ' \'' . $delskin . '\' ' . __('. Try delete it manualy via ftp', 'flash-album-gallery'));
            }
        } else {
            flagGallery::show_message(__('You need activate another skin before delete it', 'flash-album-gallery'));
        }
    } else {
        wp_die(__('You do not have sufficient permissions to delete skins of Grand Flagallery.'));
    }
}
Exemple #3
0
 /**
  * Function used to delete a folder.
  * @param string $path full-path to folder
  * @return bool result of deletion
  */
 static function flagFolderDelete($path)
 {
     if (is_dir($path)) {
         if (version_compare(PHP_VERSION, '5.0.0') < 0) {
             $entries = array();
             if ($handle = opendir($path)) {
                 while (false !== ($file = readdir($handle))) {
                     $entries[] = $file;
                 }
                 closedir($handle);
             }
         } else {
             $entries = scandir($path);
             if ($entries === false) {
                 $entries = array();
             }
         }
         foreach ($entries as $entry) {
             if ($entry != '.' && $entry != '..') {
                 flagGallery::flagFolderDelete($path . '/' . $entry);
             }
         }
         return @rmdir($path);
     } elseif (file_exists($path)) {
         return @unlink($path);
     } else {
         return false;
     }
 }