Пример #1
0
/**
 *	Function to remove a non-empty directory
 *
 *	@param string $directory
 *	@return boolean
 */
function rm_full_dir($directory)
{
    // If suplied dirname is a file then unlink it
    if (is_file($directory)) {
        return unlink($directory);
    }
    //	Empty the folder
    if (is_dir($directory)) {
        $dir = dir($directory);
        while (false !== ($entry = $dir->read())) {
            // Skip pointers
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            // Deep delete directories
            if (is_dir($directory . '/' . $entry)) {
                rm_full_dir($directory . '/' . $entry);
            } else {
                unlink($directory . '/' . $entry);
            }
        }
        // Now delete the folder
        $dir->close();
        return rmdir($directory);
    }
}
Пример #2
0
function cleanup()
{
    if (0 == func_num_args()) {
        return true;
    }
    $all_args = func_get_args();
    foreach ($all_args as &$file) {
        if (true === file_exists($file)) {
            if (true === is_dir($file)) {
                rm_full_dir($file);
            } else {
                unlink($file);
            }
        }
    }
    return true;
}
function rename_recursive_dirs($dirsource, $dirdest, $deep = 0)
{
    if (true === is_dir($dirsource)) {
        $dir = dir($dirsource);
        while ($file = $dir->read()) {
            if ($file[0] != ".") {
                if (!is_dir($dirsource . "/" . $file)) {
                    copy($dirsource . "/" . $file, $dirdest . "/" . $file);
                    change_mode($dirdest . "/" . $file);
                } else {
                    make_dir($dirdest . "/" . $file);
                    rename_recursive_dirs($dirsource . "/" . $file, $dirdest . '/' . $file, $deep + 1);
                }
            }
        }
        $dir->close();
    }
    if ($deep == 0) {
        rm_full_dir($dirsource);
    }
    return true;
}
Пример #4
0
}
// Run the modules uninstall script if there is one
if (file_exists(LEPTON_PATH . '/modules/' . $file . '/uninstall.php')) {
    $temp_css = LEPTON_PATH . '/modules/' . $file . '/backend.css';
    if (file_exists($temp_css)) {
        echo "\n<link href=\"" . (LEPTON_URL . '/modules/' . $file . '/backend.css') . " rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" />\n";
    } else {
        $temp_css = LEPTON_PATH . '/modules/' . $file . '/css/backend.css';
        if (file_exists($temp_css)) {
            echo "\n<link href=\"" . (LEPTON_URL . '/modules/' . $file . '/css/backend.css') . " rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" />\n";
        }
    }
    require LEPTON_PATH . '/modules/' . $file . '/uninstall.php';
}
// Try to delete the module dir
if (!rm_full_dir(LEPTON_PATH . '/modules/' . $file)) {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
} else {
    // Remove entry from DB
    $database->query("DELETE FROM " . TABLE_PREFIX . "addons WHERE directory = '" . $file . "' AND type = 'module'");
}
// remove module permissions
$stmt = $database->query('SELECT * FROM `' . TABLE_PREFIX . 'groups` WHERE `group_id` <> 1');
if ($stmt->numRows() > 0) {
    while ($row = $stmt->fetchRow(MYSQL_ASSOC)) {
        $gid = $row['group_id'];
        // get current value
        $modules = explode(',', $row['module_permissions']);
        // remove uninstalled module
        if (in_array($file, $modules)) {
            $i = array_search($file, $modules);
function wb_handle_export($filename = 'drop_export', $export_id = 0)
{
    global $database, $admin, $MESSAGE;
    $name = NULL;
    $list = isset($_POST['markeddroplet']) ? $_POST['markeddroplet'] : array();
    if ($export_id != 0) {
        $list = $export_id;
    }
    if (!is_array($list)) {
        $list = array($list);
    }
    if (count($list) < 1 and $export_id == 0) {
        echo '<div class="drfail">Please mark some Droplets first!</div>';
        return;
    }
    $temp_dir = WB_PATH . '/temp/droplets/';
    // make the temporary working directory
    @mkdir($temp_dir);
    foreach ($list as $id) {
        // Added by PCWacht
        // Get id - needed $admin to be global!
        if (version_compare(WB_VERSION, '2.8.2', '>=') && WB_VERSION != "2.8.x" and $export_id == 0) {
            $id = $admin->checkIDKEY($id, false, '');
            if (!$id) {
                $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
                exit;
            }
        }
        // End add
        $result = $database->query("SELECT * FROM " . TABLE_PREFIX . "mod_droplets WHERE id='{$id}'");
        if ($result->numRows() > 0) {
            $droplet = $result->fetchRow();
            $name = $droplet["name"];
            echo 'Saving: ' . $name . '.php<br />';
            $sFile = $temp_dir . $name . '.php';
            $fh = fopen($sFile, 'w');
            fwrite($fh, '//:' . $droplet['description'] . "\n");
            fwrite($fh, '//:' . str_replace("\n", " ", $droplet['comments']) . "\n");
            fwrite($fh, $droplet['code']);
            fclose($fh);
        }
    }
    // if there's only a single droplet to export, name the zip-file after this droplet
    if (count($list) === 1) {
        $filename = 'droplet_' . $name;
    }
    // add current date to filename
    $filename .= '_' . date('Y-m-d-His');
    // while there's an existing file, add a number to the filename
    if (file_exists(WB_PATH . '/temp/' . $filename . '.zip')) {
        $n = 1;
        while (file_exists(WB_PATH . '/temp/' . $filename . '_' . $n . '.zip')) {
            $n++;
        }
        $filename .= '_' . $n;
    }
    $temp_file = WB_PATH . '/temp/' . $filename . '.zip';
    // create zip
    require_once WB_PATH . '/include/pclzip/pclzip.lib.php';
    $archive = new PclZip($temp_file);
    $file_list = $archive->create($temp_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
    if ($file_list == 0) {
        echo "Packaging error: ", $archive->errorInfo(true), "<br />";
        die("Error : " . $archive->errorInfo(true));
    } else {
        // create the export folder if it doesn't exist
        if (!file_exists(WB_PATH . '/modules/droplets/export')) {
            mkdir(WB_PATH . '/modules/droplets/export');
        }
        if (!copy($temp_file, WB_PATH . '/modules/droplets/export/' . $filename . '.zip')) {
            echo '<div class="drfail">Unable to move the exported ZIP-File!</div>';
            $download = WB_URL . '/temp/' . $filename . '.zip';
        } else {
            unlink($temp_file);
            $download = WB_URL . '/modules/droplets/export/' . $filename . '.zip';
        }
        echo '<div class="drok">Backup created - <a href="' . $download . '">Download</a></div>';
    }
    rm_full_dir($temp_dir);
}
Пример #6
0
} else {
    $tpl->parse('show_settings', 'show_settings_block', true);
}
$tpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
if ($admin->get_permission('admintools') != true) {
    $tpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
    $tpl->set_block('show_admintools', '');
} else {
    $tpl->parse('show_admintools', 'show_admintools_block', true);
}
/** 
 *	Try to delete install directory - it's still not needed anymore.
 *	Additional check for the user to be logged in with administrator-rights.
 */
if (file_exists(LEPTON_PATH . '/install/') && in_array(1, $admin->get_groups_id())) {
    $result = rm_full_dir(LEPTON_PATH . '/install/');
    if (false === $result) {
        /**
         *	Removing the install directory failed! So we are
         *	in the need to throw an error-message to the user.
         */
        $tpl->set_var("WARNING", "<br  />" . $MESSAGE['START_INSTALL_DIR_EXISTS'] . "<br />");
    }
}
// Insert "Add-ons" section overview (pretty complex compared to normal)
$addons_overview = $TEXT['MANAGE'] . ' ';
$addons_count = 0;
if ($admin->get_permission('modules') == true) {
    $addons_overview .= '<a href="' . ADMIN_URL . '/modules/index.php">' . $MENU['MODULES'] . '</a>';
    $addons_count = 1;
}
        $values = array('type' => 'Template', 'type_name' => $file, 'pages' => $add);
        $msg = replace_all($msg_template_str, $values);
        $page_names = "";
        while ($data = $info->fetchRow()) {
            $page_info = array('id' => $data['page_id'], 'title' => $data['page_title']);
            $page_names .= replace_all($page_template_str, $page_info);
        }
        /**
         *    Printing out the error-message and die().
         */
        $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE'] . $msg . $page_names);
    }
}
// Check if we have permissions on the directory
if (!is_writable(WB_PATH . '/templates/' . $file)) {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL'] . WB_PATH . '/templates/' . $file);
}
// Try to delete the template dir
if (!rm_full_dir(WB_PATH . '/templates/' . $file)) {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
} else {
    // Remove entry from DB
    $database->query("DELETE FROM " . TABLE_PREFIX . "addons WHERE directory = '" . $file . "' AND type = 'template'");
}
// Update pages that use this template with default template
// $database = new database();
$database->query("UPDATE " . TABLE_PREFIX . "pages SET template = '" . DEFAULT_TEMPLATE . "' WHERE template = '{$file}'");
// Print success message
$admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
// Print admin footer
$admin->print_footer();
$archive = new PclZip($temp_file);
// extract Add-on files into WBCE temp folder
$addon_root_path = find_addon_root_path($archive);
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip, PCLZIP_CB_PRE_EXTRACT, 'pclzip_extraction_filter', PCLZIP_OPT_REPLACE_NEWER);
// Check if uploaded file is a valid Add-On zip file
if (!($list && file_exists($temp_unzip . 'info.php'))) {
    $admin->print_error($MESSAGE['GENERIC_INVALID_ADDON_FILE']);
}
// Include module info file
unset($module_directory);
require $temp_unzip . 'info.php';
// Perform Add-on requirement checks before proceeding
require WB_PATH . '/framework/addon.precheck.inc.php';
preCheckAddon($temp_file);
// Delete temporary unzip directory
rm_full_dir($temp_unzip);
// Check if the file is valid
if (!isset($module_directory)) {
    if (file_exists($temp_file)) {
        unlink($temp_file);
    }
    // Remove temp file
    $admin->print_error($MESSAGE['GENERIC_INVALID']);
}
// Check if this module is already installed
// and compare versions if so
$new_module_version = $module_version;
$action = "install";
if (is_dir(WB_PATH . '/modules/' . $module_directory)) {
    if (file_exists(WB_PATH . '/modules/' . $module_directory . '/info.php')) {
        require WB_PATH . '/modules/' . $module_directory . '/info.php';
Пример #9
0
function build_page(&$admin, &$database)
{
    global $HEADING, $TEXT, $MENU, $MESSAGE;
    // Include the functions file
    include_once get_include(LEPTON_PATH . '/framework/summary.functions.php');
    include_once get_include(ADMIN_PATH . '/media/function.inc.php');
    $memory_limit = ini_get('memory_limit');
    $post_max_size = ini_get('post_max_size');
    $upload_max_filesize = ini_get('upload_max_filesize');
    $maxUploadFiles = 12;
    $request = $_SERVER['REQUEST_METHOD'];
    $allowed_img_types = 'jpg|png|gif|tif';
    $actions = isset($_POST['action']) ? trim(stripslashes($admin->get_post('action'))) : 'show';
    $actions = isset($_POST['media_reload']) && $_POST['media_reload'] == true ? 'media_reload' : $actions;
    $actions = isset($_POST['cancel']) ? 'show' : $actions;
    // Get home folder not to show
    $home_folders = get_home_folders();
    $currentHome = $admin->get_home_folder();
    $pathsettings = get_media_settings();
    // Get the user specified dir  parent_path
    if ($request == 'GET' && isset($_REQUEST)) {
        $directory = rawurldecode(trim(stripslashes($admin->get_get('dir'))));
    } elseif (isset($_POST['current_select'])) {
        $directory = str_replace(MEDIA_DIRECTORY, '', rawurldecode(trim(stripslashes($admin->get_post('current_select')))));
    } elseif (isset($_POST['current_dir'])) {
        $directory = rawurldecode(trim(stripslashes($admin->get_post('current_dir'))));
    }
    //$directory = is_null($directory) ? $currentHome : $directory;
    // $directory is not always null ... 8-/
    $directory = is_null($directory) || empty($directory) ? $currentHome : $directory;
    $directory = $directory == '/' || $directory == '\\' ? '' : $directory;
    $target = $current_dir = $directory;
    $backlink = 'index.php?dir=' . $directory;
    $FILE = array();
    $dirs = array();
    $skip = LEPTON_PATH;
    directory_list(LEPTON_PATH . MEDIA_DIRECTORY, false, 0, $dirs, $skip);
    // dirs with readWrite access
    $dirs_rw = media_dirs_rw($admin);
    array_walk($dirs_rw, 'remove_path', LEPTON_PATH);
    if ($admin->get_user_id() == 1) {
        $id = array_unshift($dirs_rw, MEDIA_DIRECTORY);
    }
    // Define absolute path to WB media directory (using Unix path seperator)
    $mediaPath = str_replace('\\', '/', LEPTON_PATH . MEDIA_DIRECTORY);
    /* comment out to show only Home Folder  till yet not build in overall
       $acess_denied = (($currentHome != '') && (strpos($mediaPath.$directory, $currentHome))) ? false : true;
       */
    // sytem_admin if not superadmin, no homefolder, groupmember 1
    $system_admin = $admin->ami_group_member('1') == true || $admin->get_user_id() == 1;
    $group_admin = empty($currentHome) == true && $admin->ami_group_member('1') == true;
    //$full_home_folder_access = $directory == '' || in_array(MEDIA_DIRECTORY.$directory, $dirs_rw) || $group_admin ;
    /*
     * If HOME_FOLDERS are not active the user have access to all media files,
     * otherwise check if the shown folders in list are within the personal folder
     * and grant desired rights only for this folders (upload, create directory a.s.o.)
     */
    $full_home_folder_access = !HOME_FOLDERS ? true : empty($_SESSION['HOME_FOLDER']) || in_array(MEDIA_DIRECTORY . $directory, $dirs_rw) || $group_admin;
    if (strstr($current_dir, '..')) {
        // target_path contains ../
        $admin->print_error($MESSAGE['MEDIA_TARGET_DOT_DOT_SLASH'], $backlink);
    }
    // Build canonicalized absolute path from user input and check if path exists (False if not)
    $userPath = str_replace('\\', '/', realpath($mediaPath . $directory));
    // Ensure that the user specified path is located inside WB media folder
    if ($userPath == false || strpos($userPath, $mediaPath) !== 0) {
        // User defined path is invalid or is located outside the WB media directory
        $admin->print_error($MESSAGE['MEDIA_DIR_ACCESS_DENIED'], $backlink);
    }
    if (!is_writeable($mediaPath . $directory)) {
        $admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], $backlink);
    }
    $tpl = new Template(THEME_PATH . '/templates', 'keep');
    // false | true
    $tpl->debug = false;
    $file_array = array('page' => 'media.htt', 'browse' => 'media_browse.htt', 'rename' => 'media_rename.htt', 'settings' => 'setparameter.htt');
    $tpl->set_file($file_array);
    $tpl->set_block('page', 'main_block', 'main');
    // BEGIN left side always with main_block and the dropdown list may later as dirtree
    // First insert language text and messages
    $tpl->set_var(array('TEXT_RELOAD' => $TEXT['RELOAD'], 'TEXT_TARGET_FOLDER' => $TEXT['TARGET_FOLDER'], 'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'], 'TEXT_NAME' => $TEXT['TITLE'], 'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'], 'TEXT_UNZIP_FILE' => $TEXT['UNZIP_FILE'], 'TEXT_DELETE_ZIP' => $TEXT['DELETE_ZIP'], 'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING'], 'TEXT_FILES' => $TEXT['FILES']));
    $tpl->set_var(array('USER_ID' => $admin->is_authenticated() ? $admin->get_user_id() : '', 'ADMIN_URL' => ADMIN_URL, 'LEPTON_URL' => LEPTON_URL, 'LEPTON_PATH' => LEPTON_PATH, 'THEME_URL' => THEME_URL));
    //  && (($admin->ami_group_member('1') != true) || ($admin->get_user_id() != 1))
    // set optionen media_settings_block
    $tpl->set_block('main_block', 'media_settings_block', 'media_settings');
    // Only show admin the settings link
    if ($pathsettings['global']['admin_only'] == true) {
        if ($system_admin != true) {
            $tpl->set_var('DISPLAY_SETTINGS', 'hide');
            $tpl->set_block('media_settings', '');
        } else {
            $tpl->parse('media_settings', 'media_settings_block', true);
        }
    } else {
        $tpl->parse('media_settings', 'media_settings_block', true);
    }
    // set optionen media_upload_block
    $tpl->set_var(array('CHANGE_SETTINGS' => $TEXT['MODIFY_SETTINGS'], 'HEADING_BROWSE_MEDIA' => $HEADING['BROWSE_MEDIA'], 'HEADING_MEDIA' => $MENU['MEDIA'] . ' ' . $TEXT['FOLDERS'], 'HEADING_CREATE_FOLDER' => $HEADING['CREATE_FOLDER'], 'HEADING_UPLOAD_FILES' => $HEADING['UPLOAD_FILES'], 'OPTIONS' => $TEXT['OPTION'], 'SETTINGS_URL' => $_SERVER['SCRIPT_NAME']));
    $tpl->set_var(array('HOME_DIRECTORY' => $currentHome, 'MEDIA_DIRECTORY' => MEDIA_DIRECTORY, 'CURRENT_DIR' => $directory));
    // create dropdownlist dir_list_block
    $tpl->set_block('main_block', 'dir_list_block', 'dir_list');
    // select the correct directory list
    $use_dirs = !HOME_FOLDERS ? $dirs : empty($_SESSION['HOME_FOLDER']) ? $dirs : $dirs_rw;
    if (count($use_dirs) > 0) {
        foreach ($use_dirs as $name) {
            // prevent duplicate entries - default directory is also set by template!
            if ($name == MEDIA_DIRECTORY . $currentHome) {
                continue;
            }
            $tpl->set_var(array('MEDIA_NAME' => $name, 'SELECTED' => MEDIA_DIRECTORY . $directory == $name ? ' selected="selected"' : ''));
            $tpl->parse('dir_list', 'dir_list_block', true);
        }
    } else {
        $tpl->set_var('dir_list', '');
    }
    // Insert permissions values, hide for some actions
    // workout action should show default blocks
    switch ($actions) {
        // all others remove from left side
        case 'none':
        case 'show':
        case 'media_reload':
        case 'media_create':
        case 'media_upload':
        case 'media_delete':
        case 'save_media_rename':
            $tpl->set_block('main_block', 'media_create_block', 'media_create');
            if ($admin->get_permission('media_create') != true || $full_home_folder_access == false) {
                $tpl->set_var('DISPLAY_CREATE', 'hide');
                $tpl->set_block('media_create', '');
            } else {
                $tpl->set_var(array('DISPLAY_CREATE' => '', 'MAX_UPLOADS' => $maxUploadFiles, 'ALLOW_EXTS' => RENAME_FILES_ON_UPLOAD));
                $tpl->parse('media_create', 'media_create_block', true);
            }
            $tpl->set_block('main_block', 'input_upload_block', 'input_upload');
            for ($x = 0; $x <= $maxUploadFiles; $x++) {
                $tpl->parse('input_upload', 'input_upload_block', true);
            }
            $tpl->set_block('main_block', 'media_upload_block', 'media_upload');
            if ($admin->get_permission('media_upload') != true || $full_home_folder_access == false) {
                $tpl->set_var('DISPLAY_UPLOAD', 'hide');
                $tpl->set_block('media_upload', '');
            } else {
                $tpl->set_var(array('DISPLAY_UPLOAD' => ''));
                $tpl->parse('media_upload', 'media_upload_block', true);
            }
            break;
        default:
            // all the other action has to hide the blocks
            $tpl->set_block('main_block', 'media_create_block', 'media_create');
            $tpl->set_var('DISPLAY_CREATE', 'hide');
            $tpl->parse('media_create', '');
            $tpl->set_block('main_block', 'media_upload_block', 'media_upload');
            $tpl->set_var('DISPLAY_UPLOAD', 'hide');
            $tpl->parse('media_upload', '');
            break;
    }
    // END workout main_wrapper
    // Now prepare and parse values for the wrapper template show modus
    switch ($actions) {
        case 'none':
        case 'show':
        case 'media_reload':
        case 'media_create':
        case 'media_upload':
        case 'media_delete':
        case 'save_media_rename':
            $tpl->loadfile('browse');
            $tpl->set_block('main_block', 'main_wrapper_block', 'browse');
            // Workout the parent dir link PARENT_PATH
            //$parent_path = !empty($directory) ? dirname($directory) : $directory;
            if (!empty($directory)) {
                if (HOME_FOLDERS && !empty($_SESSION['HOME_FOLDER'])) {
                    $parent_path = $_SESSION['HOME_FOLDER'];
                } else {
                    $parent_path = dirname($directory);
                }
            } else {
                $parent_path = $directory;
            }
            // $parent_dir_link = ADMIN_URL.'/media/index.php?dir='.$directory.'&amp;up=1';
            $parent_dir_link = 1;
            // Workout if the up arrow should be shown
            $display_up_arrow = '';
            // $display_up_arrow = (($directory == '') || ($directory == $currentHome)) ? 'hide' : '';
            // Insert header info values main_wrapper_block
            $tpl->set_var(array('THEME_URL' => THEME_URL, 'ROOT_DIRECTORY' => MEDIA_DIRECTORY, 'MEDIA_DIRECTORY' => MEDIA_DIRECTORY, 'CURRENT_PATH' => $directory, 'PARENT_DIR_LINK' => $parent_dir_link, 'PARENT_PATH' => $parent_path));
            $tpl->set_block('browse', 'up_link_block', 'up_link');
            if (!empty($directory) && $directory != $parent_path) {
                // show only if parent <> directory
                $tpl->set_var(array('PARENT_DIR_LINK' => $parent_dir_link, 'TEXT_UP' => $TEXT['UP'], 'DISPLAY_UP_ARROW' => ''));
                $tpl->parse('up_link', 'up_link_block', true);
            } else {
                $tpl->set_block('up_link', '');
                $tpl->set_var(array('UP_LINK_COL' => ' display_up_arrow', 'TEXT_UP' => $TEXT['UP'], 'DISPLAY_UP_ARROW' => ' display_up_arrow'));
            }
            // now set the dirs and files  file_list_block  and permissions
            $tpl->set_block('browse', 'file_list_block', 'file_list');
            $tpl->set_block('file_list', 'media_rename_block', 'media_rename');
            $tpl->set_block('file_list', 'media_delete_block', 'media_delete');
            // get dirs and files in currentDir
            $FILE = scan_current_dir(LEPTON_PATH . MEDIA_DIRECTORY . '/' . $directory);
            $temp_id = 0;
            $line = $row_id = 1;
            if (count($FILE['path']) > 0) {
                foreach ($FILE['path'] as $name) {
                    $temp_id++;
                    $link_name = str_replace(' ', '%20', $name);
                    $tpl->set_var(array('NAME' => $name, 'NAME_SLASHED' => addslashes($name), 'TEMP_ID' => $temp_id, 'LINK' => 'index.php?dir=' . $directory . '/' . $link_name, 'LINK_RELATION' => '', 'ROW_ID' => $line++ & 1, 'FT_ICON' => THEME_URL . '/images/folder_16.png', 'FILETYPE_ICON' => THEME_URL . '/images/folder_16.png', 'FILETYPE' => 'dir', 'FILENAME' => '/' . addslashes($name), 'LINK_TARGET' => '_self', 'ENABLE_OVERLIB' => '', 'EXTENSION' => '', 'MOUSEOVER' => '', 'CLASS_PREVIEW' => '', 'IMAGEDETAIL' => '', 'DISPLAY_ICON' => '', 'SIZE' => '', 'DATE' => '', 'PREVIEW' => '', 'LINK_PATH' => $directory . '/' . $link_name, 'MEDIA_PATH' => MEDIA_DIRECTORY));
                    $tpl->parse('file_list', 'file_list_block', true);
                }
            }
            // now set the files  file_list_block  and permissions
            if (count($FILE['filename']) > 0) {
                // convert to correct searchpattern
                $allowed_file_types = str_replace(',', '|', RENAME_FILES_ON_UPLOAD);
                foreach ($FILE['filename'] as $name) {
                    $preview = 'preview';
                    if (!preg_match("/\\." . $allowed_file_types . "\$/i", $name)) {
                        $preview = '';
                        continue;
                    }
                    $temp_id++;
                    $overlib = preg_match("/\\." . $allowed_img_types . "\$/i", $name) ? ' overlib' : '';
                    if ($preview) {
                        $filetype = get_filetype(LEPTON_URL . MEDIA_DIRECTORY . $directory . '/' . $name);
                        $size = filesize(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name);
                        $bytes = byte_convert($size);
                        $fdate = filemtime(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name);
                        $date = date(DATE_FORMAT . ' ' . TIME_FORMAT, $fdate);
                        $filetypeicon = get_filetype_icon(LEPTON_URL . MEDIA_DIRECTORY . $directory . '/' . $name);
                        $tooltip = '';
                        $imgdetail = $bytes;
                        $icon = THEME_URL . '/images/files/unknown.png';
                        if (!$pathsettings['global']['show_thumbs']) {
                            $info = @getimagesize(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name);
                            if ($info[0]) {
                                $imgdetail = fsize(filesize(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name)) . '<br /> ' . $info[0] . ' x ' . $info[1] . ' px';
                                $icon = 'thumb.php?t=1&amp;img=' . $directory . '/' . $name;
                                $tooltip = ShowTip('thumb.php?t=2&amp;img=' . $directory . '/' . $name, $allowed_img_types);
                            } else {
                                $icon = THEME_URL . '/images/files/' . $filetypeicon . '.png';
                            }
                        } else {
                            $filetypeicon = get_filetype_icon(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name);
                            $icon = THEME_URL . '/images/files/' . $filetypeicon . '.png';
                        }
                        $tpl->set_var(array('NAME' => $name, 'NAME_SLASHED' => addslashes($name), 'TEMP_ID' => $temp_id, 'LINK' => LEPTON_URL . MEDIA_DIRECTORY . $directory . '/' . $name, 'LINK_RELATION' => '', 'ROW_ID' => $line++ & 1, 'FT_ICON' => $icon, 'FILETYPE_ICON' => THEME_URL . '/images/files/' . $filetypeicon . '.png', 'FILENAME' => addslashes($name), 'LINK_TARGET' => '_top', 'ENABLE_OVERLIB' => $overlib, 'FILETYPE' => 'file', 'EXTENSION' => $filetype, 'MOUSEOVER' => $tooltip, 'CLASS_PREVIEW' => '', 'IMAGEDETAIL' => $imgdetail, 'DISPLAY_ICON' => '', 'SIZE' => $bytes, 'DATE' => $date, 'PREVIEW' => $preview));
                        $tpl->parse('file_list', 'file_list_block', true);
                    }
                }
            }
            $tpl->set_var(array('TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'], 'TEXT_RELOAD' => $TEXT['RELOAD'], 'TEXT_RENAME' => $TEXT['RENAME'], 'TEXT_DELETE' => $TEXT['DELETE'], 'TEXT_SIZE' => $TEXT['SIZE'], 'TEXT_DATE' => $TEXT['DATE'], 'TEXT_NAME' => $TEXT['NAME'], 'TEXT_TYPE' => $TEXT['TYPE'], 'MEDIA_BROWSE' => '', 'NONE_FOUND' => $MESSAGE['MEDIA_NONE_FOUND'], 'CHANGE_SETTINGS' => $TEXT['MODIFY_SETTINGS'], 'CONFIRM_DELETE' => js_alert_encode($MESSAGE['MEDIA_CONFIRM_DELETE']), 'CONFIRM_DELETE_FILE' => js_alert_encode($MESSAGE['MEDIA_CONFIRM_DELETE_FILE']), 'CONFIRM_DELETE_DIR' => js_alert_encode($MESSAGE['MEDIA_CONFIRM_DELETE_DIR'])));
            // If no files are in the media folder say so
            if ($temp_id == 0) {
                $tpl->set_var('DISPLAY_LIST_TABLE', ' hide');
                $tpl->set_var('DISPLAY_NONE_FOUND', ' center');
                $tpl->set_var("file_list_block", "<tr><td></td></tr>");
                $tpl->parse('file_list', 'file_list_block', true);
            } else {
                $tpl->set_var('DISPLAY_LIST_TABLE', '');
                $tpl->set_var('DISPLAY_NONE_FOUND', ' hide');
            }
            $tpl->set_block('file_list', 'media_rename_block', 'media_rename');
            $tpl->set_block('file_list', 'media_delete_block', 'media_delete');
            // Insert permissions values
            if ($admin->get_permission('media_rename') != true || $full_home_folder_access == false) {
                $tpl->set_var('DISPLAY_RENAME', 'hide');
                $tpl->set_var('RENHAME_CONTENT', '');
                $tpl->parse('media_rename', '');
            } else {
                $tpl->set_var('RENHAME_CONTENT', '');
                $tpl->parse('media_rename', 'media_rename_block', true);
            }
            if ($admin->get_permission('media_delete') != true || $full_home_folder_access == false) {
                $tpl->set_var('DISPLAY_DELETE', 'hide');
                $tpl->set_var('DELETE_CONTENT', '');
                $tpl->parse('media_delete', '');
            } else {
                $tpl->set_var('DELETE_CONTENT', '');
                $tpl->parse('media_delete', 'media_delete_block', true);
            }
            break;
    }
    // begin with save modus actions
    switch ($actions) {
        // save actions
        case 'save_media_settings':
            if (($x = save_media_settings($pathsettings)) == 0) {
                $admin->print_error($MESSAGE['SETTINGS_UNABLE_WRITE_CONFIG'], $backlink);
            } else {
                $admin->print_success($MESSAGE['SETTINGS_SAVED'], $backlink);
            }
            break;
        case 'save_media_rename':
            $ext = trim(stripslashes($admin->get_post('extension')));
            $ext = empty($ext) ? '' : '.' . $ext;
            $old_file = media_filename(trim(stripslashes($admin->get_post('old_name')))) . $ext;
            $rename_file = media_filename(trim(stripslashes($admin->get_post('name')))) . $ext;
            $type = trim(stripslashes($admin->get_post('filetype')));
            // perhaps change dots in underscore by tpye = directory
            $rename_file = trim($rename_file, '.');
            $old_file = LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $old_file;
            $rename_file = LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $rename_file;
            if ($type == 'dir') {
                $rename_file = str_replace('.', '_', $rename_file);
            } elseif (!preg_match("/\\." . $allowed_file_types . "\$/i", $rename_file)) {
                $admin->print_error($TEXT['EXTENSION'] . ': ' . $MESSAGE['GENERIC_INVALID'], $backlink);
            }
            if (rename($old_file, $rename_file)) {
                $admin->print_success($MESSAGE['MEDIA_RENAMED'], $backlink);
            } else {
                $admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], $backlink);
            }
            break;
    }
    // mask input modus
    switch ($actions) {
        case 'media_rename':
            clearstatcache();
            $rename_file = media_filename(trim(stripslashes($admin->get_post('filename'))));
            $ext = trim(stripslashes($admin->get_post('fileext')));
            $type = trim(stripslashes($admin->get_post('filetype')));
            $rename_file = basename($rename_file);
            $tpl->loadfile('rename');
            $tpl->set_block('main_block', 'main_wrapper_block', 'rename');
            // false | true
            $tpl->debug = false;
            $tpl->set_var(array('THEME_URL' => THEME_URL, 'TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'], 'FILENAME' => $rename_file, 'BASENAME' => trim(str_replace($ext, '', basename($rename_file)), '.'), 'ROOT_DIRECTORY' => MEDIA_DIRECTORY, 'DISPLAY_UP_ARROW' => ' display_up_arrow', 'CURRENT_PATH' => $directory, 'DIR' => $directory, 'FILE_TYPE' => $type, 'EXTENSION' => '.' . ltrim($ext, '.'), 'FILE_EXT' => ltrim($ext, '.'), 'TEXT_OVERWRITE_EXIST' => $TEXT['OVERWRITE_EXISTING'], 'TEXT_TO' => '', 'MEDIA_BROWSE' => '', 'TEXT_RENAME' => $TEXT['RENAME'], 'TEXT_CANCEL' => $TEXT['CANCEL']));
            $tpl->parse('rename', 'main_wrapper_block', true);
            break;
        case 'media_settings':
            // load template language file
            $lang = THEME_PATH . '/languages/' . LANGUAGE . '.php';
            include_once !file_exists($lang) ? THEME_PATH . '/languages/EN.php' : $lang;
            $tpl->loadfile('settings');
            $tpl->set_block('main_block', 'main_wrapper_block', 'settings');
            // false | true
            $tpl->debug = false;
            $admin_only = isset($pathsettings['global']['admin_only']) && $pathsettings['global']['admin_only'] == true ? ' checked="checked"' : '';
            $show_thumbs = isset($pathsettings['global']['show_thumbs']) && $pathsettings['global']['show_thumbs'] == true ? ' checked="checked"' : '';
            $tpl->set_var(array('TEXT_HEADER' => $TEXT['TEXT_HEADER'], 'SAVE_TEXT' => $TEXT['SAVE'], 'CANCEL' => $TEXT['CANCEL'], 'RESET' => $TEXT['RESET'], 'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'], 'MEDIA_BROWSE' => '', 'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'], 'SETTINGS' => $TEXT['SETTINGS'], 'CURRENT_PATH' => $directory, 'ADMIN_URL' => ADMIN_URL, 'WIDTH' => $TEXT['WIDTH'], 'HEIGHT' => $TEXT['HEIGHT'], 'ADMIN_ONLY_SELECTED' => $admin_only, 'NO_SHOW_THUMBS_SELECTED' => $show_thumbs, 'NONE_FOUND' => '', 'DISPLAY_NONE' => ''));
            // Get dirs in currentDir
            $dirs = array();
            $skip = LEPTON_PATH;
            directory_list(LEPTON_PATH . MEDIA_DIRECTORY, false, 0, $dirs, $skip);
            $line = $row_id = 1;
            $tpl->set_block('settings', 'dir_settings_block', 'dir_settings');
            if (isset($dirs)) {
                $good_dirs = 0;
                $dir_filter = MEDIA_DIRECTORY . $directory;
                $parent = substr_count($dir_filter, '/') + 1;
                $dir_filter = str_replace(array('/', ' '), '_', $dir_filter);
                foreach ($dirs as $name) {
                    $relative = $name;
                    // str_replace(LEPTON_PATH, '', $name);
                    $subparent = substr_count($relative, '/') + 1;
                    $safepath = str_replace(array('/', ' '), '_', $relative);
                    $continue = strlen(str_replace($safepath, '', $dir_filter));
                    // if( (substr_count($safepath,$dir_filter) == 0) || ( $dir_filter == $safepath )      )
                    if ($parent != $subparent - 1 || substr_count($safepath, $dir_filter) == 0 || $dir_filter == $safepath) {
                        continue;
                    }
                    $good_dirs++;
                    $cur_width = $cur_height = '';
                    if (isset($pathsettings[$safepath]['width'])) {
                        $cur_width = $pathsettings[$safepath]['width'];
                    }
                    if (isset($pathsettings[$safepath]['height'])) {
                        $cur_height = $pathsettings[$safepath]['height'];
                    }
                    $cur_width = $cur_width != 0 ? (int) $cur_width : '-';
                    $cur_height = $cur_height != 0 ? (int) $cur_height : '-';
                    $tpl->set_var(array('PATH_NAME' => basename($relative), 'FIELD_NAME' => $safepath, 'CUR_WIDTH' => $cur_width, 'CUR_HEIGHT' => $cur_height, 'ROW_ID' => $line++ & 1));
                    $tpl->parse('dir_settings', 'dir_settings_block', true);
                }
                if ($good_dirs == 0) {
                    $tpl->set_var(array('PATH_NAME' => '', 'FIELD_NAME' => '', 'CUR_WIDTH' => '', 'CUR_HEIGHT' => '', 'ROW_ID' => '', 'DISPLAY_NONE' => ' hide'));
                    $tpl->parse('dir_settings', 'dir_settings_block', true);
                    $tpl->set_var('NONE_FOUND', $MESSAGE['MEDIA_NONE_FOUND']);
                    $tpl->parse('settings', 'dir_settings_block', true);
                }
            } else {
                $tpl->set_var('NONE_FOUND', $MESSAGE['MEDIA_NONE_FOUND']);
                $tpl->parse('settings', 'dir_settings_block', true);
            }
            break;
    }
    // normal actions
    switch ($actions) {
        case 'media_upload':
            $target_path = str_replace('\\', '/', LEPTON_PATH . MEDIA_DIRECTORY . $directory);
            // Create relative path of the new dir name
            $resizepath = MEDIA_DIRECTORY . $directory;
            $resizepath = str_replace(array('/', ' '), '_', $resizepath);
            // Find out whether we should replace files or give an error
            $overwrite = $admin->get_post('overwrite') != '' ? true : false;
            // convert to correct searchpattern
            $allowed_file_types = str_replace(',', '|', RENAME_FILES_ON_UPLOAD);
            $good_uploads = 0;
            // If the user chose to unzip the first file, unzip into the current folder
            if (isset($_POST['unzip']) && $_POST['unzip'] == true) {
                // include_once(get_include('thumb.php'));
                if (isset($_FILES['upload']['error'][0]) && $_FILES['upload']['error'][0] == UPLOAD_ERR_OK) {
                    $src_file = isset($_FILES['upload']['name'][0]) ? $_FILES['upload']['name'][0] : null;
                    if ($src_file && preg_match('/\\.zip$/i', $src_file)) {
                        /*
                         * Callback function to skip files not in white-list
                         */
                        function pclzipCheckValidFile($p_event, &$p_header)
                        {
                            //  return 1;
                            $allowed_file_types = str_replace(',', '|', RENAME_FILES_ON_UPLOAD);
                            $info = pathinfo($p_header['filename']);
                            $ext = isset($info['extension']) ? $info['extension'] : '';
                            $dots = substr($info['basename'], 0, 1) == '.' || substr($info['basename'], -1, 1) == '.';
                            if (preg_match('/' . $allowed_file_types . '$/i', $ext) && $dots != '.') {
                                // ----- allowed file types are extracted
                                return 1;
                            } else {
                                // ----- all other files are skiped
                                return 0;
                            }
                        }
                        /* ********************************* */
                        require_once get_include(LEPTON_PATH . '/modules/lib_lepton/pclzip/pclzip.lib.php');
                        $archive = new PclZip($_FILES['upload']['tmp_name'][0]);
                        $list = $archive->extract(PCLZIP_OPT_PATH, $target_path, PCLZIP_CB_PRE_EXTRACT, 'pclzipCheckValidFile');
                        $good_uploads = sizeof($list);
                        if ($archive->error_code != 0) {
                            $admin->print_error('UNABLE TO UNZIP FILE' . ' :: ' . $archive->errorInfo(true), $backlink);
                        }
                    }
                }
            } else {
                // proceed normal multi-upload
                $file_count = sizeof($_FILES['upload']['error']);
                for ($x = 0; $x < $file_count; $x++) {
                    // If file was upload to tmp
                    if (isset($_FILES['upload']['name'][$x])) {
                        // Remove bad characters
                        $filename = media_filename($_FILES['upload']['name'][$x]);
                        // Check if there is still a filename left and allowed filetyp
                        if ($filename != '' && preg_match("/\\." . $allowed_file_types . "\$/i", $filename)) {
                            // Move to relative path (in media folder)
                            if (file_exists($target_path . '/' . $filename) && $overwrite === true) {
                                if (move_uploaded_file($_FILES['upload']['tmp_name'][$x], $target_path . '/' . $filename)) {
                                    $good_uploads++;
                                    // Chmod the uploaded file
                                    change_mode($target_path . '/' . $filename, 'file');
                                }
                            } elseif (!file_exists($target_path . '/' . $filename)) {
                                if (move_uploaded_file($_FILES['upload']['tmp_name'][$x], $target_path . '/' . $filename)) {
                                    $good_uploads++;
                                    // Chmod the uploaded file
                                    change_mode($target_path . '/' . $filename);
                                }
                            }
                            if (file_exists($target_path . '/' . $filename) && preg_match("/\\." . $allowed_img_types . "\$/i", $filename)) {
                                if (isset($pathsettings[$resizepath])) {
                                    include_once get_include(ADMIN_PATH . '/media/resize_img.php');
                                    if ($pathsettings[$resizepath]['width'] || $pathsettings[$resizepath]['height']) {
                                        $rimg = new RESIZEIMAGE($target_path . '/' . $filename);
                                        $rimg->resize_limitwh($pathsettings[$resizepath]['width'], $pathsettings[$resizepath]['height'], $target_path . '/' . $filename);
                                        $rimg->close();
                                    }
                                }
                            }
                            // store file name of first file for possible unzip action
                            if ($x == 1) {
                                $filename1 = $target_path . '/' . $filename;
                            }
                        }
                    }
                }
            }
            if (isset($_POST['delzip'])) {
                if (file_exists($filename1)) {
                    unlink($filename1);
                }
            }
            if ($good_uploads == 1) {
                $admin->print_success($good_uploads . ' ' . $MESSAGE['MEDIA_SINGLE_UPLOADED'], $backlink);
            } else {
                $admin->print_success($good_uploads . ' ' . $MESSAGE['MEDIA_UPLOADED'], $backlink);
            }
            break;
        case 'media_create':
            // $directory = rawurldecode(trim(stripslashes($admin->get_post('current_dir'))));
            // Remove bad characters from user folder name
            $target = $admin->get_post('target') != null ? media_filename(trim(stripslashes($admin->get_post('target')))) : $current_dir;
            $userPath = LEPTON_PATH . MEDIA_DIRECTORY;
            $err_msg = array();
            if ($target == null || $target == $current_dir) {
                $err_msg[] = $MESSAGE['MEDIA_BLANK_NAME'];
            } else {
                // Try and make the dir
                $target = trim($target, '.');
                $dirname = $userPath . $current_dir . '/' . $target;
                if (file_exists($dirname)) {
                    $err_msg[] = $MESSAGE['MEDIA_DIR_EXISTS'];
                } else {
                    if (make_dir($dirname)) {
                        change_mode($dirname);
                        if (is_writable($dirname)) {
                            // Create default "index.php" file
                            $rel_pages_dir = str_replace(LEPTON_PATH . MEDIA_DIRECTORY, '', dirname($dirname));
                            $step_back = str_repeat('../', substr_count($rel_pages_dir, '/') + 1);
                            $content = '<?php' . "\n";
                            $content .= '// This file is generated by LEPTON Ver.' . VERSION . ';' . "\n";
                            $content .= "\t" . 'header(\'Location: ' . $step_back . 'index.php\');' . "\n";
                            $content .= '?>';
                            $filename = $dirname . '/index.php';
                            // write content into file
                            $handle = fopen($filename, 'w');
                            fwrite($handle, $content);
                            fclose($handle);
                            change_mode($filename, 'file');
                        } else {
                            $err_msg[] = $MESSAGE['GENERIC_BAD_PERMISSIONS'];
                        }
                    } else {
                        $err_msg[] = $MESSAGE['GENERIC_BAD_PERMISSIONS'];
                    }
                }
            }
            if (sizeof($err_msg) > 0) {
                $admin->print_error(implode('<br />', $err_msg));
            } else {
                $admin->print_success($MESSAGE['MEDIA_DIR_MADE'], $backlink);
            }
            break;
        case 'media_delete':
            $filetype = isset($_POST['filetype']) ? trim(stripslashes($admin->get_post('filetype'))) : '';
            $filename = isset($_POST['filename']) ? trim(stripslashes($admin->get_post('filename'))) : '';
            $relative_path = LEPTON_PATH . MEDIA_DIRECTORY . $directory;
            // Find out whether its a file or folder
            if ($filetype == 'dir') {
                // Try and delete the directory
                if (rm_full_dir($relative_path . '/' . $filename)) {
                    $admin->print_success($MESSAGE['MEDIA_DELETED_DIR'], $backlink);
                } else {
                    $admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_DIR'], $backlink);
                }
            } elseif ($filetype == 'file') {
                // Try and delete the file
                if (unlink($relative_path . '/' . $filename)) {
                    $admin->print_success($MESSAGE['MEDIA_DELETED_FILE'], $backlink);
                } else {
                    $admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_FILE'], $backlink);
                }
            } else {
                $admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_FILE'], $backlink);
            }
            break;
    }
    // Parse template for preferences form
    $tpl->parse('main', 'main_wrapper_block', false);
    $tpl->parse('main', 'main_block', false);
    $output = $tpl->finish($tpl->parse('output', 'page'));
    return $output;
}
Пример #10
0
 * @copyright       2004-2010 WebsiteBaker Project
 * @copyright       2010-2015 LEPTON Project
 * @link            http://www.LEPTON-cms.org
 * @license         http://www.gnu.org/licenses/gpl.html
 * @license_terms   please see info.php of this module
 *
 */
// include class.secure.php to protect this file and the whole CMS!
if (defined('LEPTON_PATH')) {
    include LEPTON_PATH . '/framework/class.secure.php';
} else {
    $oneback = "../";
    $root = $oneback;
    $level = 1;
    while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
        $root .= $oneback;
        $level += 1;
    }
    //( $level < 10 ) && ( !file_exists( $root . '/framework/class.secure.php' ) )
    if (file_exists($root . '/framework/class.secure.php')) {
        include $root . '/framework/class.secure.php';
    } else {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
// end include class.secure.php
// delete table
$database->query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_wrapper`");
// Delete directory
rm_full_dir(LEPTON_PATH . '/modules/wrapper');
Пример #11
0
<?php

/**
 * @category        modules
 * @package         wysiwyg
 * @author          WebsiteBaker Project, Michael Tenschert
 * @copyright       2010, Michael Tenschert
 * @link            http://www.websitebaker2.org/
 * @license         http://www.gnu.org/licenses/lgpl.html
 */
// Must include code to stop this file being access directly
if (defined('WB_PATH') == false) {
    exit("Cannot access this file directly");
}
// Delete the editor directory
rm_full_dir(WB_PATH . '/modules/ckeditor/ckeditor');
Пример #12
0
 *
 *   @author          Website Baker Project, LEPTON Project, Black Cat Development
 *   @copyright       2004-2010, Website Baker Project
 *   @copyright       2011-2012, LEPTON Project
 *   @copyright       2013, Black Cat Development
 *   @link            http://blackcat-cms.org
 *   @license         http://www.gnu.org/licenses/gpl.html
 *   @category        CAT_Module
 *   @package         wrapper
 *
 */
if (defined('CAT_PATH')) {
    include CAT_PATH . '/framework/class.secure.php';
} else {
    $root = "../";
    $level = 1;
    while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
        $root .= "../";
        $level += 1;
    }
    if (file_exists($root . '/framework/class.secure.php')) {
        include $root . '/framework/class.secure.php';
    } else {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
// delete table
$database->query("DROP TABLE IF EXISTS `" . CAT_TABLE_PREFIX . "mod_wrapper`");
// Delete the editor directory
rm_full_dir(CAT_PATH . '/modules/wrapper');
Пример #13
0
    exit("Cannot access this file directly");
}
// Get some default values
require_once WB_PATH . '/modules/bakery/config.php';
// Get module pages directory from general setting table
$query_general_settings = $database->query("SELECT pages_directory FROM " . TABLE_PREFIX . "mod_bakery_general_settings");
$general_settings = $query_general_settings->fetchRow();
$module_pages_directory = '/' . $general_settings['pages_directory'];
// Delete
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE name = 'module' AND value = 'bakery'");
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE extra = 'bakery'");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_items");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_images");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_options");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_attributes");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_item_attributes");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_customer");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_order");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_general_settings");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_page_settings");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_payment_methods");
// Include WB functions file
require_once WB_PATH . '/framework/functions.php';
$directory = WB_PATH . PAGES_DIRECTORY . $module_pages_directory;
if (is_dir($directory)) {
    rm_full_dir($directory);
}
$directory = WB_PATH . MEDIA_DIRECTORY . '/' . $img_dir;
if (is_dir($directory)) {
    rm_full_dir($directory);
}
Пример #14
0
 * @module   	    edit_area
 * @version        	see info.php of this module
 * @author			Christophe Dolivet (EditArea), Christian Sommer (wrapper), LEPTON Project
 * @copyright		2009-2010 Christian Sommer
 * @copyright 		2010-2015 LEPTON Project
 * @license        	GNU General Public License
 * @license terms  	see info.php of this module
 * @platform       	see info.php of this module
 *
 */
// include class.secure.php to protect this file and the whole CMS!
if (defined('LEPTON_PATH')) {
    include LEPTON_PATH . '/framework/class.secure.php';
} else {
    $oneback = "../";
    $root = $oneback;
    $level = 1;
    while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
        $root .= $oneback;
        $level += 1;
    }
    if (file_exists($root . '/framework/class.secure.php')) {
        include $root . '/framework/class.secure.php';
    } else {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
// end include class.secure.php
// Delete the editor directory
rm_full_dir(LEPTON_PATH . '/modules/edit_area');
if(!defined('WB_PATH')) die(header('Location: index.php'));
// experimental feature, export human-readable:
opf_register_filter({$filter_dump})
// if this fails to import, try the serialized version:
or opf_register_filter('{$filter_ser}', TRUE);

EOD;
    $file_contents = array('plugin_info.php' => $file_info, 'index.php' => $file_index, 'plugin_install.php' => $file_install, 'filter.php' => $filter_func);
    foreach ($file_contents as $file => $contents) {
        if ($fh = fopen($temp_dir . $temp_name . '/' . $file, 'wb')) {
            fputs($fh, $contents);
            fclose($fh);
        } else {
            $export_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_WRITE_FAILED'], $temp_dir . $temp_name . '/' . $file);
            rm_full_dir($temp_dir . $temp_name);
            return FALSE;
        }
    }
    // zip it
    if (!$archive->create($temp_dir . $temp_name, PCLZIP_OPT_REMOVE_PATH, $temp_dir . $temp_name)) {
        $export_message = sprintf($text_failed, $archive->errorInfo(true));
        rm_full_dir($temp_dir . $temp_name);
        return FALSE;
    }
}
rm_full_dir($temp_dir . $temp_name);
$link = $temp_link . $temp_file;
$export_message = $LANG['MOD_OPF']['TXT_PLUGIN_EXPORTED'];
$export_ok = TRUE;
return $link;
// the created zip still remains in media/opf_plugins/ and should be deleted manually
/**
 * handle import
 **/
function wbce_handle_upload()
{
    global $DR_TEXT, $TEXT, $database, $admin;
    if (isset($_POST['cancel'])) {
        return;
    }
    $return = '';
    if (isset($_FILES['userfile']) && isset($_FILES['userfile']['name'])) {
        // Set temp vars
        $temp_dir = WB_PATH . '/temp/';
        $temp_file = $temp_dir . $_FILES['userfile']['name'];
        $temp_unzip = WB_PATH . '/temp/unzip/';
        $errors = array();
        // Try to upload the file to the temp dir
        if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $temp_file)) {
            echo $DR_TEXT['Upload failed'];
            return;
        }
        $result = wbce_unpack_and_import($temp_file, $temp_unzip);
        // Delete the temp zip file
        if (file_exists($temp_file)) {
            unlink($temp_file);
        }
        rm_full_dir($temp_unzip);
        // show errors
        if (isset($result['errors']) && is_array($result['errors']) && count($result['errors']) > 0) {
            $return = '<div style="border: 1px solid #f00; padding: 5px; color: #f00; font-weight: bold;">' . $DR_TEXT['IMPORT_ERRORS'] . "<br />\n";
            foreach ($result['errors'] as $droplet => $error) {
                $return .= 'Droplet: ' . $droplet . '<br />' . '<span style="padding-left: 15px">' . $error . '</span>';
            }
            $return .= "</div><br /><br />\n";
        }
        $return .= '<div class="drok">' . $result['count'] . " " . $DR_TEXT['IMPORTED'] . '</div><br /><br />';
    }
    $return .= wbce_twig_display(array(), 'upload', true);
    return $return;
}
Пример #17
0
if ($admin->get_permission('admintools') != true) {
    $template->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
}
$msg .= file_exists(WB_PATH . '/install/') ? $MESSAGE['START_INSTALL_DIR_EXISTS'] : '';
// Check if installation directory still exists
//
// *****************************************************************************
// Changed this for Websitebaker Community Edition: Just delete the files
// We ignore the user rights as they don't matter; it's more dangerous to
// keep the installer there!
if (file_exists(WB_PATH . '/install/') || file_exists(WB_PATH . '/upgrade-script.php')) {
    if (file_exists(WB_PATH . '/upgrade-script.php')) {
        unlink(WB_PATH . '/upgrade-script.php');
    }
    if (file_exists(WB_PATH . '/install/')) {
        rm_full_dir(WB_PATH . '/install/');
    }
    /*
        // Check if user is part of Adminstrators group
        if(in_array(1, $admin->get_groups_id()))
        {
            $template->set_var('WARNING', $msg );
        } else {
            $template->set_var('DISPLAY_WARNING', 'display:none;');
        }
    } else {
        $template->set_var('DISPLAY_WARNING', 'display:none;');
    */
}
$template->set_var('DISPLAY_WARNING', 'display:none;');
//
Пример #18
0
}
// Set destination for language file
$language_file = WB_PATH . '/languages/' . $language_code . '.php';
$action = "install";
// Move to new location
if (file_exists($language_file)) {
    require $language_file;
    if (versionCompare($language_version, $new_language_version, '>=')) {
        // Restore to correct language
        require WB_PATH . '/languages/' . LANGUAGE . '.php';
        $admin->print_error($MESSAGE['GENERIC_ALREADY_INSTALLED']);
    }
    $action = "upgrade";
    unlink($language_file);
}
rename($temp_file, $language_file);
// Chmod the file
change_mode($language_file, 'file');
// Load language info into DB
load_language($language_file);
// Restore to correct language
require WB_PATH . '/languages/' . LANGUAGE . '.php';
rm_full_dir(WB_PATH . '/temp', true);
// Print success message
if ($action == "install") {
    $admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
} else {
    $admin->print_success($MESSAGE['GENERIC']['UPGRADED']);
}
// Print admin footer
$admin->print_footer();
Пример #19
0
 private function deletePage($page_id)
 {
     global $database;
     $dbPages = new db_wb_pages();
     $where = array();
     $where[db_wb_pages::field_page_id] = $page_id;
     $pages = array();
     if (!$dbPages->sqlSelectRecord($where, $pages)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbPages->getError()));
         return false;
     }
     if (sizeof($pages) == 0) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, sprintf(kit_error_page_not_found, $page_id)));
         return false;
     }
     $parent = $pages[0][db_wb_pages::field_parent];
     $link = $pages[0][db_wb_pages::field_link];
     $dbSections = new db_wb_sections();
     $where = array();
     $where[db_wb_sections::field_page_id] = $page_id;
     $sections = array();
     if (!$dbSections->sqlSelectRecord($where, $sections)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbSections->getError()));
         return false;
     }
     foreach ($sections as $section) {
         $section_id = $section[db_wb_sections::field_section_id];
         // Include the modules delete file if it exists
         if (file_exists(WB_PATH . '/modules/' . $section[db_wb_sections::field_module] . '/delete.php')) {
             require WB_PATH . '/modules/' . $section[db_wb_sections::field_module] . '/delete.php';
         }
     }
     $where = array();
     $where[db_wb_pages::field_page_id] = $page_id;
     if (!$dbPages->sqlDeleteRecord($where)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbPages->getError()));
         return false;
     }
     $where = array();
     $where[db_wb_sections::field_page_id] = $page_id;
     if (!$dbSections->sqlDeleteRecord($where)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbSections->getError()));
         return false;
     }
     // Include the ordering class or clean-up ordering
     $order = new order(TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent');
     $order->clean($parent);
     // Unlink the page access file and directory
     $directory = WB_PATH . PAGES_DIRECTORY . $link;
     $filename = $directory . PAGE_EXTENSION;
     $directory .= '/';
     if (file_exists($filename)) {
         if (!is_writable(WB_PATH . PAGES_DIRECTORY . '/')) {
             $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, sprintf(kit_error_delete_access_file, $filename)));
             return false;
         } else {
             unlink($filename);
             if (file_exists($directory) && rtrim($directory, '/') != WB_PATH . PAGES_DIRECTORY && substr($link, 0, 1) != '.') {
                 rm_full_dir($directory);
             }
         }
     }
     return true;
 }
function preCheckAddon($temp_addon_file)
{
    /**
     * This funtion performs pretest upfront of the Add-On installation process.
     * The requirements can be specified via the array $PRECHECK which needs to
     * be defined in the optional Add-on file precheck.php.
     */
    global $database, $admin, $TEXT, $HEADING, $MESSAGE;
    // path to the temporary Add-on folder
    $temp_path = WB_PATH . '/temp/unzip';
    // check if file precheck.php exists for the Add-On uploaded via WB installation routine
    if (!file_exists($temp_path . '/precheck.php')) {
        return;
    }
    // unset any previous declared PRECHECK array
    unset($PRECHECK);
    // include Add-On precheck.php file
    include $temp_path . '/precheck.php';
    // check if there are any Add-On requirements to check for
    if (!(isset($PRECHECK) && count($PRECHECK) > 0)) {
        return;
    }
    // sort precheck array
    $PRECHECK = sortPreCheckArray($PRECHECK);
    $failed_checks = 0;
    $msg = array();
    // check if specified addon requirements are fullfilled
    foreach ($PRECHECK as $key => $value) {
        switch ($key) {
            case 'WB_VERSION':
                if (isset($value['VERSION'])) {
                    // obtain operator for string comparison if exist
                    $operator = isset($value['OPERATOR']) && trim($value['OPERATOR']) != '' ? $value['OPERATOR'] : '>=';
                    // compare versions and extract actual status
                    $status = versionCompare(WB_VERSION, $value['VERSION'], $operator);
                    $msg[] = array('check' => 'WB-' . $TEXT['VERSION'] . ': ', 'required' => htmlentities($operator) . $value['VERSION'], 'actual' => WB_VERSION, 'status' => $status);
                    // increase counter if required
                    if (!$status) {
                        $failed_checks++;
                    }
                }
                break;
            case 'WB_ADDONS':
                if (is_array($PRECHECK['WB_ADDONS'])) {
                    foreach ($PRECHECK['WB_ADDONS'] as $addon => $values) {
                        if (is_array($values)) {
                            // extract module version and operator
                            $version = isset($values['VERSION']) && trim($values['VERSION']) != '' ? $values['VERSION'] : '';
                            $operator = isset($values['OPERATOR']) && trim($values['OPERATOR']) != '' ? $values['OPERATOR'] : '>=';
                        } else {
                            // no version and operator specified (only check if addon exists)
                            $addon = strip_tags($values);
                            $version = '';
                            $operator = '';
                        }
                        // check if addon is listed in WB database
                        $table = TABLE_PREFIX . 'addons';
                        $sql = "SELECT * FROM `{$table}` WHERE `directory` = '" . addslashes($addon) . "'";
                        $results = $database->query($sql);
                        $status = false;
                        $addon_status = $TEXT['NOT_INSTALLED'];
                        if ($results && ($row = $results->fetchRow())) {
                            $status = true;
                            $addon_status = $TEXT['INSTALLED'];
                            // compare version if required
                            if ($version != '') {
                                $status = versionCompare($row['version'], $version, $operator);
                                $addon_status = $row['version'];
                            }
                        }
                        // provide addon status
                        $msg[] = array('check' => '&nbsp; ' . $TEXT['ADDON'] . ': ' . htmlentities($addon), 'required' => $version != '' ? $operator . '&nbsp;' . $version : $TEXT['INSTALLED'], 'actual' => $addon_status, 'status' => $status);
                        // increase counter if required
                        if (!$status) {
                            $failed_checks++;
                        }
                    }
                }
                break;
            case 'PHP_VERSION':
                if (isset($value['VERSION'])) {
                    // obtain operator for string comparison if exist
                    $operator = isset($value['OPERATOR']) && trim($value['OPERATOR']) != '' ? $value['OPERATOR'] : '>=';
                    // compare versions and extract actual status
                    $status = versionCompare(PHP_VERSION, $value['VERSION'], $operator);
                    $msg[] = array('check' => 'PHP-' . $TEXT['VERSION'] . ': ', 'required' => htmlentities($operator) . '&nbsp;' . $value['VERSION'], 'actual' => PHP_VERSION, 'status' => $status);
                    // increase counter if required
                    if (!$status) {
                        $failed_checks++;
                    }
                }
                break;
            case 'PHP_EXTENSIONS':
                if (is_array($PRECHECK['PHP_EXTENSIONS'])) {
                    foreach ($PRECHECK['PHP_EXTENSIONS'] as $extension) {
                        $status = extension_loaded(strtolower($extension));
                        $msg[] = array('check' => '&nbsp; ' . $TEXT['EXTENSION'] . ': ' . htmlentities($extension), 'required' => $TEXT['INSTALLED'], 'actual' => $status ? $TEXT['INSTALLED'] : $TEXT['NOT_INSTALLED'], 'status' => $status);
                        // increase counter if required
                        if (!$status) {
                            $failed_checks++;
                        }
                    }
                }
                break;
            case 'PHP_SETTINGS':
                if (is_array($PRECHECK['PHP_SETTINGS'])) {
                    foreach ($PRECHECK['PHP_SETTINGS'] as $setting => $value) {
                        $actual_setting = ($temp = ini_get($setting)) ? $temp : 0;
                        $status = $actual_setting == $value;
                        $msg[] = array('check' => '&nbsp; ' . $setting, 'required' => $value, 'actual' => $actual_setting, 'status' => $status);
                        // increase counter if required
                        if (!$status) {
                            $failed_checks++;
                        }
                    }
                }
                break;
            case 'CUSTOM_CHECKS':
                if (is_array($PRECHECK['CUSTOM_CHECKS'])) {
                    foreach ($PRECHECK['CUSTOM_CHECKS'] as $key => $values) {
                        $status = true === array_key_exists('STATUS', $values) ? $values['STATUS'] : false;
                        $msg[] = array('check' => $key, 'required' => $values['REQUIRED'], 'actual' => $values['ACTUAL'], 'status' => $status);
                    }
                    // increase counter if required
                    if (!$status) {
                        $failed_checks++;
                    }
                }
                break;
        }
    }
    // leave if all requirements are fullfilled
    if ($failed_checks == 0) {
        return;
    }
    // output summary table with requirements not fullfilled
    echo <<<EOT
    <h2>{$HEADING['ADDON_PRECHECK_FAILED']}</h2>
    <p>{$MESSAGE['ADDON']['PRECHECK_FAILED']}</p> 

    <table width="700px" cellpadding="4" border="0" style="margin: 0.5em; border-collapse: collapse; border: 1px solid silver;">
    <tr>
        <th>{$TEXT['REQUIREMENT']}:</th>
        <th>{$TEXT['REQUIRED']}:</th>
        <th>{$TEXT['CURRENT']}:</th>
    </tr>
EOT;
    foreach ($msg as $check) {
        echo '<tr>';
        $style = $check['status'] ? 'color: #46882B;' : 'color: #C00;';
        foreach ($check as $key => $value) {
            if ($key == 'status') {
                continue;
            }
            echo '<td style="' . $style . '">' . $value . '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
    // delete the temp unzip directory
    rm_full_dir($temp_path);
    // delete the temporary zip file of the Add-on
    if (file_exists($temp_addon_file)) {
        unlink($temp_addon_file);
    }
    // output status message and die
    $admin->print_error('');
}
Пример #21
0
function delete_page($page_id)
{
    global $admin, $database, $MESSAGE;
    // Find out more about the page
    $sql = 'SELECT `page_id`, `menu_title`, `page_title`, `level`, ';
    $sql .= '`link`, `parent`, `modified_by`, `modified_when` ';
    $sql .= 'FROM `' . TABLE_PREFIX . 'pages` WHERE `page_id`=' . $page_id;
    $results = $database->query($sql);
    if ($database->is_error()) {
        $admin->print_error($database->get_error());
    }
    if ($results->numRows() == 0) {
        $admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
    }
    $results_array = $results->fetchRow();
    $parent = $results_array['parent'];
    $level = $results_array['level'];
    $link = $results_array['link'];
    $page_title = $results_array['page_title'];
    $menu_title = $results_array['menu_title'];
    // Get the sections that belong to the page
    $sql = 'SELECT `section_id`, `module` FROM `' . TABLE_PREFIX . 'sections` ';
    $sql .= 'WHERE `page_id`=' . $page_id;
    $query_sections = $database->query($sql);
    if ($query_sections->numRows() > 0) {
        while ($section = $query_sections->fetchRow()) {
            // Set section id
            $section_id = $section['section_id'];
            // Include the modules delete file if it exists
            if (file_exists(WB_PATH . '/modules/' . $section['module'] . '/delete.php')) {
                include WB_PATH . '/modules/' . $section['module'] . '/delete.php';
            }
        }
    }
    // Update the pages table
    $sql = 'DELETE FROM `' . TABLE_PREFIX . 'pages` WHERE `page_id`=' . $page_id;
    $database->query($sql);
    if ($database->is_error()) {
        $admin->print_error($database->get_error());
    }
    // Update the sections table
    $sql = 'DELETE FROM `' . TABLE_PREFIX . 'sections` WHERE `page_id`=' . $page_id;
    $database->query($sql);
    if ($database->is_error()) {
        $admin->print_error($database->get_error());
    }
    // Include the ordering class or clean-up ordering
    include_once WB_PATH . '/framework/class.order.php';
    $order = new order(TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent');
    $order->clean($parent);
    // Unlink the page access file and directory
    $directory = WB_PATH . PAGES_DIRECTORY . $link;
    $filename = $directory . PAGE_EXTENSION;
    $directory .= '/';
    if (file_exists($filename)) {
        if (!is_writable(WB_PATH . PAGES_DIRECTORY . '/')) {
            $admin->print_error($MESSAGE['PAGES']['CANNOT_DELETE_ACCESS_FILE']);
        } else {
            unlink($filename);
            if (file_exists($directory) && rtrim($directory, '/') != WB_PATH . PAGES_DIRECTORY && substr($link, 0, 1) != '.') {
                rm_full_dir($directory);
            }
        }
    }
}
Пример #22
0
            $aPageInfo = array('id' => $data['page_id'], 'title' => $aPage['page_title']);
            $page_names .= replace_all($page_template_str, $aPageInfo);
        }
        /**
         *    Printing out the error-message and die().
         */
        $admin->print_error(str_replace($TEXT['FILE'], "Modul", $MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']) . $msg . $page_names);
    }
} else {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
}
// Check if we have permissions on the directory
if (!is_writable(WB_PATH . '/modules/' . $sAddonsFile)) {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
}
// Run the modules uninstall script if there is one
if (file_exists(WB_PATH . '/modules/' . $sAddonsFile . '/uninstall.php')) {
    require WB_PATH . '/modules/' . $sAddonsFile . '/uninstall.php';
}
// Try to delete the module dir
if (!rm_full_dir(WB_PATH . '/modules/' . $sAddonsFile)) {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
} else {
    // Remove entry from DB
    $sql = 'DELETE FROM `' . TABLE_PREFIX . 'addons` ' . 'WHERE `type` = \'module\' ' . 'AND `directory` = \'' . $database->escapeString($sAddonsFile) . '\' ';
    $database->query($sql);
}
// Print success message
$admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
// Print admin footer
$admin->print_footer();
Пример #23
0
                $delete_file = $name;
                $type = 'file';
            }
        }
    }
}
// Check to see if we could find an id to match
if (!isset($delete_file)) {
    $admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], $dirlink, false);
}
$relative_path = WB_PATH . MEDIA_DIRECTORY . '/' . $directory . '/' . $delete_file;
// Check if the file/folder exists
if (!file_exists($relative_path)) {
    $admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], $dirlink, false);
}
// Find out whether its a file or folder
if ($type == 'folder') {
    // Try and delete the directory
    if (rm_full_dir($relative_path)) {
        $admin->print_success($MESSAGE['MEDIA']['DELETED_DIR'], $dirlink);
    } else {
        $admin->print_error($MESSAGE['MEDIA']['CANNOT_DELETE_DIR'], $dirlink, false);
    }
} else {
    // Try and delete the file
    if (unlink($relative_path)) {
        $admin->print_success($MESSAGE['MEDIA']['DELETED_FILE'], $dirlink);
    } else {
        $admin->print_error($MESSAGE['MEDIA']['CANNOT_DELETE_FILE'], $dirlink, false);
    }
}
    }
}
/**********************************************************
 * - check for deprecated / never needed directories
 */
if (sizeof($dirRemove)) {
    echo '<h2>Step  ' . $stepID++ . ': Remove deprecated and old folders</h2>';
    $searches = array('[ADMIN]', '[MEDIA]', '[PAGES]', '[TEMPLATE]');
    $replacements = array(substr(ADMIN_PATH, strlen(WB_PATH) + 1), MEDIA_DIRECTORY, PAGES_DIRECTORY, '/templates');
    $msg = '';
    foreach ($dirRemove as $dir) {
        $dir = str_replace($searches, $replacements, $dir);
        $dir = WB_PATH . '/' . $dir;
        if (is_dir($dir)) {
            // try to delete dir
            if (!rm_full_dir($dir)) {
                // save in err-list, if failed
                $msg .= $dir . '<br />';
            }
        }
    }
    if ($msg != '') {
        $msg = '<br /><br />Following files are deprecated, outdated or a security risk and
					can not be removed automatically.<br /><br />Please delete them
					using FTP and restart upgrade-script!<br /><br />' . $msg . '<br />';
        status_msg($msg, 'error warning', 'div');
        echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
        echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '">';
        echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
        echo '</form>';
        echo '<br /><br /></div></body></html>';
Пример #25
0
<?php

/**
 *
 * @category        modules
 * @package         news
 * @author          WebsiteBaker Project
 * @copyright       2009-2011, Website Baker Org. e.V.
 * @link			http://www.websitebaker2.org/
 * @license         http://www.gnu.org/licenses/gpl.html
 * @platform        WebsiteBaker 2.8.x
 * @requirements    PHP 5.2.2 and higher
 * @version         $Id: uninstall.php 1538 2011-12-10 15:06:15Z Luisehahne $
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb_svn/wb280/tags/2.8.3/wb/modules/news/uninstall.php $
 * @lastmodified    $Date: 2011-12-10 16:06:15 +0100 (Sa, 10. Dez 2011) $
 *
 */
// Must include code to stop this file being access directly
if (defined('WB_PATH') == false) {
    exit("Cannot access this file directly");
}
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE name = 'module' AND value = 'news'");
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE extra = 'news'");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_posts");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_groups");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_comments");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_settings");
require_once WB_PATH . '/framework/functions.php';
rm_full_dir(WB_PATH . PAGES_DIRECTORY . '/posts');
rm_full_dir(WB_PATH . MEDIA_DIRECTORY . '/.news');
Пример #26
0
        $page_template_str = "- <b><a href='../pages/settings.php?page_id={{id}}'>{{title}}</a></b><br />";
        $values = array('type' => 'Template', 'type_name' => $file, 'pages' => $add);
        $msg = replace_all($msg_template_str, $values);
        $page_names = "";
        while ($data = $info->fetchRow()) {
            $page_info = array('id' => $data['page_id'], 'title' => $data['page_title']);
            $page_names .= replace_all($page_template_str, $page_info);
        }
        /**
         *	Printing out the error-message and die().
         */
        $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE'] . $msg . $page_names);
    }
}
// Check if we have permissions on the directory
if (!is_writable(LEPTON_PATH . '/templates/' . $file)) {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL'] . LEPTON_PATH . '/templates/' . $file);
}
// Try to delete the template dir
if (!rm_full_dir(LEPTON_PATH . '/templates/' . $file)) {
    $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
} else {
    // Remove entry from DB
    $database->query("DELETE FROM " . TABLE_PREFIX . "addons WHERE directory = '" . $file . "' AND type = 'template'");
}
// Update pages that use this template with default template
$database->query("UPDATE " . TABLE_PREFIX . "pages SET template = '" . DEFAULT_TEMPLATE . "' WHERE template = '{$file}'");
// Print success message
$admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
// Print admin footer
$admin->print_footer();
 Website Baker is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 Website Baker is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with Website Baker; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
// Must include code to stop this file being access directly
if (defined('WB_PATH') == false) {
    exit("Cannot access this file directly");
}
$mod_dir = basename(dirname(__FILE__));
$tablename = $mod_dir;
// include module_settings
include WB_PATH . '/modules/' . $mod_dir . '/defaults/module_settings.default.php';
if (file_exists(WB_PATH . '/modules/' . $mod_dir . '/module_settings.php')) {
    include WB_PATH . '/modules/' . $mod_dir . '/module_settings.php';
}
$database->query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_" . $tablename . "_obsolete`");
$database->query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_" . $tablename . "_comments_obsolete`");
$database->query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_" . $tablename . "_settings_obsolete`");
$database->query("RENAME TABLE `" . TABLE_PREFIX . "mod_" . $tablename . "` TO `" . TABLE_PREFIX . "mod_" . $tablename . "_obsolete`");
$database->query("RENAME TABLE `" . TABLE_PREFIX . "mod_" . $tablename . "_comments` TO `" . TABLE_PREFIX . "mod_" . $tablename . "_comments_obsolete`");
$database->query("RENAME TABLE `" . TABLE_PREFIX . "mod_" . $tablename . "_settings` TO `" . TABLE_PREFIX . "mod_" . $tablename . "_settings_obsolete`");
rm_full_dir(WB_PATH . $topics_directory);
Пример #28
0
 *  @platform       see info.php of this module
 * 
 */
// include class.secure.php to protect this file and the whole CMS!
if (defined('LEPTON_PATH')) {
    include LEPTON_PATH . '/framework/class.secure.php';
} else {
    $oneback = "../";
    $root = $oneback;
    $level = 1;
    while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
        $root .= $oneback;
        $level += 1;
    }
    if (file_exists($root . '/framework/class.secure.php')) {
        include $root . '/framework/class.secure.php';
    } else {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
// end include class.secure.php
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE name = 'module' AND value = 'news'");
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE extra = 'news'");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_posts");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_groups");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_comments");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_news_settings");
require_once LEPTON_PATH . '/framework/summary.functions.php';
rm_full_dir(LEPTON_PATH . PAGES_DIRECTORY . '/posts');
rm_full_dir(LEPTON_PATH . MEDIA_DIRECTORY . '/.news');
Пример #29
0
if (defined('WB_PATH') == false) {
    exit("Cannot access this file directly");
}
// Include WB functions
require_once WB_PATH . '/framework/functions.php';
// Get some default values
require_once WB_PATH . '/modules/bakery/config.php';
// Delete item access file, images and thumbs associated with the section
$query_items = $database->query("SELECT item_id, link FROM " . TABLE_PREFIX . "mod_bakery_items WHERE section_id = '{$section_id}'");
if ($query_items->numRows() > 0) {
    while ($item = $query_items->fetchRow()) {
        // Delete item access file
        if (is_writable(WB_PATH . PAGES_DIRECTORY . $item['link'] . PAGE_EXTENSION)) {
            unlink(WB_PATH . PAGES_DIRECTORY . $item['link'] . PAGE_EXTENSION);
        }
        // Delete any images if they exists
        $image = WB_PATH . MEDIA_DIRECTORY . '/' . $img_dir . '/images/item' . $item['item_id'];
        $thumb = WB_PATH . MEDIA_DIRECTORY . '/' . $img_dir . '/thumbs/item' . $item['item_id'];
        if (is_dir($image)) {
            rm_full_dir($image);
        }
        if (is_dir($thumb)) {
            rm_full_dir($thumb);
        }
        // Delete item attributes in db
        $database->query("DELETE FROM " . TABLE_PREFIX . "mod_bakery_item_attributes WHERE item_id = '{$item['item_id']}'");
    }
}
// Delete items and page settings in db
$database->query("DELETE FROM " . TABLE_PREFIX . "mod_bakery_items WHERE section_id = '{$section_id}'");
$database->query("DELETE FROM " . TABLE_PREFIX . "mod_bakery_page_settings WHERE section_id = '{$section_id}'");
Пример #30
0
 * Additional license terms can be seen in the info.php of this module.
 *
 * @module          Dwoo Template Engine
 * @author          LEPTON Project
 * @copyright       2010-2011, LEPTON Project
 * @link            http://blackcat-cms.org
 * @license         http://www.gnu.org/licenses/gpl.html
 * @license_terms   please see info.php of this module
 *
 *
 */
// try to include LEPTON class.secure.php to protect this file and the whole CMS!
if (defined('CAT_PATH')) {
    include CAT_PATH . '/framework/class.secure.php';
} else {
    $root = "../";
    $level = 1;
    while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
        $root .= "../";
        $level += 1;
    }
    if (file_exists($root . '/framework/class.secure.php')) {
        include $root . '/framework/class.secure.php';
    } else {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
// end include LEPTON class.secure.php
// Delete the lib directory
rm_full_dir(CAT_PATH . '/modules/lib_dwoo/dwoo');