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/word.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'docx','image'=>plugins_url( '/user-files/img/word.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'txt','image'=>plugins_url( '/user-files/img/word.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'jpg','image'=>plugins_url( '/user-files/img/jpg.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'png','image'=>plugins_url( '/user-files/img/jpg.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'gif','image'=>plugins_url( '/user-files/img/jpg.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'jpeg','image'=>plugins_url( '/user-files/img/jpg.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'xls','image'=>plugins_url( '/user-files/img/excel.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'zip','image'=>plugins_url( '/user-files/img/zip.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_icons", array( 'id'=> '','extension'=>'rar','image'=>plugins_url( '/user-files/img/zip.jpg' , dirname(__FILE__) ))); $wpdb->insert( $wpdb->prefix . "userfile_category", array( 'id'=> '','category'=>'misc')); add_option('file_manger_show_dash', 'yes'); add_option('file_manger_show_menu', 'yes'); add_option('file_manger_allow_del', 'no'); add_option('file_manger_allow_up', 'no'); add_option('file_manger_notify', ''); add_option('file_manger_credit'); add_option('file_manger_defaultcat','misc'); add_option('file_manger_upgrade',''); update_option('file_manger_upgrade',$instalVersion); add_option('userfiles_email_subject','New File Upload'); add_option('userfiles_email_message','You have a new file upload. The file is %filename% and has been added to your %category% category.'); $wp_roles->add_cap( 'administrator', 'manage_userfiles' ); $wp_roles->add_cap( 'administrator', 'manage_userfiles_settings' ); } } function DectivateFileDir() { global $wpdb; global $wp_roles; $wp_roles->remove_cap( 'administrator', 'manage_userfiles' ); $wp_roles->remove_cap( 'administrator', 'manage_userfiles_settings' ); $upload_dir = wp_upload_dir(); $isFolder = file_exists ($upload_dir['basedir'].'/file_uploads/'); if ($isFolder) { if ($Subhandle = @opendir($isFolder)) { while (false !== ($subdirs = readdir($Subhandle))) { $files = glob( $subdirs . '*', GLOB_MARK ); foreach( $files as $file ){ if ($file != "." and $file !=".."){ unlink( $file ); } } rmdir( $subdirs ); } } $isitGone = rmdir( $isFolder ); $dir = file_exists ($upload_dir['basedir'].'/userfile_icons/'); $files = glob( $dir . '*', GLOB_MARK ); foreach( $files as $file ){ if ($file != "." and $file !=".."){ unlink( $file ); } } rmdir( $dir ); $wpdb->query('DROP TABLE '.$wpdb->prefix.'userfile_icons'); $wpdb->query('DROP TABLE '.$wpdb->prefix.'userfile_category'); $wpdb->query('DROP TABLE '.$wpdb->prefix.'userfile_data'); $wpdb->query('DROP TABLE '.$wpdb->prefix.'userfile_cats'); delete_option('file_manger_show_dash'); delete_option('file_manger_show_menu'); delete_option('file_manger_allow_up'); delete_option('file_manger_allow_del'); delete_option('file_manger_notify'); delete_option('file_manger_credit'); if ($isitGone) { echo '
';
echo __('This will delete all files, folders, categories, icons, etc. Are you sure you want to do this?','userfiles');
echo '
'.__('Yes','userfiles').' | '.__('No','userfiles').'';
echo '';
}
if ($_POST['update']) {
$currOpts_dash = get_option('file_manger_show_dash');
$currOpts_menu = get_option('file_manger_show_menu');
$currOpts_up = get_option('file_manger_allow_up');
$currOpts_del = get_option('file_manger_allow_del');
$currOpts_notify = get_option('file_manger_notify');
$currOpts_credits=get_option('file_manger_credit');
if ($_POST['file_manger_show_dash'] != $currOpts_dash ) {
if($_POST['file_manger_show_dash']=='yes') {
update_option('file_manger_show_dash','yes' );
}else{
update_option('file_manger_show_dash','no' );
}
}
if ($_POST['file_manger_dashcats'] != $currOpts_dash ) {
update_option('file_manger_dashcats',$_POST['file_manger_dashcats'] );
}
if($_POST['file_manger_dashcount'] != $currOpts_menu ) {
update_option('file_manger_dashcount',$_POST['file_manger_dashcount'] );
}
if($_POST['file_manger_allow_del'] != $currOpts_del ) {
if($_POST['file_manger_allow_del']=='yes') {
update_option('file_manger_allow_del','yes' );
}else{
update_option('file_manger_allow_del','no' );
}
}
if($_POST['file_manger_allow_up'] != $currOpts_up ) {
if($_POST['file_manger_allow_up']=='yes') {
update_option('file_manger_allow_up','yes' );
}else{
update_option('file_manger_allow_up','no' );
}
}
if($_POST['file_manger_credit'] != $currOpts_credits ) {
if($_POST['file_manger_credit']=='yes') {
update_option('file_manger_credit','yes' );
}else{
update_option('file_manger_credit','no' );
}
}
if($_POST['file_manger_notify'] != $currOpts_notify ) {
update_option('file_manger_notify',$_POST['file_manger_notify'] );
}
if($_POST['userfiles_email_subject'] ) {
update_option('userfiles_email_subject',$_POST['userfiles_email_subject'] );
}
if($_POST['userfiles_email_message'] ) {
update_option('userfiles_email_message',esc_attr($_POST['userfiles_email_message']) );
}
echo '
> |
> |
> |
> |
%user_first%,%user_last%,%user_login%,%filename%,%category% |
: |
'.__('User Files','userfiles').''; set_abase(); global $wpdb; $upload_dir = wp_upload_dir(); if (isset($_GET['deletefile'])){ $isitGone = unlink($upload_dir['basedir'].'/file_uploads/'.$_GET['deletefile']); $toUsFl=explode ( "/" , $_GET['deletefolder'] ); $wpdb->query("DELETE FROM ".$wpdb->prefix."userfile_data WHERE user_id ='" .$toUsFl[1]. "' AND filename ='".$toUsFl[2]."'"); if ($isitGone) { echo '
'; echo $c->category.' | '; if($currOpts_defcat!=$c->category){echo '(Make Default) | ';} echo '(Delete) |