<?php /** * $Id: download-add.php 440391 2011-09-19 19:38:29Z ihacklog $ * $Revision: 440391 $ * $Date: 2011-09-19 19:38:29 +0000 (Mon, 19 Sep 2011) $ * @package Hacklog-DownloadManager * @encoding UTF-8 * @author 荒野无灯 <HuangYeWuDeng> * @link http://ihacklog.com * @copyright Copyright (C) 2011 荒野无灯 * @license http://www.gnu.org/licenses/ */ ### Check Whether User Can Manage Downloads if (!current_user_can('manage_downloads')) { wp_die('Access Denied'); } require dirname(__FILE__) . '/includes/hacklogdm_admin.class.php'; require dirname(__FILE__) . '/includes/upload_handler.php'; ?> <!-- Add A File --> <?php hacklogdm_admin::print_upload_form(admin_url('admin.php?page=' . plugin_basename(__FILE__)));
break; /************************************************************************************************* * Main Page.list the files **************************************************************************************************/ /************************************************************************************************* * Main Page.list the files **************************************************************************************************/ default: ### Get Total Files $total_file = $wpdb->get_var("SELECT COUNT(file_id) FROM {$wpdb->downloads} WHERE 1=1"); $total_bandwidth = $wpdb->get_var("SELECT SUM(file_hits*file_size) AS total_bandwidth FROM {$wpdb->downloads} WHERE file_size != '" . __('unknown', hacklogdm::textdomain) . "'"); $total_filesize = $wpdb->get_var("SELECT SUM(file_size) AS total_filesize FROM {$wpdb->downloads} WHERE file_size != '" . __('unknown', hacklogdm::textdomain) . "'"); $total_filehits = $wpdb->get_var("SELECT SUM(file_hits) AS total_filehits FROM {$wpdb->downloads}"); ?> <?php hacklogdm_admin::show_message_or_error(); ?> <!-- Manage Downloads --> <?php $download_list_action = admin_url('admin.php?page=' . plugin_basename(__FILE__)); require dirname(__FILE__) . '/includes/download_list.php'; ?> <p> </p> <!-- Download Stats --> <div class="wrap"> <h3><?php _e('Download Stats', hacklogdm::textdomain); ?> </h3> <br style="" />
<td><strong><?php _e('File Last Downloaded Date:', hacklogdm::textdomain); ?> </strong></td> <td><?php 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:', hacklogdm::textdomain); ?> </strong></td> <td><?php echo hacklogdm_admin::file_permission($file->file_permission); ?> </td> </tr> <?php if (!hacklogdm::is_remote_file(stripslashes($file->file))) { ?> <tr> <td colspan="2" align="center"><input type="checkbox" id="unlinkfile" name="unlinkfile" value="1" /> <label for="unlinkfile"><?php _e('Delete File From Server?', hacklogdm::textdomain); ?> </label></td> </tr> <?php } ?>
//Check Whether User Can Manage Downloads if (!current_user_can('manage_downloads')) { wp_die('Access Denied'); } //init the variables for safe reasons. $root = ''; $dir = ''; $root = hacklogdm_admin::get_opt('download_path'); $dir = urldecode(hacklogdm_admin::post('dir')); if (file_exists($root . $dir)) { $files = scandir($root . $dir); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">"; // All dirs foreach ($files as $file) { if (hacklogdm_admin::is_normal_file($root . $dir, $file) && is_dir($root . $dir . $file)) { echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlspecialchars($dir . $file) . "/\">" . htmlspecialchars($file) . "</a></li>"; } } // All files foreach ($files as $file) { if (hacklogdm_admin::is_normal_file($root . $dir, $file) && !is_dir($root . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); echo "<li class=\"file ext_{$ext}\"><a href=\"#\" rel=\"" . htmlspecialchars($dir . $file) . "\">" . htmlspecialchars($file) . "</a></li>"; } } echo "</ul>"; } }
</a></li> </ul> </div> <?php // Get the Tab $tab = hacklogdm_admin::get('tab'); switch ($tab) { //上传文件 case 'upload': //Form Processing require dirname(__FILE__) . '/includes/upload_handler.php'; ?> <!-- Add A File --> <?php hacklogdm_admin::print_upload_form('download-upload-or-add.php?tab=upload'); ?> <script type="text/javascript"> /* <![CDATA[ */ jQuery('#insertdownload').click(function(){ var win = window.dialogArguments || opener || parent || top; win.send_to_editor('<?php echo isset($GLOBALS['insert_download_shortcode']) ? $GLOBALS['insert_download_shortcode'] : ''; ?> ]'+"\n\r"); }); /* ]]> */ </script> <?php
</label></td> </tr> <tr> <td valign="top"><strong><?php _e('File Date:', hacklogdm::textdomain); ?> </strong></td> <td><?php _e('Existing Timestamp:', hacklogdm::textdomain); ?> <?php echo mysql2date(sprintf('%s @ %s', get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $file->file_date)); ?> <br /> <?php hacklogdm_admin::file_timestamp($file->file_date); ?> <br /> <input type="checkbox" id="edit_filetimestamp" name="edit_filetimestamp" value="1" /> <label for="edit_filetimestamp"><?php _e('Edit Timestamp', hacklogdm::textdomain); ?> </label> <input type="checkbox" id="edit_usetodaydate" value="1" onclick="file_usetodaydate();" /> <label for="edit_usetodaydate"><?php _e('Use Today\'s Date', hacklogdm::textdomain); ?> </label></td> </tr> <tr>
?> </h2> <p><?php _e('Deactivating Hacklog-DownloadManager plugin does not remove any data that may have been created, such as the download options and the download data. To completely remove this plugin, you can uninstall it here.', hacklogdm::textdomain); ?> </p> <p style="color: red"><strong><?php _e('NOTE:', hacklogdm::textdomain); ?> </strong><br /> <?php _e('The download files uploaded by Hacklog-DownloadManager <strong>WILL NOT</strong> be deleted. You will have to delete it manually.', hacklogdm::textdomain); ?> <br /> <?php printf(__('The path to the downloads folder is <strong>\'%s\'</strong>.', hacklogdm::textdomain), hacklogdm_admin::get_opt('download_path')); ?> </p> <p style="color: red"><strong><?php _e('WARNING:', 'hacklog-downloadmanager'); ?> </strong><br /> <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', hacklogdm::textdomain); ?> </p> <p style="color: red"><strong><?php _e('The following WordPress Options/Tables will be DELETED:', hacklogdm::textdomain); ?> </strong><br /> </p>
"; case "popup_2": default_template = "<?php echo hacklogdm_admin::js_fix($download_template_popup_default[1]); ?> "; break; case 'custom_css': default_template = "<?php echo hacklogdm_admin::js_fix($download_template_custom_css_default); ?> "; break; case "popup": default_template ="<?php echo hacklogdm_admin::js_fix($download_template_popup_default[0]); ?> "; } jQuery("#download_template_" + template).val(default_template); } /* ]]> */ function set_template_table(type) { type = parseInt(type); switch(type) { case 0: jQuery('#table_download_template_embedded').show(); jQuery('#table_download_template_embedded_2').show();