예제 #1
0
function wpdm_free_install()
{
    global $wpdb;
    $sql = "CREATE TABLE IF NOT EXISTS `ahm_files` (\n              `id` int(11) NOT NULL AUTO_INCREMENT,\n              `title` varchar(255) NOT NULL,\n              `description` text NOT NULL,\n              `category` text NOT NULL,\n              `file` varchar(255) NOT NULL,\n              `password` varchar(40) NOT NULL,\n              `download_count` int(11) NOT NULL,\n              `access` enum('guest','member') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,\n              `show_counter` tinyint(1) NOT NULL,              \n              `quota` INT NOT NULL,\n              `link_label` varchar(255) NOT NULL,\n              `icon` VARCHAR( 256 ) NOT NULL,\n              PRIMARY KEY (`id`)\n            ) ENGINE=MyISAM  DEFAULT CHARSET=utf8";
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    $wpdb->query($sql);
    $tmpdata = $wpdb->get_results("SHOW COLUMNS FROM ahm_files");
    foreach ($tmpdata as $d) {
        $fields[] = $d->Field;
    }
    if (!in_array('icon', $fields)) {
        $wpdb->query("ALTER TABLE `ahm_files` ADD `icon` VARCHAR( 255 ) NOT NULL");
    }
    update_option('wpdm_access_level', 'publish_posts');
    delete_option('wpdm_first_install');
    $tf = $wpdb->get_var("select count(*) from `ahm_files`");
    if ($tf == 0) {
        update_option('wpdm_install_time', time());
        update_option('wpdm_first_install', 1);
    }
    wpdm_create_dir();
}
예제 #2
0
function wpdm_admin_options()
{
    if (!file_exists(UPLOAD_DIR) && isset($_GET['task']) && $_GET['task'] == 'wpdm_create_dir') {
        wpdm_create_dir();
    }
    if (!file_exists(UPLOAD_DIR) && isset($_GET['task']) && $_GET['task'] != 'wpdm_create_dir') {
        echo "    \n        <div id=\"warning\" class=\"error fade\"><p>\n        Automatic dir creation failed! [ <a href='admin.php?page=file-manager&task=CreateDir&re=1'>Try again to create dir automatically</a> ]<br><br>\n        Please create dir <strong>" . UPLOAD_DIR . "</strong> manualy and set permision to <strong>777</strong><br><br>\n        Otherwise you will not be able to upload files.</p></div>";
    }
    if (isset($_GET['success']) && $_GET['success'] == 1) {
        echo "\n        <div id=\"message\" class=\"updated fade\"><p>\n        Congratulation! Plugin is ready to use now.\n        </div>\n        ";
    }
    if (!file_exists(UPLOAD_DIR . '.htaccess')) {
        wpdm_set_htaccess();
    }
    //if(isset($_GET['task'])) die($_GET['task']);
    if (isset($_GET['task']) && $_GET['task'] == 'wpdm_edit_file') {
        return wpdm_edit_file();
    } else {
        include 'wpdm-list-files.php';
    }
}