Example #1
0
function send_file($file_name, $file_path)
{
    @session_write_close();
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    if (get_user_os() == "MAC") {
        header("Content-Type: application/x-unknown\n");
        header("Content-Disposition: attachment; filename=\"" . $file_name . "\"\n");
    } elseif (get_browser_info() == "MSIE") {
        $disposition = !preg_match("/\\.zip\$/i", $file_name) ? 'attachment' : 'inline';
        header("Content-Disposition: {$disposition}; filename=\"" . $file_name . "\"\n");
        header("Content-Type: application/x-ms-download\n");
    } else {
        header("Content-Disposition: attachment; filename=\"" . $file_name . "\"\n");
        header("Content-Type: application/octet-stream\n");
    }
    $file_path = fix_file_path($file_path);
    if (!is_remote_file($file_path) && ($filesize = filesize($file_path)) > 0 && !@ini_get('zlib.output_compression') && !@ini_get('output_handler')) {
        header("Content-Length: " . $filesize . "\n\n");
    }
    @readfile($file_path);
}
Example #2
0
 public static function getModuleProperties($dir, $filemodules = array("_" => array(), "bundles" => array()))
 {
     if (!is_dir($dir)) {
         return $filemodules;
     }
     $d = dir($dir);
     // Browser::warn("Scanning Resource Folder",$dir);
     while (false !== ($entry = $d->read())) {
         if ($entry != '.' && $entry != '..') {
             if (is_dir($dir . '/' . $entry)) {
                 $filemodules = self::getModuleProperties($dir . '/' . $entry, $filemodules);
             } else {
                 if (strcmp($entry, "module.properties") == 0) {
                     try {
                         $mod_file = $dir . '/' . $entry;
                         $mode_time = filemtime($mod_file);
                         if (!RX_MODE_DEBUG && isset($filemodules["_"][$mod_file]) && $mode_time == $filemodules["_"][$mod_file]) {
                             // Browser::log("from-cache....",$mod_file);
                         } else {
                             // if(RX_MODE_DEBUG) Browser::log("fresh ....",$dir);
                             $filemodules["_"][$mod_file] = $mode_time;
                             $r = parse_ini_file($dir . '/' . $entry, TRUE);
                             // Browser::console($dir.'/'.$entry);
                             foreach ($r as $mod => $files) {
                                 $filemodules['bundles'][$mod] = array("files" => array());
                                 foreach ($files as $key => $file) {
                                     if ($key == '@') {
                                         $filemodules['bundles'][$mod][$key] = explode(',', $file);
                                     } else {
                                         if ($key != '@' && !is_remote_file($file)) {
                                             // Browser::log("****",resolve_path($dir."/".$file),"***");
                                             $file_path = resolve_path(replace_first(PROJECT_ROOT_DIR, "", $dir . '/' . $file));
                                             $filemodules['bundles'][$mod]["files"][] = $file_path;
                                             // echo $file_path."scanning</br>";
                                             // $filemodules['bundles'][$mod]["files"][] = self::resolve_path("/resou/".$dir.'/'.$file);
                                         } else {
                                             $filemodules['bundles'][$mod]["files"][] = $file;
                                         }
                                     }
                                 }
                             }
                         }
                     } catch (Exception $e) {
                         echo 'Caught exception: ', $e->getMessage(), "\n";
                     }
                 }
             }
         }
     }
     $d->close();
     return $filemodules;
 }
Example #3
0
function download_file_url($file_id, $file_name)
{
    $file_id = intval($file_id);
    $file_name = stripslashes($file_name);
    if (!is_remote_file($file_name)) {
        $file_name = substr($file_name, 1);
    }
    $download_options = get_option('download_options');
    $download_use_filename = intval($download_options['use_filename']);
    $download_nice_permalink = intval(get_option('download_nice_permalink'));
    if ($download_nice_permalink == 1) {
        if ($download_use_filename == 1) {
            $download_file_url = get_option('home') . '/download/' . $file_name;
        } else {
            $download_file_url = get_option('home') . '/download/' . $file_id . '/';
        }
    } else {
        if ($download_use_filename == 1) {
            $download_file_url = get_option('home') . '/?dl_name=' . $file_name;
        } else {
            $download_file_url = get_option('home') . '/?dl_id=' . $file_id;
        }
    }
    return $download_file_url;
}
Example #4
0
function show_image($image_row, $mode = "", $show_link = 1, $detailed_view = 0)
{
    global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile;
    $is_new = $image_row['image_date'] >= time() - 60 * 60 * 24 * $config['new_cutoff'] ? 1 : 0;
    $description = !empty($image_row['image_description']) ? format_text($image_row['image_description'], 1, 0, 1) : REPLACE_EMPTY;
    if (!empty($image_row['image_keywords'])) {
        $split_keywords = explode(",", $image_row['image_keywords']);
        $keywords = "";
        foreach ($split_keywords as $key => $val) {
            $url_val = $val;
            if (preg_match('/[^a-z0-9]+/i', $url_val)) {
                $url_val = '"' . $url_val . '"';
            }
            $keywords .= ($keywords != "" ? ", " : "") . "<a href=\"" . $site_sess->url(ROOT_PATH . "search.php?search_keywords=" . urlencode($url_val)) . "\">" . format_text($val, 2) . "</a>";
        }
    } else {
        $keywords = REPLACE_EMPTY;
    }
    if (!check_permission("auth_readcomment", $image_row['cat_id'])) {
        $image_row['image_allow_comments'] = 0;
    }
    $num_comments = $image_row['image_allow_comments'] == 1 ? $image_row['image_comments'] : "";
    if ($user_info['user_level'] != GUEST) {
        $lightbox_url = $self_url;
        $lightbox_url .= !empty($mode) ? (strpos($lightbox_url, '?') !== false ? "&amp;" : "?") . "mode=" . $mode : "";
        $lightbox_url .= strpos($lightbox_url, '?') !== false ? "&amp;" : "?";
        if (check_lightbox($image_row['image_id'])) {
            $lightbox_url .= "action=removefromlightbox&amp;id=" . $image_row['image_id'];
            $lightbox_button = "<a href=\"" . $site_sess->url($lightbox_url) . "\"><img src=\"" . get_gallery_image("lightbox_yes.gif") . "\" border=\"0\" alt=\"\" /></a>";
        } else {
            $lightbox_url .= "action=addtolightbox&amp;id=" . $image_row['image_id'];
            $lightbox_button = "<a href=\"" . $site_sess->url($lightbox_url) . "\"><img src=\"" . get_gallery_image("lightbox_no.gif") . "\" border=\"0\" alt=\"\" /></a>";
        }
    } else {
        $lightbox_button = "<img src=\"" . get_gallery_image("lightbox_off.gif") . "\" border=\"0\" alt=\"\" />";
    }
    if (!check_permission("auth_download", $image_row['cat_id'])) {
        $download_button = "<img src=\"" . get_gallery_image("download_off.gif") . "\" border=\"0\" alt=\"\" />";
        $download_zip_button = function_exists("gzcompress") && function_exists("crc32") ? "<img src=\"" . get_gallery_image("download_zip_off.gif") . "\" border=\"0\" alt=\"\" />" : "";
        $allow_download = 0;
        clear_download_token($image_row['image_id']);
    } else {
        $target = !empty($image_row['image_download_url']) && !is_remote_file($image_row['image_download_url']) && !is_local_file($image_row['image_download_url']) ? "target=\"_blank\"" : "";
        $download_button = "<a href=\"" . $site_sess->url(ROOT_PATH . "download.php?" . URL_IMAGE_ID . "=" . $image_row['image_id']) . "\"" . $target . "><img src=\"" . get_gallery_image("download.gif") . "\" border=\"0\" alt=\"\" /></a>";
        $download_zip_button = $target == "" && function_exists("gzcompress") && function_exists("crc32") ? "<a href=\"" . $site_sess->url(ROOT_PATH . "download.php?action=zip&amp;" . URL_IMAGE_ID . "=" . $image_row['image_id']) . "\"" . $target . "><img src=\"" . get_gallery_image("download_zip.gif") . "\" border=\"0\" alt=\"\" /></a>" : "";
        $allow_download = 1;
        set_download_token($image_row['image_id']);
    }
    if (!check_permission("auth_sendpostcard", $image_row['cat_id'])) {
        $postcard_button = "<img src=\"" . get_gallery_image("postcard_off.gif") . "\" border=\"0\" alt=\"\" />";
    } else {
        $postcard_button = "<a href=\"" . $site_sess->url(ROOT_PATH . "postcards.php?" . URL_IMAGE_ID . "=" . $image_row['image_id'] . (!empty($mode) ? "&amp;mode=" . $mode : "")) . "\"><img src=\"" . get_gallery_image("postcard.gif") . "\" border=\"0\" alt=\"\" /></a>";
    }
    if (!check_permission("auth_viewimage", $image_row['cat_id']) || !check_permission("auth_viewcat", $image_row['cat_id'])) {
        $show_link = 0;
    }
    $file_size = "n/a";
    if (!is_remote($image_row['image_media_file'])) {
        if ($file_size = @filesize(MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_media_file'])) {
            $file_size = format_file_size($file_size);
        }
    } elseif ($detailed_view) {
        $file_size = get_remote_file_size($image_row['image_media_file']);
    }
    if (isset($image_row[$user_table_fields['user_name']]) && $image_row['user_id'] != GUEST) {
        $user_name = format_text($image_row[$user_table_fields['user_name']], 2);
        $user_profile_link = !empty($url_show_profile) ? str_replace("{user_id}", $image_row['user_id'], $url_show_profile) : ROOT_PATH . "member.php?action=showprofile&amp;" . URL_USER_ID . "=" . $image_row['user_id'];
        $user_name_link = "<a href=\"" . $site_sess->url($user_profile_link) . "\">" . $user_name . "</a>";
    } else {
        $user_name = format_text($lang['userlevel_guest'], 2);
        $user_name_link = $user_name;
    }
    $site_template->register_vars(array("image_id" => $image_row['image_id'], "user_id" => $image_row['user_id'], "user_name" => $user_name, "user_name_link" => $user_name_link, "image_name" => format_text($image_row['image_name'], 2), "image_description" => $description, "image_keywords" => $keywords, "image_date" => format_date($config['date_format'] . " " . $config['time_format'], $image_row['image_date']), "image_is_new" => $is_new, "lang_new" => $lang['new'], "image_active" => $image_row['image_active'], "cat_id" => $image_row['cat_id'], "cat_name" => format_text($image_row['cat_name'], 2), "cat_url" => $site_sess->url(ROOT_PATH . "categories.php?" . URL_CAT_ID . "=" . $image_row['cat_id']), "image_downloads" => $image_row['image_downloads'], "image_votes" => $image_row['image_votes'], "image_rating" => $image_row['image_rating'], "image_hits" => $image_row['image_hits'], "allow_comments" => $image_row['image_allow_comments'], "lang_comments" => $lang['comments'], "image_comments" => $num_comments, "lightbox_button" => $lightbox_button, "postcard_button" => $postcard_button, "download_button" => $download_button, "download_zip_button" => $download_zip_button, "image_download_url" => $image_row['image_download_url'], "allow_download" => $allow_download, "url_download" => $site_sess->url(ROOT_PATH . "download.php?" . URL_IMAGE_ID . "=" . $image_row['image_id']), "image_file_size" => $file_size, "image_url" => $show_link ? $site_sess->url(ROOT_PATH . "details.php?" . URL_IMAGE_ID . "=" . $image_row['image_id'] . (!empty($mode) ? "&amp;mode=" . $mode : "")) : "", "thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link), "thumbnail_openwindow" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, 1), "image_file_name" => $image_row['image_media_file'], "thumbnail_file_name" => $image_row['image_thumb_file']));
    if (!empty($additional_image_fields)) {
        $additional_field_array = array();
        foreach ($additional_image_fields as $key => $val) {
            $additional_field_array[$key] = !empty($image_row[$key]) ? format_text($image_row[$key], 1) : REPLACE_EMPTY;
            $additional_field_array['lang_' . $key] = $val[0];
        }
        if (!empty($additional_field_array)) {
            $site_template->register_vars($additional_field_array);
        }
    }
    $rate_form = "";
    if (check_permission("auth_vote", $image_row['cat_id'])) {
        $site_template->register_vars("rate", $lang['rate']);
        $rate_form = $site_template->parse_template("rate_form");
    }
    $site_template->register_vars("rate_form", $rate_form);
    $site_template->register_vars(array("image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view)));
    return true;
}
Example #5
0
        echo mysql2date(sprintf('%s @ %s', get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $file->file_last_downloaded_date));
        ?>
</td>
					</tr>
					<tr class="alternate">
						<td><strong><?php 
        _e('Allowed To Download:', 'wp-downloadmanager');
        ?>
</strong></td>
						<td><?php 
        echo file_permission($file->file_permission);
        ?>
</td>
					</tr>
					<?php 
        if (!is_remote_file(stripslashes($file->file))) {
            ?>
					<tr>
						<td colspan="2" align="center"><input type="checkbox" id="unlinkfile" name="unlinkfile" value="1" />&nbsp;<label for="unlinkfile"><?php 
            _e('Delete File From Server?', 'wp-downloadmanager');
            ?>
</label></td>
					</tr>
					<?php 
        }
        ?>
					<tr class="alternate">
						<td colspan="2" align="center"><input type="submit" name="do" value="<?php 
        _e('Delete File', 'wp-downloadmanager');
        ?>
" class="button"  onclick="return confirm('You Are About To The Delete This File \'<?php