AnkietyGO/user-files/user_files.php

1 line
60 KiB
PHP
Raw Normal View History

<?php /* Plugin Name: User File Manager Plugin URI: http://www.whereyoursolutionis.com/user-files-plugin/ Description: Plugin to manage files for your users. You can upload files for your users to access, files uploaded to the user account are only viewable by the designated user. Files can be sorted and uploaded by category. Options available for user to add and/or delete files, upload notifications, widgets, and shortcode. You can also use custom icons for files. Author: Innovative Solutions Author URI: http://www.whereyoursolutionis.com/author/scriptonite/ Version: 2.4.2 */ register_activation_hook(__FILE__,'ActivateFileDir'); add_action('admin_menu', 'show_FM_pages'); add_action('wp_dashboard_setup', 'file_manager_dashboard'); add_shortcode( 'user_file_manager' , 'manage_files_userpage' ); add_action('init','getDownloads'); add_action('wp_head','uploadHelper'); add_action('admin_notices','verifyInstall'); add_filter('query_vars', 'getDeleted'); add_action( 'init', 'userfiles_textdomain' ); function userfiles_textdomain() { load_plugin_textdomain( 'userfiles', false, 'user-files/lang/' ); } require(ABSPATH . 'wp-content/plugins/user-files/widget.php'); require(ABSPATH . 'wp-content/plugins/user-files/functions.php'); $instalversion=5; function ActivateFileDir() { global $instalVersion; $isInstallOK=get_option('file_manger_upgrade'); if($isInstallOK!=$instalVersion){ global $wpdb; global $wp_roles; $upload_dir = wp_upload_dir(); $isFolder = file_exists ( $upload_dir['basedir'].'/file_uploads'); if (!$isFolder) { mkdir ( $upload_dir['basedir'].'/file_uploads', 0777 , true ); chmod($upload_dir['basedir'].'/file_uploads', 0777); } $isUpFolder = file_exists ( $upload_dir['basedir'].'/userfile_icons/'); if (!$isUpFolder) { mkdir ( $upload_dir['basedir'].'/userfile_icons', 0777 , true ); chmod($upload_dir['basedir'].'/userfile_icons', 0777); } if($wpdb->get_var("show tables like ".$wpdb->prefix . "userfile_icons") != $wpdb->prefix . "userfile_icons") { $sql1 = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "userfile_icons( id int NOT NULL AUTO_INCREMENT PRIMARY KEY, extension varchar(10) NOT NULL UNIQUE, image varchar (500) NOT NULL );"; } if($wpdb->get_var("show tables like ".$wpdb->prefix . "userfile_category") != $wpdb->prefix . "userfile_category") { $sql2 = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "userfile_category( id int NOT NULL AUTO_INCREMENT PRIMARY KEY, category varchar(50) NOT NULL, UNIQUE (category) );"; } if($wpdb->get_var("show tables like ".$wpdb->prefix . "userfile_data") != $wpdb->prefix . "userfile_data") { $sql3 = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "userfile_data( id int NOT NULL AUTO_INCREMENT PRIMARY KEY, user_id int NOT NULL, category varchar(50) NOT NULL, filename varchar (500) NOT NULL, description longtext NOT NULL );"; } require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql1); dbDelta($sql2); dbDelta($sql3); if($wpdb->get_var("show tables like ".$wpdb->prefix . "userfile_category") == $wpdb->prefix . "userfile_category") { $DumpFiles = $wpdb->get_results("SELECT * FROM ". $wpdb->prefix."userfile_category"); foreach ( $DumpFiles as $SaveFiles ) { $wpdb->insert($wpdb->prefix . "userfile_data", array( 'id'=>$SaveFiles->id,'user_id'=>$SaveFiles->user_id,'category'=>$SaveFiles->category,'filename'=>$SaveFiles->filename)); } $wpdb->query("DROP TABLE ".$wpdb->prefix . "userfile_category"); } $wpdb->query( "ALTER TABLE " . $wpdb->prefix . "userfile_category MODIFY category VARCHAR( 50 )" ); $wpdb->query( "ALTER TABLE " . $wpdb->prefix . "userfile_data MODIFY category VARCHAR( 50 )" ); $wpdb->insert($wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'pdf','image'=>plugins_url( '/user-files/img/pdf.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'doc','image'=>plugins_url( '/user-files/img/