<?php

cw_load('user');
$location[] = array(cw_get_langvar_by_name("lbl_file_management"), "");
$root_dir = cw_user_get_files_location();
$what_to_edit = "files";
$action_script = "index.php?target=file_manage";
$smarty->assign('what_to_edit', $what_to_edit);
$smarty->assign('action_script', $action_script);
include $app_main_dir . '/include/image/file.php';
<?php

cw_load('files', 'user');
$filename = $_GET['file'];
$file_exists = false;
#
# Check if file exists
#
$allowed_path = realpath(cw_user_get_files_location());
if (!@file_exists($filename)) {
    $filename = realpath($allowed_path . DIRECTORY_SEPARATOR . $filename);
    $file_exists = file_exists($filename);
} else {
    $filename = realpath($filename);
    $file_exists = !strncmp($filename, $allowed_path, strlen($allowed_path));
}
if ($file_exists) {
    #
    # Output file content
    #
    $imageinfo = cw_get_image_size($filename);
    if (!empty($imageinfo)) {
        header("Content-type: " . ($imageinfo[3] ? $imageinfo[3] : "application/octet-stream"));
    } else {
        header("Content-type: application/force-download");
        header("Content-Disposition: attachment; filename=" . basename($filename));
    }
    cw_readfile($filename);
}
exit;
<?php

cw_load('files', 'image', 'user');
$file_upload_data =& cw_session_register('file_upload_data', array());
$service_fields = array("file_path", "source", "image_x", "image_y", "image_size", "image_type", "dir_upload", "id", "type", "date", "filename");
if (!isset($available_images[$type]) || empty($type)) {
    cw_close_window();
}
$userfiles_dir = cw_user_get_files_location() . DIRECTORY_SEPARATOR;
if ($REQUEST_METHOD == "POST") {
    $data = array();
    $userfiles = $_FILES['userfiles'];
    if (is_array($userfiles)) {
        foreach ($userfiles['tmp_name'] as $index => $userfile) {
            if (zerolen($userfile)) {
                break;
            }
            if (cw_is_image_userfile($userfile, $userfiles['size'][$index], $userfiles['type'][$index])) {
                $tmp = array();
                $tmp['is_copied'] = true;
                $tmp['filename'] = strtolower($userfiles['name'][$index]);
                $tmp['file_path'] = cw_move_uploaded_file('userfiles', '', $index);
                $tmp['source'] = 'S';
                $data[] = $tmp;
            }
        }
    }
    if (is_array($filenames)) {
        foreach ($filenames as $ind => $filename) {
            $filename = trim($filename);
            if (!zerolen($filename)) {
    $result = db_query($query);
    $total_labels_in_search = db_num_rows($result);
    $navigation = cw_core_get_navigation($target, $total_labels_in_search, $page);
    $navigation['script'] = "index.php?target={$target}&language={$language}";
    $smarty->assign('navigation', $navigation);
    if ($total_labels_in_search > 0) {
        $smarty->assign("data", cw_query("{$query} LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}"));
    }
}
$smarty->assign("upload_max_filesize", ini_get("upload_max_filesize"));
$smarty->assign("my_files_location", cw_user_get_files_location());
if (!empty($serverfile)) {
    $smarty->assign("localfile", $serverfile);
    $serverfile = false;
} else {
    $smarty->assign("localfile", cw_user_get_files_location() . "/lng_file.csv");
}
if ($language) {
    $smarty->assign('topics', $topics);
    $smarty->assign('search_prefilled', cw_array_map('stripslashes', $search_data['languages']));
    $smarty->assign('language', $language);
    $location[] = array(cw_get_langvar_by_name('lbl_edit_languages'), 'index.php?target=' . $target);
    $location[] = array(cw_get_langvar_by_name('lbl_edit_language'), '');
    $smarty->assign('main', 'language');
} else {
    $new_languages = cw_query("SELECT {$tables['map_countries']}.*, IFNULL(lng1c.value, lng2c.value) as country, IFNULL(lng1l.value, lng2l.value) as language FROM {$tables['map_countries']} LEFT JOIN {$tables['languages']} as lng1c ON lng1c.name = CONCAT('country_', {$tables['map_countries']}.code) AND lng1c.code = '{$current_language}' LEFT JOIN {$tables['languages']} as lng2c ON lng2c.name = CONCAT('country_', {$tables['map_countries']}.code) AND lng2c.code = '{$config['default_admin_language']}' LEFT JOIN {$tables['languages']} as lng1l ON lng1l.name = CONCAT('language_', {$tables['map_countries']}.code) AND lng1l.code = '{$current_language}' LEFT JOIN {$tables['languages']} as lng2l ON lng2l.name = CONCAT('language_', {$tables['map_countries']}.code) AND lng2l.code = '{$config['default_admin_language']}' WHERE (lng1l.value != '' OR lng2l.value != '') GROUP BY language ORDER BY language");
    $smarty->assign("new_languages", $new_languages);
    $smarty->assign('languages', $languages);
    $location[] = array(cw_get_langvar_by_name('lbl_edit_languages'), '');
    $smarty->assign('main', 'languages');
}